summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/asan_stack.cc
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-08-22 13:31:37 +0000
committerAlexey Samsonov <samsonov@google.com>2012-08-22 13:31:37 +0000
commita85b6b8154f57043af388d7626502fbcc93150ed (patch)
tree793ee040c1d0daa71bf153b6dc64a699bcee30f6 /compiler-rt/lib/asan/asan_stack.cc
parent9e10605d6b4b508c38234524fe69e6fca62cf217 (diff)
downloadbcm5719-llvm-a85b6b8154f57043af388d7626502fbcc93150ed.tar.gz
bcm5719-llvm-a85b6b8154f57043af388d7626502fbcc93150ed.zip
[ASan] get rid of ASAN_USE_EXTERNAL_SYMBOLIZER compiler def in favor of __asan_set_symbolize_callback interface function. Now the user doesn't have to recompile ASan runtime to provide its own symbolizer
llvm-svn: 162358
Diffstat (limited to 'compiler-rt/lib/asan/asan_stack.cc')
-rw-r--r--compiler-rt/lib/asan/asan_stack.cc41
1 files changed, 21 insertions, 20 deletions
diff --git a/compiler-rt/lib/asan/asan_stack.cc b/compiler-rt/lib/asan/asan_stack.cc
index 1099f32fa13..42ef88c6bb7 100644
--- a/compiler-rt/lib/asan/asan_stack.cc
+++ b/compiler-rt/lib/asan/asan_stack.cc
@@ -12,6 +12,7 @@
// Code for ASan stack trace.
//===----------------------------------------------------------------------===//
#include "asan_interceptors.h"
+#include "asan_interface.h"
#include "asan_lock.h"
#include "asan_stack.h"
#include "asan_thread.h"
@@ -19,13 +20,10 @@
#include "sanitizer_common/sanitizer_procmaps.h"
#include "sanitizer_common/sanitizer_symbolizer.h"
-#ifdef ASAN_USE_EXTERNAL_SYMBOLIZER
-extern bool
-ASAN_USE_EXTERNAL_SYMBOLIZER(const void *pc, char *out, int out_size);
-#endif
-
namespace __asan {
+static __asan_symbolize_callback symbolize_callback;
+
static const char *StripPathPrefix(const char *filepath) {
const char *path_prefix = flags()->strip_path_prefix;
if (filepath == internal_strstr(filepath, path_prefix))
@@ -45,25 +43,21 @@ static uptr patch_pc(uptr pc) {
return pc - 1;
}
-#if defined(ASAN_USE_EXTERNAL_SYMBOLIZER)
-void AsanStackTrace::PrintStack(uptr *addr, uptr size) {
- for (uptr i = 0; i < size && addr[i]; i++) {
- uptr pc = patch_pc(addr[i]);
- char buff[4096];
- ASAN_USE_EXTERNAL_SYMBOLIZER((void*)pc, buff, sizeof(buff));
- // We can't know anything about the string returned by external
- // symbolizer, but if it starts with filename, try to strip path prefix
- // from it.
- AsanPrintf(" #%zu 0x%zx %s\n", i, pc, StripPathPrefix(buff));
- }
-}
-
-#else // ASAN_USE_EXTERNAL_SYMBOLIZER
void AsanStackTrace::PrintStack(uptr *addr, uptr size) {
ProcessMaps proc_maps;
uptr frame_num = 0;
for (uptr i = 0; i < size && addr[i]; i++) {
uptr pc = patch_pc(addr[i]);
+ if (symbolize_callback) {
+ char buff[4096];
+ symbolize_callback((void*)pc, buff, sizeof(buff));
+ // We can't know anything about the string returned by external
+ // symbolizer, but if it starts with filename, try to strip path prefix
+ // from it.
+ AsanPrintf(" #%zu 0x%zx %s\n", frame_num, pc, StripPathPrefix(buff));
+ frame_num++;
+ continue;
+ }
AddressInfo addr_frames[64];
uptr addr_frames_num = 0;
if (flags()->symbolize) {
@@ -102,7 +96,6 @@ void AsanStackTrace::PrintStack(uptr *addr, uptr size) {
}
}
}
-#endif // ASAN_USE_EXTERNAL_SYMBOLIZER
uptr AsanStackTrace::GetCurrentPc() {
return GET_CALLER_PC();
@@ -240,3 +233,11 @@ void AsanStackTrace::UncompressStack(AsanStackTrace *stack,
}
} // namespace __asan
+
+// ------------------ Interface -------------- {{{1
+using namespace __asan; // NOLINT
+
+void NOINLINE __asan_set_symbolize_callback(
+ __asan_symbolize_callback callback) {
+ symbolize_callback = callback;
+}
OpenPOWER on IntegriCloud