Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h @@ -392,12 +392,16 @@ // Construct a one-line string: // SUMMARY: SanitizerToolName: error_message // and pass it to __sanitizer_report_error_summary. -void ReportErrorSummary(const char *error_message); +// If alt_tool_name is provided, it's used in place of SanitizerToolName. +void ReportErrorSummary(const char *error_message, + const char *alt_tool_name = nullptr); // Same as above, but construct error_message as: // error_type file:line[:column][ function] -void ReportErrorSummary(const char *error_type, const AddressInfo &info); +void ReportErrorSummary(const char *error_type, const AddressInfo &info, + const char *alt_tool_name = nullptr); // Same as above, but obtains AddressInfo by symbolizing top stack trace frame. -void ReportErrorSummary(const char *error_type, const StackTrace *trace); +void ReportErrorSummary(const char *error_type, const StackTrace *trace, + const char *alt_tool_name = nullptr); // Math #if SANITIZER_WINDOWS && !defined(__clang__) && !defined(__GNUC__) Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc @@ -199,23 +199,24 @@ return module; } -void ReportErrorSummary(const char *error_message) { +void ReportErrorSummary(const char *error_message, const char *alt_tool_name) { if (!common_flags()->print_summary) return; InternalScopedString buff(kMaxSummaryLength); - buff.append("SUMMARY: %s: %s", SanitizerToolName, error_message); + buff.append("SUMMARY: %s: %s", + alt_tool_name ? alt_tool_name : SanitizerToolName, error_message); __sanitizer_report_error_summary(buff.data()); } #if !SANITIZER_GO -void ReportErrorSummary(const char *error_type, const AddressInfo &info) { - if (!common_flags()->print_summary) - return; +void ReportErrorSummary(const char *error_type, const AddressInfo &info, + const char *alt_tool_name) { + if (!common_flags()->print_summary) return; InternalScopedString buff(kMaxSummaryLength); buff.append("%s ", error_type); RenderFrame(&buff, "%L %F", 0, info, common_flags()->symbolize_vs_style, common_flags()->strip_path_prefix); - ReportErrorSummary(buff.data()); + ReportErrorSummary(buff.data(), alt_tool_name); } #endif Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_libcdep.cc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_libcdep.cc +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_libcdep.cc @@ -47,7 +47,8 @@ sandboxing_callback = f; } -void ReportErrorSummary(const char *error_type, const StackTrace *stack) { +void ReportErrorSummary(const char *error_type, const StackTrace *stack, + const char *alt_tool_name) { #if !SANITIZER_GO if (!common_flags()->print_summary) return; @@ -59,7 +60,7 @@ // Maybe sometimes we need to choose another frame (e.g. skip memcpy/etc). uptr pc = StackTrace::GetPreviousInstructionPc(stack->trace[0]); SymbolizedStack *frame = Symbolizer::GetOrInit()->SymbolizePC(pc); - ReportErrorSummary(error_type, frame->info); + ReportErrorSummary(error_type, frame->info, alt_tool_name); frame->ClearAll(); #endif } Index: compiler-rt/trunk/lib/ubsan/ubsan_diag.cc =================================================================== --- compiler-rt/trunk/lib/ubsan/ubsan_diag.cc +++ compiler-rt/trunk/lib/ubsan/ubsan_diag.cc @@ -79,16 +79,16 @@ AI.line = SLoc.getLine(); AI.column = SLoc.getColumn(); AI.function = internal_strdup(""); // Avoid printing ?? as function name. - ReportErrorSummary(ErrorKind, AI); + ReportErrorSummary(ErrorKind, AI, GetSanititizerToolName()); AI.Clear(); return; } } else if (Loc.isSymbolizedStack()) { const AddressInfo &AI = Loc.getSymbolizedStack()->info; - ReportErrorSummary(ErrorKind, AI); + ReportErrorSummary(ErrorKind, AI, GetSanititizerToolName()); return; } - ReportErrorSummary(ErrorKind); + ReportErrorSummary(ErrorKind, GetSanititizerToolName()); } namespace { Index: compiler-rt/trunk/lib/ubsan/ubsan_init.h =================================================================== --- compiler-rt/trunk/lib/ubsan/ubsan_init.h +++ compiler-rt/trunk/lib/ubsan/ubsan_init.h @@ -15,6 +15,9 @@ namespace __ubsan { +// Get the full tool name for UBSan. +const char *GetSanititizerToolName(); + // Initialize UBSan as a standalone tool. Typically should be called early // during initialization. void InitAsStandalone(); Index: compiler-rt/trunk/lib/ubsan/ubsan_init.cc =================================================================== --- compiler-rt/trunk/lib/ubsan/ubsan_init.cc +++ compiler-rt/trunk/lib/ubsan/ubsan_init.cc @@ -23,6 +23,10 @@ using namespace __ubsan; +const char *__ubsan::GetSanititizerToolName() { + return "UndefinedBehaviorSanitizer"; +} + static enum { UBSAN_MODE_UNKNOWN = 0, UBSAN_MODE_STANDALONE, @@ -35,7 +39,7 @@ } static void CommonStandaloneInit() { - SanitizerToolName = "UndefinedBehaviorSanitizer"; + SanitizerToolName = GetSanititizerToolName(); InitializeFlags(); CacheBinaryName(); __sanitizer_set_report_path(common_flags()->log_path); Index: compiler-rt/trunk/test/ubsan/TestCases/Integer/summary.cpp =================================================================== --- compiler-rt/trunk/test/ubsan/TestCases/Integer/summary.cpp +++ compiler-rt/trunk/test/ubsan/TestCases/Integer/summary.cpp @@ -7,7 +7,7 @@ int main() { (void)(uint64_t(10000000000000000000ull) + uint64_t(9000000000000000000ull)); - // CHECK-NOTYPE: SUMMARY: AddressSanitizer: undefined-behavior {{.*}}summary.cpp:[[@LINE-1]]:44 - // CHECK-TYPE: SUMMARY: AddressSanitizer: unsigned-integer-overflow {{.*}}summary.cpp:[[@LINE-2]]:44 + // CHECK-NOTYPE: SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior {{.*}}summary.cpp:[[@LINE-1]]:44 + // CHECK-TYPE: SUMMARY: UndefinedBehaviorSanitizer: unsigned-integer-overflow {{.*}}summary.cpp:[[@LINE-2]]:44 return 0; }