aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2012-03-23 20:26:14 +0000
committerPedro Alves <palves@redhat.com>2012-03-23 20:26:14 +0000
commit485f1ee4f6b7f8ae37640b65966ad82eeced8f9a (patch)
treedb04dcc3f64533d3a6baf77351f08c328955f3cd /gdb/gdbserver
parentf24fcb9dad8d6883b0f2dfe302c87557aae3bd1e (diff)
downloadgdb-485f1ee4f6b7f8ae37640b65966ad82eeced8f9a.zip
gdb-485f1ee4f6b7f8ae37640b65966ad82eeced8f9a.tar.gz
gdb-485f1ee4f6b7f8ae37640b65966ad82eeced8f9a.tar.bz2
2012-03-23 Pedro Alves <palves@redhat.com>
* linux-low.c (read_one_ptr): Read the inferior's pointer through a variable whose type size is the same as the inferior's pointer size.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r--gdb/gdbserver/ChangeLog6
-rw-r--r--gdb/gdbserver/linux-low.c26
2 files changed, 30 insertions, 2 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 155dbb1..d141bac 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,9 @@
+2012-03-23 Pedro Alves <palves@redhat.com>
+
+ * linux-low.c (read_one_ptr): Read the inferior's pointer through
+ a variable whose type size is the same as the inferior's pointer
+ size.
+
2012-03-21 Thomas Schwinge <thomas@codesourcery.com>
* linux-arm-low.c (arm_stopped_by_watchpoint): Use siginfo_t instead of
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 4734f15..2dc903d 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -5428,8 +5428,30 @@ get_r_debug (const int pid, const int is_elf64)
static int
read_one_ptr (CORE_ADDR memaddr, CORE_ADDR *ptr, int ptr_size)
{
- *ptr = 0;
- return linux_read_memory (memaddr, (unsigned char *) ptr, ptr_size);
+ int ret;
+
+ /* Go through a union so this works on either big or little endian
+ hosts, when the inferior's pointer size is smaller than the size
+ of CORE_ADDR. It is assumed the inferior's endianness is the
+ same of the superior's. */
+ union
+ {
+ CORE_ADDR core_addr;
+ unsigned int ui;
+ unsigned char uc;
+ } addr;
+
+ ret = linux_read_memory (memaddr, &addr.uc, ptr_size);
+ if (ret == 0)
+ {
+ if (ptr_size == sizeof (CORE_ADDR))
+ *ptr = addr.core_addr;
+ else if (ptr_size == sizeof (unsigned int))
+ *ptr = addr.ui;
+ else
+ gdb_assert_not_reached ("unhandled pointer size");
+ }
+ return ret;
}
struct link_map_offsets