1 //===-- sanitizer_stacktrace_printer.h --------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file is shared between sanitizers' run-time libraries.
11 //===----------------------------------------------------------------------===//
12 #ifndef SANITIZER_STACKTRACE_PRINTER_H
13 #define SANITIZER_STACKTRACE_PRINTER_H
15 #include "sanitizer_common.h"
16 #include "sanitizer_symbolizer.h"
18 namespace __sanitizer
{
20 // Render the contents of "info" structure, which represents the contents of
21 // stack frame "frame_no" and appends it to the "buffer". "format" is a
22 // string with placeholders, which is copied to the output with
23 // placeholders substituted with the contents of "info". For example,
25 // " frame %n: function %F at %S"
26 // will be turned into
27 // " frame 10: function foo::bar() at my/file.cc:10"
28 // You may additionally pass "strip_path_prefix" to strip prefixes of paths to
29 // source files and modules, and "strip_func_prefix" to strip prefixes of
31 // Here's the full list of available placeholders:
32 // %% - represents a '%' character;
33 // %n - frame number (copy of frame_no);
34 // %p - PC in hex format;
35 // %m - path to module (binary or shared object);
36 // %o - offset in the module in hex format;
37 // %f - function name;
38 // %q - offset in the function in hex format (*if available*);
39 // %s - path to source file;
40 // %l - line in the source file;
41 // %c - column in the source file;
42 // %F - if function is known to be <foo>, prints "in <foo>", possibly
43 // followed by the offset in this function, but only if source file
45 // %S - prints file/line/column information;
46 // %L - prints location information: file/line/column, if it is known, or
47 // module+offset if it is known, or (<unknown module>) string.
48 // %M - prints module basename and offset, if it is known, or PC.
49 void RenderFrame(InternalScopedString
*buffer
, const char *format
, int frame_no
,
50 uptr address
, const AddressInfo
*info
, bool vs_style
,
51 const char *strip_path_prefix
= "",
52 const char *strip_func_prefix
= "");
54 bool RenderNeedsSymbolization(const char *format
);
56 void RenderSourceLocation(InternalScopedString
*buffer
, const char *file
,
57 int line
, int column
, bool vs_style
,
58 const char *strip_path_prefix
);
60 void RenderModuleLocation(InternalScopedString
*buffer
, const char *module
,
61 uptr offset
, ModuleArch arch
,
62 const char *strip_path_prefix
);
64 // Same as RenderFrame, but for data section (global variables).
65 // Accepts %s, %l from above.
67 // %g - name of the global variable.
68 void RenderData(InternalScopedString
*buffer
, const char *format
,
69 const DataInfo
*DI
, const char *strip_path_prefix
= "");
71 } // namespace __sanitizer
73 #endif // SANITIZER_STACKTRACE_PRINTER_H