[llvm-commits] [compiler-rt] r161568 - in /compiler-rt/trunk/lib/asan: asan_posix.cc asan_report.cc asan_report.h

Alexey Samsonov samsonov at google.com
Thu Aug 9 00:40:58 PDT 2012


Author: samsonov
Date: Thu Aug  9 02:40:58 2012
New Revision: 161568

URL: http://llvm.org/viewvc/llvm-project?rev=161568&view=rev
Log:
[ASan] Create new files asan_report.{h,cc} as a preparation for refactoring of ASan error reporting code.
Currently ASan reports many kinds of errors, and the code that actually prints error messages can
be found inside allocator, OS-specific files, interceptors code etc.

An example of maintenance troubles this situation causes:
There is currently an ASan interface function that registers
callback which should take the char buffer with error report printed by ASan.
This function is now broken, as one has to insert callback calls to all the places in
ASan code where the error reports are printed, surprisingly it is not only
"__asan_report_error" function...

Added:
    compiler-rt/trunk/lib/asan/asan_report.cc
    compiler-rt/trunk/lib/asan/asan_report.h
Modified:
    compiler-rt/trunk/lib/asan/asan_posix.cc

Modified: compiler-rt/trunk/lib/asan/asan_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_posix.cc?rev=161568&r1=161567&r2=161568&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_posix.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_posix.cc Thu Aug  9 02:40:58 2012
@@ -16,6 +16,7 @@
 #include "asan_internal.h"
 #include "asan_interceptors.h"
 #include "asan_mapping.h"
+#include "asan_report.h"
 #include "asan_stack.h"
 #include "asan_thread_registry.h"
 #include "sanitizer_common/sanitizer_libc.h"
@@ -53,14 +54,7 @@
   if (13 != internal_write(2, "ASAN:SIGSEGV\n", 13)) Die();
   uptr pc, sp, bp;
   GetPcSpBp(context, &pc, &sp, &bp);
-  AsanReport("ERROR: AddressSanitizer crashed on unknown address %p"
-             " (pc %p sp %p bp %p T%d)\n",
-             (void*)addr, (void*)pc, (void*)sp, (void*)bp,
-             asanThreadRegistry().GetCurrentTidOrInvalid());
-  AsanPrintf("AddressSanitizer can not provide additional info. ABORTING\n");
-  GET_STACK_TRACE_WITH_PC_AND_BP(kStackTraceMax, pc, bp);
-  stack.PrintStack();
-  ShowStatsAndAbort();
+  ReportSIGSEGV(pc, sp, bp, addr);
 }
 
 void SetAlternateSignalStack() {

Added: compiler-rt/trunk/lib/asan/asan_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_report.cc?rev=161568&view=auto
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_report.cc (added)
+++ compiler-rt/trunk/lib/asan/asan_report.cc Thu Aug  9 02:40:58 2012
@@ -0,0 +1,32 @@
+//===-- asan_report.cc ----------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of AddressSanitizer, an address sanity checker.
+//
+// This file contains error reporting code.
+//===----------------------------------------------------------------------===//
+#include "asan_internal.h"
+#include "asan_report.h"
+#include "asan_stack.h"
+#include "asan_thread_registry.h"
+
+namespace __asan {
+
+void ReportSIGSEGV(uptr pc, uptr sp, uptr bp, uptr addr) {
+  AsanReport("ERROR: AddressSanitizer crashed on unknown address %p"
+             " (pc %p sp %p bp %p T%d)\n",
+             (void*)addr, (void*)pc, (void*)sp, (void*)bp,
+             asanThreadRegistry().GetCurrentTidOrInvalid());
+  AsanPrintf("AddressSanitizer can not provide additional info. ABORTING\n");
+  GET_STACK_TRACE_WITH_PC_AND_BP(kStackTraceMax, pc, bp);
+  stack.PrintStack();
+  ShowStatsAndAbort();
+}
+
+}  // namespace __asan

Added: compiler-rt/trunk/lib/asan/asan_report.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_report.h?rev=161568&view=auto
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_report.h (added)
+++ compiler-rt/trunk/lib/asan/asan_report.h Thu Aug  9 02:40:58 2012
@@ -0,0 +1,21 @@
+//===-- asan_report.h -------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of AddressSanitizer, an address sanity checker.
+//
+// ASan-private header for error reporting functions.
+//===----------------------------------------------------------------------===//
+
+#include "asan_internal.h"
+
+namespace __asan {
+
+void ReportSIGSEGV(uptr pc, uptr sp, uptr bp, uptr addr);
+
+}  // namespace __asan





More information about the llvm-commits mailing list