I noticed some unexpected behavior with a batch command file which calls a target function and encounters a breakpoint. The batch command file is abandoned, rather than continuing to be executed following the breakpoint. $ cat t.c #include <stdio.h> void foo (int a) { printf ("a = %d\n", a); } void main (void) { foo (123); } $cat gdb.cmd b main b foo run call foo(234) p a c $ gdb -x gdb.cmd t ... Breakpoint 1 at 0x400551: file t.c, line 7. Breakpoint 2 at 0x400537: file t.c, line 3. Breakpoint 1, main () at t.c:7 7 foo (123); Breakpoint 2, foo (a=234) at t.c:3 3 printf ("a = %d\n", a); gdb.cmd:4: Error in sourced command file: The program being debugged stopped while in a function called from GDB. Evaluation of the expression containing the function (foo) will be abandoned. When the function is done executing, GDB will silently stop. (gdb) The breakpoint during the target function call apparently causes gdb to decide that there is an error in the batch file which it abandons. Subsequent commands in the batch file are ignored. It doesn't seem to matter whether the target generates an interrupt from a breakpoint or a SEGV. If run with --batch --command instead of -x, gdb terminates rather than generating the CLI prompt, but does not execute the remaining commands. Being able to include commands in a batch command file which are executed after a brakepoint is hit is useful in a couple cases. The first is to create a script which demonstrates a gdb bug. Second is for automated testing.
Not sure if this is a dup of PR8487.