Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: kateausten on April 25, 2010, 09:14:03 am
-
Hello,
I'm new to codeblocks and I'm learning how to debug.
I am facing some problems :
- how can I watch the fields of a structure that is an element of an array ?
I managed to show the elements of the array, but there are just memory addresses and I'd like to access these addresses to show its fields.
- is it possible to debug a gui application, and if it is then how ?
Thanks
-
Hello,
I'm new to codeblocks and I'm learning how to debug.
I am facing some problems :
- how can I watch the fields of a structure that is an element of an array ?
Have you tried to add: my_array[0] in the watches window?
If the variable is int**my_array[5], you can use *my_array[3]...
I managed to show the elements of the array, but there are just memory addresses and I'd like to access these addresses to show its fields.
- is it possible to debug a gui application, and if it is then how ?
A GUI app is the same (on win32 it's almost the same) as console app, so there is no difference in the way one debugs it.
-
I'm sorry I don't understand how it is the same.
Would you mind explaining to me how to debug a GUI then ?
I'm trying to debug a SDL application. The process terminates with status 3 when I click on a specific item.
Hence I added a breakpoint to the line saying "case SDL_MOUSEBUTTONUP:" (= if a mouse click has been detected).
When I click on debug/continue (to start the debugger), the application opens and I see it in the task bar but I can't see its contents (it is reduced and I can't restore it).
I'm using svn 6088.
-
Hm, a GUI app is the same thing as a non GUI app, both are C/C++ applications.
The difference is only in the used frameworks.
If your app crashes, the debugger should catch it and break on the line of the crash.
If this is not happening there is something wrong in your setup.
-
okay, I believe you... can you help me to figure out what's wrong in my setup then?
I must say that I have no problem debugging console applications though.
-
Does your app reaches the beginning of the main function (put a breakpoint on the first line)?
There is a chance that when run the executable couldn't find all needed dlls.
Also does it start with the run button?
-
When executed with the run button, the application opens normally.
As I said, it's only when I click on a specific button with my mouse that the application crashes.
If I click on debug/continue without any breakpoints, the application opens normally but I can't click on anything but 'stop debugger' (next line, for instance, is grey).
This is very weird, it seems I have to press on 'stop debugger' twice to make it stop.
I'm awaiting your help because I really don't know what's going on.
-
Stop button usage:
1. first click/press = pause debuggee (debugged executable)
2. second click/press = stop debugging session
The step/next buttons are active only when the debugger is in paused mode:
1. with the stop button
2. when a breakpoint is hit
-
hmm...
So how can I basically see what makes my program freeze/stop unexpectedly, and then fix it ?
(My program consists mainly of a while 1 loop).
-
Maybe you should start from here: http://www.whyprogramsfail.com/