Qt Application Debugging with GDB
-
Hi,
I am trying to debug a Qt application using GDB. The problem I face is that when I start the application via GDB, the application gui comes up, but the moment I try to use one of the buttons on the application the application freezes and I get the following message from gdb:
@C:\Devel\KFTools\KFFlashDL\debug>gdb KFFlashDL.exe
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-mingw32"...
(gdb) run
Starting program: C:\Devel\KFTools\KFFlashDL\debug/KFFlashDL.exe
[New thread 4468.0x12ac]
warning: Lowest section in C:\WINDOWS\system32\xpsp2res.dll is .rsrc at 00011000
[New thread 4468.0x1604]
[New thread 4468.0x1278]
[New thread 4468.0xd74]
[New thread 4468.0x17c0]
[New thread 4468.0xbc0]
[New thread 4468.0xda0]
[New thread 4468.0x11d0]
warning: HEAP[KFFlashDL.exe]:
warning: Invalid Address specified to RtlFreeHeap( 003E0000, 0639FC88 )Program received signal SIGTRAP, Trace/breakpoint trap.
[Switching to thread 4468.0x11d0]
0x7c90120f in ntdll!DbgUiConnectToDbg () from C:\WINDOWS\system32\ntdll.dll
(gdb) bt
#0 0x7c90120f in ntdll!DbgUiConnectToDbg () from C:\WINDOWS\system32\ntdll.dll
#1 0x7c96ee31 in ntdll!RtlpNtMakeTemporaryKey () from C:\WINDOWS\system32\ntdll.dll
#2 0x7c96f26e in ntdll!RtlpNtMakeTemporaryKey () from C:\WINDOWS\system32\ntdll.dll
#3 0x7c970456 in ntdll!RtlpNtMakeTemporaryKey () from C:\WINDOWS\system32\ntdll.dll
#4 0x7c94bafc in ntdll!LdrFindEntryForAddress () from C:\WINDOWS\system32\ntdll.dll
#5 0x003e0000 in ?? ()
#6 0x50000061 in ?? ()
#7 0x0639fc88 in ?? ()
#8 0x003e0000 in ?? ()
#9 0x0639fc88 in ?? ()
#10 0x40000060 in ?? ()
#11 0x00000000 in ?? ()
(gdb)@I have build my application using the debug configuration. The strange part is that the debug application runs fine if it is started using the exe and not via gdb.
Please can someone help me debug my application using GDB.
Thanks
Aquib -
You can prevent gdb from setting an automatic breakpoint in your program with this command:
@handle SIGTRAP nostop@
That way it should continue. This is not the solution to your problem though. The part that I wonder about is:
@warning: HEAP[KFFlashDL.exe]:
warning: Invalid Address specified to RtlFreeHeap( 003E0000, 0639FC88 )@Looks like you have a bug that frees the heap prematurely or something. I confess that I don't have the depth of understanding (yet) to be able to track that down.
-
Hi Kromacast,
The handle SIGTRAP nostop command worked. I can now run the program from gdb. However it defeats the purpose of my debugging. The application that I am working on occasionally crashes when running and I am trying to debug it.
The plan was to let the application run continuously via the gdb and get some information when the program crashes.
So I have passed one hurdle and need to figure out a way to pass the next.
If you have any ideas, it would surely help. Between the gdb did spill out information.
@C:\Devel\KFTools\KFFlashDL\debug>gdb KFFlashDL.exe
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-mingw32"...
(gdb) handle SIGTRAP nostop
SIGTRAP is used by the debugger.
Are you sure you want to change it? (y or n) y
Signal Stop Print Pass to program Description
SIGTRAP No Yes No Trace/breakpoint trap
(gdb) run
Starting program: C:\Devel\KFTools\KFFlashDL\debug/KFFlashDL.exe
[New thread 3904.0x11ac]
warning: Lowest section in C:\WINDOWS\system32\xpsp2res.dll is .rsrc at 00011000
[New thread 3904.0xd20]
[New thread 3904.0xf78]
[New thread 3904.0x2e8]
[New thread 3904.0x1334]
[New thread 3904.0x1634]
[New thread 3904.0xfd8]
[New thread 3904.0x13f8]
warning: HEAP[KFFlashDL.exe]:
warning: Invalid Address specified to RtlFreeHeap( 003E0000, 0639FC88 )Program received signal SIGTRAP, Trace/breakpoint trap.
warning: HEAP[KFFlashDL.exe]:
warning: Invalid Address specified to RtlFreeHeap( 003E0000, 0639FC88 )Program received signal SIGTRAP, Trace/breakpoint trap.
warning: HEAP[KFFlashDL.exe]:
warning: Invalid Address specified to RtlFreeHeap( 003E0000, 0639FC88 )Program received signal SIGTRAP, Trace/breakpoint trap.
[New thread 3904.0x1164]@Cheers
Aquib -
Aquib,
I am glad it worked for you.
The only additional idea that I can offer you is that you examine the call stack of your application when it crashes. Doing some research on Google I found "this":http://stackoverflow.com/questions/1621059/breakpoints-out-of-nowhere-when-debgging-with-gdb-inside-ntdll
The last post looks like it could be helpful to you.
-
Hi Kromacast,
Interesting post on stackoverflow, thanks for that. I have been doing a bit of Googling and trying to build on the lead you gave me. I stumbled upon a pdf on gdb by Richard Stallman. It is very intense and covers how to use gdb in detail. I am sure I will be able to find a solution to my problem in this pdf.
If you have any more ideas for me that would be great. I will update this post with my findings .
Cheers
Aquib -