Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] windows-nat.c: Fix offset problem in signal string handling
@ 2013-03-19 16:24 Corinna Vinschen
  2013-03-20  2:25 ` Joel Brobecker
  0 siblings, 1 reply; 17+ messages in thread
From: Corinna Vinschen @ 2013-03-19 16:24 UTC (permalink / raw)
  To: gdb-patches

Hi,

another problem I found when trying the Cygwin signal handling on 64 bit
is that the address string of the context information can't be fetched,
because the pointer `p' points to the space in front of the address
string, but string_to_core_addr doesn't handle leading spaces.

The easiest way to fix this is to change the call to string_to_core_addr(p)
in handle_output_debug_string to `string_to_core_addr (p + 1)'.

Alternatively the call to string_to_core_addr could be replaced with a 
call to `strtoull (p, NULL, 0)'.  Since this code is only supported on
Cygwin, it's safe to assume that the strtoull function exists.

So I have two variations of the patch, I apply whatever you think is best.


Thanks,
Corinna


Version 1:

	* windows-nat.c (handle_output_debug_string): Fix offset in
	call to string_to_core_addr.

Index: windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.242
diff -u -p -r1.242 windows-nat.c
--- windows-nat.c	19 Mar 2013 15:06:26 -0000	1.242
+++ windows-nat.c	19 Mar 2013 15:11:55 -0000
@@ -978,7 +978,7 @@ handle_output_debug_string (struct targe
 	  retval = strtoul (p, &p, 0);
 	  if (!retval)
 	    retval = main_thread_id;
-	  else if ((x = (LPCVOID) string_to_core_addr (p))
+	  else if ((x = (LPCVOID) string_to_core_addr (p + 1))
 		   && ReadProcessMemory (current_process_handle, x,
 					 &saved_context,
 					 __COPY_CONTEXT_SIZE, &n)

Version 2:

	* windows-nat.c (handle_output_debug_string): Replace call
	to string_to_core_addr with call to strtoull.

Index: windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.242
diff -u -p -r1.242 windows-nat.c
--- windows-nat.c	19 Mar 2013 15:06:26 -0000	1.242
+++ windows-nat.c	19 Mar 2013 15:13:10 -0000
@@ -978,7 +978,7 @@ handle_output_debug_string (struct targe
 	  retval = strtoul (p, &p, 0);
 	  if (!retval)
 	    retval = main_thread_id;
-	  else if ((x = (LPCVOID) string_to_core_addr (p))
+	  else if ((x = (LPCVOID) strtoull (p, NULL, 0))
 		   && ReadProcessMemory (current_process_handle, x,
 					 &saved_context,
 					 __COPY_CONTEXT_SIZE, &n)

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat


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

end of thread, other threads:[~2013-03-27 11:52 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-19 16:24 [patch] windows-nat.c: Fix offset problem in signal string handling Corinna Vinschen
2013-03-20  2:25 ` Joel Brobecker
2013-03-20  9:36   ` Corinna Vinschen
2013-03-27  4:59   ` [RFA] Fix cygwin32 failure introduced by " Pierre Muller
2013-03-27  7:53     ` Joel Brobecker
2013-03-27 10:47       ` Corinna Vinschen
2013-03-27 11:13         ` Pierre Muller
     [not found]   ` <000101ce2a6b$8c855a60$a5900f20$%muller@ics-cnrs.unistra.fr>
2013-03-27 10:02     ` Eli Zaretskii
2013-03-27 10:53       ` Corinna Vinschen
2013-03-27 10:59       ` Pierre Muller
     [not found]       ` <005501ce2ac8$ae830150$0b8903f0$%muller@ics-cnrs.unistra.fr>
2013-03-27 12:24         ` Eli Zaretskii
2013-03-27 14:39           ` Eli Zaretskii
2013-03-27 14:50           ` Eli Zaretskii
2013-03-27 15:23           ` Corinna Vinschen
2013-03-27 16:06             ` Eli Zaretskii
2013-03-27 16:45               ` Corinna Vinschen
2013-03-27 16:58                 ` Eli Zaretskii

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