User forums > Using Code::Blocks
Debugging Fun
Andrew:
A random question, but first...
A quick thank you and congratulations to the development team of this software. I haven't used a Windows IDE in a few years and I had code compiling very quickly. Ease of use is great and everything seems to be where it should.
I have a pretty general question about GDB (windows, 1rc2). I have a set of code from iLBCfreeware.org that I am trying to dissect and make sense out of. I'm watching variables in a certain function and they are behaving...strangely to say the least.
This is kind of a newbie question, so forgive my ignorance. When i push the step into button, it seems like the code is not executing sequentially. This may be due to compiler optimizations (although the only compiler option I have enabled is -g) or some translation going on between the processor and the code, but at this point I'm pretty much clueless. I'm watching variables and many times the correct value will end up in the variable for a line or two, but will then change to garbage after a few more lines have executed. The scary part for me is that the lines executing after the vars have changed depend on the value of the vars.
I guess my question is, does C::B set up a protected memory space for the program it's debugging, or is that set up with Windows, or are other processes altering the memory space? Furthermore, why wouldn't it sequentially? I realize this question may be code specific but I'm not sure I'm allowed to post the code without the permission of Global IP Sound (the developers).
With that in mind, if anyone has insight about how the compiler and debugger work, I could use that to my advantage. My apologies for my ignorance - I'm used to working on microcontrollers.
Thanks in advance
Andrew
TDragon:
If you're certain you don't have any optimization flags turned on, it may be a bug in the C::B/GDB interface. I would highly recommend upgrading to a Nightly Build, most of which are both more stable and more feature-rich than RC2. It would also be a good idea to ensure that you're running GDB 6.3.
Andrew:
Dragon:
Turns out that for some reason my compiler options didn't take. I changed them to (-g) only, saved, closed C::B, reopened, rebuilt, and the debugger seems to be working as expected.
Thanks for the help and sorry for the waste of a thread.
Andrew
Andrew:
Actually, to make this less of a waste, I have another question. I have values starting at an address in an array, but the variable where the values are being stored is a pointer. I can display the value of the first index of the pointer in the watch list by dereferencing it (for instance, i have a pointer called ptr, and i can watch the value in the watch list by having it watch *ptr). However, I want to view the rest of the variables in the array - I tried the syntax *ptr+1 and *(ptr+1) and both just add one to the value in the address. Any suggestions?
Andrew:
--- Quote from: Andrew on May 24, 2006, 11:51:36 pm ---However, I want to view the rest of the variables in the array - I tried the syntax *ptr+1 and *(ptr+1) and both just add one to the value in the address. Any suggestions?
--- End quote ---
Turns out I'm a moron, and the second one works. However this is an array of 10 values or more and there's got to be a better way than to add a watch for each index. Any pointers? heh...heh..
Andrew
Navigation
[0] Message Index
[#] Next page
Go to full version