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

Qt-interest Archive, July 2007
how to debug inside QT


Message 1 in thread

Dear Experts,

i have some unresolved issue with gdb debugger. From unknown reasons for
some QT functions it does not want to step into this function, when is a
part of QT library. This happens for
some 'set of fuctions' (otherwise i can not explain why you can step into
some functions and not some others, or not deeper into qt). funny thing
about it is that i have compiled
qt with the same flags (basically --enable-debug=full) on MSVC and there if
i step into qt from my software it works perfectly up to lowest possible
software level.

is there some issue i should know to be able to use gdb in the same way? why
it acts like this?


typical example:

when tracing this function:     return property (name.toAscii());
i can easily trace into the function 'property'

however tracing this:     return setProperty (name.toAscii(), attr);

leads to either skip of the function as in case of step_over, or it simply
behaves in kdevelop like it stepped inside assembly or code where source is
not available

thanks
d.

Message 2 in thread

> however tracing this:     return setProperty (name.toAscii(), attr);
> 
> leads to either skip of the function as in case of step_over, or it 
> simply behaves in kdevelop like it stepped inside assembly or code where 
> source is not available

Just to check a basic issue: Are you sure you disabled all optimisations 
("-O0", IIRC)?

Martin

-- 
 [ signature omitted ] 

Message 3 in thread

Martin Gebert wrote:
>> however tracing this:     return setProperty (name.toAscii(), attr);
>>
>> leads to either skip of the function as in case of step_over, or it
>> simply behaves in kdevelop like it stepped inside assembly or code
>> where source is not available
> 
> Just to check a basic issue: Are you sure you disabled all optimisations
> ("-O0", IIRC)?

You may also want to disable code inlining (-fno-inline) .

To explain: gdb can debug optimised code. That means that it can keep
track of the program's execution point even where code has been
reordered, rearranged, or wholly optimised out. This can, however,
result in extremely confusing behaviour when you compare what happens as
you step through in gdb to what's written in your source code. It'll do
things like switch back and forth between two lines (because the
compiler has cleverly stacked the pipeline?) or execute something
outside a loop that you wrote inside the loop.

This ability is extremely useful. However, for your sanity's sake, when
doing simple debugging it's often best to disable optimisation so that
it's easier to follow what's going on.

The other thing to check is that you really built Qt with debugging on.
Use Qt's configure script to do a debug build if possible, rather than
trying to play with the compiler flags directly. If you must specify
flags directly, do so through Qt's configure if possible rather than
through the environment. As Qt compiles, have a look at the compile
output to verify that it's really using appropriate debug flags. Look
for -O0 or a more reasonable -O1, -g or -g3, and maybe -fno-inline .

On an only remotely related side note, anybody know what the status of
Qt 4.3 Open Source is with Visual C++ Express Edition?

--
 [ signature omitted ] 

Message 4 in thread

okay, thanks to all. i'll try to recompile the qt libraries with these
flags.