sanitizer_stacktrace_printer.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //===-- sanitizer_stacktrace_printer.h --------------------------*- C++ -*-===//
  2. //
  3. // This file is distributed under the University of Illinois Open Source
  4. // License. See LICENSE.TXT for details.
  5. //
  6. //===----------------------------------------------------------------------===//
  7. //
  8. // This file is shared between sanitizers' run-time libraries.
  9. //
  10. //===----------------------------------------------------------------------===//
  11. #ifndef SANITIZER_STACKTRACE_PRINTER_H
  12. #define SANITIZER_STACKTRACE_PRINTER_H
  13. #include "sanitizer_common.h"
  14. #include "sanitizer_symbolizer.h"
  15. namespace __sanitizer {
  16. // Render the contents of "info" structure, which represents the contents of
  17. // stack frame "frame_no" and appends it to the "buffer". "format" is a
  18. // string with placeholders, which is copied to the output with
  19. // placeholders substituted with the contents of "info". For example,
  20. // format string
  21. // " frame %n: function %F at %S"
  22. // will be turned into
  23. // " frame 10: function foo::bar() at my/file.cc:10"
  24. // You may additionally pass "strip_path_prefix" to strip prefixes of paths to
  25. // source files and modules, and "strip_func_prefix" to strip prefixes of
  26. // function names.
  27. // Here's the full list of available placeholders:
  28. // %% - represents a '%' character;
  29. // %n - frame number (copy of frame_no);
  30. // %p - PC in hex format;
  31. // %m - path to module (binary or shared object);
  32. // %o - offset in the module in hex format;
  33. // %f - function name;
  34. // %q - offset in the function in hex format (*if available*);
  35. // %s - path to source file;
  36. // %l - line in the source file;
  37. // %c - column in the source file;
  38. // %F - if function is known to be <foo>, prints "in <foo>", possibly
  39. // followed by the offset in this function, but only if source file
  40. // is unknown;
  41. // %S - prints file/line/column information;
  42. // %L - prints location information: file/line/column, if it is known, or
  43. // module+offset if it is known, or (<unknown module>) string.
  44. // %M - prints module basename and offset, if it is known, or PC.
  45. void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no,
  46. const AddressInfo &info, const char *strip_path_prefix = "",
  47. const char *strip_func_prefix = "");
  48. void RenderSourceLocation(InternalScopedString *buffer, const char *file,
  49. int line, int column, const char *strip_path_prefix);
  50. void RenderModuleLocation(InternalScopedString *buffer, const char *module,
  51. uptr offset, const char *strip_path_prefix);
  52. } // namespace __sanitizer
  53. #endif // SANITIZER_STACKTRACE_PRINTER_H