Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force a breakpoint from .gdbinit?

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?

like image 729
0xC0000022L Avatar asked Feb 27 '15 16:02

0xC0000022L


People also ask

How do you set a breakpoint?

To set a breakpoint in source code: Click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.

What GDB command would you need to call in order to set a breakpoint on line 14?

break function-name will set a breakpoint at the start of the function.

How do I delete a specific breakpoint in GDB?

With the clear command you can delete breakpoints according to where they are in your program. With the delete command you can delete individual breakpoints, watchpoints, or catchpoints by specifying their breakpoint numbers.

Why is GDB not stopping at breakpoint?

GDB normally ignores breakpoints when it resumes execution, until at least one instruction has been executed. If it did not do this, you would be unable to proceed past a breakpoint without first disabling the breakpoint. This rule applies whether or not the breakpoint already existed when your program stopped.


1 Answers

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.

like image 197
Mark Plotnick Avatar answered Sep 30 '22 03:09

Mark Plotnick