diff --git a/gdb/gdbserver/lynx-low.c b/gdb/gdbserver/lynx-low.c index dba26d0..7a949c0 100644 --- a/gdb/gdbserver/lynx-low.c +++ b/gdb/gdbserver/lynx-low.c @@ -41,9 +41,9 @@ lynx_debug (char *string, ...) return; va_start (args, string); - fprintf (stdout, "DEBUG(lynx): "); - vfprintf (stdout, string, args); - fprintf (stdout, "\n"); + fprintf (stderr, "DEBUG(lynx): "); + vfprintf (stderr, string, args); + fprintf (stderr, "\n"); va_end (args); } @@ -310,16 +310,19 @@ lynx_ptrace (int request, ptid_t ptid, int addr, int data, int addr2) { int result; const int pid = lynx_ptrace_pid_from_ptid (ptid); + int saved_errno; if (debug_threads) - printf ("PTRACE (%s, pid=%d(pid=%d, tid=%d), addr=0x%x, data=0x%x, " - "addr2=0x%x)", - ptrace_request_to_str (request), pid, PIDGET (pid), TIDGET (pid), - addr, data, addr2); + fprintf (stderr, "PTRACE (%s, pid=%d(pid=%d, tid=%d), addr=0x%x, " + "data=0x%x, addr2=0x%x)", + ptrace_request_to_str (request), pid, PIDGET (pid), TIDGET (pid), + addr, data, addr2); result = ptrace (request, pid, addr, data, addr2); + saved_errno = errno; if (debug_threads) - printf (" -> %d (=0x%x)\n", result, result); + fprintf (stderr, " -> %d (=0x%x)\n", result, result); + errno = saved_errno; return result; } @@ -494,7 +497,7 @@ retry: else if (WIFEXITED (wstat)) { status->kind = TARGET_WAITKIND_EXITED; - status->value.integer = target_signal_from_host (WEXITSTATUS (wstat)); + status->value.integer = WEXITSTATUS (wstat); lynx_debug ("process exited with code: %d", status->value.integer); } else if (WIFSIGNALED (wstat)) @@ -518,7 +521,7 @@ retry: breakpoint events (Eg. new-thread events). Handle those other types of events, and resume the execution if necessary. */ if (status->kind == TARGET_WAITKIND_STOPPED - && status->value.integer == target_signal_from_host (SIGTRAP)) + && status->value.integer == TARGET_SIGNAL_TRAP) { const int realsig = lynx_ptrace (PTRACE_GETTRACESIG, new_ptid, 0, 0, 0); @@ -565,9 +568,15 @@ lynx_kill (int pid) { ptid_t ptid = lynx_ptid_build (pid, 0); struct target_waitstatus status; + struct process_info *process; + + process = find_process_pid (pid); + if (process == NULL) + return -1; lynx_ptrace (PTRACE_KILL, ptid, 0, 0, 0); lynx_wait (ptid, &status, 0); + the_target->mourn (process); return 0; } @@ -577,8 +586,14 @@ static int lynx_detach (int pid) { ptid_t ptid = lynx_ptid_build (pid, 0); + struct process_info *process; + + process = find_process_pid (pid); + if (process == NULL) + return -1; lynx_ptrace (PTRACE_DETACH, ptid, 0, 0, 0); + the_target->mourn (process); return 0; } @@ -675,7 +690,7 @@ lynx_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len) of int types, and they should also be aligned accordingly. */ int buf; const int xfer_size = sizeof (buf); - CORE_ADDR addr = memaddr & -(CORE_ADDR)xfer_size; + CORE_ADDR addr = memaddr & -(CORE_ADDR) xfer_size; ptid_t inferior_ptid = thread_to_gdb_id (current_inferior); while (addr < memaddr + len) @@ -691,7 +706,7 @@ lynx_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len) buf = lynx_ptrace (PTRACE_PEEKTEXT, inferior_ptid, addr, 0, 0); if (errno) return errno; - memcpy (myaddr + (addr - memaddr) + skip, (gdb_byte *)&buf + skip, + memcpy (myaddr + (addr - memaddr) + skip, (gdb_byte *) &buf + skip, xfer_size - skip - truncate); addr += xfer_size; } @@ -708,7 +723,7 @@ lynx_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len) of int types, and they should also be aligned accordingly. */ int buf; const int xfer_size = sizeof (buf); - CORE_ADDR addr = memaddr & -(CORE_ADDR)xfer_size; + CORE_ADDR addr = memaddr & -(CORE_ADDR) xfer_size; ptid_t inferior_ptid = thread_to_gdb_id (current_inferior); while (addr < memaddr + len)