This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch, i386] Use read_memory_unsigned_integer to get address
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: yao at codesourcery dot com
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 22 Sep 2011 13:46:53 +0200 (CEST)
- Subject: Re: [patch, i386] Use read_memory_unsigned_integer to get address
- References: <4E7A98B0.20809@codesourcery.com>
> Date: Thu, 22 Sep 2011 10:08:48 +0800
> From: Yao Qi <yao@codesourcery.com>
>
> The address on i386 is unsigned, so we should use
> read_memory_unsigned_integer to fetch address from memory.
That depends on your point of view...
> OK to apply?
No. On OpenBSD, the structure members that are assigned have type
'int', so they're signed. So I consider using read_memory_integer()
appropriate here.
The Linux bit is ok.
> gdb/
> * i386-linux-nat.c (i386_linux_resume): Use read_memory_unsigned_integer
> to get address.
> * i386obsd-nat.c (i386obsd_supply_pcb): Likewise.
>
> diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
> index e32a119..6257931 100644
> --- a/gdb/i386-linux-nat.c
> +++ b/gdb/i386-linux-nat.c
> @@ -893,7 +893,8 @@ i386_linux_resume (struct target_ops *ops,
>
> regcache_cooked_read_unsigned (regcache, I386_ESP_REGNUM, &sp);
> if (syscall == SYS_rt_sigreturn)
> - addr = read_memory_integer (sp + 8, 4, byte_order) + 20;
> + addr = read_memory_unsigned_integer (sp + 8, 4, byte_order)
> + + 20;
> else
> addr = sp;
>
> diff --git a/gdb/i386obsd-nat.c b/gdb/i386obsd-nat.c
> index db1f693..1c0d047 100644
> --- a/gdb/i386obsd-nat.c
> +++ b/gdb/i386obsd-nat.c
> @@ -78,8 +78,8 @@ i386obsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
> {
> /* No, the pcb must have been last updated by savectx(). */
> pcb->pcb_esp = pcb->pcb_ebp;
> - pcb->pcb_ebp = read_memory_integer(pcb->pcb_esp, 4, byte_order);
> - sf.sf_eip = read_memory_integer(pcb->pcb_esp + 4, 4, byte_order);
> + pcb->pcb_ebp = read_memory_unsigned_integer (pcb->pcb_esp, 4, byte_order);
> + sf.sf_eip = read_memory_unsigned_integer (pcb->pcb_esp + 4, 4, byte_order);
> regcache_raw_supply (regcache, I386_EIP_REGNUM, &sf.sf_eip);
> }
>
>