1*5f757f3fSDimitry Andric //===-- sanitizer_symbolizer_markup.h -----------------------------------===// 2*5f757f3fSDimitry Andric // 3*5f757f3fSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*5f757f3fSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*5f757f3fSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*5f757f3fSDimitry Andric // 7*5f757f3fSDimitry Andric //===----------------------------------------------------------------------===// 8*5f757f3fSDimitry Andric // 9*5f757f3fSDimitry Andric // This file is shared between various sanitizers' runtime libraries. 10*5f757f3fSDimitry Andric // 11*5f757f3fSDimitry Andric // Header for the offline markup symbolizer. 12*5f757f3fSDimitry Andric //===----------------------------------------------------------------------===// 13*5f757f3fSDimitry Andric #ifndef SANITIZER_SYMBOLIZER_MARKUP_H 14*5f757f3fSDimitry Andric #define SANITIZER_SYMBOLIZER_MARKUP_H 15*5f757f3fSDimitry Andric 16*5f757f3fSDimitry Andric #include "sanitizer_common.h" 17*5f757f3fSDimitry Andric #include "sanitizer_stacktrace_printer.h" 18*5f757f3fSDimitry Andric #include "sanitizer_symbolizer.h" 19*5f757f3fSDimitry Andric #include "sanitizer_symbolizer_internal.h" 20*5f757f3fSDimitry Andric 21*5f757f3fSDimitry Andric namespace __sanitizer { 22*5f757f3fSDimitry Andric 23*5f757f3fSDimitry Andric // Simplier view of a LoadedModule. It only holds information necessary to 24*5f757f3fSDimitry Andric // identify unique modules. 25*5f757f3fSDimitry Andric struct RenderedModule { 26*5f757f3fSDimitry Andric char *full_name; 27*5f757f3fSDimitry Andric uptr base_address; 28*5f757f3fSDimitry Andric u8 uuid[kModuleUUIDSize]; // BuildId 29*5f757f3fSDimitry Andric }; 30*5f757f3fSDimitry Andric 31*5f757f3fSDimitry Andric class MarkupStackTracePrinter : public StackTracePrinter { 32*5f757f3fSDimitry Andric public: 33*5f757f3fSDimitry Andric // We don't support the stack_trace_format flag at all. 34*5f757f3fSDimitry Andric void RenderFrame(InternalScopedString *buffer, const char *format, 35*5f757f3fSDimitry Andric int frame_no, uptr address, const AddressInfo *info, 36*5f757f3fSDimitry Andric bool vs_style, const char *strip_path_prefix = "") override; 37*5f757f3fSDimitry Andric 38*5f757f3fSDimitry Andric bool RenderNeedsSymbolization(const char *format) override; 39*5f757f3fSDimitry Andric 40*5f757f3fSDimitry Andric // We ignore the format argument to __sanitizer_symbolize_global. 41*5f757f3fSDimitry Andric void RenderData(InternalScopedString *buffer, const char *format, 42*5f757f3fSDimitry Andric const DataInfo *DI, 43*5f757f3fSDimitry Andric const char *strip_path_prefix = "") override; 44*5f757f3fSDimitry Andric 45*5f757f3fSDimitry Andric private: 46*5f757f3fSDimitry Andric // Keeps track of the modules that have been rendered to avoid re-rendering 47*5f757f3fSDimitry Andric // them 48*5f757f3fSDimitry Andric InternalMmapVector<RenderedModule> renderedModules_; 49*5f757f3fSDimitry Andric void RenderContext(InternalScopedString *buffer); 50*5f757f3fSDimitry Andric 51*5f757f3fSDimitry Andric protected: 52*5f757f3fSDimitry Andric ~MarkupStackTracePrinter() {} 53*5f757f3fSDimitry Andric }; 54*5f757f3fSDimitry Andric 55*5f757f3fSDimitry Andric class MarkupSymbolizerTool final : public SymbolizerTool { 56*5f757f3fSDimitry Andric public: 57*5f757f3fSDimitry Andric // This is used in some places for suppression checking, which we 58*5f757f3fSDimitry Andric // don't really support for Fuchsia. It's also used in UBSan to 59*5f757f3fSDimitry Andric // identify a PC location to a function name, so we always fill in 60*5f757f3fSDimitry Andric // the function member with a string containing markup around the PC 61*5f757f3fSDimitry Andric // value. 62*5f757f3fSDimitry Andric // TODO(mcgrathr): Under SANITIZER_GO, it's currently used by TSan 63*5f757f3fSDimitry Andric // to render stack frames, but that should be changed to use 64*5f757f3fSDimitry Andric // RenderStackFrame. 65*5f757f3fSDimitry Andric bool SymbolizePC(uptr addr, SymbolizedStack *stack) override; 66*5f757f3fSDimitry Andric 67*5f757f3fSDimitry Andric // Always claim we succeeded, so that RenderDataInfo will be called. 68*5f757f3fSDimitry Andric bool SymbolizeData(uptr addr, DataInfo *info) override; 69*5f757f3fSDimitry Andric 70*5f757f3fSDimitry Andric // May return NULL if demangling failed. 71*5f757f3fSDimitry Andric // This is used by UBSan for type names, and by ASan for global variable 72*5f757f3fSDimitry Andric // names. It's expected to return a static buffer that will be reused on each 73*5f757f3fSDimitry Andric // call. 74*5f757f3fSDimitry Andric const char *Demangle(const char *name) override; 75*5f757f3fSDimitry Andric }; 76*5f757f3fSDimitry Andric 77*5f757f3fSDimitry Andric } // namespace __sanitizer 78*5f757f3fSDimitry Andric 79*5f757f3fSDimitry Andric #endif // SANITIZER_SYMBOLIZER_MARKUP_H 80