Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: Andrew on May 24, 2006, 11:14:11 pm
-
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
-
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 (http://forums.codeblocks.org/index.php?board=20.0), 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.
-
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
-
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?
-
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?
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
-
Any pointers?
You 've been given already :)
I would highly recommend upgrading to a Nightly Build, most of which are both more stable and more feature-rich than RC2.
-
Well, I'm using the latest build available at the moment (24 may) + gdb 6.3 and C::B still has problems with the debugger. I have a global array int v[10], add it in watches and see only one element (0), even if I'm setting the array's start at 0 and count 10. Then, I set v[5] = 1 and see it in the list as element #2. Then v[2] = 4 and see it as element #3. :shock: In the end I have 0,1,4 instead of 0,0,4,0,0,1,0,0,0,0. Pretty wierd, huh? :D If I'm using the debugger directly, print v gives the right result.
-
Well, I'm using the latest build available at the moment (24 may) + gdb 6.3 and C::B still has problems with the debugger.
Hijacking a topic is not polite at all. The original poster's questions have nothing to do with what you said (which btw is already reported (https://developer.berlios.de/bugs/?func=detailbug&bug_id=6687&group_id=5358) in the bug tracker).
-
I know that hijacking is not polite and I didn't consider my post as hijacking. Maybe I haven't used the right words.
I was replying to two things:
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.
- the fact that arrays aren't functioning right in the debugger (sorry, didn't see the bug report). Therefore there isn't a way of watching elements of a pointer to an array.
- @TDragon: the fact that this problem exists even in the latest nightly build + gdb 6.3
-
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.
- the fact that arrays aren't functioning right in the debugger (sorry, didn't see the bug report). Therefore there isn't a way of watching elements of a pointer to an array.
Read the bug report. It's a completely different thing. You 're talking about watching a C array as returned by the debugger. OTOH, current C::B allows you to set the watch's format to "array" which behaves entirely different.
Anyway, enough hijacking from my part too. It's an open bug...
-
This is Andrew...I figured i might as well register.
Anyhow, thanks for the tips. I got the may 24 nightly build running and tried to add some watches. I realize that this may be a bug, but I thought I would make sure I wasn't just missing something simple.
A snapshot of my watches are attached. Upon right clicking and then clicking edit watches, I have the choice of setting the array size. However, this option seems to have no effect, and in fact sets the array size for all of my watches.
As I sad I realize this just may be a bug, and the work around isn't that bad. It's just that my optiplex gx620 with 2 gigs of ram doesn't like to hibernate/suspend correctly which leaves me shutting down my computer at the end of the day to prevent disasters. That, of course, means restarting C::B and re-instating my watches.
Once again, the work around is no big deal, and I realize that this may be a bit much to expect, but I wanted to make sure I wasn't missing anything.
Thanks again for your help.
Edit: the reason it won't hibernate correctly is because i get a message saying it doesn't have enough memory to complete the API...that's apparently too much for a brand new p4 and 2 gigs...gotta love windows...
[attachment deleted by admin]
-
That, of course, means restarting C::B and re-instating my watches.
If that's the problem, try right-clicking in the watches tree and select "Save watch file" ;)
-
Ah, sweet. I knew I was missing something. Thanks for your help, I really appreciate it. This really is a nice IDE, and I am thankful for the amount of effort that has gone into it.
Thanks again