Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* [patch gdb]: Fix display for LLP64 target in window-nat.c
@ 2013-02-19 14:09 Kai Tietz
  2013-02-19 14:16 ` Joel Brobecker
  2013-02-19 16:30 ` Eli Zaretskii
  0 siblings, 2 replies; 6+ messages in thread
From: Kai Tietz @ 2013-02-19 14:09 UTC (permalink / raw)
  To: gdb

Hello,

this patch fixes a pointer-truncation in display on Windows LLP64 target.

ChangeLog 2013-02-19  Kai Tietz  <ktietz@redhat.com>

	* windows-nat.c (windows_xfer_memory): Fix debug-output
	for LLP64.

Ok for apply?

Regards,
Kai

Index: windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.238
diff -p -u -r1.238 windows-nat.c
--- windows-nat.c	1 Jan 2013 06:41:29 -0000	1.238
+++ windows-nat.c	19 Feb 2013 14:05:20 -0000
@@ -2312,8 +2312,8 @@ windows_xfer_memory (CORE_ADDR memaddr,
   SIZE_T done = 0;
   if (write)
     {
-      DEBUG_MEM (("gdb: write target memory, %d bytes at 0x%08lx\n",
-		  len, (DWORD) (uintptr_t) memaddr));
+      DEBUG_MEM (("gdb: write target memory, %d bytes at 0x%p\n",
+		  len, (LPVOID) (uintptr_t) memaddr));
       if (!WriteProcessMemory (current_process_handle,
 			       (LPVOID) (uintptr_t) memaddr, our,
 			       len, &done))
@@ -2323,8 +2323,8 @@ windows_xfer_memory (CORE_ADDR memaddr,
     }
   else
     {
-      DEBUG_MEM (("gdb: read target memory, %d bytes at 0x%08lx\n",
-		  len, (DWORD) (uintptr_t) memaddr));
+      DEBUG_MEM (("gdb: read target memory, %d bytes at 0x%p\n",
+		  len, (LPVOID) (uintptr_t) memaddr));
       if (!ReadProcessMemory (current_process_handle,
 			      (LPCVOID) (uintptr_t) memaddr, our,
 			      len, &done))


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

* Re: [patch gdb]: Fix display for LLP64 target in window-nat.c
  2013-02-19 14:09 [patch gdb]: Fix display for LLP64 target in window-nat.c Kai Tietz
@ 2013-02-19 14:16 ` Joel Brobecker
  2013-02-19 14:52   ` Joel Brobecker
  2013-02-19 16:30 ` Eli Zaretskii
  1 sibling, 1 reply; 6+ messages in thread
From: Joel Brobecker @ 2013-02-19 14:16 UTC (permalink / raw)
  To: Kai Tietz; +Cc: gdb

> ChangeLog 2013-02-19  Kai Tietz  <ktietz@redhat.com>
> 
> 	* windows-nat.c (windows_xfer_memory): Fix debug-output
> 	for LLP64.
> 
> Ok for apply?

(wrong mailing-list)...

You should use %s & host_address_to_string instead of %p &
the various casts. So the following should work:

      DEBUG_MEM (("gdb: write target memory, %d bytes at 0x%s\n",
		  len, host_address_to_string (memaddr)));

OK with that change.

> Index: windows-nat.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/windows-nat.c,v
> retrieving revision 1.238
> diff -p -u -r1.238 windows-nat.c
> --- windows-nat.c	1 Jan 2013 06:41:29 -0000	1.238
> +++ windows-nat.c	19 Feb 2013 14:05:20 -0000
> @@ -2312,8 +2312,8 @@ windows_xfer_memory (CORE_ADDR memaddr,
>    SIZE_T done = 0;
>    if (write)
>      {
> -      DEBUG_MEM (("gdb: write target memory, %d bytes at 0x%08lx\n",
> -		  len, (DWORD) (uintptr_t) memaddr));
> +      DEBUG_MEM (("gdb: write target memory, %d bytes at 0x%p\n",
> +		  len, (LPVOID) (uintptr_t) memaddr));
>        if (!WriteProcessMemory (current_process_handle,
>  			       (LPVOID) (uintptr_t) memaddr, our,
>  			       len, &done))
> @@ -2323,8 +2323,8 @@ windows_xfer_memory (CORE_ADDR memaddr,
>      }
>    else
>      {
> -      DEBUG_MEM (("gdb: read target memory, %d bytes at 0x%08lx\n",
> -		  len, (DWORD) (uintptr_t) memaddr));
> +      DEBUG_MEM (("gdb: read target memory, %d bytes at 0x%p\n",
> +		  len, (LPVOID) (uintptr_t) memaddr));
>        if (!ReadProcessMemory (current_process_handle,
>  			      (LPCVOID) (uintptr_t) memaddr, our,
>  			      len, &done))

-- 
Joel


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

* Re: [patch gdb]: Fix display for LLP64 target in window-nat.c
  2013-02-19 14:16 ` Joel Brobecker
@ 2013-02-19 14:52   ` Joel Brobecker
  2013-02-19 14:59     ` Kai Tietz
  0 siblings, 1 reply; 6+ messages in thread
From: Joel Brobecker @ 2013-02-19 14:52 UTC (permalink / raw)
  To: Kai Tietz; +Cc: gdb

> You should use %s & host_address_to_string instead of %p &
> the various casts. So the following should work:
> 
>       DEBUG_MEM (("gdb: write target memory, %d bytes at 0x%s\n",
> 		  len, host_address_to_string (memaddr)));
> 
> OK with that change.

Actually, I was confused. Sorry. Try either core_addr_to_string_nz
(or core_addr_to_string if you want leading zeros)...


> 
> > Index: windows-nat.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/windows-nat.c,v
> > retrieving revision 1.238
> > diff -p -u -r1.238 windows-nat.c
> > --- windows-nat.c	1 Jan 2013 06:41:29 -0000	1.238
> > +++ windows-nat.c	19 Feb 2013 14:05:20 -0000
> > @@ -2312,8 +2312,8 @@ windows_xfer_memory (CORE_ADDR memaddr,
> >    SIZE_T done = 0;
> >    if (write)
> >      {
> > -      DEBUG_MEM (("gdb: write target memory, %d bytes at 0x%08lx\n",
> > -		  len, (DWORD) (uintptr_t) memaddr));
> > +      DEBUG_MEM (("gdb: write target memory, %d bytes at 0x%p\n",
> > +		  len, (LPVOID) (uintptr_t) memaddr));
> >        if (!WriteProcessMemory (current_process_handle,
> >  			       (LPVOID) (uintptr_t) memaddr, our,
> >  			       len, &done))
> > @@ -2323,8 +2323,8 @@ windows_xfer_memory (CORE_ADDR memaddr,
> >      }
> >    else
> >      {
> > -      DEBUG_MEM (("gdb: read target memory, %d bytes at 0x%08lx\n",
> > -		  len, (DWORD) (uintptr_t) memaddr));
> > +      DEBUG_MEM (("gdb: read target memory, %d bytes at 0x%p\n",
> > +		  len, (LPVOID) (uintptr_t) memaddr));
> >        if (!ReadProcessMemory (current_process_handle,
> >  			      (LPCVOID) (uintptr_t) memaddr, our,
> >  			      len, &done))
> 
> -- 
> Joel

-- 
Joel


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

* Re: [patch gdb]: Fix display for LLP64 target in window-nat.c
  2013-02-19 14:52   ` Joel Brobecker
@ 2013-02-19 14:59     ` Kai Tietz
  0 siblings, 0 replies; 6+ messages in thread
From: Kai Tietz @ 2013-02-19 14:59 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb

2013/2/19 Joel Brobecker <brobecker@adacore.com>:
>> You should use %s & host_address_to_string instead of %p &
>> the various casts. So the following should work:
>>
>>       DEBUG_MEM (("gdb: write target memory, %d bytes at 0x%s\n",
>>                 len, host_address_to_string (memaddr)));
>>
>> OK with that change.
>
> Actually, I was confused. Sorry. Try either core_addr_to_string_nz
> (or core_addr_to_string if you want leading zeros)...
>

Ok, I was now confused too due host_address_to_string is requiring an
pointer as input.

Just re-testing adjusted patch and will commit then.

Thanks,
Kai


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

* Re: [patch gdb]: Fix display for LLP64 target in window-nat.c
  2013-02-19 14:09 [patch gdb]: Fix display for LLP64 target in window-nat.c Kai Tietz
  2013-02-19 14:16 ` Joel Brobecker
@ 2013-02-19 16:30 ` Eli Zaretskii
  2013-02-19 17:24   ` Kai Tietz
  1 sibling, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2013-02-19 16:30 UTC (permalink / raw)
  To: Kai Tietz; +Cc: gdb

> Date: Tue, 19 Feb 2013 15:09:06 +0100
> From: Kai Tietz <ktietz70@googlemail.com>
> 
> this patch fixes a pointer-truncation in display on Windows LLP64 target.
> 
> ChangeLog 2013-02-19  Kai Tietz  <ktietz@redhat.com>
> 
> 	* windows-nat.c (windows_xfer_memory): Fix debug-output
> 	for LLP64.
> 
> Ok for apply?

Isn't DWORD_PTR the right replacement for DWORD in these cases?

Actually, I don't understand what is the cast to uintptr_t doing
there, it seems redundant.


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

* Re: [patch gdb]: Fix display for LLP64 target in window-nat.c
  2013-02-19 16:30 ` Eli Zaretskii
@ 2013-02-19 17:24   ` Kai Tietz
  0 siblings, 0 replies; 6+ messages in thread
From: Kai Tietz @ 2013-02-19 17:24 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb

2013/2/19 Eli Zaretskii <eliz@gnu.org>:
>> Date: Tue, 19 Feb 2013 15:09:06 +0100
>> From: Kai Tietz <ktietz70@googlemail.com>
>>
>> this patch fixes a pointer-truncation in display on Windows LLP64 target.
>>
>> ChangeLog 2013-02-19  Kai Tietz  <ktietz@redhat.com>
>>
>>       * windows-nat.c (windows_xfer_memory): Fix debug-output
>>       for LLP64.
>>
>> Ok for apply?
>
> Isn't DWORD_PTR the right replacement for DWORD in these cases?
No, CORE_ADDR is the type we want to print.  DWORD_PTR is holding the
width of the host-pointer, not necessarily compatible to CORE_ADDR.
We want to fix pointer truncation here, not just express it different.

> Actually, I don't understand what is the cast to uintptr_t doing
> there, it seems redundant.

Well, the issue is that CORE_ADDR might be a smaller integer-scalar as
a pointer.  So before casting it to a pointer you need to make integer
wide-enough.

Cheers,
Kai


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

end of thread, other threads:[~2013-02-19 17:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-19 14:09 [patch gdb]: Fix display for LLP64 target in window-nat.c Kai Tietz
2013-02-19 14:16 ` Joel Brobecker
2013-02-19 14:52   ` Joel Brobecker
2013-02-19 14:59     ` Kai Tietz
2013-02-19 16:30 ` Eli Zaretskii
2013-02-19 17:24   ` Kai Tietz

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