-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[sanitizer_symbolizer] Add initial symbolizer markup #72605
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,28 +12,14 @@ | |
|
||
#include "sanitizer_stacktrace_printer.h" | ||
|
||
#include "sanitizer_common.h" | ||
#include "sanitizer_file.h" | ||
#include "sanitizer_flags.h" | ||
#include "sanitizer_fuchsia.h" | ||
#include "sanitizer_symbolizer_markup.h" | ||
|
||
namespace __sanitizer { | ||
|
||
StackTracePrinter *StackTracePrinter::GetOrInit() { | ||
static StackTracePrinter *stacktrace_printer; | ||
static StaticSpinMutex init_mu; | ||
SpinMutexLock l(&init_mu); | ||
if (stacktrace_printer) | ||
return stacktrace_printer; | ||
|
||
stacktrace_printer = | ||
new (GetGlobalLowLevelAllocator()) FormattedStackTracePrinter(); | ||
|
||
CHECK(stacktrace_printer); | ||
return stacktrace_printer; | ||
} | ||
|
||
const char *FormattedStackTracePrinter::StripFunctionName( | ||
const char *function) { | ||
const char *StackTracePrinter::StripFunctionName(const char *function) { | ||
if (!common_flags()->demangle) | ||
return function; | ||
if (!function) | ||
|
@@ -59,8 +45,27 @@ const char *FormattedStackTracePrinter::StripFunctionName( | |
return function; | ||
} | ||
|
||
// sanitizer_symbolizer_markup.cpp implements these differently. | ||
#if !SANITIZER_SYMBOLIZER_MARKUP | ||
// sanitizer_symbolizer_markup_fuchsia.cpp implements these differently. | ||
#if !SANITIZER_FUCHSIA | ||
|
||
StackTracePrinter *StackTracePrinter::GetOrInit() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does wrapping this with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It means it won't be used if we are compiling for fuchsia, this one was part of the motivation on renaming this definition. |
||
static StackTracePrinter *stacktrace_printer; | ||
static StaticSpinMutex init_mu; | ||
SpinMutexLock l(&init_mu); | ||
if (stacktrace_printer) | ||
return stacktrace_printer; | ||
|
||
if (common_flags()->enable_symbolizer_markup) { | ||
stacktrace_printer = | ||
new (GetGlobalLowLevelAllocator()) MarkupStackTracePrinter(); | ||
} else { | ||
stacktrace_printer = | ||
new (GetGlobalLowLevelAllocator()) FormattedStackTracePrinter(); | ||
} | ||
|
||
CHECK(stacktrace_printer); | ||
return stacktrace_printer; | ||
} | ||
|
||
static const char *DemangleFunctionName(const char *function) { | ||
if (!common_flags()->demangle) | ||
|
@@ -322,11 +327,12 @@ void FormattedStackTracePrinter::RenderData(InternalScopedString *buffer, | |
} | ||
} | ||
|
||
#endif // !SANITIZER_SYMBOLIZER_MARKUP | ||
#endif // !SANITIZER_FUCHSIA | ||
|
||
void FormattedStackTracePrinter::RenderSourceLocation( | ||
InternalScopedString *buffer, const char *file, int line, int column, | ||
bool vs_style, const char *strip_path_prefix) { | ||
void StackTracePrinter::RenderSourceLocation(InternalScopedString *buffer, | ||
const char *file, int line, | ||
int column, bool vs_style, | ||
const char *strip_path_prefix) { | ||
Comment on lines
+332
to
+335
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change is that this and |
||
if (vs_style && line > 0) { | ||
buffer->AppendF("%s(%d", StripPathPrefix(file, strip_path_prefix), line); | ||
if (column > 0) | ||
|
@@ -343,9 +349,10 @@ void FormattedStackTracePrinter::RenderSourceLocation( | |
} | ||
} | ||
|
||
void FormattedStackTracePrinter::RenderModuleLocation( | ||
InternalScopedString *buffer, const char *module, uptr offset, | ||
ModuleArch arch, const char *strip_path_prefix) { | ||
void StackTracePrinter::RenderModuleLocation(InternalScopedString *buffer, | ||
const char *module, uptr offset, | ||
ModuleArch arch, | ||
const char *strip_path_prefix) { | ||
buffer->AppendF("(%s", StripPathPrefix(module, strip_path_prefix)); | ||
if (arch != kModuleArchUnknown) { | ||
buffer->AppendF(":%s", ModuleArchToString(arch)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
|
||
#include "sanitizer_common.h" | ||
#include "sanitizer_internal_defs.h" | ||
#include "sanitizer_platform.h" | ||
#include "sanitizer_symbolizer.h" | ||
|
||
namespace __sanitizer { | ||
|
@@ -25,7 +26,16 @@ class StackTracePrinter { | |
public: | ||
static StackTracePrinter *GetOrInit(); | ||
|
||
virtual const char *StripFunctionName(const char *function) = 0; | ||
// Strip interceptor prefixes from function name. | ||
const char *StripFunctionName(const char *function); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are not viritual functions anymore, the implementation of this functions are shared between all the implementation of |
||
|
||
void RenderSourceLocation(InternalScopedString *buffer, const char *file, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't move code around in separate NFC patches |
||
int line, int column, bool vs_style, | ||
const char *strip_path_prefix); | ||
|
||
void RenderModuleLocation(InternalScopedString *buffer, const char *module, | ||
uptr offset, ModuleArch arch, | ||
const char *strip_path_prefix); | ||
|
||
virtual void RenderFrame(InternalScopedString *buffer, const char *format, | ||
int frame_no, uptr address, const AddressInfo *info, | ||
|
@@ -34,15 +44,6 @@ class StackTracePrinter { | |
|
||
virtual bool RenderNeedsSymbolization(const char *format) = 0; | ||
|
||
virtual void RenderSourceLocation(InternalScopedString *buffer, | ||
const char *file, int line, int column, | ||
bool vs_style, | ||
const char *strip_path_prefix) = 0; | ||
|
||
virtual void RenderModuleLocation(InternalScopedString *buffer, | ||
const char *module, uptr offset, | ||
ModuleArch arch, | ||
const char *strip_path_prefix) = 0; | ||
virtual void RenderData(InternalScopedString *buffer, const char *format, | ||
const DataInfo *DI, | ||
const char *strip_path_prefix = "") = 0; | ||
|
@@ -51,11 +52,13 @@ class StackTracePrinter { | |
~StackTracePrinter() {} | ||
}; | ||
|
||
// See sanitizer_symbolizer_markup.h for the markup implementation of | ||
// StackTracePrinter. This is code is omited for targets that opt in to | ||
// use SymbolizerMarkup only. | ||
#if !SANITIZER_FUCHSIA | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it runs, I'd prefer we have it everywhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even SANITIZER_SYMBOLIZER_MARKUP seems nicer. |
||
|
||
class FormattedStackTracePrinter : public StackTracePrinter { | ||
public: | ||
// Strip interceptor prefixes from function name. | ||
const char *StripFunctionName(const char *function) override; | ||
|
||
// Render the contents of "info" structure, which represents the contents of | ||
// stack frame "frame_no" and appends it to the "buffer". "format" is a | ||
// string with placeholders, which is copied to the output with | ||
|
@@ -90,14 +93,6 @@ class FormattedStackTracePrinter : public StackTracePrinter { | |
|
||
bool RenderNeedsSymbolization(const char *format) override; | ||
|
||
void RenderSourceLocation(InternalScopedString *buffer, const char *file, | ||
int line, int column, bool vs_style, | ||
const char *strip_path_prefix) override; | ||
|
||
void RenderModuleLocation(InternalScopedString *buffer, const char *module, | ||
uptr offset, ModuleArch arch, | ||
const char *strip_path_prefix) override; | ||
|
||
// Same as RenderFrame, but for data section (global variables). | ||
// Accepts %s, %l from above. | ||
// Also accepts: | ||
|
@@ -110,6 +105,8 @@ class FormattedStackTracePrinter : public StackTracePrinter { | |
~FormattedStackTracePrinter() {} | ||
}; | ||
|
||
#endif // !SANITIZER_FUCHSIA | ||
|
||
} // namespace __sanitizer | ||
|
||
#endif // SANITIZER_STACKTRACE_PRINTER_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't mix random fix-ups with actual patch