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