infrun.c:handle_inferior_event: Don't fall through in TARGET_WAITKIND_LOADED handling.
authorPedro Alves <palves@redhat.com>
Thu, 14 Nov 2013 19:43:25 +0000 (19:43 +0000)
committerPedro Alves <palves@redhat.com>
Thu, 14 Nov 2013 19:43:25 +0000 (19:43 +0000)
commit5c09a2c53c3d3259392ada37303af8033ab91c7e
tree10ebfbed836e7b7e2c617249b7dd272c88d763e3
parent94e49e160d0c3f0b1b838f9963b1da5d3cfc795b
infrun.c:handle_inferior_event: Don't fall through in TARGET_WAITKIND_LOADED handling.

Of all the TARGET_WAITKIND_XXXs event kinds other than
TARGET_WAITKIND_STOPPED, TARGET_WAITKIND_LOADED is the only kind that
doesn't end in a return, instead falling through to all the
signal/breakpoint/stepping handling code.  But it only falls through
in the STOP_QUIETLY_NO_SIGSTOP and STOP_QUIETLY_REMOTE cases, which
means the

  /* This is originated from start_remote(), start_inferior() and
     shared libraries hook functions.  */
  if (stop_soon == STOP_QUIETLY || stop_soon == STOP_QUIETLY_REMOTE)
    {
      if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, "infrun: quietly stopped\n");
      stop_stepping (ecs);
      return;
    }

bit is eventually reached.  All tests before that is reached will
always fail.  It's simpler to inline the stop_soon checks close to the
TARGET_WAITKIND_LOADED code, which allows removing the fall through.

Tested on x86_64 Fedora 17, but that doesn't exercise this
TARGET_WAITKIND_LOADED.

Also ran gdb.base/solib-disc.exp on Cygwin/gdbserver, which exercises
reconnection while the inferior is stopped at an solib event, but then
again, gdbserver always replies a regular trap on initial connection,
instead of the last event the program had seen:

 Sending packet: $?#3f...Packet received: T0505:4ca72800;04:f8a62800;08:62fcc877;thread:d28;
 Sending packet: $Hc-1#09...Packet received: E01
 Sending packet: $qAttached#8f...Packet received: 0
 Packet qAttached (query-attached) is supported
 infrun: clear_proceed_status_thread (Thread 3368)
 Sending packet: $qOffsets#4b...Packet received:
 infrun: wait_for_inferior ()
 infrun: target_wait (-1, status) =
 infrun:   42000 [Thread 3368],
 infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
 infrun: infwait_normal_state
 infrun: TARGET_WAITKIND_STOPPED
 infrun: stop_pc = 0x77c8fc62
 infrun: quietly stopped
 infrun: stop_stepping

So the only way to exercise this would be to hack gdbserver.  I didn't
go that far though.  I'm reasonably confident this is correct.

gdb/
2013-11-14  Pedro Alves  <palves@redhat.com>

* infrun.c (handle_inferior_event) <TARGET_WAITKIND_LOADED>:
Handle STOP_QUIETLY_NO_SIGSTOP and STOP_QUIETLY_REMOTE here.
Assert we never fall through out of the TARGET_WAITKIND_LOADED
case.
gdb/ChangeLog
gdb/infrun.c