[sanitizer] Simplify with GET_CALLER_PC_BP. NFC

This commit is contained in:
Fangrui Song 2023-02-04 11:30:14 -08:00
parent d81d60876a
commit 39b8a27132
4 changed files with 14 additions and 28 deletions

View File

@ -197,8 +197,7 @@ static dfsan_origin GetOriginIfTainted(uptr addr, uptr size) {
#define PRINT_CALLER_STACK_TRACE \
{ \
GET_CALLER_PC_BP_SP; \
(void)sp; \
GET_CALLER_PC_BP; \
GET_STORE_STACK_TRACE_PC_BP(pc, bp) \
stack.Print(); \
}
@ -381,8 +380,7 @@ static void SetOrigin(const void *dst, uptr size, u32 origin) {
}
#define RET_CHAIN_ORIGIN(id) \
GET_CALLER_PC_BP_SP; \
(void)sp; \
GET_CALLER_PC_BP; \
GET_STORE_STACK_TRACE_PC_BP(pc, bp); \
return ChainOrigin(id, &stack);
@ -567,8 +565,7 @@ void SetShadow(dfsan_label label, void *addr, uptr size, dfsan_origin origin) {
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __dfsan_maybe_store_origin(
dfsan_label s, void *p, uptr size, dfsan_origin o) {
if (UNLIKELY(s)) {
GET_CALLER_PC_BP_SP;
(void)sp;
GET_CALLER_PC_BP;
GET_STORE_STACK_TRACE_PC_BP(pc, bp);
SetOrigin(p, size, ChainOrigin(o, &stack));
}

View File

@ -345,8 +345,7 @@ using namespace __msan;
#define MSAN_MAYBE_WARNING(type, size) \
void __msan_maybe_warning_##size(type s, u32 o) { \
GET_CALLER_PC_BP_SP; \
(void) sp; \
GET_CALLER_PC_BP; \
if (UNLIKELY(s)) { \
PrintWarningWithOrigin(pc, bp, o); \
if (__msan::flags()->halt_on_error) { \
@ -365,8 +364,7 @@ MSAN_MAYBE_WARNING(u64, 8)
void __msan_maybe_store_origin_##size(type s, void *p, u32 o) { \
if (UNLIKELY(s)) { \
if (__msan_get_track_origins() > 1) { \
GET_CALLER_PC_BP_SP; \
(void) sp; \
GET_CALLER_PC_BP; \
GET_STORE_STACK_TRACE_PC_BP(pc, bp); \
o = ChainOrigin(o, &stack); \
} \
@ -380,8 +378,7 @@ MSAN_MAYBE_STORE_ORIGIN(u32, 4)
MSAN_MAYBE_STORE_ORIGIN(u64, 8)
void __msan_warning() {
GET_CALLER_PC_BP_SP;
(void)sp;
GET_CALLER_PC_BP;
PrintWarningWithOrigin(pc, bp, 0);
if (__msan::flags()->halt_on_error) {
if (__msan::flags()->print_stats)
@ -392,8 +389,7 @@ void __msan_warning() {
}
void __msan_warning_noreturn() {
GET_CALLER_PC_BP_SP;
(void)sp;
GET_CALLER_PC_BP;
PrintWarningWithOrigin(pc, bp, 0);
if (__msan::flags()->print_stats)
ReportStats();
@ -402,8 +398,7 @@ void __msan_warning_noreturn() {
}
void __msan_warning_with_origin(u32 origin) {
GET_CALLER_PC_BP_SP;
(void)sp;
GET_CALLER_PC_BP;
PrintWarningWithOrigin(pc, bp, origin);
if (__msan::flags()->halt_on_error) {
if (__msan::flags()->print_stats)
@ -414,8 +409,7 @@ void __msan_warning_with_origin(u32 origin) {
}
void __msan_warning_with_origin_noreturn(u32 origin) {
GET_CALLER_PC_BP_SP;
(void)sp;
GET_CALLER_PC_BP;
PrintWarningWithOrigin(pc, bp, origin);
if (__msan::flags()->print_stats)
ReportStats();
@ -513,8 +507,7 @@ void __msan_set_expect_umr(int expect_umr) {
if (expect_umr) {
msan_expected_umr_found = 0;
} else if (!msan_expected_umr_found) {
GET_CALLER_PC_BP_SP;
(void)sp;
GET_CALLER_PC_BP;
GET_FATAL_STACK_TRACE_PC_BP(pc, bp);
ReportExpectedUMRNotFound(&stack);
Die();
@ -562,8 +555,7 @@ void __msan_check_mem_is_initialized(const void *x, uptr size) {
if (offset < 0)
return;
GET_CALLER_PC_BP_SP;
(void)sp;
GET_CALLER_PC_BP;
ReportUMRInsideAddressRange(__func__, x, size, offset);
__msan::PrintWarningWithOrigin(pc, bp,
__msan_get_origin(((const char *)x) + offset));
@ -622,8 +614,7 @@ void __msan_set_alloca_origin_no_descr(void *a, uptr size, u32 *id_ptr) {
}
u32 __msan_chain_origin(u32 id) {
GET_CALLER_PC_BP_SP;
(void)sp;
GET_CALLER_PC_BP;
GET_STORE_STACK_TRACE_PC_BP(pc, bp);
return ChainOrigin(id, &stack);
}

View File

@ -93,8 +93,7 @@ struct DlsymAlloc : public DlSymAllocator<DlsymAlloc> {
if (__msan::IsInSymbolizerOrUnwider()) \
break; \
if (__offset >= 0 && __msan::flags()->report_umrs) { \
GET_CALLER_PC_BP_SP; \
(void)sp; \
GET_CALLER_PC_BP; \
ReportUMRInsideAddressRange(__func__, x, n, __offset); \
__msan::PrintWarningWithOrigin( \
pc, bp, __msan_get_origin((const char *)x + __offset)); \

View File

@ -107,8 +107,7 @@ void ReportMmapWriteExec(int prot, int flags) {
stack->Reset();
uptr top = 0;
uptr bottom = 0;
GET_CALLER_PC_BP_SP;
(void)sp;
GET_CALLER_PC_BP;
bool fast = common_flags()->fast_unwind_on_fatal;
if (StackTrace::WillUseFastUnwind(fast)) {
GetThreadStackTopAndBottom(false, &top, &bottom);