1 //===-- sanitizer_symbolizer_markup.h -----------------------------------===//
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 various sanitizers' runtime libraries.
11 // Header for the offline markup symbolizer.
12 //===----------------------------------------------------------------------===//
13 #ifndef SANITIZER_SYMBOLIZER_MARKUP_H
14 #define SANITIZER_SYMBOLIZER_MARKUP_H
16 #include "sanitizer_common.h"
17 #include "sanitizer_stacktrace_printer.h"
18 #include "sanitizer_symbolizer.h"
19 #include "sanitizer_symbolizer_internal.h"
21 namespace __sanitizer
{
23 // Simplier view of a LoadedModule. It only holds information necessary to
24 // identify unique modules.
25 struct RenderedModule
{
28 u8 uuid
[kModuleUUIDSize
]; // BuildId
31 class MarkupStackTracePrinter
: public StackTracePrinter
{
33 // We don't support the stack_trace_format flag at all.
34 void RenderFrame(InternalScopedString
*buffer
, const char *format
,
35 int frame_no
, uptr address
, const AddressInfo
*info
,
36 bool vs_style
, const char *strip_path_prefix
= "") override
;
38 bool RenderNeedsSymbolization(const char *format
) override
;
40 // We ignore the format argument to __sanitizer_symbolize_global.
41 void RenderData(InternalScopedString
*buffer
, const char *format
,
43 const char *strip_path_prefix
= "") override
;
46 // Keeps track of the modules that have been rendered to avoid re-rendering
48 InternalMmapVector
<RenderedModule
> renderedModules_
;
49 void RenderContext(InternalScopedString
*buffer
);
52 ~MarkupStackTracePrinter() {}
55 class MarkupSymbolizerTool final
: public SymbolizerTool
{
57 // This is used in some places for suppression checking, which we
58 // don't really support for Fuchsia. It's also used in UBSan to
59 // identify a PC location to a function name, so we always fill in
60 // the function member with a string containing markup around the PC
62 // TODO(mcgrathr): Under SANITIZER_GO, it's currently used by TSan
63 // to render stack frames, but that should be changed to use
65 bool SymbolizePC(uptr addr
, SymbolizedStack
*stack
) override
;
67 // Always claim we succeeded, so that RenderDataInfo will be called.
68 bool SymbolizeData(uptr addr
, DataInfo
*info
) override
;
70 // May return NULL if demangling failed.
71 // This is used by UBSan for type names, and by ASan for global variable
72 // names. It's expected to return a static buffer that will be reused on each
74 const char *Demangle(const char *name
) override
;
77 } // namespace __sanitizer
79 #endif // SANITIZER_SYMBOLIZER_MARKUP_H