diff options
author | Stu Grossman <grossman@cygnus> | 1993-08-02 15:48:42 +0000 |
---|---|---|
committer | Stu Grossman <grossman@cygnus> | 1993-08-02 15:48:42 +0000 |
commit | db691e4b554f2b81c950172238e6a9c8a455352f (patch) | |
tree | 6171a7b9ee135a21d1fa54c6d11c484d43727c49 /gdb/gdbserver | |
parent | 884914bf03af1a838162648dff5d87e9e099501f (diff) | |
download | gdb-db691e4b554f2b81c950172238e6a9c8a455352f.zip gdb-db691e4b554f2b81c950172238e6a9c8a455352f.tar.gz gdb-db691e4b554f2b81c950172238e6a9c8a455352f.tar.bz2 |
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.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r-- | gdb/gdbserver/remote-inflow.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/gdb/gdbserver/remote-inflow.c b/gdb/gdbserver/remote-inflow.c index 931cf2c..44070c5 100644 --- a/gdb/gdbserver/remote-inflow.c +++ b/gdb/gdbserver/remote-inflow.c @@ -44,8 +44,7 @@ char registers[REGISTER_BYTES]; #include <sys/ptrace.h> /* 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; |