GDB testing: timeout and buffer cleanup

Jimmy Guo guo@cup.hp.com
Thu Jun 24 23:00:00 GMT 1999


Here is an interesting test timeout related problem:

running gdb.base/nodebug.exp against the latest snapshot gdb on
hppa1.1-hp-hpux11.00:
  gdb spits out unexpected output and 'p/c array_index' timed out;
  then, nodebug.exp calls run_to_main;
  run_to_main calls delete_breakpoints;
  delete_breakpoints sends 'delete breakpoints' command to gdb;
  it sees '(gdb) ' from the unmatched output produced by the
    'p/c array_index' test point, and thinks there's no breakpoint
    to be deleted, and moves on;
  it sends 'info breakpoints' command to gdb;
  gdb, in the mean time, has issued 'Delete all breakpoints? (y or n) '
    and expects an answer, so it takes the 'info breakpoints' command
    has an invalid response, and insists again for an answer;
  delete_breakpoints sees this prompt, and answers 'y', and then it
    does the exp_continue;
  (with a larger timeout value, say 300, instead of 30) gdb is satisfied
    with the answer and deletes the breakpoint, and returned '(gdb) '
    (or with a smaller timeout value what I saw is delete_breakpoints has
    not yet responded with a 'y' before it timed out, and the remaining
    test points were all confused since gdb insists on a y or n answer);
  if with a larger timeout value here, delete_breakpoints sees '(gdb) '
    and issues perror "breakpoints not deleted" :(

While I could argue that delete_breakpoints is not robust enough since
it should try to resend the 'info breakpoints' command after answering
'y' to trigger the 'No breakpoints or watchpoints' response from gdb,
the root of the problem is with the handling of timeout for
'p/c array_index'.  Any timeout action should try to clean the internal
expect buffer (and its associated kernel buffer), so that unmatched
outputs from the failed test point will not interfere with the following
test point.  The O'Reilly 'Exploring Expect' book p. 150 contains a way
to clean up these two buffers.  There needs to be a proc which
implements this in gdb.exp so that it can be called by all timeout {...}
actions in all GDB tests.

I haven't yet implemented this myself, and I'd like to know if someone
more comfortable with expect / TCL programming can try it out.  And
comments on this idea are welcome.

- Jimmy Guo, guo@cup.hp.com




More information about the Gdb mailing list