Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [commit] Ignore SEGVs from win32 IsBad* functions
@ 2005-03-27  5:21 Christopher Faylor
  2005-03-27 10:56 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Christopher Faylor @ 2005-03-27  5:21 UTC (permalink / raw)
  To: gdb-patches

There have been a number of complaints in the cygwin lists about
gdb's behavior with the win32 IsBad*Ptr calls.

This patch causes gdb to ignore notification of SEGV from within
those calls.

cgf

2005-03-27  Christopher Faylor  <cgf@timesys.com>

        * win32-nat.c (handle_exception): Treat win32 routines which check for
        valid addresses as "special" and don't stop when a SEGV is detected.
        (get_child_debug_event): Properly flag exception as unhandled.

Index: win32-nat.c
===================================================================
RCS file: /cvs/uberbaum/gdb/win32-nat.c,v
retrieving revision 1.109
diff -u -p -r1.109 win32-nat.c
--- win32-nat.c	21 Mar 2005 19:54:15 -0000	1.109
+++ win32-nat.c	27 Mar 2005 05:17:45 -0000
@@ -1077,6 +1077,14 @@ handle_exception (struct target_waitstat
     case EXCEPTION_ACCESS_VIOLATION:
       DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_ACCESS_VIOLATION");
       ourstatus->value.sig = TARGET_SIGNAL_SEGV;
+      {
+	char *fn;
+	if (find_pc_partial_function ((CORE_ADDR) current_event.u.Exception
+				      .ExceptionRecord.ExceptionAddress,
+				      &fn, NULL, NULL)
+	    && strncmp (fn, "KERNEL32!IsBad", strlen ("KERNEL32!IsBad")) == 0)
+	  return 0;
+      }
       break;
     case STATUS_STACK_OVERFLOW:
       DEBUG_EXCEPTION_SIMPLE ("STATUS_STACK_OVERFLOW");
@@ -1360,6 +1368,8 @@ get_child_debug_event (int pid, struct t
 	break;
       if (handle_exception (ourstatus))
 	retval = current_event.dwThreadId;
+      else
+	continue_status = DBG_EXCEPTION_NOT_HANDLED;
       break;
 
     case OUTPUT_DEBUG_STRING_EVENT:	/* message from the kernel */


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

* Re: [commit] Ignore SEGVs from win32 IsBad* functions
  2005-03-27  5:21 [commit] Ignore SEGVs from win32 IsBad* functions Christopher Faylor
@ 2005-03-27 10:56 ` Eli Zaretskii
  2005-03-27 15:42   ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2005-03-27 10:56 UTC (permalink / raw)
  To: gdb-patches

> Date: Sun, 27 Mar 2005 00:20:52 -0500
> From: Christopher Faylor <cgf@gnu.org>
> 
> +      {
> +	char *fn;
> +	if (find_pc_partial_function ((CORE_ADDR) current_event.u.Exception
> +				      .ExceptionRecord.ExceptionAddress,
> +				      &fn, NULL, NULL)
> +	    && strncmp (fn, "KERNEL32!IsBad", strlen ("KERNEL32!IsBad")) == 0)
> +	  return 0;
> +      }

Nitpicking: won't it be cleaner to have a single string
"KERNEL32!IsBad", instead of mentioning it twice, and to use sizeof
instead of strlen?


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

* Re: [commit] Ignore SEGVs from win32 IsBad* functions
  2005-03-27 10:56 ` Eli Zaretskii
@ 2005-03-27 15:42   ` Daniel Jacobowitz
  2005-03-27 19:31     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2005-03-27 15:42 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On Sun, Mar 27, 2005 at 12:53:25PM +0200, Eli Zaretskii wrote:
> > Date: Sun, 27 Mar 2005 00:20:52 -0500
> > From: Christopher Faylor <cgf@gnu.org>
> > 
> > +      {
> > +	char *fn;
> > +	if (find_pc_partial_function ((CORE_ADDR) current_event.u.Exception
> > +				      .ExceptionRecord.ExceptionAddress,
> > +				      &fn, NULL, NULL)
> > +	    && strncmp (fn, "KERNEL32!IsBad", strlen ("KERNEL32!IsBad")) == 0)
> > +	  return 0;
> > +      }
> 
> Nitpicking: won't it be cleaner to have a single string
> "KERNEL32!IsBad", instead of mentioning it twice, and to use sizeof
> instead of strlen?

The only thing this saves you is the chance of typos; recent GCC
versions will not only combine the strings, but also fold strlen to a
constant.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


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

* Re: [commit] Ignore SEGVs from win32 IsBad* functions
  2005-03-27 15:42   ` Daniel Jacobowitz
@ 2005-03-27 19:31     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2005-03-27 19:31 UTC (permalink / raw)
  To: gdb-patches

> Date: Sun, 27 Mar 2005 10:43:40 -0500
> From: Daniel Jacobowitz <drow@false.org>
> Cc: gdb-patches@sourceware.org
> 
> > Nitpicking: won't it be cleaner to have a single string
> > "KERNEL32!IsBad", instead of mentioning it twice, and to use sizeof
> > instead of strlen?
> 
> The only thing this saves you is the chance of typos; recent GCC
> versions will not only combine the strings, but also fold strlen to a
> constant.

I know about these GCC features, but IMHO the code still looks cleaner
with the changes I suggested, and typos are not something we should
take too lightly.

(I did say I was nitpicking ;-)


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

end of thread, other threads:[~2005-03-27 19:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-27  5:21 [commit] Ignore SEGVs from win32 IsBad* functions Christopher Faylor
2005-03-27 10:56 ` Eli Zaretskii
2005-03-27 15:42   ` Daniel Jacobowitz
2005-03-27 19:31     ` Eli Zaretskii

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