[compiler-rt] a88b199 - [𝘀𝗽𝗿] initial version

2023-11-21 Thread Andrés Villegas via llvm-branch-commits

Author: Andrés Villegas
Date: 2023-11-21T21:20:05Z
New Revision: a88b199f945c3bfceefdb3aeae9d54a527f8e678

URL: 
https://github.com/llvm/llvm-project/commit/a88b199f945c3bfceefdb3aeae9d54a527f8e678
DIFF: 
https://github.com/llvm/llvm-project/commit/a88b199f945c3bfceefdb3aeae9d54a527f8e678.diff

LOG: [𝘀𝗽𝗿] initial version

Created using spr 1.3.4

Added: 


Modified: 
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h

Removed: 




diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
index 8db321051e1a0de..69047c2e31eca2a 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
@@ -32,8 +32,7 @@ StackTracePrinter *StackTracePrinter::GetOrInit() {
   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)
@@ -324,9 +323,10 @@ void 
FormattedStackTracePrinter::RenderData(InternalScopedString *buffer,
 
 #endif  // !SANITIZER_SYMBOLIZER_MARKUP
 
-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) {
   if (vs_style && line > 0) {
 buffer->AppendF("%s(%d", StripPathPrefix(file, strip_path_prefix), line);
 if (column > 0)
@@ -343,9 +343,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));

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h 
b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h
index 3e02333a8c8d5cc..9cf39013e78bc17 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h
@@ -25,7 +25,8 @@ 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);
 
   virtual void RenderFrame(InternalScopedString *buffer, const char *format,
int frame_no, uptr address, const AddressInfo *info,
@@ -34,15 +35,13 @@ 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;
+  void RenderSourceLocation(InternalScopedString *buffer, const char *file,
+int line, int column, bool vs_style,
+const char *strip_path_prefix);
 
-  virtual void RenderModuleLocation(InternalScopedString *buffer,
-const char *module, uptr offset,
-ModuleArch arch,
-const char *strip_path_prefix) = 0;
+  void RenderModuleLocation(InternalScopedString *buffer, const char *module,
+uptr offset, ModuleArch arch,
+const char *strip_path_prefix);
   virtual void RenderData(InternalScopedString *buffer, const char *format,
   const DataInfo *DI,
   const char *strip_path_prefix = "") = 0;
@@ -53,9 +52,6 @@ class StackTracePrinter {
 
 class FormattedStackTracePrinter : public StackTracePrinter {
  public:
-  // Strip interceptor prefixes from function name.
-  const char *StripFunctionName(cons

[compiler-rt] 1aae915 - [𝘀𝗽𝗿] initial version

2023-11-21 Thread Andrés Villegas via llvm-branch-commits

Author: Andrés Villegas
Date: 2023-11-21T21:20:12Z
New Revision: 1aae91547a1825f07a5426872cd7eeb22adf9719

URL: 
https://github.com/llvm/llvm-project/commit/1aae91547a1825f07a5426872cd7eeb22adf9719
DIFF: 
https://github.com/llvm/llvm-project/commit/1aae91547a1825f07a5426872cd7eeb22adf9719.diff

LOG: [𝘀𝗽𝗿] initial version

Created using spr 1.3.4

Added: 


Modified: 
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp

Removed: 




diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
index 8db321051e1a0de..e0c3943e4a9743e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
@@ -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"
@@ -25,15 +26,13 @@ StackTracePrinter *StackTracePrinter::GetOrInit() {
   if (stacktrace_printer)
 return stacktrace_printer;
 
-  stacktrace_printer =
-  new (GetGlobalLowLevelAllocator()) FormattedStackTracePrinter();
+  stacktrace_printer = StackTracePrinter::PlatformInit();
 
   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)
@@ -62,6 +61,10 @@ const char *FormattedStackTracePrinter::StripFunctionName(
 // sanitizer_symbolizer_markup.cpp implements these 
diff erently.
 #if !SANITIZER_SYMBOLIZER_MARKUP
 
+StackTracePrinter *StackTracePrinter::PlatformInit() {
+  return new (GetGlobalLowLevelAllocator()) FormattedStackTracePrinter();
+}
+
 static const char *DemangleFunctionName(const char *function) {
   if (!common_flags()->demangle)
 return function;
@@ -324,9 +327,10 @@ void 
FormattedStackTracePrinter::RenderData(InternalScopedString *buffer,
 
 #endif  // !SANITIZER_SYMBOLIZER_MARKUP
 
-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) {
   if (vs_style && line > 0) {
 buffer->AppendF("%s(%d", StripPathPrefix(file, strip_path_prefix), line);
 if (column > 0)
@@ -343,9 +347,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));

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h 
b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h
index 3e02333a8c8d5cc..9de09bda0062d45 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h
@@ -25,7 +25,8 @@ 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);
 
   virtual void RenderFrame(InternalScopedString *buffer, const char *format,
int frame_no, uptr address, const AddressInfo *info,
@@ -34,28 +35,27 @@ 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;
+  void RenderSourceLocation(InternalScopedString *buffer, const char *file,
+int line, int colum

[llvm-branch-commits] [compiler-rt] [sanitizer_symbolizer] Add MarkupStackTracePrinter (PR #73040)

2023-11-21 Thread Andres Villegas via llvm-branch-commits

https://github.com/avillega created 
https://github.com/llvm/llvm-project/pull/73040

This PR is part of a stack, #73029 should be merged
and reviewed first. Please only review the last commit
of this PR.

Adds a new Implementation of StackTracePrinter that only
emits symbolizer markup. Currently this change only
affects Fuchsia OS. Should be NFC.



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] [sanitizer_symbolizer] Add MarkupStackTracePrinter (PR #73040)

2023-11-21 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Andres Villegas (avillega)


Changes

This PR is part of a stack, #73029 should be merged
and reviewed first. Please only review the last commit
of this PR.

Adds a new Implementation of StackTracePrinter that only
emits symbolizer markup. Currently this change only
affects Fuchsia OS. Should be NFC.


---
Full diff: https://github.com/llvm/llvm-project/pull/73040.diff


3 Files Affected:

- (modified) compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp 
(+6-2) 
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h 
(+4) 
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp 
(+23-21) 


``diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
index 69047c2e31eca2a..e0c3943e4a9743e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
@@ -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"
@@ -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;
@@ -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;
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h 
b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h
index 9cf39013e78bc17..9de09bda0062d45 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h
@@ -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() {}
 };
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp
index 6402cfd7c36e443..ef3866a4bd32ac8 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp
@@ -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(kFor

[llvm-branch-commits] [compiler-rt] [sanitizer_symbolizer] Add MarkupStackTracePrinter (PR #73040)

2023-11-21 Thread Andres Villegas via llvm-branch-commits

https://github.com/avillega closed 
https://github.com/llvm/llvm-project/pull/73040
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] [sanitizer_symbolizer] Add MarkupStackTracePrinter (PR #73040)

2023-11-21 Thread Andres Villegas via llvm-branch-commits

avillega wrote:

Was trying out spr

https://github.com/llvm/llvm-project/pull/73040
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits