Skip to content

[sanitizer_symbolizer] Add MarkupStackTracePrinter #73040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "sanitizer_stacktrace_printer.h"

#include "sanitizer_common.h"
#include "sanitizer_file.h"
#include "sanitizer_flags.h"
#include "sanitizer_fuchsia.h"
Expand All @@ -25,8 +26,7 @@ StackTracePrinter *StackTracePrinter::GetOrInit() {
if (stacktrace_printer)
return stacktrace_printer;

stacktrace_printer =
new (GetGlobalLowLevelAllocator()) FormattedStackTracePrinter();
stacktrace_printer = StackTracePrinter::PlatformInit();

CHECK(stacktrace_printer);
return stacktrace_printer;
Expand Down Expand Up @@ -61,6 +61,10 @@ const char *StackTracePrinter::StripFunctionName(const char *function) {
// sanitizer_symbolizer_markup.cpp implements these differently.
#if !SANITIZER_SYMBOLIZER_MARKUP

StackTracePrinter *StackTracePrinter::PlatformInit() {
return new (GetGlobalLowLevelAllocator()) FormattedStackTracePrinter();
}

static const char *DemangleFunctionName(const char *function) {
if (!common_flags()->demangle)
return function;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class StackTracePrinter {
const DataInfo *DI,
const char *strip_path_prefix = "") = 0;

private:
// To be called from StackTracePrinter::GetOrInit
static StackTracePrinter *PlatformInit();

protected:
~StackTracePrinter() {}
};
Expand Down
44 changes: 23 additions & 21 deletions compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,29 @@ bool Symbolizer::SymbolizeData(uptr addr, DataInfo *info) {
return true;
}

// We ignore the format argument to __sanitizer_symbolize_global.
void FormattedStackTracePrinter::RenderData(InternalScopedString *buffer,
const char *format,
const DataInfo *DI,
const char *strip_path_prefix) {
buffer->AppendF(kFormatData, DI->start);
}

bool FormattedStackTracePrinter::RenderNeedsSymbolization(const char *format) {
return false;
}

// We don't support the stack_trace_format flag at all.
void FormattedStackTracePrinter::RenderFrame(InternalScopedString *buffer,
const char *format, int frame_no,
uptr address,
const AddressInfo *info,
bool vs_style,
const char *strip_path_prefix) {
CHECK(!RenderNeedsSymbolization(format));
buffer->AppendF(kFormatFrame, frame_no, address);
class MarkupStackTracePrinter : public StackTracePrinter {
// We ignore the format argument to __sanitizer_symbolize_global.
void RenderData(InternalScopedString *buffer, const char *format,
const DataInfo *DI, const char *strip_path_prefix) override {
buffer->AppendF(kFormatData, DI->start);
}

bool RenderNeedsSymbolization(const char *format) override { return false; }

// We don't support the stack_trace_format flag at all.
void RenderFrame(InternalScopedString *buffer, const char *format,
int frame_no, uptr address, const AddressInfo *info,
bool vs_style, const char *strip_path_prefix) override {
CHECK(!RenderNeedsSymbolization(format));
buffer->AppendF(kFormatFrame, frame_no, address);
}

protected:
~MarkupStackTracePrinter();
};

StackTracePrinter *StackTracePrinter::PlatformInit() {
return new (GetGlobalLowLevelAllocator()) MarkupStackTracePrinter();
}

Symbolizer *Symbolizer::PlatformInit() {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.