15ef59e75Smrg //===-- sanitizer_stacktrace_printer.h --------------------------*- C++ -*-===// 25ef59e75Smrg // 3*490215a3Smrg // This file is distributed under the University of Illinois Open Source 4*490215a3Smrg // License. See LICENSE.TXT for details. 55ef59e75Smrg // 65ef59e75Smrg //===----------------------------------------------------------------------===// 75ef59e75Smrg // 85ef59e75Smrg // This file is shared between sanitizers' run-time libraries. 95ef59e75Smrg // 105ef59e75Smrg //===----------------------------------------------------------------------===// 115ef59e75Smrg #ifndef SANITIZER_STACKTRACE_PRINTER_H 125ef59e75Smrg #define SANITIZER_STACKTRACE_PRINTER_H 135ef59e75Smrg 145ef59e75Smrg #include "sanitizer_common.h" 155ef59e75Smrg #include "sanitizer_symbolizer.h" 165ef59e75Smrg 175ef59e75Smrg namespace __sanitizer { 185ef59e75Smrg 195ef59e75Smrg // Render the contents of "info" structure, which represents the contents of 205ef59e75Smrg // stack frame "frame_no" and appends it to the "buffer". "format" is a 215ef59e75Smrg // string with placeholders, which is copied to the output with 225ef59e75Smrg // placeholders substituted with the contents of "info". For example, 235ef59e75Smrg // format string 245ef59e75Smrg // " frame %n: function %F at %S" 255ef59e75Smrg // will be turned into 265ef59e75Smrg // " frame 10: function foo::bar() at my/file.cc:10" 275ef59e75Smrg // You may additionally pass "strip_path_prefix" to strip prefixes of paths to 285ef59e75Smrg // source files and modules, and "strip_func_prefix" to strip prefixes of 295ef59e75Smrg // function names. 305ef59e75Smrg // Here's the full list of available placeholders: 315ef59e75Smrg // %% - represents a '%' character; 325ef59e75Smrg // %n - frame number (copy of frame_no); 335ef59e75Smrg // %p - PC in hex format; 345ef59e75Smrg // %m - path to module (binary or shared object); 355ef59e75Smrg // %o - offset in the module in hex format; 365ef59e75Smrg // %f - function name; 375ef59e75Smrg // %q - offset in the function in hex format (*if available*); 385ef59e75Smrg // %s - path to source file; 395ef59e75Smrg // %l - line in the source file; 405ef59e75Smrg // %c - column in the source file; 415ef59e75Smrg // %F - if function is known to be <foo>, prints "in <foo>", possibly 425ef59e75Smrg // followed by the offset in this function, but only if source file 435ef59e75Smrg // is unknown; 445ef59e75Smrg // %S - prints file/line/column information; 455ef59e75Smrg // %L - prints location information: file/line/column, if it is known, or 465ef59e75Smrg // module+offset if it is known, or (<unknown module>) string. 475ef59e75Smrg // %M - prints module basename and offset, if it is known, or PC. 485ef59e75Smrg void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no, 4963aace61Smrg const AddressInfo &info, bool vs_style, 5063aace61Smrg const char *strip_path_prefix = "", 515ef59e75Smrg const char *strip_func_prefix = ""); 525ef59e75Smrg 535ef59e75Smrg void RenderSourceLocation(InternalScopedString *buffer, const char *file, 5463aace61Smrg int line, int column, bool vs_style, 5563aace61Smrg const char *strip_path_prefix); 565ef59e75Smrg 575ef59e75Smrg void RenderModuleLocation(InternalScopedString *buffer, const char *module, 583903d7f3Smrg uptr offset, ModuleArch arch, 593903d7f3Smrg const char *strip_path_prefix); 605ef59e75Smrg 616a5c9aabSmrg // Same as RenderFrame, but for data section (global variables). 626a5c9aabSmrg // Accepts %s, %l from above. 636a5c9aabSmrg // Also accepts: 646a5c9aabSmrg // %g - name of the global variable. 656a5c9aabSmrg void RenderData(InternalScopedString *buffer, const char *format, 666a5c9aabSmrg const DataInfo *DI, const char *strip_path_prefix = ""); 676a5c9aabSmrg 685ef59e75Smrg } // namespace __sanitizer 695ef59e75Smrg 705ef59e75Smrg #endif // SANITIZER_STACKTRACE_PRINTER_H 71