forked from OSchip/llvm-project
[Sanitizer] Print column number in SUMMARY line if it's available.
llvm-svn: 230721
This commit is contained in:
parent
5339a52c9a
commit
0b0cafc8fc
|
@ -16,6 +16,7 @@
|
||||||
#include "sanitizer_flags.h"
|
#include "sanitizer_flags.h"
|
||||||
#include "sanitizer_libc.h"
|
#include "sanitizer_libc.h"
|
||||||
#include "sanitizer_placement_new.h"
|
#include "sanitizer_placement_new.h"
|
||||||
|
#include "sanitizer_symbolizer.h"
|
||||||
|
|
||||||
namespace __sanitizer {
|
namespace __sanitizer {
|
||||||
|
|
||||||
|
@ -230,15 +231,18 @@ void ReportErrorSummary(const char *error_message) {
|
||||||
__sanitizer_report_error_summary(buff.data());
|
__sanitizer_report_error_summary(buff.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportErrorSummary(const char *error_type, const char *file,
|
void ReportErrorSummary(const char *error_type, const AddressInfo &info) {
|
||||||
int line, const char *function) {
|
|
||||||
if (!common_flags()->print_summary)
|
if (!common_flags()->print_summary)
|
||||||
return;
|
return;
|
||||||
InternalScopedString buff(kMaxSummaryLength);
|
InternalScopedString buff(kMaxSummaryLength);
|
||||||
buff.append("%s %s:%d %s", error_type,
|
buff.append(
|
||||||
file ? StripPathPrefix(file, common_flags()->strip_path_prefix)
|
"%s %s:%d", error_type,
|
||||||
|
info.file ? StripPathPrefix(info.file, common_flags()->strip_path_prefix)
|
||||||
: "??",
|
: "??",
|
||||||
line, function ? function : "??");
|
info.line);
|
||||||
|
if (info.column > 0)
|
||||||
|
buff.append(":%d", info.column);
|
||||||
|
buff.append(" %s", info.function ? info.function : "??");
|
||||||
ReportErrorSummary(buff.data());
|
ReportErrorSummary(buff.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
namespace __sanitizer {
|
namespace __sanitizer {
|
||||||
struct StackTrace;
|
struct StackTrace;
|
||||||
|
struct AddressInfo;
|
||||||
|
|
||||||
// Constants.
|
// Constants.
|
||||||
const uptr kWordSize = SANITIZER_WORDSIZE / 8;
|
const uptr kWordSize = SANITIZER_WORDSIZE / 8;
|
||||||
|
@ -288,9 +289,9 @@ const int kMaxSummaryLength = 1024;
|
||||||
// and pass it to __sanitizer_report_error_summary.
|
// and pass it to __sanitizer_report_error_summary.
|
||||||
void ReportErrorSummary(const char *error_message);
|
void ReportErrorSummary(const char *error_message);
|
||||||
// Same as above, but construct error_message as:
|
// Same as above, but construct error_message as:
|
||||||
// error_type file:line function
|
// error_type file:line[:column][ function]
|
||||||
void ReportErrorSummary(const char *error_type, const char *file,
|
void ReportErrorSummary(const char *error_type, const AddressInfo &info);
|
||||||
int line, const char *function);
|
// Same as above, but obtains AddressInfo by symbolizing top stack trace frame.
|
||||||
void ReportErrorSummary(const char *error_type, StackTrace *trace);
|
void ReportErrorSummary(const char *error_type, StackTrace *trace);
|
||||||
|
|
||||||
// Math
|
// Math
|
||||||
|
|
|
@ -44,20 +44,14 @@ void SetSandboxingCallback(void (*f)()) {
|
||||||
void ReportErrorSummary(const char *error_type, StackTrace *stack) {
|
void ReportErrorSummary(const char *error_type, StackTrace *stack) {
|
||||||
if (!common_flags()->print_summary)
|
if (!common_flags()->print_summary)
|
||||||
return;
|
return;
|
||||||
#if !SANITIZER_GO
|
if (stack->size == 0 || !Symbolizer::GetOrInit()->CanReturnFileLineInfo())
|
||||||
if (stack->size > 0 && Symbolizer::GetOrInit()->CanReturnFileLineInfo()) {
|
return;
|
||||||
// Currently, we include the first stack frame into the report summary.
|
// Currently, we include the first stack frame into the report summary.
|
||||||
// Maybe sometimes we need to choose another frame (e.g. skip memcpy/etc).
|
// Maybe sometimes we need to choose another frame (e.g. skip memcpy/etc).
|
||||||
uptr pc = StackTrace::GetPreviousInstructionPc(stack->trace[0]);
|
uptr pc = StackTrace::GetPreviousInstructionPc(stack->trace[0]);
|
||||||
SymbolizedStack *frame = Symbolizer::GetOrInit()->SymbolizePC(pc);
|
SymbolizedStack *frame = Symbolizer::GetOrInit()->SymbolizePC(pc);
|
||||||
const AddressInfo &ai = frame->info;
|
ReportErrorSummary(error_type, frame->info);
|
||||||
ReportErrorSummary(error_type, ai.file, ai.line, ai.function);
|
|
||||||
frame->ClearAll();
|
frame->ClearAll();
|
||||||
}
|
|
||||||
#else
|
|
||||||
AddressInfo ai;
|
|
||||||
ReportErrorSummary(error_type, ai.file, ai.line, ai.function);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void (*SoftRssLimitExceededCallback)(bool exceeded);
|
static void (*SoftRssLimitExceededCallback)(bool exceeded);
|
||||||
|
|
|
@ -335,10 +335,8 @@ void PrintReport(const ReportDesc *rep) {
|
||||||
Printf(" And %d more similar thread leaks.\n\n", rep->count - 1);
|
Printf(" And %d more similar thread leaks.\n\n", rep->count - 1);
|
||||||
|
|
||||||
if (ReportStack *stack = ChooseSummaryStack(rep)) {
|
if (ReportStack *stack = ChooseSummaryStack(rep)) {
|
||||||
if (SymbolizedStack *frame = SkipTsanInternalFrames(stack->frames)) {
|
if (SymbolizedStack *frame = SkipTsanInternalFrames(stack->frames))
|
||||||
const AddressInfo &info = frame->info;
|
ReportErrorSummary(rep_typ_str, frame->info);
|
||||||
ReportErrorSummary(rep_typ_str, info.file, info.line, info.function);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Printf("==================\n");
|
Printf("==================\n");
|
||||||
|
|
|
@ -49,8 +49,13 @@ static void MaybeReportErrorSummary(Location Loc) {
|
||||||
if (Loc.isSourceLocation()) {
|
if (Loc.isSourceLocation()) {
|
||||||
SourceLocation SLoc = Loc.getSourceLocation();
|
SourceLocation SLoc = Loc.getSourceLocation();
|
||||||
if (!SLoc.isInvalid()) {
|
if (!SLoc.isInvalid()) {
|
||||||
ReportErrorSummary("undefined-behavior", SLoc.getFilename(),
|
AddressInfo AI;
|
||||||
SLoc.getLine(), "");
|
AI.file = internal_strdup(SLoc.getFilename());
|
||||||
|
AI.line = SLoc.getLine();
|
||||||
|
AI.column = SLoc.getColumn();
|
||||||
|
AI.function = internal_strdup(""); // Avoid printing ?? as function name.
|
||||||
|
ReportErrorSummary("undefined-behavior", AI);
|
||||||
|
AI.Clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
(void)(uint64_t(10000000000000000000ull) + uint64_t(9000000000000000000ull));
|
(void)(uint64_t(10000000000000000000ull) + uint64_t(9000000000000000000ull));
|
||||||
// CHECK: SUMMARY: AddressSanitizer: undefined-behavior {{.*}}summary.cpp:[[@LINE-1]]
|
// CHECK: SUMMARY: AddressSanitizer: undefined-behavior {{.*}}summary.cpp:[[@LINE-1]]:44
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue