[compiler-rt] ef85ea9 - [msan] Print both shadow and user address
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 7 17:56:57 PDT 2021
Author: Vitaly Buka
Date: 2021-10-07T17:56:46-07:00
New Revision: ef85ea9a4fbd65e7df2cef0b058f733dee15a42c
URL: https://github.com/llvm/llvm-project/commit/ef85ea9a4fbd65e7df2cef0b058f733dee15a42c
DIFF: https://github.com/llvm/llvm-project/commit/ef85ea9a4fbd65e7df2cef0b058f733dee15a42c.diff
LOG: [msan] Print both shadow and user address
before:
00 00 00 00 ff ff ff ff 00 00 00 00 00 00 00 00
Shadow map of [0x211000000005, 0x21100000012e), 297 bytes:
now:
0x2f60d213ac10[0x7f60d213ac10] 00 00 00 00 ff ff ff ff 00 00 00 00 00 00 00 00
Shadow map [0x211000000005, 0x21100000012e) of [0x711000000005, 0x711000000135), 297 bytes:
Differential Revision: https://reviews.llvm.org/D111261
Added:
Modified:
compiler-rt/lib/msan/msan.cpp
compiler-rt/lib/msan/msan_report.cpp
compiler-rt/test/msan/msan_check_mem_is_initialized.cpp
compiler-rt/test/msan/msan_dump_shadow.cpp
compiler-rt/test/msan/msan_print_shadow.cpp
compiler-rt/test/msan/msan_print_shadow2.cpp
compiler-rt/test/msan/msan_print_shadow3.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/msan/msan.cpp b/compiler-rt/lib/msan/msan.cpp
index 3c1ae17c7bb34..2202e34469213 100644
--- a/compiler-rt/lib/msan/msan.cpp
+++ b/compiler-rt/lib/msan/msan.cpp
@@ -515,6 +515,7 @@ void __msan_dump_shadow(const void *x, uptr size) {
}
unsigned char *s = (unsigned char*)MEM_TO_SHADOW(x);
+ Printf("%p[%p] ", s, x);
for (uptr i = 0; i < size; i++)
Printf("%x%x ", s[i] >> 4, s[i] & 0xf);
Printf("\n");
diff --git a/compiler-rt/lib/msan/msan_report.cpp b/compiler-rt/lib/msan/msan_report.cpp
index 3a7a237dea070..ff3e38c7db9ed 100644
--- a/compiler-rt/lib/msan/msan_report.cpp
+++ b/compiler-rt/lib/msan/msan_report.cpp
@@ -201,15 +201,18 @@ void DescribeMemoryRange(const void *x, uptr size) {
Decorator d;
Printf("%s", d.Warning());
- Printf("Shadow map of [%p, %p), %zu bytes:\n",
+ uptr start_x = reinterpret_cast<uptr>(x);
+ Printf("Shadow map [%p, %p) of [%p, %p), %zu bytes:\n",
reinterpret_cast<void *>(start), reinterpret_cast<void *>(end),
- end - start);
+ reinterpret_cast<void *>(start_x),
+ reinterpret_cast<void *>(start_x + end - start), end - start);
Printf("%s", d.Default());
while (s < e) {
// Line start.
if (pos % 16 == 0) {
for (int i = 0; i < 4; ++i) origin_ids[i] = -1;
- Printf("%p:", reinterpret_cast<void *>(s));
+ Printf("%p[%p]:", reinterpret_cast<void *>(s),
+ reinterpret_cast<void *>(start_x - start + s));
}
// Group start.
if (pos % 4 == 0) {
diff --git a/compiler-rt/test/msan/msan_check_mem_is_initialized.cpp b/compiler-rt/test/msan/msan_check_mem_is_initialized.cpp
index 81f7895f7aea3..81752291c7c5c 100644
--- a/compiler-rt/test/msan/msan_check_mem_is_initialized.cpp
+++ b/compiler-rt/test/msan/msan_check_mem_is_initialized.cpp
@@ -16,7 +16,7 @@ int main(void) {
#ifdef POSITIVE
__msan_check_mem_is_initialized(p + 5, 20);
// CHECK: Uninitialized bytes in __msan_check_mem_is_initialized at offset 5 inside [0x{{.*}}, 20)
- // CHECK-VERBOSE: Shadow map of [0x{{.*}}, 0x{{.*}}), 20 bytes:
+ // CHECK-VERBOSE: Shadow map [0x{{.*}}, 0x{{.*}}) of [0x{{.*}}, 0x{{.*}}), 20 bytes:
// CHECK-VERBOSE: 0x{{.*}}: ..000000 0000ffff 00000000 00000000
// CHECK-VERBOSE: 0x{{.*}}: 00000000 00...... ........ ........
diff --git a/compiler-rt/test/msan/msan_dump_shadow.cpp b/compiler-rt/test/msan/msan_dump_shadow.cpp
index 543fa70132239..48b84ef50f723 100644
--- a/compiler-rt/test/msan/msan_dump_shadow.cpp
+++ b/compiler-rt/test/msan/msan_dump_shadow.cpp
@@ -18,5 +18,5 @@ int main(void) {
return 0;
}
-// CHECK: ff ff ff ff ff
-// CHECK: 00 00 00
+// CHECK: 0x{{[0-9a-f]+}}[0x{{[0-9a-f]+}}] ff ff ff ff ff
+// CHECK: 0x{{[0-9a-f]+}}[0x{{[0-9a-f]+}}] 00 00 00
diff --git a/compiler-rt/test/msan/msan_print_shadow.cpp b/compiler-rt/test/msan/msan_print_shadow.cpp
index bdee3102c1ccb..2782fcd83ed7d 100644
--- a/compiler-rt/test/msan/msan_print_shadow.cpp
+++ b/compiler-rt/test/msan/msan_print_shadow.cpp
@@ -52,7 +52,7 @@ int main(void) {
return 0;
}
-// CHECK: Shadow map of [{{.*}}), 297 bytes:
+// CHECK: Shadow map [0x{{.*}}, 0x{{.*}}) of [0x{{.*}}, 0x{{.*}}), 297 bytes:
// CHECK-NO-ORIGINS: 0x{{.*}}: ..00ffff 00000000 ffffffff ffffffff
// CHECK-NO-ORIGINS: 0x{{.*}}: ffffffff ffffffff ffffffff ffffffff
diff --git a/compiler-rt/test/msan/msan_print_shadow2.cpp b/compiler-rt/test/msan/msan_print_shadow2.cpp
index 5095081c9655d..05c1cb12bef8c 100644
--- a/compiler-rt/test/msan/msan_print_shadow2.cpp
+++ b/compiler-rt/test/msan/msan_print_shadow2.cpp
@@ -22,28 +22,28 @@ int main(void) {
return 0;
}
-// CHECK: Shadow map of [0x{{.*}}, 0x{{.*}}), 1 bytes:
+// CHECK: Shadow map [0x{{.*}}, 0x{{.*}}) of [0x{{.*}}, 0x{{.*}}), 1 bytes:
// CHECK-NO-ORIGINS: 0x{{.*}}: ff...... ........ ........ ........
// CHECK-ORIGINS: 0x{{.*}}: ff...... ........ ........ ........ |A . . .|
// CHECK-ORIGINS: Origin A (origin_id {{.*}}):
-// CHECK: Shadow map of [0x{{.*}}, 0x{{.*}}), 1 bytes:
+// CHECK: Shadow map [0x{{.*}}, 0x{{.*}}) of [0x{{.*}}, 0x{{.*}}), 1 bytes:
// CHECK-NO-ORIGINS: 0x{{.*}}: ..ff.... ........ ........ ........
// CHECK-ORIGINS: 0x{{.*}}: ..ff.... ........ ........ ........ |A . . .|
// CHECK-ORIGINS: Origin A (origin_id {{.*}}):
-// CHECK: Shadow map of [0x{{.*}}, 0x{{.*}}), 1 bytes:
+// CHECK: Shadow map [0x{{.*}}, 0x{{.*}}) of [0x{{.*}}, 0x{{.*}}), 1 bytes:
// CHECK-NO-ORIGINS: 0x{{.*}}: ......ff ........ ........ ........
// CHECK-ORIGINS: 0x{{.*}}: ......ff ........ ........ ........ |A . . .|
// CHECK-ORIGINS: Origin A (origin_id {{.*}}):
-// CHECK: Shadow map of [0x{{.*}}, 0x{{.*}}), 1 bytes:
+// CHECK: Shadow map [0x{{.*}}, 0x{{.*}}) of [0x{{.*}}, 0x{{.*}}), 1 bytes:
// CHECK-NO-ORIGINS: 0x{{.*}}: ......ff ........ ........ ........
// CHECK-ORIGINS: 0x{{.*}}: ......ff ........ ........ ........ |A . . .|
// CHECK-ORIGINS: Origin A (origin_id {{.*}}):
-// CHECK: Shadow map of [0x{{.*}}, 0x{{.*}}), 0 bytes:
+// CHECK: Shadow map [0x{{.*}}, 0x{{.*}}) of [0x{{.*}}, 0x{{.*}}), 0 bytes:
-// CHECK: Shadow map of [0x{{.*}}, 0x{{.*}}), 3 bytes:
+// CHECK: Shadow map [0x{{.*}}, 0x{{.*}}) of [0x{{.*}}, 0x{{.*}}), 3 bytes:
// CHECK-NO-ORIGINS: 0x{{.*}}: 000000.. ........ ........ ........
// CHECK-ORIGINS: 0x{{.*}}: 000000.. ........ ........ ........ |. . . .|
diff --git a/compiler-rt/test/msan/msan_print_shadow3.cpp b/compiler-rt/test/msan/msan_print_shadow3.cpp
index 410755e5dbaaa..d9f55a6eef9a8 100644
--- a/compiler-rt/test/msan/msan_print_shadow3.cpp
+++ b/compiler-rt/test/msan/msan_print_shadow3.cpp
@@ -12,5 +12,5 @@ int main(void) {
return 0;
}
-// CHECK: Shadow map of [{{.*}}), 4 bytes:
+// CHECK: Shadow map [0x{{[0-9a-f]+}}, 0x{{[0-9a-f]+}}) of [0x{{[0-9a-f]+}}, 0x{{[0-9a-f]+}}), 4 bytes:
// CHECK: 0x{{.*}}: 77654321 ........ ........ ........
More information about the llvm-commits
mailing list