2008-06-28 Pedro Alves * server.c (attach_inferior): Add vattach parameter. If attaching due to a vAttach, don't hide a SIGSTOP, and, if attaching finishes with a SIGTRAP, pretend it was a SIGSTOP. (handle_v_attach): Pass 1 as vattach parameter to attach_inferior. Don't report dll changes. (main): Pass 0 as vattach parameter to attach_inferior. --- gdb/gdbserver/server.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) Index: src/gdb/gdbserver/server.c =================================================================== --- src.orig/gdb/gdbserver/server.c +++ src/gdb/gdbserver/server.c @@ -160,7 +160,7 @@ start_inferior (char **argv, char *statu } static int -attach_inferior (int pid, char *statusptr, int *sigptr) +attach_inferior (int pid, char *statusptr, int *sigptr, int vattach) { /* myattach should return -1 if attaching is unsupported, 0 if it succeeded, and call error() otherwise. */ @@ -180,11 +180,17 @@ attach_inferior (int pid, char *statuspt *sigptr = mywait (statusptr, 0); - /* GDB knows to ignore the first SIGSTOP after attaching to a running - process using the "attach" command, but this is different; it's - just using "target remote". Pretend it's just starting up. */ - if (*statusptr == 'T' && *sigptr == TARGET_SIGNAL_STOP) + /* GDB knows to ignore the first SIGSTOP after attaching to a + running process using the "attach" command, but if we're + attaching due to --attach this is different; it's just using + "target remote". Pretend it's just starting up. */ + if (!vattach && *statusptr == 'T' && *sigptr == TARGET_SIGNAL_STOP) *sigptr = TARGET_SIGNAL_TRAP; + /* Similarly, on some targets, attaching finishes with a SIGTRAP + (e.g., on Windows it's called the initial breakpoint). Pretend + it was a SIGSTOP, so GDB hushes it. */ + else if (vattach && *statusptr == 'T' && *sigptr == TARGET_SIGNAL_TRAP) + *sigptr = TARGET_SIGNAL_STOP; return 0; } @@ -1011,8 +1017,13 @@ handle_v_attach (char *own_buf, char *st int pid; pid = strtol (own_buf + 8, NULL, 16); - if (pid != 0 && attach_inferior (pid, status, signal) == 0) + if (pid != 0 && attach_inferior (pid, status, signal, 1) == 0) { + /* Don't report shared library events after attaching, even if + some libraries are preloaded. GDB will always poll the + library list. Avoids the "stopped by shared library event" + notice on the GDB side. */ + dlls_changed = 0; prepare_resume_reply (own_buf, *status, *signal); return 1; } @@ -1336,7 +1347,7 @@ main (int argc, char *argv[]) } else if (pid != 0) { - if (attach_inferior (pid, &status, &signal) == -1) + if (attach_inferior (pid, &status, &signal, 0) == -1) error ("Attaching not supported on this target"); /* Otherwise succeeded. */