[PATCH] [RFC] Print exact source locations of global variables in ASan error reports.

Alexey Samsonov vonosmas at gmail.com
Thu Jun 19 15:30:34 PDT 2014


================
Comment at: lib/Transforms/Instrumentation/AddressSanitizer.cpp:247
@@ +246,3 @@
+          GlobalVariable *GVLoc = cast<GlobalVariable>(Loc);
+          SourceLocation[GV] = GVLoc;
+          addSourceLocationGlobal(GVLoc);
----------------
Kostya Serebryany wrote:
> can this be done with a single lookup to SourceLocation and only if DN->getOperand(1) is non-zero?
Done.

================
Comment at: projects/compiler-rt/lib/asan/asan_interface_internal.h:53
@@ -44,1 +52,3 @@
     uptr has_dynamic_init;   // Non-zero if the global has dynamic initializer.
+    __asan_global_source_location *location;  // Source location of a global,
+                                              // or NULL if it is unknown.
----------------
Alexander Potapenko wrote:
> If you store file and line/column location separately you can probably save some memory.
Maybe, but 8 byte per global is not a big deal (we spend a bunch of memory for redzones anyway). I'd like to keep source location in a struct. In future we may be able to share it between different sanitizers. E.g. UBSan already has it, and uses the same layout.

http://reviews.llvm.org/D4203






More information about the cfe-commits mailing list