Fix Cygwin gdb build
authorTom Tromey <tromey@adacore.com>
Thu, 16 Apr 2020 13:24:57 +0000 (07:24 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 16 Apr 2020 13:24:57 +0000 (07:24 -0600)
Simon pointed out that the windows-nat sharing series broke the Cygwin
build.  This patch fixes the problem, by moving the Cygwin-specific
code to a new handler function.  This approach is taken because this
code calls find_pc_partial_function, which isn't available in
gdbserver.

gdb/ChangeLog
2020-04-16  Tom Tromey  <tromey@adacore.com>

* windows-nat.c (windows_nat::handle_access_violation): New
function.
* nat/windows-nat.h (handle_access_violation): Declare.
* nat/windows-nat.c (handle_exception): Move Cygwin code to
windows-nat.c.  Call handle_access_violation.

gdbserver/ChangeLog
2020-04-16  Tom Tromey  <tromey@adacore.com>

* win32-low.cc (windows_nat::handle_access_violation): New
function.

gdb/ChangeLog
gdb/nat/windows-nat.c
gdb/nat/windows-nat.h
gdb/windows-nat.c
gdbserver/ChangeLog
gdbserver/win32-low.cc

index b019ca9b46126d2747dfda9a269270406e5425a8..7ba862edd3496987a2251b77769a6ee361db1620 100644 (file)
@@ -1,3 +1,11 @@
+2020-04-16  Tom Tromey  <tromey@adacore.com>
+
+       * windows-nat.c (windows_nat::handle_access_violation): New
+       function.
+       * nat/windows-nat.h (handle_access_violation): Declare.
+       * nat/windows-nat.c (handle_exception): Move Cygwin code to
+       windows-nat.c.  Call handle_access_violation.
+
 2020-04-16  Tom de Vries  <tdevries@suse.de>
 
        PR symtab/25791
index cd7c1d177c6c2453f3feaf3174096cf057ec2368..8c2092a51d709974b4e93515bf6b7b00133846dd 100644 (file)
@@ -184,26 +184,8 @@ handle_exception (struct target_waitstatus *ourstatus, bool debug_exceptions)
     case EXCEPTION_ACCESS_VIOLATION:
       DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_ACCESS_VIOLATION");
       ourstatus->value.sig = GDB_SIGNAL_SEGV;
-#ifdef __CYGWIN__
-      {
-       /* See if the access violation happened within the cygwin DLL
-          itself.  Cygwin uses a kind of exception handling to deal
-          with passed-in invalid addresses.  gdb should not treat
-          these as real SEGVs since they will be silently handled by
-          cygwin.  A real SEGV will (theoretically) be caught by
-          cygwin later in the process and will be sent as a
-          cygwin-specific-signal.  So, ignore SEGVs if they show up
-          within the text segment of the DLL itself.  */
-       const char *fn;
-       CORE_ADDR addr = (CORE_ADDR) (uintptr_t) rec->ExceptionAddress;
-
-       if ((!cygwin_exceptions && (addr >= cygwin_load_start
-                                   && addr < cygwin_load_end))
-           || (find_pc_partial_function (addr, &fn, NULL, NULL)
-               && startswith (fn, "KERNEL32!IsBad")))
-         return HANDLE_EXCEPTION_UNHANDLED;
-      }
-#endif
+      if (handle_access_violation (rec))
+       return HANDLE_EXCEPTION_UNHANDLED;
       break;
     case STATUS_STACK_OVERFLOW:
       DEBUG_EXCEPTION_SIMPLE ("STATUS_STACK_OVERFLOW");
index aea1519672d4f72aac0680504be03b5db8b8ad44..8d0fa9bd2165b730d49c470d15dd2e0bfcef4553 100644 (file)
@@ -157,6 +157,13 @@ extern void handle_unload_dll ();
 
 extern bool handle_ms_vc_exception (const EXCEPTION_RECORD *rec);
 
+/* When EXCEPTION_ACCESS_VIOLATION is processed, we give the embedding
+   application a chance to change it to be considered "unhandled".
+   This function must be supplied by the embedding application.  If it
+   returns true, then the exception is "unhandled".  */
+
+extern bool handle_access_violation (const EXCEPTION_RECORD *rec);
+
 
 /* Currently executing process */
 extern HANDLE current_process_handle;
index e82e58ec1f2ea15e918794b3b2d752ab81daafad..b857f82eb897434cc6e1fc21d569dc22fd8015e5 100644 (file)
@@ -1230,6 +1230,31 @@ windows_nat::handle_ms_vc_exception (const EXCEPTION_RECORD *rec)
   return false;
 }
 
+/* See nat/windows-nat.h.  */
+
+bool
+windows_nat::handle_access_violation (const EXCEPTION_RECORD *rec)
+{
+#ifdef __CYGWIN__
+  /* See if the access violation happened within the cygwin DLL
+     itself.  Cygwin uses a kind of exception handling to deal with
+     passed-in invalid addresses.  gdb should not treat these as real
+     SEGVs since they will be silently handled by cygwin.  A real SEGV
+     will (theoretically) be caught by cygwin later in the process and
+     will be sent as a cygwin-specific-signal.  So, ignore SEGVs if
+     they show up within the text segment of the DLL itself.  */
+  const char *fn;
+  CORE_ADDR addr = (CORE_ADDR) (uintptr_t) rec->ExceptionAddress;
+
+  if ((!cygwin_exceptions && (addr >= cygwin_load_start
+                             && addr < cygwin_load_end))
+      || (find_pc_partial_function (addr, &fn, NULL, NULL)
+         && startswith (fn, "KERNEL32!IsBad")))
+    return true;
+#endif
+  return false;
+}
+
 /* Resume thread specified by ID, or all artificially suspended
    threads, if we are continuing execution.  KILLED non-zero means we
    have killed the inferior, so we should ignore weird errors due to
index 2abe0f1268c22b75c8b0447e1d622ba03c20985a..96642e5cf391413c06fd384f86b87b7e49770772 100644 (file)
@@ -1,3 +1,8 @@
+2020-04-16  Tom Tromey  <tromey@adacore.com>
+
+       * win32-low.cc (windows_nat::handle_access_violation): New
+       function.
+
 2020-04-15  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * win32-low.cc (get_child_debug_event): Fix format string warning.
index 75305a4cfabbb9c7fc876fc3999d73d95345c1d3..5a6f0df39f57197bc5a2c8512ae1113cd958b520 100644 (file)
@@ -1198,6 +1198,14 @@ windows_nat::handle_ms_vc_exception (const EXCEPTION_RECORD *rec)
   return false;
 }
 
+/* See nat/windows-nat.h.  */
+
+bool
+windows_nat::handle_access_violation (const EXCEPTION_RECORD *rec)
+{
+  return false;
+}
+
 /* A helper function that will, if needed, set
    'stopped_at_software_breakpoint' on the thread and adjust the
    PC.  */
This page took 0.031602 seconds and 4 git commands to generate.