<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello Filip,<br>
    <br>
    Very tidy solution, thanks for putting in the time.<br>
    <br>
    <br>
    <code>Index: tools/libclang/CIndex.cpp</code><code><br>
    </code><code>===================================================================</code><code><br>
    </code><code>--- tools/libclang/CIndex.cpp    (revision 193960)</code><code><br>
    </code><code>+++ tools/libclang/CIndex.cpp    (working copy)</code><code><br>
    </code><code>@@ -2544,10 +2544,6 @@</code><code><br>
    </code><code> extern "C" {</code><code><br>
    </code><code> CXIndex clang_createIndex(int
      excludeDeclarationsFromPCH,</code><code><br>
    </code><code>                           int displayDiagnostics) {</code><code><br>
    </code><code>-  // Disable pretty stack trace functionality, which
      will otherwise be a very</code><code><br>
    </code><code>-  // poor citizen of the world and set up all sorts of
      signal handlers.</code><code><br>
    </code><code>-  llvm::DisablePrettyStackTrace = true;</code><code><br>
    </code><code>-</code><code><br>
    </code><code>   // We use crash recovery to make some of our APIs
      more reliable, implicitly</code><code><br>
    </code><code>   // enable it.</code><code><br>
    </code><code>   llvm::CrashRecoveryContext::Enable();</code><br>
    <br>
    <br>
    You can remove the old PrettyStackTrace.h include here as well.<br>
    <br>
    Also lldb will need patching:<br>
    <br>
    <code>source/Expression/ClangExpressionParser.cpp:           
      llvm::DisablePrettyStackTrace = true;</code><code><br>
    </code><br>
    Otherwise I think this is ready to go<br>
    <br>
    Alp.<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 03/11/2013 17:17, Filip Pizlo wrote:<br>
    </div>
    <blockquote
      cite="mid:8B0C4DFD-944E-46A4-AFE3-64367C19643B@apple.com"
      type="cite">
      <pre wrap="">Hi!

Currently some large subset of LLVM embedders are expected to call to set DisablePrettyStackTrace to true to disable LLVM's pretty stack trace printing.

Probably, it would be even better to flip this around: if you want pretty stack traces, you should ask for them explicitly.  This patch implements just such behavior, and does it in a way that I believe requires minimal changes from LLVM clients.

Previously the pretty stack trace signal handler would be installed whenever a PrettyStackTraceEntry was constructed, unless the DisablePrettyStackTrace variable was set to true.  The C API would set this variable to true by calling LLVMDisablePrettyStackTrace().  Now, the signal handler is only installed if you call llvm::EnablePrettyStackTrace().

At first glance this would seem to imply that any LLVM client that does not currently set DisablePrettyStackTrace to true should now add a call to llvm::EnablePrettyStackTrace().  But I believe this patch avoids this: instead, I've made PrettyStackTraceProgram's constructor call EnablePrettyStackTrace().  PrettyStackTraceProgram is never used in LLVM library code - only in LLVM tools and in clients (like clang).  I believe that this automatically gives us the behavior we want:

- Existing LLVM-based tools continue to have pretty stack traces even though I didn't have to change any of their code.

- LLVM embedders that use the C API will not get pretty stack traces anymore unless they call LLVMEnablePrettyStackTrace().  I believe that this is a good thing, since if embedders were getting pretty stack traces just by calling into the LLVM C API, then that was probably a bug.

- LLVM embedders that use the C++ API will not get pretty stack traces unless they either use PrettyStackTraceProgram or call llvm::EnablePrettyStackTrace().

I also include a corresponding clang patch, which removes CIndex's use of DisablePrettyStackTrace.

-Filip


</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext" href="http://www.nuanti.com">http://www.nuanti.com</a>
the browser experts
</pre>
  </body>
</html>