From db691e4b554f2b81c950172238e6a9c8a455352f Mon Sep 17 00:00:00 2001 From: Stu Grossman Date: Mon, 2 Aug 1993 15:48:42 +0000 Subject: [PATCH] Mon Aug 2 08:42:50 1993 Stu Grossman (grossman at cygnus.com) * gdbserver/remote-inflow.c (create_inferior): Fix comments, and error msg. Setup seperate process group for child. * (write_inferior_memory): Sleep for 1 second and retry on ptrace failure. --- gdb/ChangeLog | 7 +++++++ gdb/gdbserver/remote-inflow.c | 32 +++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0dbf969ea91..9aad241cca6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +Mon Aug 2 08:42:50 1993 Stu Grossman (grossman at cygnus.com) + + * gdbserver/remote-inflow.c (create_inferior): Fix comments, and + error msg. Setup seperate process group for child. + * (write_inferior_memory): Sleep for 1 second and retry on ptrace + failure. + Sun Aug 1 22:58:18 1993 Stu Grossman (grossman at cygnus.com) * config/i386/i386lynx.mh (NATDEPFILES): Drop coredep (for now). diff --git a/gdb/gdbserver/remote-inflow.c b/gdb/gdbserver/remote-inflow.c index 931cf2c313b..44070c52158 100644 --- a/gdb/gdbserver/remote-inflow.c +++ b/gdb/gdbserver/remote-inflow.c @@ -44,8 +44,7 @@ char registers[REGISTER_BYTES]; #include /* Start an inferior process and returns its pid. - ALLARGS is a vector of program-name and args. - ENV is the environment vector to pass. */ + ALLARGS is a vector of program-name and args. */ int create_inferior (program, allargs) @@ -60,11 +59,21 @@ create_inferior (program, allargs) if (pid == 0) { + int pgrp; + + /* Switch child to it's own process group so that signals won't + directly affect gdbserver. */ + + pgrp = getpid(); + setpgrp(0, pgrp); + ioctl (0, TIOCSPGRP, &pgrp); + ptrace (PTRACE_TRACEME); execv (program, allargs); - fprintf (stderr, "Cannot exec %s: %s.\n", program, + fprintf (stderr, "GDBserver (process %d): Cannot exec %s: %s.\n", + getpid(), program, errno < sys_nerr ? sys_errlist[errno] : "unknown error"); fflush (stderr); _exit (0177); @@ -317,10 +326,19 @@ write_inferior_memory (memaddr, myaddr, len) for (i = 0; i < count; i++, addr += sizeof (int)) { - errno = 0; - ptrace (PTRACE_POKETEXT, inferior_pid, addr, buffer[i]); - if (errno) - return errno; + while (1) + { + errno = 0; + ptrace (PTRACE_POKETEXT, inferior_pid, addr, buffer[i]); + if (errno) + { + fprintf(stderr, "ptrace (PTRACE_POKETEXT): errno=%d, inferior_pid=0x%x, addr=0x%x, buffer[i] = 0x%x\n", errno, inferior_pid, addr, buffer[i]); + fprintf(stderr, "Sleeping for 1 second\n"); + sleep(1); + } + else + break; + } } return 0; -- 2.30.2