Thursday, February 25, 2010

Debugging Qt application on maemo

When i started development on qt Maemo platform, it was quite difficult to debug Qt application because Qt creator is not supporting debugging inside scratch box and at that time i was unaware of using gdb and my only hope was to use qDebug() to print function name at start of each function.

But now I know how to use gdb to debug qt application inside scratchbox environment. To be able to debug application on scratchbox you need to install maemo debug script.

run "fakeroot apt-get install maemo-debug-scripts" inside scratchbox. This will install necessary tool required to debug maemo application.

Now on command prompt type "native-gdb", normal gdb command will not work, it will crash immediately. you need to use native-gdb command.

native-gdb command will bring gdb prompt. If gdb prompt comes then setup is ready to debug application.

Now you can use native-gdb to debug application. To start debugging run "native-gbd applicationName" command. applicaitonName is name of binary file that you want to debug.

To put break point you can use "break" gdb commnad.

"break filename:line number" will put break point in mentioned file at mentioned line number.

"break className::functionName()" will put break point at mentioned function.

To run application, type "run" command, now when instruction at breakpoint will execute gdb will stop at that break point and will ask you for command.

to run next line number in code type "next" command.

to run next instruction in code type "step" commnad.

to go to end of current function type "finish" command.

to continue execution until next breakpoint type "continue" command.

to know call stack type "where" command.

to list current function type "list" or "list numberOfLine" commanad.

to run previous command you can just press enter key and it will run previous command.

If you want to exit gdb type quit or q, to bring gdb prompt you can press ctrl + c.

Hope this will help you to start debugging with gdb on maemo platform.

No comments:

Post a Comment