11

When I set a breakpoint in my .gdbinit using:

b foobar

I get this:

Function "foobar" not defined.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]

Now the first line is understandable, because the function resides in a shared library. However, this defaults to no.

How do I force it to set the breakpoint in such a non-interactive scenario?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0xC0000022L
  • 20,597
  • 9
  • 86
  • 152
  • possible duplicate of [gdb: how to set breakpoints on future shared libraries with a --command flag](http://stackoverflow.com/questions/100444/gdb-how-to-set-breakpoints-on-future-shared-libraries-with-a-command-flag) – TooTone Jul 16 '15 at 11:06

1 Answers1

19

This can be done using set breakpoint pending on. From the Setting Breakpoints documentation:

gdb provides some additional commands for controlling what happens when the break command cannot resolve breakpoint address specification to an address:

set breakpoint pending auto - This is the default behavior. When gdb cannot find the breakpoint location, it queries you whether a pending breakpoint should be created.
set breakpoint pending on - This indicates that an unrecognized breakpoint location should automatically result in a pending breakpoint being created.
set breakpoint pending off - This indicates that pending breakpoints are not to be created. Any unrecognized breakpoint location results in an error.

Community
  • 1
  • 1
Mark Plotnick
  • 9,598
  • 1
  • 24
  • 40