1

When I run gdb, there seems to be a notion of a main file, as if I set a breakpoint with just a number, it will get set for the source file that contains the main function.

How can I reconfigure gdb to set this to the file containing a function named my_main? (My actual main is provided by my library, in 99.9% of cases I want to focus on the the wrapped and prefixed main that the actual, library-provided, main calls).

PSkocik
  • 55,062
  • 6
  • 86
  • 132

2 Answers2

1

GDB isn't doing what you say. When you say break LINE it sets a breakpoint in the "current" file, as per the docs:

The current source file is the last file whose source text was printed.

So perhaps what you want is to always set a breakpoint in my_main. If it helps you can make GDB let you up-arrow or Ctrl-R search backward through commands entered in previous sessions by following the instructions here: How can I make gdb save the command history?

Community
  • 1
  • 1
John Zwinck
  • 223,042
  • 33
  • 293
  • 407
1

You can set a breakpoint using directly function name: break my_main or you can specify filename and line: break file.c:100

MirkoBanchi
  • 2,125
  • 5
  • 34
  • 52