www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - TracedException - exception with stacktrace information

reply Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Flectioned now includes a TracedException class that provides stack
trace information.

sample:
# import cn.kuehne.flectioned;
# 
# class MyException : TracedException{
#    this(char[] message){
#       super(message);
#    }
# }
# 
# void foo(int i){
#    if(i > 0) {
#       foo(i - 1);
#    } else {
#       throw new MyException("message");
#    }
# }
# 
# void main(){
#    foo(2);
# }

# Error: (sample.MyException) message
#    0xFC8967F0   0x804F612   void sample.foo(int)
#    0xFC8967F8   0x804F5F1   void sample.foo(int)
#    0xFC896800   0x804F5F1   void sample.foo(int)
#    0xFC896808   0x804F629   int main(char[][])
#    0xFC896838   0x8050E7F   extern(C) int main(int, char**)

Flectioned:
http://flectioned.kuehne.cn

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFFul13LK5blCcjpWoRAsAoAJ9ik6JRMk+Poa+GJIgkbXl+GZcNFQCgnKuY
3muZaqbVNObzM06Vt0mn2O8=
=mBwf
-----END PGP SIGNATURE-----
Jan 26 2007
next sibling parent Sean Kelly <sean f4.ca> writes:
Thomas Kuehne wrote:
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 Flectioned now includes a TracedException class that provides stack
 trace information.
 
 sample:
 # import cn.kuehne.flectioned;
 # 
 # class MyException : TracedException{
 #    this(char[] message){
 #       super(message);
 #    }
 # }
 # 
 # void foo(int i){
 #    if(i > 0) {
 #       foo(i - 1);
 #    } else {
 #       throw new MyException("message");
 #    }
 # }
 # 
 # void main(){
 #    foo(2);
 # }
 
 # Error: (sample.MyException) message
 #    0xFC8967F0   0x804F612   void sample.foo(int)
 #    0xFC8967F8   0x804F5F1   void sample.foo(int)
 #    0xFC896800   0x804F5F1   void sample.foo(int)
 #    0xFC896808   0x804F629   int main(char[][])
 #    0xFC896838   0x8050E7F   extern(C) int main(int, char**)
 
 Flectioned:
 http://flectioned.kuehne.cn

Well I'm sold. Great work! Sean
Jan 26 2007
prev sibling next sibling parent kris <foo bar.com> writes:
Thomas Kuehne wrote:
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 Flectioned now includes a TracedException class that provides stack
 trace information.
 
 sample:
 # import cn.kuehne.flectioned;
 # 
 # class MyException : TracedException{
 #    this(char[] message){
 #       super(message);
 #    }
 # }
 # 
 # void foo(int i){
 #    if(i > 0) {
 #       foo(i - 1);
 #    } else {
 #       throw new MyException("message");
 #    }
 # }
 # 
 # void main(){
 #    foo(2);
 # }
 
 # Error: (sample.MyException) message
 #    0xFC8967F0   0x804F612   void sample.foo(int)
 #    0xFC8967F8   0x804F5F1   void sample.foo(int)
 #    0xFC896800   0x804F5F1   void sample.foo(int)
 #    0xFC896808   0x804F629   int main(char[][])
 #    0xFC896838   0x8050E7F   extern(C) int main(int, char**)
 
 Flectioned:
 http://flectioned.kuehne.cn
 
 Thomas

This is just awesome! Very nice, thomasK :)
Jan 26 2007
prev sibling next sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

If you compile with -version=TraceAllExceptions all
Exceptions(object.Exception and derived classes) will be traced.

sample:
# import cn.kuehne.flectioned;
# import std.utf, std.stdio;
#
# void main(){
#    try{
#       toUTF16("a\xFFb"c);
#    }catch(Exception e){
#	writefln("(%s) %s", e.classinfo.name, e);
#       foreach(step; TracedException.retraced[e]){
#          writefln("%s", step);
#       }
#    }
# }

dmd -version=TraceAllExceptions sample.d && ./sample

# (std.utf.UtfException) 4invalid UTF-8 sequence
# 0xFFCA5438      0x8061716       dchar std.utf.decode(char[], uint*)
# 0xFFCA546C      0x8061E09       wchar[] std.utf.toUTF16(char[])
# 0xFFCA54A8      0x804ADF6       int main(char[][])
# 0xFFCA54D8      0x80513AF       extern(C) int main(int, char**)

Flectioned:
http://flectioned.kuehne.cn

PAX users:
Please set NOMPROTECT e.g. via "paxctl -m sample".

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFFu7GnLK5blCcjpWoRAnyJAJ0QbFVAIzbv8a6vofTd79DGzGatiQCfSS0u
YnidjSMrL+bkMesMygmm4L8=
=17ni
-----END PGP SIGNATURE-----
Jan 27 2007
prev sibling parent reply Dejan Lekic <dejan.lekic gmail.com> writes:
Good work Mr. Kuehne!
I would like to see this in phobos (I hope Mr. Bright is reading this thread :)
Feb 06 2007
next sibling parent reply torhu <fake address.dude> writes:
Dejan Lekic wrote:
 Good work Mr. Kuehne!
 I would like to see this in phobos (I hope Mr. Bright is reading this thread :)

It sure would be nice to have a stack trace printed by default. Most of the time I fire up windbg with D, it's to trace an Access Violation. This would make debugging D apps ten times faster. And much less painful. Why not incorporate that backtrace patch someone posted into Phobos?
Feb 07 2007
next sibling parent reply Charlie <charlie.fats gmail.com> writes:
Shinh's only works on win32 , its still very useful , but this code 
works on linux + win32.

I'd really love to see this for tango also.

Charlie

torhu wrote:
 Dejan Lekic wrote:
 Good work Mr. Kuehne!
 I would like to see this in phobos (I hope Mr. Bright is reading this 
 thread :)

It sure would be nice to have a stack trace printed by default. Most of the time I fire up windbg with D, it's to trace an Access Violation. This would make debugging D apps ten times faster. And much less painful. Why not incorporate that backtrace patch someone posted into Phobos?

Feb 07 2007
parent Lars Ivar Igesund <larsivar igesund.net> writes:
Charlie wrote:

 Shinh's only works on win32 , its still very useful , but this code
 works on linux + win32.
 
 I'd really love to see this for tango also.
 
 Charlie

We are planning to add this in the 0.96 timeframe, but are dependant on Thomas porting it to Tango for us :) -- Lars Ivar Igesund blog at http://larsivi.net DSource & #D: larsivi Dancing the Tango
Feb 07 2007
prev sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"torhu" <fake address.dude> wrote in message 
news:eqd3ss$f6e$1 digitaldaemon.com...

 Why not incorporate that backtrace patch someone posted into Phobos?

Because nothing that anyone writes for Phobos ever seems to make it in. :\ (A notable exception would be std.cpuid.)
Feb 07 2007
parent Derek Parnell <derek nomail.afraid.org> writes:
On Wed, 7 Feb 2007 19:37:15 -0500, Jarrett Billingsley wrote:

 "torhu" <fake address.dude> wrote in message 
 news:eqd3ss$f6e$1 digitaldaemon.com...
 
 Why not incorporate that backtrace patch someone posted into Phobos?

Because nothing that anyone writes for Phobos ever seems to make it in. :\ (A notable exception would be std.cpuid.)

Well... I did manage to get a change to the GC incorporated (setting array.length = 0 no longer invalidates the allocated RAM), so keep on lobbying <G>. -- Derek (skype: derek.j.parnell) Melbourne, Australia "Justice for David Hicks!" 8/02/2007 11:39:33 AM
Feb 07 2007
prev sibling parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Dejan Lekic wrote:
 Good work Mr. Kuehne!
 I would like to see this in phobos (I hope Mr. Bright is reading this thread :)

Yes++. SOME kind of built-in core dump/stack trace ability in dmd would make debugging sessions go *much* faster than the current binary search for the offending line with writeflns. --bb
Feb 07 2007
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Bill Baxter" <dnewsgroup billbaxter.com> wrote in message 
news:eqe1ui$1jbf$2 digitaldaemon.com...
 Dejan Lekic wrote:
 Good work Mr. Kuehne!
 I would like to see this in phobos (I hope Mr. Bright is reading this 
 thread :)

Yes++. SOME kind of built-in core dump/stack trace ability in dmd would make debugging sessions go *much* faster than the current binary search for the offending line with writeflns.

sarcasm { But Bill! Isn't it just so easy to load your program into the debugger and have it break on segfault? } I especially love tracking down really insidious segfaults which are data-dependent or which don't rear their head until half an hour into execution. Yeah, it's completely practical to load the program into the debugger then. I put shinichiro's stacktrace patch into Phobos a few months ago and LOVED it. Of course it went away when I updated DMD, and I never got around to putting it back in, but..
Feb 07 2007