<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Oct 28, 2013 at 12:08 AM, Iain Buclaw <span dir="ltr"><<a href="mailto:ibuclaw@ubuntu.com" target="_blank">ibuclaw@ubuntu.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">On 27 October 2013 23:43, Timothee Cour <<a href="mailto:thelastmammoth@gmail.com">thelastmammoth@gmail.com</a>> wrote:<br>

> ideal syntax would be something along those lines:<br>
><br>
> try{...}<br>
> catch(SomeThrowableType e, &callback_before_unwinding){...}<br>
> with callback_before_unwinding of type 'void function(Throwable t)'<br>
><br>
> The semantics of which is:<br>
> if 'e' is about to be caught in this particular catch block, call<br>
> callback_before_unwinding(e) _before_ unwinding stack and entering catch<br>
> block.<br>
><br>
> Advantages are:<br>
> * it allows one to, for example, attach a debugger before stack unwinds and<br>
> entering this catch block<br>
> * the debugger is only attached at that point, hence not making the regular<br>
> program slower<br>
> * it doesn't affect other catch blocks nor does it affect how<br>
> exceptions/errors are thrown<br>
> * it could even allow one to make speed up exception handling, by computing<br>
> backtrace _only_ inside this callback_before_unwinding, so that usual<br>
> exceptions (std.conv conversions etc) can be caught without any backtrace<br>
> inside the main program while unusual unintended exceptions would be caught<br>
> at the root and show proper stack trace.<br>
><br>
> This saves a lot of time when debugging issues, at _zero_ cost in<br>
> performance.<br>
><br>
> Does libunwind allow that? Otherwise could it be adapted to do that?<br>
><br>
<br>
</div>GDB has 'catch throw' and 'catch catch' as convenient C++ breakpoint<br>
placeholders in the debugger.  Can certainly implement them for D too.<br>
<br>
<a href="http://www.delorie.com/gnu/docs/gdb/gdb_31.html" target="_blank">http://www.delorie.com/gnu/docs/gdb/gdb_31.html</a><br><span class=""><font color="#888888"><br></font></span></blockquote><div><br></div>I'm worried about that from performance standpoint:</div>
<div class="gmail_quote">* that implies running the normal program execution while attached to a debugger, which would be slower</div><div class="gmail_quote">* catch throw will stop at every thrown exception as opposed to the ones that are caught at a certain 'root' point.</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">In what I suggested (and implemented for dmd), it has 0 performance penalty and only triggers when a thrown exception is caught in a particular location; debugger isn't attached during normal program execution.</div>
<div class="gmail_quote"><br><div><br></div><div class="gmail_extra"><br><br></div><div> </div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class=""><font color="#888888">
--<br>
Iain Buclaw<br>
<br>
*(p < e ? p++ : p) = (c & 0x0f) + '0';<br>
</font></span></blockquote></div><br></div></div>