Re: [PATCH v2] Indicate batch mode failures by exiting with nonzero status

Tom Tromey
2018-08-31T14:33:00Z

>>>>> "Gary" == Gary Benson <gbenson@redhat.com> writes:

Gary> Yes please! Is it failing on *every* platform? I looked in gdb.log.xz
Gary> but there's no output from GDB, only the PASS/FAIL lines. So I don't
Gary> really know what to do, I can't reproduce :/

It fails for me too. I ran with -v and saw this in the .log:

RESULT = 11271 exp6 0 0
PASS: gdb.base/batch-exit-status.exp: -batch: [lindex $result 2] == 0
PASS: gdb.base/batch-exit-status.exp: -batch: $actual_status == $expect_status
Quitting /home/tromey/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/tromey/gdb/build/gdb/testsuite/../data-directory
doing kill, pid is 11271
Spawning /home/tromey/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/tromey/gdb/build/gdb/testsuite/../data-directory -batch -jslkflsdjlkfjlksdjf
RESULT = 11271 exp6 0 0
PASS: gdb.base/batch-exit-status.exp: -batch -jslkflsdjlkfjlksdjf: [lindex $result 2] == 0
FAIL: gdb.base/batch-exit-status.exp: -batch -jslkflsdjlkfjlksdjf: $actual_status == $expect_status
Quitting /home/tromey/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/tromey/gdb/build/gdb/testsuite/../data-directory
doing kill, pid is 11271

Note how the PID doesn't change.

I suspect that what is happening is that gdb_spawn_id isn't being reset,
and so we're hitting this code in default_gdb_spawn:

if [info exists gdb_spawn_id] {
return 0
}

Something has to unset this after each invocation.
Maybe calling clear_gdb_spawn_id, but I don't know if that's best or if
there should be something else.

Tom