diff options
author | Alexey Samsonov <vonosmas@gmail.com> | 2014-07-11 23:34:26 +0000 |
---|---|---|
committer | Alexey Samsonov <vonosmas@gmail.com> | 2014-07-11 23:34:26 +0000 |
commit | 8a017a0ac65a43aae8a267af9803022a268e46ce (patch) | |
tree | 4df5e51f582cf72ab483e5aa5bccd477598d29f2 | |
parent | 9135deb114aebbce1d47065a2b15d48f2edd6842 (diff) | |
download | compiler-rt-8a017a0ac65a43aae8a267af9803022a268e46ce.tar.gz |
[ASan] Improve ODR-violation error reports.
Demangle names of involved globals. Print a more consistent summary line.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@212857 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/asan/asan_report.cc | 11 | ||||
-rw-r--r-- | test/asan/TestCases/Linux/odr-violation.cc | 13 |
2 files changed, 15 insertions, 9 deletions
diff --git a/lib/asan/asan_report.cc b/lib/asan/asan_report.cc index cee0db574..d45e027fa 100644 --- a/lib/asan/asan_report.cc +++ b/lib/asan/asan_report.cc @@ -768,8 +768,10 @@ void ReportODRViolation(const __asan_global *g1, u32 stack_id1, InternalScopedString g1_loc(256), g2_loc(256); PrintGlobalLocation(&g1_loc, *g1); PrintGlobalLocation(&g2_loc, *g2); - Printf(" [1] size=%zd %s %s\n", g1->size, g1->name, g1_loc.data()); - Printf(" [2] size=%zd %s %s\n", g2->size, g2->name, g2_loc.data()); + Printf(" [1] size=%zd '%s' %s\n", g1->size, + MaybeDemangleGlobalName(g1->name), g1_loc.data()); + Printf(" [2] size=%zd '%s' %s\n", g2->size, + MaybeDemangleGlobalName(g2->name), g2_loc.data()); if (stack_id1 && stack_id2) { Printf("These globals were registered at these points:\n"); Printf(" [1]:\n"); @@ -782,7 +784,10 @@ void ReportODRViolation(const __asan_global *g1, u32 stack_id1, } Report("HINT: if you don't care about these warnings you may set " "ASAN_OPTIONS=detect_odr_violation=0\n"); - ReportErrorSummary("odr-violation", g1_loc.data(), 0, g1->name); + InternalScopedString error_msg(256); + error_msg.append("odr-violation: global '%s' at %s", + MaybeDemangleGlobalName(g1->name), g1_loc.data()); + ReportErrorSummary(error_msg.data()); } // ----------------------- CheckForInvalidPointerPair ----------- {{{1 diff --git a/test/asan/TestCases/Linux/odr-violation.cc b/test/asan/TestCases/Linux/odr-violation.cc index 48e0907cf..ddc68a2db 100644 --- a/test/asan/TestCases/Linux/odr-violation.cc +++ b/test/asan/TestCases/Linux/odr-violation.cc @@ -23,19 +23,20 @@ #endif #if BUILD_SO -char G[SZ]; +namespace foo { char G[SZ]; } #else #include <stdio.h> -char G[100]; +namespace foo { char G[100]; } +// CHECK: ERROR: AddressSanitizer: odr-violation +// CHECK: size=100 'foo::G' {{.*}}odr-violation.cc:[[@LINE-2]]:22 +// CHECK: size={{4|100}} 'foo::G' int main(int argc, char **argv) { - printf("PASS: %p\n", &G); + printf("PASS: %p\n", &foo::G); } #endif -// CHECK: ERROR: AddressSanitizer: odr-violation -// CHECK: size=100 G -// CHECK: size={{4|100}} G // CHECK: These globals were registered at these points: // CHECK: ODR-EXE // CHECK: ODR-SO +// CHECK: SUMMARY: AddressSanitizer: odr-violation: global 'foo::G' at {{.*}}odr-violation.cc // DISABLED: PASS |