Printf(" '%s' is ascii string '%s'\n", g.name, (char*)g.beg);
}
+static const char *MaybeDemangleGlobalName(const char *name) {
+ // We can spoil names of globals with C linkage, so use an heuristic
+ // approach to check if the name should be demangled.
+ return (name[0] == '_' && name[1] == 'Z') ? Demangle(name) : name;
+}
+
bool DescribeAddressRelativeToGlobal(uptr addr, uptr size,
const __asan_global &g) {
static const uptr kMinimalDistanceFromAnotherGlobal = 64;
Printf("%p is located %zd bytes inside", (void*)addr, addr - g.beg);
}
Printf(" of global variable '%s' from '%s' (0x%zx) of size %zu\n",
- g.name, g.module_name, g.beg, g.size);
+ MaybeDemangleGlobalName(g.name), g.module_name, g.beg, g.size);
Printf("%s", d.EndLocation());
PrintGlobalNameIfASCII(g);
return true;
--- /dev/null
+// Don't run through %symbolize to avoid c++filt demangling.
+// RUN: %clangxx_asan -m64 -O0 %s -o %t && %t 2>&1 | FileCheck %s
+
+namespace XXX {
+class YYY {
+ public:
+ static int ZZZ[];
+};
+int YYY::ZZZ[] = {0, 1, 2, 3};
+}
+
+int main(int argc, char **argv) {
+ return XXX::YYY::ZZZ[argc + 5]; // BOOM
+ // CHECK: {{READ of size 4 at 0x.*}}
+ // CHECK: {{0x.* is located 8 bytes to the right of global variable}}
+ // CHECK: 'XXX::YYY::ZZZ' {{.*}} of size 16
+}