Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 6

Qt-interest Archive, May 2007
Trapping Qt-Assertions in gdb


Message 1 in thread

Hi all.

Is there a way to make a Qt-assertion trap the debugger instead of calling 
exit() ?  I'm left with "no stack" for backtraces.

Regards
.....Volker

PS: it's Qt 4.2

--
 [ signature omitted ] 

Message 2 in thread

On Thursday 24 May 2007, Volker Poplawski wrote:
> Is there a way to make a Qt-assertion trap the debugger instead of
> calling exit() ?  I'm left with "no stack" for backtraces.

If you are using Linux/Unix, set "ulimit -c unlimited", so that any crash 
generates a core-file which you can load in gdb.

If you are already running inside the debugger, try to set a breakpoint on 
abort(), which is called by Qt assertions. (You might need the 
debug-version of libc.)


	Konrad

Attachment:

Attachment: pgpnWG6xmKMz2.pgp
Description: PGP signature


Message 3 in thread

Yeah, the same problem is with unhandled exceptions that annoyed me
too. But for that I have just made a solution.

I have created library containing abort() function (and those two used
by assert), that will cause SIGSEGV when abort() is called. And
SIGSEGV produces nice usable backtraces, unlike standart abort
function.

See attachment libbruteabort.tgz (only 536 bytes :) -  use 'make'  to
build the library

You use LD_PRELOAD to load it, before running the program, type:

export LD_PRELOAD=/full/path/to/libbruteabort.so

then run program in gdb as usual

This can catch Q_ASSERT, standard assert, abort() or uncaught
exceptions and ensure backtrace for all of them.

I think I'll put some proper readme and put it up somewhere.

Martin Petricek

On 5/24/07, Konrad Rosenbaum <konrad@xxxxxxxxx> wrote:
> On Thursday 24 May 2007, Volker Poplawski wrote:
> > Is there a way to make a Qt-assertion trap the debugger instead of
> > calling exit() ?  I'm left with "no stack" for backtraces.
>
> If you are using Linux/Unix, set "ulimit -c unlimited", so that any crash
> generates a core-file which you can load in gdb.
>
> If you are already running inside the debugger, try to set a breakpoint on
> abort(), which is called by Qt assertions. (You might need the
> debug-version of libc.)
>
>
>         Konrad
>
>

Attachment:

Attachment: libbruteabort.tgz
Description: GNU Zip compressed data


Message 4 in thread

Hi,

A further option would be to install a replacement message hander and 
set a breakpoint on the fatal case. This will then work on all platforms.

Tim

--
 [ signature omitted ] 

Message 5 in thread

Tim Dewhirst wrote:
> Hi,
> 
> A further option would be to install a replacement message hander and 
> set a breakpoint on the fatal case. This will then work on all platforms.
> 
> Tim
Or install a replacement message handler and call abort() in the 
QtFatalMsg case.

> 
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/

--
 [ signature omitted ]