On 2010-03-04 21:29:15 +0100, "Nick Sabalausky" <a...@a.a> said:

"bearophile" <bearophileh...@lycos.com> wrote in message
news:hmovte$243...@digitalmars.com...
What do you think of the idea of the Exception to remember (so later it
can be shown if uncaught) the line number and file name where it was
instantiated?

void foo() {
auto e = new Exception(""); // instantiation line number here
throw e;
}
void main() {
foo();
}

Exceptions get caught, rethrown, stored, etc. But in many cases in my code
they are instantiated close to where the cause was. So knowing such line
number can be useful (if you are using a debugger this is not so useful).

Bye,
bearophile

Doesn't tango's exception tracing do that?

sure it does, just import TraceExceptions...
The exception will contain the stacktrace at the throwing point (adresses)... and with printOut you can get a symbolic trace (if possible).

I have also tried to have a way to get the trace of all threads

http://github.com/fawzi/blip/blob/master/blip/util/TraceAll.d

it is not perfect, probably I should trade a little bit more of memory and suspend all threads (instead of one at a time), but it can be useful when there is a deadlock and you want to see who is the culprit.

that uses signals, so it is unsafe, also it will deadlock if the gc tries to suspend all threads while tracing, but I find it useful all the same, so that you don't have to attach a debugger...

Fawzi

Reply via email to