Add base 'enable/disable invalid location range' tests
[deliverable/binutils-gdb.git] / gdb / windows-nat.c
index 1ef38fb32b4bd8cb9d9907ba1c7d728658a9f446..128edc22027ec5e28dee7cc64aa3b4e64120df9a 100644 (file)
@@ -42,6 +42,7 @@
 #include <sys/cygwin.h>
 #include <cygwin/version.h>
 #endif
+#include <algorithm>
 
 #include "buildsym.h"
 #include "filenames.h"
@@ -465,7 +466,7 @@ do_windows_fetch_inferior_registers (struct regcache *regcache,
                                     windows_thread_info *th, int r)
 {
   char *context_offset = ((char *) &th->context) + mappings[r];
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   long l;
 
@@ -552,7 +553,7 @@ do_windows_store_inferior_registers (const struct regcache *regcache,
                          ((char *) &th->context) + mappings[r]);
   else
     {
-      for (r = 0; r < gdbarch_num_regs (get_regcache_arch (regcache)); r++)
+      for (r = 0; r < gdbarch_num_regs (regcache->arch ()); r++)
        do_windows_store_inferior_registers (regcache, th, r);
     }
 }
@@ -755,8 +756,8 @@ get_image_name (HANDLE h, void *address, int unicode)
    do_initial_windows_stuff and windows_add_all_dlls for more info
    on how we handle DLL loading during that phase).  */
 
-static int
-handle_load_dll (void *dummy)
+static void
+handle_load_dll ()
 {
   LOAD_DLL_DEBUG_INFO *event = &current_event.u.LoadDll;
   char *dll_name;
@@ -769,7 +770,7 @@ handle_load_dll (void *dummy)
   dll_name = get_image_name (current_process_handle,
                             event->lpImageName, event->fUnicode);
   if (!dll_name)
-    return 1;
+    return;
 
   solib_end->next = windows_make_so (dll_name, event->lpBaseOfDll);
   solib_end = solib_end->next;
@@ -778,8 +779,6 @@ handle_load_dll (void *dummy)
 
   DEBUG_EVENTS (("gdb: Loading dll \"%s\" at %s.\n", solib_end->so_name,
                 host_address_to_string (li->load_addr)));
-
-  return 1;
 }
 
 static void
@@ -799,8 +798,8 @@ windows_free_so (struct so_list *so)
    do_initial_windows_stuff and windows_add_all_dlls for more info
    on how we handle DLL loading during that phase).  */
 
-static int
-handle_unload_dll (void *dummy)
+static void
+handle_unload_dll ()
 {
   LPVOID lpBaseOfDll = current_event.u.UnloadDll.lpBaseOfDll;
   struct so_list *so;
@@ -819,7 +818,7 @@ handle_unload_dll (void *dummy)
          DEBUG_EVENTS (("gdb: Unloading dll \"%s\".\n", sodel->so_name));
 
          windows_free_so (sodel);
-         return 1;
+         return;
        }
     }
 
@@ -832,8 +831,23 @@ handle_unload_dll (void *dummy)
      32bit and 64bit worlds).  */
   complaint (&symfile_complaints, _("dll starting at %s not found."),
             host_address_to_string (lpBaseOfDll));
+}
 
-  return 0;
+/* Call FUNC wrapped in a TRY/CATCH that swallows all GDB
+   exceptions.  */
+
+static void
+catch_errors (void (*func) ())
+{
+  TRY
+    {
+      func ();
+    }
+  CATCH (ex, RETURN_MASK_ALL)
+    {
+      exception_print (gdb_stderr, ex);
+    }
+  END_CATCH
 }
 
 /* Clear list of loaded DLLs.  */
@@ -1362,7 +1376,7 @@ windows_resume (struct target_ops *ops,
        {
          /* Single step by setting t bit.  */
          struct regcache *regcache = get_current_regcache ();
-         struct gdbarch *gdbarch = get_regcache_arch (regcache);
+         struct gdbarch *gdbarch = regcache->arch ();
          windows_fetch_inferior_registers (ops, regcache,
                                            gdbarch_ps_regnum (gdbarch));
          th->context.EFlags |= FLAG_TRACE_BIT;
@@ -1541,7 +1555,7 @@ get_windows_debug_event (struct target_ops *ops,
       CloseHandle (current_event.u.LoadDll.hFile);
       if (saw_create != 1 || ! windows_initialization_done)
        break;
-      catch_errors (handle_load_dll, NULL, (char *) "", RETURN_MASK_ALL);
+      catch_errors (handle_load_dll);
       ourstatus->kind = TARGET_WAITKIND_LOADED;
       ourstatus->value.integer = 0;
       thread_id = main_thread_id;
@@ -1554,7 +1568,7 @@ get_windows_debug_event (struct target_ops *ops,
                     "UNLOAD_DLL_DEBUG_EVENT"));
       if (saw_create != 1 || ! windows_initialization_done)
        break;
-      catch_errors (handle_unload_dll, NULL, (char *) "", RETURN_MASK_ALL);
+      catch_errors (handle_unload_dll);
       ourstatus->kind = TARGET_WAITKIND_LOADED;
       ourstatus->value.integer = 0;
       thread_id = main_thread_id;
This page took 0.034126 seconds and 4 git commands to generate.