2006-09-27 Jan Kratochvil * target.c (target_read_memory): Cut memory address to the target's address bit size, bugreport by John Reiser. (target_write_memory): Likewise. Index: gdb/target.c =================================================================== RCS file: /cvs/src/src/gdb/target.c,v retrieving revision 1.126 diff -u -p -r1.126 target.c --- gdb/target.c 21 Sep 2006 14:00:53 -0000 1.126 +++ gdb/target.c 27 Sep 2006 16:01:27 -0000 @@ -1032,6 +1032,16 @@ target_xfer_partial (struct target_ops * int target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len) { + /* `x/x $ebx' on gdb/amd64 debugging inferior/i386 causes + Cannot access memory at address 0xffffce70 + as $ebx is considered `int' and sign-extended to 64-bit. + $esp does not exhibit this problem as it is `builtin_type_void_data_ptr', + not `builtin_type_int' as $ebx is. + Simulate the part of paddress() here. */ + int addr_bit = TARGET_ADDR_BIT; + if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)) + memaddr &= ((CORE_ADDR) 1 << addr_bit) - 1; + if (target_read (¤t_target, TARGET_OBJECT_MEMORY, NULL, myaddr, memaddr, len) == len) return 0; @@ -1042,6 +1052,11 @@ target_read_memory (CORE_ADDR memaddr, g int target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len) { + /* See `target_read_memory' above. */ + int addr_bit = TARGET_ADDR_BIT; + if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)) + memaddr &= ((CORE_ADDR) 1 << addr_bit) - 1; + if (target_write (¤t_target, TARGET_OBJECT_MEMORY, NULL, myaddr, memaddr, len) == len) return 0;