[llvm-commits] [compiler-rt] r157924 - in /compiler-rt/trunk/lib/asan: asan_rtl.cc asan_stack.cc

Alexey Samsonov samsonov at google.com
Mon Jun 4 04:20:17 PDT 2012


Author: samsonov
Date: Mon Jun  4 06:20:17 2012
New Revision: 157924

URL: http://llvm.org/viewvc/llvm-project?rev=157924&view=rev
Log:
[ASan] Use ASan option symbolize to turn on internal symbolizer (in development)

Modified:
    compiler-rt/trunk/lib/asan/asan_rtl.cc
    compiler-rt/trunk/lib/asan/asan_stack.cc

Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=157924&r1=157923&r2=157924&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Mon Jun  4 06:20:17 2012
@@ -38,7 +38,7 @@
 s64 FLAG_report_globals = 1;
 bool    FLAG_handle_segv = ASAN_NEEDS_SEGV;
 bool    FLAG_use_sigaltstack = 0;
-bool    FLAG_symbolize = 1;
+bool    FLAG_symbolize = 0;
 s64 FLAG_demangle = 1;
 s64 FLAG_debug = 0;
 bool    FLAG_replace_cfallocator = 1;  // Used on Mac only.

Modified: compiler-rt/trunk/lib/asan/asan_stack.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_stack.cc?rev=157924&r1=157923&r2=157924&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_stack.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_stack.cc Mon Jun  4 06:20:17 2012
@@ -17,6 +17,9 @@
 #include "asan_stack.h"
 #include "asan_thread.h"
 #include "asan_thread_registry.h"
+#include "sanitizer_common/sanitizer_symbolizer.h"
+
+using namespace __sanitizer; // NOLINT
 
 #ifdef ASAN_USE_EXTERNAL_SYMBOLIZER
 extern bool
@@ -39,16 +42,32 @@
 #else  // ASAN_USE_EXTERNAL_SYMBOLIZER
 void AsanStackTrace::PrintStack(uptr *addr, uptr size) {
   AsanProcMaps proc_maps;
+  uptr frame_num = 0;
   for (uptr i = 0; i < size && addr[i]; i++) {
     proc_maps.Reset();
     uptr pc = addr[i];
     uptr offset;
     char filename[4096];
-    if (proc_maps.GetObjectNameAndOffset(pc, &offset,
-                                         filename, sizeof(filename))) {
-      Printf("    #%zu 0x%zx (%s+0x%zx)\n", i, pc, filename, offset);
+    if (FLAG_symbolize) {
+      AddressInfoList *address_info_list = SymbolizeCode(pc);
+      for (AddressInfoList *entry = address_info_list; entry;
+           entry = entry->next) {
+        AddressInfo info = entry->info;
+        Printf("    #%zu 0x%zx %s:%d:%d\n", frame_num, pc,
+                                            (info.file) ? info.file : "",
+                                            info.line, info.column);
+        frame_num++;
+      }
+      address_info_list->Clear();
     } else {
-      Printf("    #%zu 0x%zx\n", i, pc);
+      if (proc_maps.GetObjectNameAndOffset(pc, &offset,
+                                           filename, sizeof(filename))) {
+        Printf("    #%zu 0x%zx (%s+0x%zx)\n", frame_num, pc, filename,
+                                              offset);
+      } else {
+        Printf("    #%zu 0x%zx\n", frame_num, pc);
+      }
+      frame_num++;
     }
   }
 }





More information about the llvm-commits mailing list