Skip to content

Commit 95ba9f9

Browse files
committed
[hwasan] print globals in symbolizer-friendly format.
Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D109698
1 parent 1bd5ea9 commit 95ba9f9

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

compiler-rt/lib/hwasan/hwasan_report.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,16 @@ static void ShowHeapOrGlobalCandidate(uptr untagged_addr, tag_t *candidate,
351351
uptr size = GetGlobalSizeFromDescriptor(mem);
352352
if (size == 0)
353353
// We couldn't find the size of the global from the descriptors.
354-
Printf("%p is located to the %s of a global variable in (%s+0x%x)\n",
355-
untagged_addr, candidate == left ? "right" : "left", module_name,
356-
module_address);
354+
Printf(
355+
"%p is located to the %s of a global variable in "
356+
"\n #0 0x%x (%s+0x%x)\n",
357+
untagged_addr, candidate == left ? "right" : "left", mem,
358+
module_name, module_address);
357359
else
358360
Printf(
359361
"%p is located to the %s of a %zd-byte global variable in "
360-
"(%s+0x%x)\n",
361-
untagged_addr, candidate == left ? "right" : "left", size,
362+
"\n #0 0x%x (%s+0x%x)\n",
363+
untagged_addr, candidate == left ? "right" : "left", size, mem,
362364
module_name, module_address);
363365
}
364366
Printf("%s", d.Default());

compiler-rt/test/hwasan/TestCases/global.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ int x = 1;
1212
int main(int argc, char **argv) {
1313
// CHECK: Cause: global-overflow
1414
// RSYM: is located 0 bytes to the right of 4-byte global variable x {{.*}} in {{.*}}global.c.tmp
15-
// RNOSYM: is located to the right of a 4-byte global variable in ({{.*}}global.c.tmp+{{.*}})
15+
// RNOSYM: is located to the right of a 4-byte global variable in
16+
// RNOSYM-NEXT: #0 0x{{.*}} ({{.*}}global.c.tmp+{{.*}})
1617
// LSYM: is located 4 bytes to the left of 4-byte global variable x {{.*}} in {{.*}}global.c.tmp
17-
// LNOSYM: is located to the left of a 4-byte global variable in ({{.*}}global.c.tmp+{{.*}})
18+
// LNOSYM: is located to the left of a 4-byte global variable in
19+
// LNOSYM-NEXT: #0 0x{{.*}} ({{.*}}global.c.tmp+{{.*}})
1820
// CHECK-NOT: can not describe
1921
(&x)[atoi(argv[1])] = 1;
2022
}

0 commit comments

Comments
 (0)