34

I use gdb to debug my cpp code. I set breakpoints in this way:

(gdb) break ParseDriver.cc:60
No source file named ParseDriver.cc.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (ParseDriver.cc:60) pending.

To simplify setting breakpoints, I wrote a simple gdb script(named breakpoints.gdb), it simply contains only one line:

break ParseDriver.cc:60

I source this script in gdb terminal, but it failed.

(gdb) source ~/breakpoints.gdb
No source file named ParseDriver.cc.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]

It seems that we need to answer Y in script in order to set breakpoint.

So, how can I answer Y in gdb script ? Thank you in advance.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
hellojinjie
  • 1,868
  • 3
  • 17
  • 23
  • 1
    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

60
(gdb) set breakpoint pending on

This will make gdb skip asking for confirmation, quote from the docs:

This indicates that an unrecognized breakpoint location should automatically result in a pending breakpoint being created.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
matt
  • 5,364
  • 1
  • 25
  • 25