Author Topic: Break points  (Read 5964 times)

Offline johne53

  • Regular
  • ***
  • Posts: 253
Break points
« on: April 27, 2007, 05:18:42 pm »
Hi - I just installed C::B under OpenSuse having already used the Windows version for a couple of days. OpenSuse is what I'll mostly be using and I've set GCC as the default compiler. I wrote a trivial "Hello World" type app in C, like so:-

Code
#include <stdio.h>

int main()
{
    printf( "Hello World" );

    return 0;
}

I compiled a Debug build and placed a break point at the printf() line and pressed F8 (which, I'm assuming, is supposed to run the program in the debugger). However, it didn't stop at the break point. What am I doing wrong?

Offline johne53

  • Regular
  • ***
  • Posts: 253
Re: Break points
« Reply #1 on: April 27, 2007, 09:53:55 pm »
Still can't seem to make break points work (presumably they do work, don't they??) Can anyone tell me what I've done wrong? I'm using the standard GDB debugger.

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: Break points
« Reply #2 on: April 28, 2007, 01:41:12 am »
Can anyone tell me what I've done wrong? I'm using the standard GDB debugger.
Is "-g" in the build options? Are you using GDB 6.3 or later?
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Offline johne53

  • Regular
  • ***
  • Posts: 253
Re: Break points
« Reply #3 on: April 28, 2007, 07:39:49 am »
Thanks. The -g option is set but I must admit, I'm rather confused about it. I would have assumed that I should be able to set it for a Debug build but not for a Release build. However, unless I'm missing something, I can't find a way of producing different settings for each target. If I de-select -g whilst my 'Release' target is selected, it also gets de-selected for the 'Debug' target...  :cry:

2) I'm not sure how to find out what version of GDB is installed. I've inspected the properties for the executable but all I can tell is that it's dated 27th November 2006.

qed

  • Guest
Re: Break points
« Reply #4 on: April 28, 2007, 12:00:03 pm »
as the 'great'  :shock: michael jackson once sang.. 'you are not alone'..  :P this has been driving me nuts for weeks.. exactly the same thing.. i have currently 6.4 version of gdb running under cygwin although i've tried a couple of others with the same result i never get a symbol file 'use file option'.. duuuhh.. also i've noticed that if i reload the file at a later date the breakpoints haven't been saved.. strange. if anyone can solve this you get 8.5 billion karma air miles .. heh

oh type gdb --version

Offline johne53

  • Regular
  • ***
  • Posts: 253
Re: Break points
« Reply #5 on: April 28, 2007, 02:21:56 pm »
type gdb --version
Thanks qed - in that case, I'm running GDB version 6.5

also i've noticed that if i reload the file at a later date the breakpoints haven't been saved.
Ah - a kindred spirit. I get the same problem.... I save the project then reload it sometime later and all my break points are gone...!

Please is there anyone who can confirm that this should in fact be working...?

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: Break points
« Reply #6 on: April 28, 2007, 03:37:46 pm »
If I de-select -g whilst my 'Release' target is selected, it also gets de-selected for the 'Debug' target...
Changing your targets' build options has nothing to do with which target is selected to be built, or selected in the drop-down list on the toolbar, and everything to do with which target is selected in the tree on the left in the actual build options dialog.
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Offline johne53

  • Regular
  • ***
  • Posts: 253
Re: Break points
« Reply #7 on: April 28, 2007, 06:39:51 pm »
Thanks TDragon - in that case, -g is selected for my Debug build and -s is selected for my Release build (with no other options selected). Does this make it any clearer why the break points don't seem to be working? Or could it maybe be a problem with optimizations?

[Edit...] Ah - a breakthrough! If I change the code to this:-

Code
#include <stdio.h>

int main()
{
    printf("Hello World");
    printf("Hello Earth");
    printf("Hello Venus");

    return (0);
}

I can place a break point on any line after the first printf() line and it will work!! The only problem is that I can't continue execution by using CTRL+F7. Strangely though, if I select Debug->Continue (which is theoretically the same thing) that does work ?!? It's a step forward but I'm still baffled.

Oh, and I still lose the breakpoints if I save and reload the project (or workspace).
« Last Edit: April 28, 2007, 07:40:34 pm by johne53 »

qed

  • Guest
Re: Break points
« Reply #8 on: April 29, 2007, 11:56:15 pm »
heh amazing yeah hello venus hello earth is the key 8).. seriously though mine does exactly the same thing with the two extra printf's.. i.e. i don't get the no symbol file please use file option.. i don't get any arrows though so i know where the trace is.. continue exhibits the same behaviour and i get no console output.. but exit code zero..
for the record and just to see if there is any thread in this i'm running gcc version 3.4.4 gdb 6.5.5 both under cygwin and xp pro sp2 on a centrino laptop.. also have visual studio 6.0 ..full directx 9 dev kit ..any similarities?? areas of common  :?interest??

qed

  • Guest
Re: Break points
« Reply #9 on: April 30, 2007, 10:06:15 pm »
hi there.. i was thinking it might be a good idea that your gdb environment works properly at all.. under the cli run your 'hello world' program that you compiled with the -g option.. mine is called test.. do..

gdb test                  .. runs test executable
break 5                        .. set breakpoint at line 5
run                              .. should run to line 5
continue                       .. run until end.. does printf's
quit                             .. exit gdb

if all that works it points the finger at codeblocks .. not gcc/gdb imo
hth
keep the faith.. we'' figure it out in the end!


Offline johne53

  • Regular
  • ***
  • Posts: 253
Re: Break points
« Reply #10 on: May 01, 2007, 07:14:56 am »
Also, does anyone have any thoughts about why the break points are getting lost if I re-open an old project? I've tried saving them with both the project and the workspace - but either way, they still get lost...  :(

It's still 'early days' for me with C::B - but I can imagine that this will become extremely irritating after a while...