13cab2bb3Spatrick //===-- sanitizer_stacktrace_printer.h --------------------------*- C++ -*-===// 23cab2bb3Spatrick // 33cab2bb3Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 43cab2bb3Spatrick // See https://llvm.org/LICENSE.txt for license information. 53cab2bb3Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 63cab2bb3Spatrick // 73cab2bb3Spatrick //===----------------------------------------------------------------------===// 83cab2bb3Spatrick // 93cab2bb3Spatrick // This file is shared between sanitizers' run-time libraries. 103cab2bb3Spatrick // 113cab2bb3Spatrick //===----------------------------------------------------------------------===// 123cab2bb3Spatrick #ifndef SANITIZER_STACKTRACE_PRINTER_H 133cab2bb3Spatrick #define SANITIZER_STACKTRACE_PRINTER_H 143cab2bb3Spatrick 153cab2bb3Spatrick #include "sanitizer_common.h" 163cab2bb3Spatrick #include "sanitizer_symbolizer.h" 173cab2bb3Spatrick 183cab2bb3Spatrick namespace __sanitizer { 193cab2bb3Spatrick 203cab2bb3Spatrick // Render the contents of "info" structure, which represents the contents of 213cab2bb3Spatrick // stack frame "frame_no" and appends it to the "buffer". "format" is a 223cab2bb3Spatrick // string with placeholders, which is copied to the output with 233cab2bb3Spatrick // placeholders substituted with the contents of "info". For example, 243cab2bb3Spatrick // format string 253cab2bb3Spatrick // " frame %n: function %F at %S" 263cab2bb3Spatrick // will be turned into 273cab2bb3Spatrick // " frame 10: function foo::bar() at my/file.cc:10" 283cab2bb3Spatrick // You may additionally pass "strip_path_prefix" to strip prefixes of paths to 293cab2bb3Spatrick // source files and modules, and "strip_func_prefix" to strip prefixes of 303cab2bb3Spatrick // function names. 313cab2bb3Spatrick // Here's the full list of available placeholders: 323cab2bb3Spatrick // %% - represents a '%' character; 333cab2bb3Spatrick // %n - frame number (copy of frame_no); 343cab2bb3Spatrick // %p - PC in hex format; 353cab2bb3Spatrick // %m - path to module (binary or shared object); 363cab2bb3Spatrick // %o - offset in the module in hex format; 373cab2bb3Spatrick // %f - function name; 383cab2bb3Spatrick // %q - offset in the function in hex format (*if available*); 393cab2bb3Spatrick // %s - path to source file; 403cab2bb3Spatrick // %l - line in the source file; 413cab2bb3Spatrick // %c - column in the source file; 423cab2bb3Spatrick // %F - if function is known to be <foo>, prints "in <foo>", possibly 433cab2bb3Spatrick // followed by the offset in this function, but only if source file 443cab2bb3Spatrick // is unknown; 453cab2bb3Spatrick // %S - prints file/line/column information; 463cab2bb3Spatrick // %L - prints location information: file/line/column, if it is known, or 473cab2bb3Spatrick // module+offset if it is known, or (<unknown module>) string. 483cab2bb3Spatrick // %M - prints module basename and offset, if it is known, or PC. 493cab2bb3Spatrick void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no, 50*d89ec533Spatrick uptr address, const AddressInfo *info, bool vs_style, 513cab2bb3Spatrick const char *strip_path_prefix = "", 523cab2bb3Spatrick const char *strip_func_prefix = ""); 533cab2bb3Spatrick 54*d89ec533Spatrick bool RenderNeedsSymbolization(const char *format); 55*d89ec533Spatrick 563cab2bb3Spatrick void RenderSourceLocation(InternalScopedString *buffer, const char *file, 573cab2bb3Spatrick int line, int column, bool vs_style, 583cab2bb3Spatrick const char *strip_path_prefix); 593cab2bb3Spatrick 603cab2bb3Spatrick void RenderModuleLocation(InternalScopedString *buffer, const char *module, 613cab2bb3Spatrick uptr offset, ModuleArch arch, 623cab2bb3Spatrick const char *strip_path_prefix); 633cab2bb3Spatrick 643cab2bb3Spatrick // Same as RenderFrame, but for data section (global variables). 653cab2bb3Spatrick // Accepts %s, %l from above. 663cab2bb3Spatrick // Also accepts: 673cab2bb3Spatrick // %g - name of the global variable. 683cab2bb3Spatrick void RenderData(InternalScopedString *buffer, const char *format, 693cab2bb3Spatrick const DataInfo *DI, const char *strip_path_prefix = ""); 703cab2bb3Spatrick 713cab2bb3Spatrick } // namespace __sanitizer 723cab2bb3Spatrick 733cab2bb3Spatrick #endif // SANITIZER_STACKTRACE_PRINTER_H 74