[sanitizer] Simplify __sanitizer::BufferedStackTrace::UnwindImpl implementations

Intended to be NFC. D102046 relies on the refactoring for stack boundaries.
This commit is contained in:
Fangrui Song 2021-05-13 21:26:31 -07:00
parent 9cf6ff7aff
commit 261d6e05d5
5 changed files with 15 additions and 21 deletions

View File

@ -74,7 +74,8 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(
if (SANITIZER_MIPS && t &&
!IsValidFrame(bp, t->stack_top(), t->stack_bottom()))
return;
Unwind(max_depth, pc, bp, context, 0, 0, false);
Unwind(max_depth, pc, bp, context, t ? t->stack_top() : 0,
t ? t->stack_bottom() : 0, false);
}
// ------------------ Interface -------------- {{{1

View File

@ -35,18 +35,14 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(
uptr pc, uptr bp, void *context, bool request_fast, u32 max_depth) {
using namespace __lsan;
uptr stack_top = 0, stack_bottom = 0;
ThreadContext *t;
if (StackTrace::WillUseFastUnwind(request_fast) &&
(t = CurrentThreadContext())) {
if (ThreadContext *t = CurrentThreadContext()) {
stack_top = t->stack_end();
stack_bottom = t->stack_begin();
}
if (!SANITIZER_MIPS || IsValidFrame(bp, stack_top, stack_bottom)) {
if (StackTrace::WillUseFastUnwind(request_fast))
Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, true);
else
Unwind(max_depth, pc, 0, context, 0, 0, false);
}
if (SANITIZER_MIPS && !IsValidFrame(bp, stack_top, stack_bottom))
return;
bool fast = StackTrace::WillUseFastUnwind(request_fast);
Unwind(max_depth, pc, bp, context, stack_top, stack_bottom, fast);
}
using namespace __lsan;

View File

@ -308,7 +308,8 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(
if (!t || !StackTrace::WillUseFastUnwind(request_fast)) {
// Block reports from our interceptors during _Unwind_Backtrace.
SymbolizerScope sym_scope;
return Unwind(max_depth, pc, bp, context, 0, 0, false);
return Unwind(max_depth, pc, bp, context, t ? t->stack_top() : 0,
t ? t->stack_bottom() : 0, false);
}
if (StackTrace::WillUseFastUnwind(request_fast))
Unwind(max_depth, pc, bp, nullptr, t->stack_top(), t->stack_bottom(), true);

View File

@ -54,10 +54,8 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(
uptr pc, uptr bp, void *context, bool request_fast, u32 max_depth) {
uptr top = 0;
uptr bottom = 0;
if (StackTrace::WillUseFastUnwind(request_fast)) {
GetThreadStackTopAndBottom(false, &top, &bottom);
Unwind(max_depth, pc, bp, nullptr, top, bottom, true);
} else
Unwind(max_depth, pc, 0, context, 0, 0, false);
GetThreadStackTopAndBottom(false, &top, &bottom);
bool fast = StackTrace::WillUseFastUnwind(request_fast);
Unwind(max_depth, pc, bp, context, top, bottom, fast);
}
#endif // SANITIZER_GO

View File

@ -20,11 +20,9 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(
uptr pc, uptr bp, void *context, bool request_fast, u32 max_depth) {
uptr top = 0;
uptr bottom = 0;
if (StackTrace::WillUseFastUnwind(request_fast)) {
GetThreadStackTopAndBottom(false, &top, &bottom);
Unwind(max_depth, pc, bp, nullptr, top, bottom, true);
} else
Unwind(max_depth, pc, bp, context, 0, 0, false);
GetThreadStackTopAndBottom(false, &top, &bottom);
bool fast = StackTrace::WillUseFastUnwind(request_fast);
Unwind(max_depth, pc, bp, context, top, bottom, fast);
}
extern "C" {