Author Topic: Setting breakpoint while executing program  (Read 4702 times)

Offline geronet

  • Multiple posting newcomer
  • *
  • Posts: 14
Setting breakpoint while executing program
« on: July 31, 2006, 05:41:14 pm »
Hello, perhaps it's not a fault of CodeBlocks, but if it try to add a breakpoint while the debugger and the program is running, it doesn't set it.
I'm using C:B nightly build from 29/06, gcc as the compiler and gdb. If i add a breakpoint before the debugger starts or while the program is halted, it works like it should. (build target is debug, and "produce debugging symbols is also set)

The problem is, if i make breakpoints, the program stops there every time, but i need to run it some time and then set a breakpoint.. is this possible?

Thanks, Stefan
« Last Edit: July 31, 2006, 05:44:47 pm by geronet »

Offline klight

  • Multiple posting newcomer
  • *
  • Posts: 24
Re: Setting breakpoint while executing program
« Reply #1 on: July 31, 2006, 06:10:50 pm »
I've been annoyed by this too but have come up with a few work-arounds that actually have worked out better than planned.  (Sorry if this is off topic from the original thread)

1. Conditional breakpoints on hit count. 

2. Coding a conditional line of code that a breakpoint can be set at in the block of code you are trying to debug.  If you can afford the additional code, this works well as addtional code to enable the breakpoint from other events can be coded.  This also seems to avoid side effects from "real" conditional breakpoints such as a change in execution speed.

3. If your project is a GUI, create a "Breakpoint" button.  Create a basic event handler on the button click and then put a breakpoint at the button the event handler.   When the code is stopped by the manual breakpoint, set your desired breakpoint in the main application.  You could hard-code an assembly breakpoint instruction in the button hander as well.

darus

  • Guest
Re: Setting breakpoint while executing program
« Reply #2 on: October 12, 2006, 08:37:55 am »
Hi!

I miss this feature too  :(
A special button like "Break execution" as in Visual C++ would be nice too. Is it possible?

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Setting breakpoint while executing program
« Reply #3 on: October 12, 2006, 08:56:25 am »
Quote
Is it possible?

Not as far as I know, not under windows with gdb.
Be patient!
This bug will be fixed soon...

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Setting breakpoint while executing program
« Reply #4 on: October 12, 2006, 09:20:34 am »
Presumably, this works by sending Ctrl-C to gdb.

(Edit: actually it is SIGINT which gdb catches. So it may be possible that it indeed does not work under Windows...)
« Last Edit: October 12, 2006, 09:23:03 am by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Setting breakpoint while executing program
« Reply #5 on: October 12, 2006, 10:11:54 am »
Presumably, this works by sending Ctrl-C to gdb.

Have you tried this under windows? It doesn't work...
Be patient!
This bug will be fixed soon...