Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch, i386] Use read_memory_unsigned_integer to get address
@ 2011-09-22 10:23 Yao Qi
  2011-09-22 13:55 ` Mark Kettenis
  0 siblings, 1 reply; 3+ messages in thread
From: Yao Qi @ 2011-09-22 10:23 UTC (permalink / raw)
  To: gdb-patches

The address on i386 is unsigned, so we should use
read_memory_unsigned_integer to fetch address from memory.

OK to apply?

-- 
Yao (齐尧) 

	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);
     }
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch, i386] Use read_memory_unsigned_integer to get address
  2011-09-22 10:23 [patch, i386] Use read_memory_unsigned_integer to get address Yao Qi
@ 2011-09-22 13:55 ` Mark Kettenis
  2011-09-23  8:11   ` [committed]: " Yao Qi
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2011-09-22 13:55 UTC (permalink / raw)
  To: yao; +Cc: gdb-patches

> 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);
>      }
>  
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [committed]: [patch, i386] Use read_memory_unsigned_integer to get address
  2011-09-22 13:55 ` Mark Kettenis
@ 2011-09-23  8:11   ` Yao Qi
  0 siblings, 0 replies; 3+ messages in thread
From: Yao Qi @ 2011-09-23  8:11 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

On 09/22/2011 07:46 PM, Mark Kettenis wrote:
>> > 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.
> 

Linux bit is committed.  Thanks for your review, Mark.

http://sourceware.org/ml/gdb-cvs/2011-09/msg00139.html

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-09-23  7:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-22 10:23 [patch, i386] Use read_memory_unsigned_integer to get address Yao Qi
2011-09-22 13:55 ` Mark Kettenis
2011-09-23  8:11   ` [committed]: " Yao Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox