[compiler-rt] r367471 - compiler-rt: Rename .cc file in lib/sanitizer_common/symbolizer to .cpp

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 31 12:41:02 PDT 2019


Author: nico
Date: Wed Jul 31 12:41:02 2019
New Revision: 367471

URL: http://llvm.org/viewvc/llvm-project?rev=367471&view=rev
Log:
compiler-rt: Rename .cc file in lib/sanitizer_common/symbolizer to .cpp

Added:
    compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cpp
      - copied, changed from r367470, compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cc
    compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_wrappers.cpp
      - copied, changed from r367470, compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_wrappers.cc
Removed:
    compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cc
    compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_wrappers.cc
Modified:
    compiler-rt/trunk/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh

Removed: compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cc?rev=367470&view=auto
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cc (removed)
@@ -1,80 +0,0 @@
-//===-- sanitizer_symbolize.cc ----------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Implementation of weak hooks from sanitizer_symbolizer_posix_libcdep.cpp.
-//
-//===----------------------------------------------------------------------===//
-
-#include <stdio.h>
-#include <string>
-
-#include "llvm/DebugInfo/Symbolize/DIPrinter.h"
-#include "llvm/DebugInfo/Symbolize/Symbolize.h"
-
-static llvm::symbolize::LLVMSymbolizer *getDefaultSymbolizer() {
-  static llvm::symbolize::LLVMSymbolizer *DefaultSymbolizer =
-      new llvm::symbolize::LLVMSymbolizer();
-  return DefaultSymbolizer;
-}
-
-namespace __sanitizer {
-int internal_snprintf(char *buffer, unsigned long length, const char *format,
-                      ...);
-}  // namespace __sanitizer
-
-extern "C" {
-
-typedef uint64_t u64;
-
-bool __sanitizer_symbolize_code(const char *ModuleName, uint64_t ModuleOffset,
-                                char *Buffer, int MaxLength) {
-  std::string Result;
-  {
-    llvm::raw_string_ostream OS(Result);
-    llvm::symbolize::DIPrinter Printer(OS);
-    // TODO: it is neccessary to set proper SectionIndex here.
-    // object::SectionedAddress::UndefSection works for only absolute addresses.
-    auto ResOrErr = getDefaultSymbolizer()->symbolizeInlinedCode(
-        ModuleName,
-        {ModuleOffset, llvm::object::SectionedAddress::UndefSection});
-    Printer << (ResOrErr ? ResOrErr.get() : llvm::DIInliningInfo());
-  }
-  return __sanitizer::internal_snprintf(Buffer, MaxLength, "%s",
-                                        Result.c_str()) < MaxLength;
-}
-
-bool __sanitizer_symbolize_data(const char *ModuleName, uint64_t ModuleOffset,
-                                char *Buffer, int MaxLength) {
-  std::string Result;
-  {
-    llvm::raw_string_ostream OS(Result);
-    llvm::symbolize::DIPrinter Printer(OS);
-    // TODO: it is neccessary to set proper SectionIndex here.
-    // object::SectionedAddress::UndefSection works for only absolute addresses.
-    auto ResOrErr = getDefaultSymbolizer()->symbolizeData(
-        ModuleName,
-        {ModuleOffset, llvm::object::SectionedAddress::UndefSection});
-    Printer << (ResOrErr ? ResOrErr.get() : llvm::DIGlobal());
-  }
-  return __sanitizer::internal_snprintf(Buffer, MaxLength, "%s",
-                                        Result.c_str()) < MaxLength;
-}
-
-void __sanitizer_symbolize_flush() { getDefaultSymbolizer()->flush(); }
-
-int __sanitizer_symbolize_demangle(const char *Name, char *Buffer,
-                                   int MaxLength) {
-  std::string Result =
-      llvm::symbolize::LLVMSymbolizer::DemangleName(Name, nullptr);
-  return __sanitizer::internal_snprintf(Buffer, MaxLength, "%s",
-                                        Result.c_str()) < MaxLength
-             ? static_cast<int>(Result.size() + 1)
-             : 0;
-}
-
-}  // extern "C"

Copied: compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cpp (from r367470, compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cpp?p2=compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cpp&p1=compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cc&r1=367470&r2=367471&rev=367471&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cpp Wed Jul 31 12:41:02 2019
@@ -1,4 +1,4 @@
-//===-- sanitizer_symbolize.cc ----------------------------------*- C++ -*-===//
+//===-- sanitizer_symbolize.cpp ---------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

Removed: compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_wrappers.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_wrappers.cc?rev=367470&view=auto
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_wrappers.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_wrappers.cc (removed)
@@ -1,198 +0,0 @@
-//===-- sanitizer_wrappers.cc -----------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Redirect some functions to sanitizer interceptors.
-//
-//===----------------------------------------------------------------------===//
-
-#include <dlfcn.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include <tuple>
-
-// Need to match ../sanitizer_common/sanitizer_internal_defs.h
-#if defined(ARCH_PPC)
-#define OFF_T unsigned long
-#else
-#define OFF_T unsigned long long
-#endif
-
-namespace __sanitizer {
-unsigned long internal_open(const char *filename, int flags);
-unsigned long internal_open(const char *filename, int flags, unsigned mode);
-unsigned long internal_close(int fd);
-unsigned long internal_stat(const char *path, void *buf);
-unsigned long internal_lstat(const char *path, void *buf);
-unsigned long internal_fstat(int fd, void *buf);
-size_t internal_strlen(const char *s);
-unsigned long internal_mmap(void *addr, unsigned long length, int prot,
-                            int flags, int fd, OFF_T offset);
-void *internal_memcpy(void *dest, const void *src, unsigned long n);
-// Used to propagate errno.
-bool internal_iserror(unsigned long retval, int *rverrno = 0);
-}  // namespace __sanitizer
-
-namespace {
-
-template <typename T>
-struct GetTypes;
-
-template <typename R, typename... Args>
-struct GetTypes<R(Args...)> {
-  using Result = R;
-  template <size_t i>
-  struct Arg {
-    using Type = typename std::tuple_element<i, std::tuple<Args...>>::type;
-  };
-};
-
-#define LLVM_SYMBOLIZER_GET_FUNC(Function) \
-  ((__interceptor_##Function)              \
-       ? (__interceptor_##Function)        \
-       : reinterpret_cast<decltype(&Function)>(dlsym(RTLD_NEXT, #Function)))
-
-#define LLVM_SYMBOLIZER_INTERCEPTOR1(Function, ...)               \
-  GetTypes<__VA_ARGS__>::Result __interceptor_##Function(         \
-      GetTypes<__VA_ARGS__>::Arg<0>::Type) __attribute__((weak)); \
-  GetTypes<__VA_ARGS__>::Result Function(                         \
-      GetTypes<__VA_ARGS__>::Arg<0>::Type arg0) {                 \
-    return LLVM_SYMBOLIZER_GET_FUNC(Function)(arg0);              \
-  }
-
-#define LLVM_SYMBOLIZER_INTERCEPTOR2(Function, ...)               \
-  GetTypes<__VA_ARGS__>::Result __interceptor_##Function(         \
-      GetTypes<__VA_ARGS__>::Arg<0>::Type,                        \
-      GetTypes<__VA_ARGS__>::Arg<1>::Type) __attribute__((weak)); \
-  GetTypes<__VA_ARGS__>::Result Function(                         \
-      GetTypes<__VA_ARGS__>::Arg<0>::Type arg0,                   \
-      GetTypes<__VA_ARGS__>::Arg<1>::Type arg1) {                 \
-    return LLVM_SYMBOLIZER_GET_FUNC(Function)(arg0, arg1);        \
-  }
-
-#define LLVM_SYMBOLIZER_INTERCEPTOR3(Function, ...)               \
-  GetTypes<__VA_ARGS__>::Result __interceptor_##Function(         \
-      GetTypes<__VA_ARGS__>::Arg<0>::Type,                        \
-      GetTypes<__VA_ARGS__>::Arg<1>::Type,                        \
-      GetTypes<__VA_ARGS__>::Arg<2>::Type) __attribute__((weak)); \
-  GetTypes<__VA_ARGS__>::Result Function(                         \
-      GetTypes<__VA_ARGS__>::Arg<0>::Type arg0,                   \
-      GetTypes<__VA_ARGS__>::Arg<1>::Type arg1,                   \
-      GetTypes<__VA_ARGS__>::Arg<2>::Type arg2) {                 \
-    return LLVM_SYMBOLIZER_GET_FUNC(Function)(arg0, arg1, arg2);  \
-  }
-
-#define LLVM_SYMBOLIZER_INTERCEPTOR4(Function, ...)                    \
-  GetTypes<__VA_ARGS__>::Result __interceptor_##Function(              \
-      GetTypes<__VA_ARGS__>::Arg<0>::Type,                             \
-      GetTypes<__VA_ARGS__>::Arg<1>::Type,                             \
-      GetTypes<__VA_ARGS__>::Arg<2>::Type,                             \
-      GetTypes<__VA_ARGS__>::Arg<3>::Type) __attribute__((weak));      \
-  GetTypes<__VA_ARGS__>::Result Function(                              \
-      GetTypes<__VA_ARGS__>::Arg<0>::Type arg0,                        \
-      GetTypes<__VA_ARGS__>::Arg<1>::Type arg1,                        \
-      GetTypes<__VA_ARGS__>::Arg<2>::Type arg2,                        \
-      GetTypes<__VA_ARGS__>::Arg<3>::Type arg3) {                      \
-    return LLVM_SYMBOLIZER_GET_FUNC(Function)(arg0, arg1, arg2, arg3); \
-  }
-
-}  // namespace
-
-// C-style interface around internal sanitizer libc functions.
-extern "C" {
-
-#define RETURN_OR_SET_ERRNO(T, res)                   \
-  int rverrno;                                        \
-  if (__sanitizer::internal_iserror(res, &rverrno)) { \
-    errno = rverrno;                                  \
-    return (T)-1;                                     \
-  }                                                   \
-  return (T)res;
-
-int open(const char *filename, int flags, ...) {
-  unsigned long res;
-  if (flags | O_CREAT) {
-    va_list va;
-    va_start(va, flags);
-    unsigned mode = va_arg(va, unsigned);
-    va_end(va);
-    res = __sanitizer::internal_open(filename, flags, mode);
-  } else {
-    res = __sanitizer::internal_open(filename, flags);
-  }
-  RETURN_OR_SET_ERRNO(int, res);
-}
-
-int close(int fd) {
-  unsigned long res = __sanitizer::internal_close(fd);
-  RETURN_OR_SET_ERRNO(int, res);
-}
-
-#define STAT(func, arg, buf)                                  \
-  unsigned long res = __sanitizer::internal_##func(arg, buf); \
-  RETURN_OR_SET_ERRNO(int, res);
-
-int stat(const char *path, struct stat *buf) { STAT(stat, path, buf); }
-
-int lstat(const char *path, struct stat *buf) { STAT(lstat, path, buf); }
-
-int fstat(int fd, struct stat *buf) { STAT(fstat, fd, buf); }
-
-// Redirect versioned stat functions to the __sanitizer::internal() as well.
-int __xstat(int version, const char *path, struct stat *buf) {
-  STAT(stat, path, buf);
-}
-
-int __lxstat(int version, const char *path, struct stat *buf) {
-  STAT(lstat, path, buf);
-}
-
-int __fxstat(int version, int fd, struct stat *buf) { STAT(fstat, fd, buf); }
-
-size_t strlen(const char *s) { return __sanitizer::internal_strlen(s); }
-
-void *mmap(void *addr, size_t length, int prot, int flags, int fd,
-           off_t offset) {
-  unsigned long res = __sanitizer::internal_mmap(
-      addr, (unsigned long)length, prot, flags, fd, (unsigned long long)offset);
-  RETURN_OR_SET_ERRNO(void *, res);
-}
-
-LLVM_SYMBOLIZER_INTERCEPTOR3(read, ssize_t(int, void *, size_t))
-LLVM_SYMBOLIZER_INTERCEPTOR4(pread, ssize_t(int, void *, size_t, off_t))
-LLVM_SYMBOLIZER_INTERCEPTOR4(pread64, ssize_t(int, void *, size_t, off64_t))
-LLVM_SYMBOLIZER_INTERCEPTOR2(realpath, char *(const char *, char *))
-
-LLVM_SYMBOLIZER_INTERCEPTOR1(pthread_cond_broadcast, int(pthread_cond_t *))
-LLVM_SYMBOLIZER_INTERCEPTOR2(pthread_cond_wait,
-                             int(pthread_cond_t *, pthread_mutex_t *))
-LLVM_SYMBOLIZER_INTERCEPTOR1(pthread_mutex_lock, int(pthread_mutex_t *))
-LLVM_SYMBOLIZER_INTERCEPTOR1(pthread_mutex_unlock, int(pthread_mutex_t *))
-LLVM_SYMBOLIZER_INTERCEPTOR1(pthread_mutex_destroy, int(pthread_mutex_t *))
-LLVM_SYMBOLIZER_INTERCEPTOR2(pthread_mutex_init,
-                             int(pthread_mutex_t *,
-                                 const pthread_mutexattr_t *))
-LLVM_SYMBOLIZER_INTERCEPTOR1(pthread_mutexattr_destroy,
-                             int(pthread_mutexattr_t *))
-LLVM_SYMBOLIZER_INTERCEPTOR1(pthread_mutexattr_init, int(pthread_mutexattr_t *))
-LLVM_SYMBOLIZER_INTERCEPTOR2(pthread_mutexattr_settype,
-                             int(pthread_mutexattr_t *, int))
-LLVM_SYMBOLIZER_INTERCEPTOR1(pthread_getspecific, void *(pthread_key_t))
-LLVM_SYMBOLIZER_INTERCEPTOR2(pthread_key_create,
-                             int(pthread_key_t *, void (*)(void *)))
-LLVM_SYMBOLIZER_INTERCEPTOR2(pthread_once,
-                             int(pthread_once_t *, void (*)(void)))
-LLVM_SYMBOLIZER_INTERCEPTOR2(pthread_setspecific,
-                             int(pthread_key_t, const void *))
-LLVM_SYMBOLIZER_INTERCEPTOR3(pthread_sigmask,
-                             int(int, const sigset_t *, sigset_t *))
-
-}  // extern "C"

Copied: compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_wrappers.cpp (from r367470, compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_wrappers.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_wrappers.cpp?p2=compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_wrappers.cpp&p1=compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_wrappers.cc&r1=367470&r2=367471&rev=367471&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_wrappers.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/symbolizer/sanitizer_wrappers.cpp Wed Jul 31 12:41:02 2019
@@ -1,4 +1,4 @@
-//===-- sanitizer_wrappers.cc -----------------------------------*- C++ -*-===//
+//===-- sanitizer_wrappers.cpp ----------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

Modified: compiler-rt/trunk/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh?rev=367471&r1=367470&r2=367471&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh (original)
+++ compiler-rt/trunk/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh Wed Jul 31 12:41:02 2019
@@ -136,7 +136,7 @@ cd ${SYMBOLIZER_BUILD}
 
 echo "Compiling..."
 SYMBOLIZER_FLAGS="$LLVM_FLAGS -I${LLVM_SRC}/include -I${LLVM_BUILD}/include -std=c++11"
-$CXX $SYMBOLIZER_FLAGS ${SRC_DIR}/sanitizer_symbolize.cc ${SRC_DIR}/sanitizer_wrappers.cc -c
+$CXX $SYMBOLIZER_FLAGS ${SRC_DIR}/sanitizer_symbolize.cpp ${SRC_DIR}/sanitizer_wrappers.cpp -c
 $AR rc symbolizer.a sanitizer_symbolize.o sanitizer_wrappers.o
 
 SYMBOLIZER_API_LIST=__sanitizer_symbolize_code,__sanitizer_symbolize_data,__sanitizer_symbolize_flush,__sanitizer_symbolize_demangle




More information about the llvm-commits mailing list