Results 1 to 5 of 5

Thread: backtrace and unwind with c++

  1. #1
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    99
    Thanks
    11
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default backtrace and unwind with c++

    I'm trying to create a framework for producing a stacktrace when an exception gets thrown in c++ (gcc 3.3)

    I've found that glibc (the GNU C library) has something called backtrace and am wondering how it compares to gcc's unwind facility. Using _Unwind_Backtrace i can traverse the stack and get a bunch of instruction pointers, but no more context than that. I was hoping to be able to get file name and line number...maybe even method and class name.

    Also, i've found some example code that uses _Unwind_Backtrace but that also checks if the gcc version is >=3.4...so i'm also wondering if there's any difference in unwind's behavior between gcc 3.3 and 3.4?

    This is a very specific and niched question and i'm not really expecting a wealth of response...i don't really know where else to turn.

    thanks in advance!

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: backtrace and unwind with c++

    Not sure if this helps anyhow but have you noticed src/corelib/kernel/qcrashhandler?
    J-P Nurmi

  3. #3
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    99
    Thanks
    11
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: backtrace and unwind with c++

    Quote Originally Posted by jpn View Post
    Not sure if this helps anyhow but have you noticed src/corelib/kernel/qcrashhandler?
    no, no i have not...i'll look into it

  4. #4
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    99
    Thanks
    11
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: backtrace and unwind with c++

    Having had a quick look at the code it looks like it starts a debugger and writes the output to a file. I'm wondering if this is done while the process is still 'active' in the sense that it can continue execution after the debuginfo has been saved, or if this is done right before termination?

  5. #5
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    99
    Thanks
    11
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: backtrace and unwind with c++

    Having looked more closely at it i'll go ahead and reply to myself: Yes, the process is still 'active' since we're only opening a pipe to a forked process. This solution is not really what i had hoped for (a bit too quick and dirty) but gets the job done...sort of.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.