sanitizer_symbolizer_libbacktrace.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //===-- sanitizer_symbolizer_libbacktrace.h ---------------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file is shared between AddressSanitizer and ThreadSanitizer
  10. // run-time libraries.
  11. // Header for libbacktrace symbolizer.
  12. //===----------------------------------------------------------------------===//
  13. #ifndef SANITIZER_SYMBOLIZER_LIBBACKTRACE_H
  14. #define SANITIZER_SYMBOLIZER_LIBBACKTRACE_H
  15. #include "sanitizer_platform.h"
  16. #include "sanitizer_common.h"
  17. #include "sanitizer_allocator_internal.h"
  18. #include "sanitizer_symbolizer_internal.h"
  19. #ifndef SANITIZER_LIBBACKTRACE
  20. # define SANITIZER_LIBBACKTRACE 0
  21. #endif
  22. #ifndef SANITIZER_CP_DEMANGLE
  23. # define SANITIZER_CP_DEMANGLE 0
  24. #endif
  25. namespace __sanitizer {
  26. class LibbacktraceSymbolizer final : public SymbolizerTool {
  27. public:
  28. static LibbacktraceSymbolizer *get(LowLevelAllocator *alloc);
  29. bool SymbolizePC(uptr addr, SymbolizedStack *stack) override;
  30. bool SymbolizeData(uptr addr, DataInfo *info) override;
  31. // May return NULL if demangling failed.
  32. const char *Demangle(const char *name) override;
  33. private:
  34. explicit LibbacktraceSymbolizer(void *state) : state_(state) {}
  35. void *state_; // Leaked.
  36. };
  37. } // namespace __sanitizer
  38. #endif // SANITIZER_SYMBOLIZER_LIBBACKTRACE_H