[compiler-rt] r212857 - [ASan] Improve ODR-violation error reports.
Kostya Serebryany
kcc at google.com
Mon Jul 14 01:50:22 PDT 2014
nice!
On Sat, Jul 12, 2014 at 3:34 AM, Alexey Samsonov <vonosmas at gmail.com> wrote:
> Author: samsonov
> Date: Fri Jul 11 18:34:26 2014
> New Revision: 212857
>
> URL: http://llvm.org/viewvc/llvm-project?rev=212857&view=rev
> Log:
> [ASan] Improve ODR-violation error reports.
>
> Demangle names of involved globals. Print a more consistent summary line.
>
> Modified:
> compiler-rt/trunk/lib/asan/asan_report.cc
> compiler-rt/trunk/test/asan/TestCases/Linux/odr-violation.cc
>
> Modified: compiler-rt/trunk/lib/asan/asan_report.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_report.cc?rev=212857&r1=212856&r2=212857&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/asan_report.cc (original)
> +++ compiler-rt/trunk/lib/asan/asan_report.cc Fri Jul 11 18:34:26 2014
> @@ -768,8 +768,10 @@ void ReportODRViolation(const __asan_glo
> 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_glo
> }
> 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
>
> Modified: compiler-rt/trunk/test/asan/TestCases/Linux/odr-violation.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/odr-violation.cc?rev=212857&r1=212856&r2=212857&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/test/asan/TestCases/Linux/odr-violation.cc (original)
> +++ compiler-rt/trunk/test/asan/TestCases/Linux/odr-violation.cc Fri Jul
> 11 18:34:26 2014
> @@ -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
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140714/7dfa5ccd/attachment.html>
More information about the llvm-commits
mailing list