[Sanitizer] Use same PC threshold in slow unwinder on all platforms

llvm-svn: 194580
This commit is contained in:
Alexey Samsonov 2013-11-13 15:20:10 +00:00
parent 9ff4598225
commit cf6ac12e23
3 changed files with 7 additions and 4 deletions

View File

@ -161,7 +161,7 @@ void StackTrace::SlowUnwindStack(uptr pc, uptr max_depth) {
UnwindTraceArg arg = {this, Min(max_depth + 1, kStackTraceMax)}; UnwindTraceArg arg = {this, Min(max_depth + 1, kStackTraceMax)};
_Unwind_Backtrace(Unwind_Trace, &arg); _Unwind_Backtrace(Unwind_Trace, &arg);
// We need to pop a few frames so that pc is on top. // We need to pop a few frames so that pc is on top.
uptr to_pop = LocatePcInTrace(pc, 64, 6); uptr to_pop = LocatePcInTrace(pc, 6);
// trace[0] belongs to the current function so we always pop it. // trace[0] belongs to the current function so we always pop it.
if (to_pop == 0) if (to_pop == 0)
to_pop = 1; to_pop = 1;

View File

@ -152,9 +152,12 @@ static bool MatchPc(uptr cur_pc, uptr trace_pc, uptr threshold) {
} }
uptr uptr
StackTrace::LocatePcInTrace(uptr pc, uptr pc_threshold, uptr max_pc_depth) { StackTrace::LocatePcInTrace(uptr pc, uptr max_pc_depth) {
// Use threshold to find PC in stack trace, as PC we want to unwind from may
// slightly differ from return address in the actual unwinded stack trace.
const int kPcThreshold = 64;
for (uptr i = 0; i < max_pc_depth && i < size; ++i) { for (uptr i = 0; i < max_pc_depth && i < size; ++i) {
if (MatchPc(pc, trace[i], pc_threshold)) if (MatchPc(pc, trace[i], kPcThreshold))
return i; return i;
} }
return 0; return 0;

View File

@ -69,7 +69,7 @@ struct StackTrace {
uptr max_depth); uptr max_depth);
void SlowUnwindStack(uptr pc, uptr max_depth); void SlowUnwindStack(uptr pc, uptr max_depth);
void PopStackFrames(uptr count); void PopStackFrames(uptr count);
uptr LocatePcInTrace(uptr pc, uptr pc_threshold = 0, uptr max_pc_depth = -1); uptr LocatePcInTrace(uptr pc, uptr max_pc_depth = -1);
}; };
} // namespace __sanitizer } // namespace __sanitizer