Author Topic: suggest to use "start" command to start GDB  (Read 5818 times)

Offline Anbang24

  • Multiple posting newcomer
  • *
  • Posts: 14
suggest to use "start" command to start GDB
« on: February 09, 2023, 04:09:35 am »
In current version of C::B, when we start GDB, it executes "run" command inside GDB. If there is any breakpoint in the source, the program will run and stop at the first breakpoint. However, if there is no breakpoint in the source, then the program will run through.

As I know, many programming beginners hope the program automatically stops at the first executable statement in main(), this will be more convenient for them. So, I suggest to execute "start" command inside GDB when we start a debugging.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: suggest to use "start" command to start GDB
« Reply #1 on: February 10, 2023, 12:39:58 pm »
For some reference:

GDB Command Reference - start command https://visualgdb.com/gdbreference/commands/start

It means:

Quote
start command

Sets a temporary breakpoint on main() and starts executing a program under GDB.


For C/C++ programs the start command is equivalent to the following command sequence:

tbreak main
run
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1635
Re: suggest to use "start" command to start GDB
« Reply #2 on: February 10, 2023, 02:06:28 pm »
Probably this can be added as a new debugger setting, defaulting to current behaviour.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: suggest to use "start" command to start GDB
« Reply #3 on: April 17, 2023, 10:49:19 am »
Probably this can be added as a new debugger setting, defaulting to current behaviour.

+1.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1635
Re: suggest to use "start" command to start GDB
« Reply #4 on: April 18, 2023, 08:08:16 pm »
void GDB_driver::Start(bool breakOnEntry) already executes "start" if the parameter is true.

Start() is called by Debug() from four places:
  - From RunToCursor() using false
  - From AttachToProcess(), also false
  - From OnStart(), also false
  - From OnStep() using true

I think OnStart() is where we must make it configurable, but I have no time currently to do it.