Skip to content

Commit 23c84fb

Browse files
author
Andres Villegas
authored
[NFC sanitizer_symbolizer] Make some functions non virtual in StackTracePrinter. (#73029)
Make some methods of StackTracPrinter that will have a common implementation, non virtual.
1 parent ca9b1d1 commit 23c84fb

File tree

2 files changed

+17
-28
lines changed

2 files changed

+17
-28
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ StackTracePrinter *StackTracePrinter::GetOrInit() {
3232
return stacktrace_printer;
3333
}
3434

35-
const char *FormattedStackTracePrinter::StripFunctionName(
36-
const char *function) {
35+
const char *StackTracePrinter::StripFunctionName(const char *function) {
3736
if (!common_flags()->demangle)
3837
return function;
3938
if (!function)
@@ -324,9 +323,10 @@ void FormattedStackTracePrinter::RenderData(InternalScopedString *buffer,
324323

325324
#endif // !SANITIZER_SYMBOLIZER_MARKUP
326325

327-
void FormattedStackTracePrinter::RenderSourceLocation(
328-
InternalScopedString *buffer, const char *file, int line, int column,
329-
bool vs_style, const char *strip_path_prefix) {
326+
void StackTracePrinter::RenderSourceLocation(InternalScopedString *buffer,
327+
const char *file, int line,
328+
int column, bool vs_style,
329+
const char *strip_path_prefix) {
330330
if (vs_style && line > 0) {
331331
buffer->AppendF("%s(%d", StripPathPrefix(file, strip_path_prefix), line);
332332
if (column > 0)
@@ -343,9 +343,10 @@ void FormattedStackTracePrinter::RenderSourceLocation(
343343
}
344344
}
345345

346-
void FormattedStackTracePrinter::RenderModuleLocation(
347-
InternalScopedString *buffer, const char *module, uptr offset,
348-
ModuleArch arch, const char *strip_path_prefix) {
346+
void StackTracePrinter::RenderModuleLocation(InternalScopedString *buffer,
347+
const char *module, uptr offset,
348+
ModuleArch arch,
349+
const char *strip_path_prefix) {
349350
buffer->AppendF("(%s", StripPathPrefix(module, strip_path_prefix));
350351
if (arch != kModuleArchUnknown) {
351352
buffer->AppendF(":%s", ModuleArchToString(arch));

compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class StackTracePrinter {
2525
public:
2626
static StackTracePrinter *GetOrInit();
2727

28-
virtual const char *StripFunctionName(const char *function) = 0;
28+
// Strip interceptor prefixes from function name.
29+
const char *StripFunctionName(const char *function);
2930

3031
virtual void RenderFrame(InternalScopedString *buffer, const char *format,
3132
int frame_no, uptr address, const AddressInfo *info,
@@ -34,15 +35,13 @@ class StackTracePrinter {
3435

3536
virtual bool RenderNeedsSymbolization(const char *format) = 0;
3637

37-
virtual void RenderSourceLocation(InternalScopedString *buffer,
38-
const char *file, int line, int column,
39-
bool vs_style,
40-
const char *strip_path_prefix) = 0;
38+
void RenderSourceLocation(InternalScopedString *buffer, const char *file,
39+
int line, int column, bool vs_style,
40+
const char *strip_path_prefix);
4141

42-
virtual void RenderModuleLocation(InternalScopedString *buffer,
43-
const char *module, uptr offset,
44-
ModuleArch arch,
45-
const char *strip_path_prefix) = 0;
42+
void RenderModuleLocation(InternalScopedString *buffer, const char *module,
43+
uptr offset, ModuleArch arch,
44+
const char *strip_path_prefix);
4645
virtual void RenderData(InternalScopedString *buffer, const char *format,
4746
const DataInfo *DI,
4847
const char *strip_path_prefix = "") = 0;
@@ -53,9 +52,6 @@ class StackTracePrinter {
5352

5453
class FormattedStackTracePrinter : public StackTracePrinter {
5554
public:
56-
// Strip interceptor prefixes from function name.
57-
const char *StripFunctionName(const char *function) override;
58-
5955
// Render the contents of "info" structure, which represents the contents of
6056
// stack frame "frame_no" and appends it to the "buffer". "format" is a
6157
// string with placeholders, which is copied to the output with
@@ -90,14 +86,6 @@ class FormattedStackTracePrinter : public StackTracePrinter {
9086

9187
bool RenderNeedsSymbolization(const char *format) override;
9288

93-
void RenderSourceLocation(InternalScopedString *buffer, const char *file,
94-
int line, int column, bool vs_style,
95-
const char *strip_path_prefix) override;
96-
97-
void RenderModuleLocation(InternalScopedString *buffer, const char *module,
98-
uptr offset, ModuleArch arch,
99-
const char *strip_path_prefix) override;
100-
10189
// Same as RenderFrame, but for data section (global variables).
10290
// Accepts %s, %l from above.
10391
// Also accepts:

0 commit comments

Comments
 (0)