How to tell gdb to exit?

Grant Edwards
Thu May 6 15:50:00 GMT 2004

I'm trying to figure out how to run gdb from a shell script,
and everything works, except I can't get gdb to exit.  What I
want to do is:

 1) set target to /dev/ttyS0
 2) load an elf file
 3) start it (continue)
 4) exit gdb

Steps 1-3 work great, but at step 4) gdb won't accept a new
command in human-interface mode, so this doesn't work:

  h8300-elf-gdb <<EOF
  set arch h8300h
  target remote /dev/ttyS0
  load test.elf

I tried "detach" instead of "cont" since the info file says
that it continues exection, but it doesn't actual seem to do
that for remote targets.

In MI mode, I can't figure out what the "quit" command is, and
it just hangs on EOF -- so this doesn't work either:

  h8300-elf-gdb -interpreter=mi <<EOF
  10-target-select async /dev/ttyS0
  20-target-download test.elf

I'm sure I'm missing an obvious clue, could somebody point it
out to me?
Grant Edwards

More information about the Gdb mailing list