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