[compiler-rt] r232567 - Improve SUMMARY reporting in sanitizers.
Alexey Samsonov
vonosmas at gmail.com
Tue Mar 17 16:46:07 PDT 2015
Author: samsonov
Date: Tue Mar 17 18:46:06 2015
New Revision: 232567
URL: http://llvm.org/viewvc/llvm-project?rev=232567&view=rev
Log:
Improve SUMMARY reporting in sanitizers.
Make sure SUMMARY is always reported unless print_summary flag is set to
false, even if symbolizer is unavailable or report stack trace is empty.
If file/line info for PC can't be evaluated, print module name/offset
like we do in stack trace.
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_libcdep.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h
compiler-rt/trunk/test/asan/TestCases/print_summary.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc?rev=232567&r1=232566&r2=232567&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc Tue Mar 17 18:46:06 2015
@@ -16,6 +16,7 @@
#include "sanitizer_flags.h"
#include "sanitizer_libc.h"
#include "sanitizer_placement_new.h"
+#include "sanitizer_stacktrace_printer.h"
#include "sanitizer_symbolizer.h"
namespace __sanitizer {
@@ -231,20 +232,16 @@ void ReportErrorSummary(const char *erro
__sanitizer_report_error_summary(buff.data());
}
+#ifndef SANITIZER_GO
void ReportErrorSummary(const char *error_type, const AddressInfo &info) {
if (!common_flags()->print_summary)
return;
InternalScopedString buff(kMaxSummaryLength);
- buff.append(
- "%s %s:%d", error_type,
- info.file ? StripPathPrefix(info.file, common_flags()->strip_path_prefix)
- : "??",
- info.line);
- if (info.column > 0)
- buff.append(":%d", info.column);
- buff.append(" %s", info.function ? info.function : "??");
+ buff.append("%s ", error_type);
+ RenderFrame(&buff, "%L %F", 0, info, common_flags()->strip_path_prefix);
ReportErrorSummary(buff.data());
}
+#endif
LoadedModule::LoadedModule(const char *module_name, uptr base_address) {
full_name_ = internal_strdup(module_name);
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_libcdep.cc?rev=232567&r1=232566&r2=232567&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_libcdep.cc Tue Mar 17 18:46:06 2015
@@ -44,8 +44,10 @@ void SetSandboxingCallback(void (*f)())
void ReportErrorSummary(const char *error_type, StackTrace *stack) {
if (!common_flags()->print_summary)
return;
- if (stack->size == 0 || !Symbolizer::GetOrInit()->CanReturnFileLineInfo())
+ if (stack->size == 0) {
+ ReportErrorSummary(error_type);
return;
+ }
// Currently, we include the first stack frame into the report summary.
// Maybe sometimes we need to choose another frame (e.g. skip memcpy/etc).
uptr pc = StackTrace::GetPreviousInstructionPc(stack->trace[0]);
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h?rev=232567&r1=232566&r2=232567&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h Tue Mar 17 18:46:06 2015
@@ -93,7 +93,6 @@ class Symbolizer {
return module_name;
return nullptr;
}
- bool CanReturnFileLineInfo() { return !tools_.empty(); }
// Release internal caches (if any).
void Flush();
// Attempts to demangle the provided C++ mangled name.
Modified: compiler-rt/trunk/test/asan/TestCases/print_summary.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/print_summary.cc?rev=232567&r1=232566&r2=232567&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/print_summary.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/print_summary.cc Tue Mar 17 18:46:06 2015
@@ -1,14 +1,16 @@
// RUN: %clangxx_asan -O0 %s -o %t
-// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=YES
-// RUN: env ASAN_OPTIONS=print_summary=false not %run %t 2>&1 | FileCheck %s --check-prefix=NO
+// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=SOURCE
+// RUN: env ASAN_OPTIONS=symbolize=false not %run %t 2>&1 | FileCheck %s --check-prefix=MODULE
+// RUN: env ASAN_OPTIONS=print_summary=false not %run %t 2>&1 | FileCheck %s --check-prefix=MISSING
int main() {
char *x = new char[20];
delete[] x;
return x[0];
- // YES: ERROR: AddressSanitizer: heap-use-after-free
- // YES: SUMMARY: AddressSanitizer: heap-use-after-free
- // NO: ERROR: AddressSanitizer: heap-use-after-free
- // NO-NOT: SUMMARY: AddressSanitizer: heap-use-after-free
+ // SOURCE: ERROR: AddressSanitizer: heap-use-after-free
+ // SOURCE: SUMMARY: AddressSanitizer: heap-use-after-free {{.*}}print_summary.cc:[[@LINE-2]]{{.*}} main
+ // MODULE: ERROR: AddressSanitizer: heap-use-after-free
+ // MODULE: SUMMARY: AddressSanitizer: heap-use-after-free ({{.*}}+0x{{.*}})
+ // MISSING: ERROR: AddressSanitizer: heap-use-after-free
+ // MISSING-NOT: SUMMARY
}
-
More information about the llvm-commits
mailing list