This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Batch command file - bug or feature?


I noticed some unexpected behavior with a batch command
file which calls a target function.

$ 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.

I think that this is a bug and that execution should continue
with the next command in the batch file.  Does anyone think gdb
is working as intended?

--
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]