Jump to page: 1 27  
Page
Thread overview
[Issue 1001] New: print stack trace (in debug mode) when program die
Feb 23, 2007
d-bugmail
Feb 23, 2007
d-bugmail
Jan 18, 2010
Hoenir
Feb 03, 2010
Sean Kelly
Feb 03, 2010
BCS
Feb 03, 2010
Brad Roberts
Feb 03, 2010
BCS
Feb 03, 2010
Brad Roberts
Feb 05, 2010
Sean Kelly
Feb 05, 2010
Sean Kelly
Feb 05, 2010
Witold Baryluk
Feb 05, 2010
Witold Baryluk
Feb 05, 2010
Sean Kelly
Feb 05, 2010
Witold Baryluk
Feb 05, 2010
Sean Kelly
Feb 05, 2010
Witold Baryluk
May 05, 2010
Sean Kelly
May 06, 2010
Brad Roberts
May 06, 2010
Sean Kelly
May 25, 2010
Brad Roberts
May 25, 2010
Sean Kelly
May 25, 2010
Brad Roberts
May 26, 2010
Don
May 29, 2010
Brad Roberts
May 31, 2010
Brad Roberts
Aug 22, 2010
Jonathan M Davis
Aug 23, 2010
nfxjfg@gmail.com
Aug 23, 2010
faithful
Aug 23, 2010
Johannes Pfau
Sep 09, 2010
Sean Kelly
Sep 16, 2010
Trass3r
Oct 02, 2010
vano
Oct 07, 2010
Benjamin Thaut
Nov 24, 2010
Witold Baryluk
Jan 20, 2011
Sean Kelly
Mar 15, 2011
Trass3r
Mar 16, 2011
Sean Kelly
Mar 23, 2011
Benjamin Thaut
Mar 24, 2011
Sean Kelly
May 21, 2011
Matt Peterson
May 23, 2011
Sean Kelly
May 23, 2011
Matt Peterson
May 24, 2011
Jonathan M Davis
May 24, 2011
Matt Peterson
May 24, 2011
Matt Peterson
Jul 03, 2011
Brad Roberts
Aug 10, 2011
Trass3r
Aug 18, 2011
Trass3r
Aug 18, 2011
Jonathan M Davis
Aug 18, 2011
Trass3r
Aug 19, 2011
Don
Aug 19, 2011
Sean Kelly
Dec 02, 2011
Trass3r
Jan 06, 2012
Vladimir Panteleev
Jul 24, 2012
Vladimir Panteleev
Dec 23, 2012
Benjamin Thaut
May 23, 2013
Jameson
February 23, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1001

           Summary: print stack trace (in debug mode) when program die
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: someanon@yahoo.com


Just as Java, it's a great life saver in development, especially when we don't have a decent debugger right now.


-- 

February 23, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1001





------- Comment #1 from tknott@gmail.com  2007-02-23 00:07 -------
The Flectioned runtime reflection library (http://flectioned.kuehne.cn/) can provide this, though language support would be welcome.


-- 

January 18, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1001


Hoenir <mrmocool@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mrmocool@gmx.de


--- Comment #2 from Hoenir <mrmocool@gmx.de> 2010-01-17 17:58:15 PST ---
Flectioned hasn't been updated since over 2 years though.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 03, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1001


Sean Kelly <sean@invisibleduck.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED


--- Comment #3 from Sean Kelly <sean@invisibleduck.org> 2010-02-02 20:12:53 PST ---
Flectioned doesn't work any more I'm afraid.  A replacement would be welcome, though I may be able to sort something out quickly with the stuff in ucontext.h on *nix.  Some platforms even have a backtrace call here, though output is fixed to a specific format.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 03, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1001


BCS <shro8822@vandals.uidaho.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |shro8822@vandals.uidaho.edu


--- Comment #4 from BCS <shro8822@vandals.uidaho.edu> 2010-02-02 22:40:41 PST ---
does anyone know if the "backtrace" function from execinfo.h works with DMD/Linux?


If it does, than that's the way to go. Heck, I've even got a blob of CPP code I'd give way that calls addr2line to get nice output.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 03, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1001


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |braddr@puremagic.com


--- Comment #5 from Brad Roberts <braddr@puremagic.com> 2010-02-02 22:52:04 PST ---
The c function works, so it will work with dmd.  I've been meaning to hook the thing into the runtime for ages.  It's easy to use.  The only interesting trick is that the app needs to be linked with -rdynamic (check the man pages, this is off the top of my head from when I've done it at work).  That'll likely require a minor tweak to dmd itself since it's what invokes the linker.  It could probably be added to dmd.conf as an alternative.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 03, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1001



--- Comment #6 from BCS <shro8822@vandals.uidaho.edu> 2010-02-02 23:44:41 PST ---
(In reply to comment #5)
> The c function works, so it will work with dmd.

It will work with extern C functions but something's ticking a memory that D functions aren't necessarily the same, or is that just the arguments layout?

What the heck, I'll try it tomorrow and see if it works.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 03, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1001



--- Comment #7 from Brad Roberts <braddr@puremagic.com> 2010-02-03 01:19:34 PST ---
Created an attachment (id=560)
first pass patch to add stack tracing for exceptions on linux

It's dumping filename (always the test binary name right now) and address, but not function name for some reason.. at least on my debian amd/64 box.  I'm not sure yet why it's failing to find the symbols right now.  I need to pull the code over into a C app to make sure it works there.  That'd at least help narrow down where the problem lies.

Current output:
$ ./obj/posix/debug/unittest.brad
object.Exception: blah
----------------
./obj/posix/debug/unittest.brad [0x804b684] ./obj/posix/debug/unittest.brad [0x804b65c] ./obj/posix/debug/unittest.brad [0x804ab0b] ./obj/posix/debug/unittest.brad [0x804a8f0] ./obj/posix/debug/unittest.brad [0x804ab27] ./obj/posix/debug/unittest.brad [0x80491de] ./obj/posix/debug/unittest.brad [0x80491f0] ./obj/posix/debug/unittest.brad [0x804b93c] ./obj/posix/debug/unittest.brad [0x804b745] ./obj/posix/debug/unittest.brad [0x804b97e] ./obj/posix/debug/unittest.brad [0x804b745] ./obj/posix/debug/unittest.brad [0x804b603] /lib32/libc.so.6(__libc_start_main+0xe6) [0xf7e02b46] ./obj/posix/debug/unittest.brad [0x8049101]

test code:
public import std.c.stdio;

void foo()
{
    throw new Exception("blah");
}

int main(char[][] args)
{
    foo();
    printf("Success!\n");
    return 0;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 05, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1001



--- Comment #8 from Sean Kelly <sean@invisibleduck.org> 2010-02-04 16:38:11 PST ---
printstack doesn't exist on OSX, so it has to be faked there (which is pretty easy to do).  The only trick is that the stack trace integration is line-based using opApply, so on platforms where backtrace isn't available, the trace should really be output to a buffer and then parsed for opApply output.  This might not be possible with printstack though.  In any case, here's some code I've used to mimic printstack on OSX.  The backtrace_symbols call is what I'd use for opApply, since it's pretty much exactly what's needed.  If I remember correctly, backtrace is just a wrapper for some of the stuff in <ucontext.h>.

#if defined(sun) || defined(__sun) || defined(_sun_) || defined(__solaris__)
#   include <ucontext.h>
#elif defined(__APPLE__)
#   include <execinfo.h>

    int printstack( int fd )
    {
        void* callstack[128];
        int   frames = backtrace( callstack, 128 );
        backtrace_symbols_fd( callstack, frames, fd );

        /*
        char** strs = backtrace_symbols( callstack, frames );
        for( i = 0; i < frames; ++i )
        {
            fprintf( fd, "%s\n", strs[i] );
        }
        free( strs );
        */
        return 0;
    }
#else
    int printstack( int fd )
    {
        return 0;
    }
#endif

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 05, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1001



--- Comment #9 from Sean Kelly <sean@invisibleduck.org> 2010-02-04 16:40:01 PST ---
Oops!  Looks like Brad beat me to it.  So it looks like backtrace is available on both OSX and Linux.  I guess that leaves us needing backtrace support on Win32.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2 3 4 5 6 7