Skip to content

Commit c567e94

Browse files
committed
[NFC][HWASAN] Extract BaseReport::PrintTags
1 parent d217aeb commit c567e94

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

compiler-rt/lib/hwasan/hwasan_report.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ class BaseReport {
450450
OverflowCandidate FindBufferOverflowCandidate() const;
451451
void PrintAddressDescription() const;
452452
void PrintHeapOrGlobalCandidate() const;
453+
void PrintTags(uptr addr) const;
453454

454455
SavedStackAllocations stack_allocations_storage[16];
455456
HeapAllocation heap_allocations_storage[256];
@@ -765,6 +766,14 @@ void BaseReport::PrintAddressDescription() const {
765766
}
766767
}
767768

769+
void BaseReport::PrintTags(uptr addr) const {
770+
if (shadow.addr) {
771+
PrintTagsAroundAddr(
772+
addr, [&](uptr addr) { return GetTagCopy(addr); },
773+
[&](uptr addr) { return GetShortTagCopy(addr); });
774+
}
775+
}
776+
768777
class InvalidFreeReport : public BaseReport {
769778
public:
770779
InvalidFreeReport(StackTrace *stack, uptr tagged_addr)
@@ -797,13 +806,7 @@ InvalidFreeReport::~InvalidFreeReport() {
797806
stack->Print();
798807

799808
PrintAddressDescription();
800-
801-
if (shadow.addr) {
802-
PrintTagsAroundAddr(
803-
untagged_addr, [&](uptr addr) { return GetTagCopy(addr); },
804-
[&](uptr addr) { return GetShortTagCopy(addr); });
805-
}
806-
809+
PrintTags(untagged_addr);
807810
MaybePrintAndroidHelpUrl();
808811
ReportErrorSummary(bug_type, stack);
809812
}
@@ -883,11 +886,7 @@ TailOverwrittenReport::~TailOverwrittenReport() {
883886
kShadowAlignment, SanitizerToolName);
884887
Printf("%s", s.data());
885888
GetCurrentThread()->Announce();
886-
887-
PrintTagsAroundAddr(
888-
untagged_addr, [&](uptr addr) { return GetTagCopy(addr); },
889-
[&](uptr addr) { return GetShortTagCopy(addr); });
890-
889+
PrintTags(untagged_addr);
891890
MaybePrintAndroidHelpUrl();
892891
ReportErrorSummary(bug_type, stack);
893892
}
@@ -963,9 +962,7 @@ TagMismatchReport::~TagMismatchReport() {
963962
PrintAddressDescription();
964963
t->Announce();
965964

966-
PrintTagsAroundAddr(
967-
untagged_addr + offset, [&](uptr addr) { return GetTagCopy(addr); },
968-
[&](uptr addr) { return GetShortTagCopy(addr); });
965+
PrintTags(untagged_addr + offset);
969966

970967
if (registers_frame)
971968
ReportRegisters(registers_frame, pc);

0 commit comments

Comments
 (0)