[compiler-rt] r192534 - [Sanitizer] Remove StackTrace::max_depth field
Alexey Samsonov
samsonov at google.com
Sat Oct 12 05:40:47 PDT 2013
Author: samsonov
Date: Sat Oct 12 07:40:47 2013
New Revision: 192534
URL: http://llvm.org/viewvc/llvm-project?rev=192534&view=rev
Log:
[Sanitizer] Remove StackTrace::max_depth field
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_stacktrace_test.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc?rev=192534&r1=192533&r2=192534&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc Sat Oct 12 07:40:47 2013
@@ -139,12 +139,17 @@ uptr Unwind_GetIP(struct _Unwind_Context
#endif
}
+struct UnwindTraceArg {
+ StackTrace *stack;
+ uptr max_depth;
+};
+
_Unwind_Reason_Code Unwind_Trace(struct _Unwind_Context *ctx, void *param) {
- StackTrace *b = (StackTrace*)param;
- CHECK(b->size < b->max_size);
+ UnwindTraceArg *arg = (UnwindTraceArg*)param;
+ CHECK_LT(arg->stack->size, arg->max_depth);
uptr pc = Unwind_GetIP(ctx);
- b->trace[b->size++] = pc;
- if (b->size == b->max_size) return UNWIND_STOP;
+ arg->stack->trace[arg->stack->size++] = pc;
+ if (arg->stack->size == arg->max_depth) return UNWIND_STOP;
return UNWIND_CONTINUE;
}
@@ -153,10 +158,10 @@ static bool MatchPc(uptr cur_pc, uptr tr
}
void StackTrace::SlowUnwindStack(uptr pc, uptr max_depth) {
- this->size = 0;
- this->max_size = max_depth;
+ size = 0;
+ UnwindTraceArg arg = {this, max_depth};
if (max_depth > 1) {
- _Unwind_Backtrace(Unwind_Trace, this);
+ _Unwind_Backtrace(Unwind_Trace, &arg);
// We need to pop a few frames so that pc is on top.
// trace[0] belongs to the current function so we always pop it.
int to_pop = 1;
@@ -165,9 +170,9 @@ void StackTrace::SlowUnwindStack(uptr pc
else if (size > 3 && MatchPc(pc, trace[3])) to_pop = 3;
else if (size > 4 && MatchPc(pc, trace[4])) to_pop = 4;
else if (size > 5 && MatchPc(pc, trace[5])) to_pop = 5;
- this->PopStackFrames(to_pop);
+ PopStackFrames(to_pop);
}
- this->trace[0] = pc;
+ trace[0] = pc;
}
#endif // !SANITIZER_GO
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc?rev=192534&r1=192533&r2=192534&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc Sat Oct 12 07:40:47 2013
@@ -114,8 +114,7 @@ uptr StackTrace::GetCurrentPc() {
void StackTrace::FastUnwindStack(uptr pc, uptr bp,
uptr stack_top, uptr stack_bottom,
uptr max_depth) {
- max_size = max_depth;
- if (max_size == 0) {
+ if (max_depth == 0) {
size = 0;
return;
}
@@ -129,7 +128,7 @@ void StackTrace::FastUnwindStack(uptr pc
frame < (uhwptr *)stack_top - 2 &&
frame > (uhwptr *)stack_bottom &&
IsAligned((uptr)frame, sizeof(*frame)) &&
- size < max_size) {
+ size < max_depth) {
uhwptr pc1 = frame[1];
if (pc1 != pc) {
trace[size++] = (uptr) pc1;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h?rev=192534&r1=192533&r2=192534&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h Sat Oct 12 07:40:47 2013
@@ -32,8 +32,8 @@ struct StackTrace {
typedef bool (*SymbolizeCallback)(const void *pc, char *out_buffer,
int out_size);
uptr size;
- uptr max_size;
uptr trace[kStackTraceMax];
+
static void PrintStack(const uptr *addr, uptr size, bool symbolize,
SymbolizeCallback symbolize_callback);
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc?rev=192534&r1=192533&r2=192534&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Sat Oct 12 07:40:47 2013
@@ -381,13 +381,12 @@ void StackTrace::Unwind(uptr max_depth,
(void)fast;
(void)stack_top;
(void)stack_bottom;
- max_size = max_depth;
void *tmp[kStackTraceMax];
// FIXME: CaptureStackBackTrace might be too slow for us.
// FIXME: Compare with StackWalk64.
// FIXME: Look at LLVMUnhandledExceptionFilter in Signals.inc
- uptr cs_ret = CaptureStackBackTrace(1, max_size, tmp, 0);
+ uptr cs_ret = CaptureStackBackTrace(1, max_depth, tmp, 0);
uptr offset = 0;
// Skip the RTL frames by searching for the PC in the stacktrace.
// FIXME: this doesn't work well for the malloc/free stacks yet.
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_stacktrace_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_stacktrace_test.cc?rev=192534&r1=192533&r2=192534&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_stacktrace_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_stacktrace_test.cc Sat Oct 12 07:40:47 2013
@@ -91,7 +91,6 @@ TEST_F(FastUnwindTest, OneFrameStackTrac
trace.FastUnwindStack(start_pc, (uptr)&fake_stack[0],
fake_top, fake_bottom, 1);
EXPECT_EQ(1U, trace.size);
- EXPECT_EQ(1U, trace.max_size);
EXPECT_EQ(start_pc, trace.trace[0]);
}
More information about the llvm-commits
mailing list