aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2004-03-05 03:43:19 +0000
committerDaniel Jacobowitz <drow@false.org>2004-03-05 03:43:19 +0000
commitc3e735a6a3d7b849b44f102a0c3e2722d49666b7 (patch)
tree624482b0563448cde74e4eb0b15a82dcfd18d4ba /gdb/gdbserver
parentd81510055c95d786c5ce789b1e96f9919f91b05a (diff)
downloadgdb-c3e735a6a3d7b849b44f102a0c3e2722d49666b7.zip
gdb-c3e735a6a3d7b849b44f102a0c3e2722d49666b7.tar.gz
gdb-c3e735a6a3d7b849b44f102a0c3e2722d49666b7.tar.bz2
* linux-low.c (linux_read_memory): Change return type to
int. Check for and return error from ptrace(). * target.c (read_inferior_memory): Change return type to int. Pass back return status from the_target->read_memory(). * target.h (struct target_ops): Adapt *read_memory() prototype. Update comment. (read_inferior_memory): Adapt prototype. * server.c (main): Return an error packet if read_inferior_memory() returns an error.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r--gdb/gdbserver/ChangeLog12
-rw-r--r--gdb/gdbserver/linux-low.c7
-rw-r--r--gdb/gdbserver/server.c6
-rw-r--r--gdb/gdbserver/target.c8
-rw-r--r--gdb/gdbserver/target.h8
5 files changed, 32 insertions, 9 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 31734c2..19227d1 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,15 @@
+2004-03-04 Nathan J. Williams <nathanw@wasabisystems.com>
+
+ * linux-low.c (linux_read_memory): Change return type to
+ int. Check for and return error from ptrace().
+ * target.c (read_inferior_memory): Change return type to int. Pass
+ back return status from the_target->read_memory().
+ * target.h (struct target_ops): Adapt *read_memory() prototype.
+ Update comment.
+ (read_inferior_memory): Adapt prototype.
+ * server.c (main): Return an error packet if
+ read_inferior_memory() returns an error.
+
2004-03-04 Daniel Jacobowitz <drow@mvista.com>
* Makefile.in (distclean): Remove config.h, stamp-h, and config.log.
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index ea15516..69b35c1 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -1281,7 +1281,7 @@ linux_store_registers (int regno)
/* Copy LEN bytes from inferior's memory starting at MEMADDR
to debugger memory starting at MYADDR. */
-static void
+static int
linux_read_memory (CORE_ADDR memaddr, char *myaddr, int len)
{
register int i;
@@ -1298,11 +1298,16 @@ linux_read_memory (CORE_ADDR memaddr, char *myaddr, int len)
/* Read all the longwords */
for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
{
+ errno = 0;
buffer[i] = ptrace (PTRACE_PEEKTEXT, inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
+ if (errno)
+ return errno;
}
/* Copy appropriate bytes out of the buffer. */
memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)), len);
+
+ return 0;
}
/* Copy LEN bytes of data from debugger memory at MYADDR
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index fb667ef..cc8923e 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -462,8 +462,10 @@ main (int argc, char *argv[])
break;
case 'm':
decode_m_packet (&own_buf[1], &mem_addr, &len);
- read_inferior_memory (mem_addr, mem_buf, len);
- convert_int_to_ascii (mem_buf, own_buf, len);
+ if (read_inferior_memory (mem_addr, mem_buf, len) == 0)
+ convert_int_to_ascii (mem_buf, own_buf, len);
+ else
+ write_enn (own_buf);
break;
case 'M':
decode_M_packet (&own_buf[1], &mem_addr, &len, mem_buf);
diff --git a/gdb/gdbserver/target.c b/gdb/gdbserver/target.c
index 1c2860a..2c60e17 100644
--- a/gdb/gdbserver/target.c
+++ b/gdb/gdbserver/target.c
@@ -1,5 +1,5 @@
/* Target operations for the remote server for GDB.
- Copyright 2002
+ Copyright 2002, 2004
Free Software Foundation, Inc.
Contributed by MontaVista Software.
@@ -57,11 +57,13 @@ set_desired_inferior (int use_general)
current_inferior = found;
}
-void
+int
read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
{
- (*the_target->read_memory) (memaddr, myaddr, len);
+ int res;
+ res = (*the_target->read_memory) (memaddr, myaddr, len);
check_mem_read (memaddr, myaddr, len);
+ return res;
}
int
diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h
index 88ff2d4..770ffcb 100644
--- a/gdb/gdbserver/target.h
+++ b/gdb/gdbserver/target.h
@@ -102,9 +102,11 @@ struct target_ops
/* Read memory from the inferior process. This should generally be
called through read_inferior_memory, which handles breakpoint shadowing.
- Read LEN bytes at MEMADDR into a buffer at MYADDR. */
+ Read LEN bytes at MEMADDR into a buffer at MYADDR.
+
+ Returns 0 on success and errno on failure. */
- void (*read_memory) (CORE_ADDR memaddr, char *myaddr, int len);
+ int (*read_memory) (CORE_ADDR memaddr, char *myaddr, int len);
/* Write memory to the inferior process. This should generally be
called through write_inferior_memory, which handles breakpoint shadowing.
@@ -160,7 +162,7 @@ void set_target_ops (struct target_ops *);
unsigned char mywait (char *statusp, int connected_wait);
-void read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len);
+int read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len);
int write_inferior_memory (CORE_ADDR memaddr, const char *myaddr, int len);