diff --git a/compiler-rt/lib/hwasan/hwasan_report.cpp b/compiler-rt/lib/hwasan/hwasan_report.cpp --- a/compiler-rt/lib/hwasan/hwasan_report.cpp +++ b/compiler-rt/lib/hwasan/hwasan_report.cpp @@ -442,20 +442,30 @@ static const char *kDoubleSpace = " "; static const char *kSingleSpace = " "; void ReportRegisters(uptr *frame, uptr pc) { - Printf("Registers where the failure occurred (pc %p):", pc); - - for (unsigned i = 0; i <= 30; i++) { - if (i % 4 == 0) - Printf("\n "); + Printf("Registers where the failure occurred (pc %p):\n", pc); + // We explicitly print a single line (4 registers/line) each iteration to + // reduce the amount of logcat error messages printed. Each Printf() will + // result in a new logcat line, irrespective of whether a newline is present, + // and so we wish to reduce the number of Printf() calls we have to make. + for (unsigned i = 0; i <= 24; i += 4) { // Note - manually inserting a double or single space here based on the // number of digits in the register name, as our sanitizer Printf does not // support padding where the content is left aligned (i.e. the format // specifier "%-2d" will CHECK fail). - Printf(" x%d%s%016llx", i, (i < 10) ? kDoubleSpace : kSingleSpace, - frame[i]); + Printf(" x%d%s%016llx" + " x%d%s%016llx" + " x%d%s%016llx" + " x%d%s%016llx\n", + i + 0, (i + 0 < 10) ? kDoubleSpace : kSingleSpace, frame[i + 0], + i + 1, (i + 1 < 10) ? kDoubleSpace : kSingleSpace, frame[i + 1], + i + 2, (i + 2 < 10) ? kDoubleSpace : kSingleSpace, frame[i + 2], + i + 3, (i + 3 < 10) ? kDoubleSpace : kSingleSpace, frame[i + 3]); } - Printf("\n"); + Printf(" x%d %016llx" + " x%d %016llx" + " x%d %016llx\n", + 28, frame[28], 29, frame[29], 30, frame[30]); } } // namespace __hwasan