<div dir="ltr">Please review it.<div><br></div><div><br></div><div><div>Index: lib/asan/asan_thread.h</div><div>===================================================================</div><div>--- lib/asan/asan_thread.h<span class="" style="white-space:pre"> </span>(revision 190475)</div>
<div>+++ lib/asan/asan_thread.h<span class="" style="white-space:pre"> </span>(working copy)</div><div>@@ -86,12 +86,19 @@</div><div> UnmapOrDie(fake_stack_, sizeof(FakeStack));</div><div> }</div><div> FakeStack *fake_stack() { return fake_stack_; }</div>
<div>+ bool isStacktracing() const { </div><div>+ return stacktracing;</div><div>+ }</div><div>+ void setStacktracing(bool b) {</div><div>+ stacktracing = b;</div><div>+ }</div><div> </div><div> AsanThreadLocalMallocStorage &malloc_storage() { return malloc_storage_; }</div>
<div> AsanStats &stats() { return stats_; }</div><div> </div><div> private:</div><div>- AsanThread() {}</div><div>+ AsanThread()</div><div>+ : stacktracing(false) {}</div><div> void SetThreadStackAndTls();</div>
<div> void ClearShadowForThreadStackAndTLS();</div><div> AsanThreadContext *context_;</div><div>@@ -105,8 +112,23 @@</div><div> FakeStack *fake_stack_;</div><div> AsanThreadLocalMallocStorage malloc_storage_;</div>
<div> AsanStats stats_;</div><div>+ bool stacktracing;</div><div> };</div><div> </div><div>+// ScopedStacktracing is a scope for stacktracing member of a context</div><div>+class ScopedStacktracing {</div><div>+ public:</div>
<div>+ ScopedStacktracing (AsanThread * t)</div><div>+ : thread(t) {</div><div>+ t->setStacktracing(true);</div><div>+ }</div><div>+ ~ScopedStacktracing() {</div><div>+ thread->setStacktracing(false);</div>
<div>+ }</div><div>+ private:</div><div>+ AsanThread * thread;</div><div>+};</div><div>+</div><div> struct CreateThreadContextArgs {</div><div> AsanThread *thread;</div><div> StackTrace *stack;</div><div>Index: lib/asan/asan_stack.h</div>
<div>===================================================================</div><div>--- lib/asan/asan_stack.h<span class="" style="white-space:pre"> </span>(revision 190475)</div><div>+++ lib/asan/asan_stack.h<span class="" style="white-space:pre"> </span>(working copy)</div>
<div>@@ -36,14 +36,16 @@</div><div> #define GET_STACK_TRACE_WITH_PC_AND_BP(max_s, pc, bp, fast) \</div><div> StackTrace stack; \</div><div> { \</div>
<div>- uptr stack_top = 0, stack_bottom = 0; \</div><div> AsanThread *t; \</div><div>- if (asan_inited && (t = GetCurrentThread())) { \</div>
<div>- stack_top = t->stack_top(); \</div><div>- stack_bottom = t->stack_bottom(); \</div><div>+ stack.size = 0; \</div>
<div>+ if (asan_inited && (t = GetCurrentThread()) \</div><div>+ && !t->isStacktracing()) { \</div><div>+ uptr stack_top = t->stack_top(); \</div>
<div>+ uptr stack_bottom = t->stack_bottom(); \</div><div>+ ScopedStacktracing sink(t); \</div><div>+ GetStackTrace(&stack, max_s, pc, bp, \</div>
<div>+ stack_top, stack_bottom, fast); \</div><div> } \</div><div>- GetStackTrace(&stack, max_s, pc, bp, \</div>
<div>- stack_top, stack_bottom, fast); \</div><div> }</div><div> #endif // SANITIZER_WINDOWS</div><div> </div></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
2013/9/10 Evgeniy Stepanov <span dir="ltr"><<a href="mailto:eugeni.stepanov@gmail.com" target="_blank">eugeni.stepanov@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Mon, Sep 9, 2013 at 2:09 PM, ÁÖ×÷½¡ <<a href="mailto:manjian2006@gmail.com">manjian2006@gmail.com</a>> wrote:<br>
> Index: lib/asan/asan_thread.h<br>
> ===================================================================<br>
> --- lib/asan/asan_thread.h (revision 190121)<br>
> +++ lib/asan/asan_thread.h (working copy)<br>
> @@ -36,10 +36,12 @@<br>
> explicit AsanThreadContext(int tid)<br>
> : ThreadContextBase(tid),<br>
> announced(false),<br>
> + stacktracing(false),<br>
> thread(0) {<br>
> internal_memset(&stack, 0, sizeof(stack));<br>
> }<br>
> bool announced;<br>
> + bool stacktracing;<br>
<br>
</div>Thread context objects live forever. Please move this to AsanThread.<br>
<div class="im"><br>
> StackTrace stack;<br>
> AsanThread *thread;<br>
><br>
> @@ -86,6 +88,12 @@<br>
> UnmapOrDie(fake_stack_, sizeof(FakeStack));<br>
> }<br>
> FakeStack *fake_stack() { return fake_stack_; }<br>
> + bool isStacktracing() {<br>
> + if (context()) {<br>
> + return context()->stacktracing;<br>
> + }<br>
> + return false;<br>
> + }<br>
><br>
> AsanThreadLocalMallocStorage &malloc_storage() { return malloc_storage_;<br>
> }<br>
> AsanStats &stats() { return stats_; }<br>
> @@ -107,6 +115,24 @@<br>
> AsanStats stats_;<br>
> };<br>
><br>
> +// AsanStacktracingSink is a sink for stacktracing member of a context<br>
> +class AsanStacktracingSink {<br>
<br>
</div>Please call it ScopedSomething. M/b ScopedInStackTrace or ScopedStacktracing.<br>
<div><div class="h5"><br>
> + public:<br>
> + AsanStacktracingSink(AsanThread * t)<br>
> + : thread(t) {<br>
> + if(t->context()) {<br>
> + t->context()->stacktracing = true;<br>
> + }<br>
> + }<br>
> + ~AsanStacktracingSink() {<br>
> + if(thread->context()) {<br>
> + thread->context()->stacktracing = false;<br>
> + }<br>
> + }<br>
> + private:<br>
> + AsanThread * thread;<br>
> +};<br>
> +<br>
> struct CreateThreadContextArgs {<br>
> AsanThread *thread;<br>
> StackTrace *stack;<br>
> Index: lib/asan/asan_stack.h<br>
> ===================================================================<br>
> --- lib/asan/asan_stack.h (revision 190121)<br>
> +++ lib/asan/asan_stack.h (working copy)<br>
> @@ -36,14 +36,16 @@<br>
> #define GET_STACK_TRACE_WITH_PC_AND_BP(max_s, pc, bp, fast) \<br>
> StackTrace stack; \<br>
> { \<br>
> - uptr stack_top = 0, stack_bottom = 0; \<br>
> AsanThread *t; \<br>
> - if (asan_inited && (t = GetCurrentThread())) { \<br>
> - stack_top = t->stack_top(); \<br>
> - stack_bottom = t->stack_bottom(); \<br>
> + stack.size = 0; \<br>
> + if (asan_inited && (t = GetCurrentThread()) \<br>
> + && !t->isStacktracing()) { \<br>
> + uptr stack_top = t->stack_top(); \<br>
> + uptr stack_bottom = t->stack_bottom(); \<br>
> + AsanStacktracingSink sink(t); \<br>
> + GetStackTrace(&stack, max_s, pc, bp, \<br>
> + stack_top, stack_bottom, fast); \<br>
> } \<br>
> - GetStackTrace(&stack, max_s, pc, bp, \<br>
> - stack_top, stack_bottom, fast); \<br>
> }<br>
> #endif // SANITIZER_WINDOWS<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
</blockquote></div><br></div>