2011-02-15 Paul Pluzhnikov <ppluzhnikov@google.com>
authorPaul Pluzhnikov <ppluzhnikov@google.com>
Tue, 15 Feb 2011 21:23:34 +0000 (21:23 +0000)
committerPaul Pluzhnikov <ppluzhnikov@google.com>
Tue, 15 Feb 2011 21:23:34 +0000 (21:23 +0000)
* breakpoint.c ((create_overlay_event_breakpoint): Const-propagate
parameter value.
(create_longjmp_master_breakpoint): Loop over longjmp names.
(create_std_terminate_master_breakpoint): Const-propagate parameter
value.
(update_breakpoints_after_exec): Adjust.
(breakpoint_re_set): Adjust.

gdb/ChangeLog
gdb/breakpoint.c

index 6d4c923595a6557307f9aab8fa3141f0a75bbf09..dfa0bf602c62e2332547a5aaa9175c864a2dbc57 100644 (file)
@@ -1,3 +1,13 @@
+2011-02-15  Paul Pluzhnikov  <ppluzhnikov@google.com>
+
+       * breakpoint.c ((create_overlay_event_breakpoint): Const-propagate
+       parameter value.
+       (create_longjmp_master_breakpoint): Loop over longjmp names.
+       (create_std_terminate_master_breakpoint): Const-propagate parameter
+       value.
+       (update_breakpoints_after_exec): Adjust.
+       (breakpoint_re_set): Adjust.
+
 2011-02-15  Michael Snyder  <msnyder@vmware.com>
 
        * command.h (enum command_class): New class 'no_set_class', for
index 39d9b02fe43e50d61fdf3742e6b2dc48d3c32177..029ce6b22edca8d801cd3da89dc00ffba40d415d 100644 (file)
@@ -2218,9 +2218,10 @@ create_internal_breakpoint (struct gdbarch *gdbarch,
 }
 
 static void
-create_overlay_event_breakpoint (char *func_name)
+create_overlay_event_breakpoint (void)
 {
   struct objfile *objfile;
+  const char *const func_name = "_ovly_debug_event";
 
   ALL_OBJFILES (objfile)
     {
@@ -2251,48 +2252,64 @@ create_overlay_event_breakpoint (char *func_name)
 }
 
 static void
-create_longjmp_master_breakpoint (char *func_name)
+create_longjmp_master_breakpoint (void)
 {
   struct program_space *pspace;
-  struct objfile *objfile;
   struct cleanup *old_chain;
 
   old_chain = save_current_program_space ();
 
   ALL_PSPACES (pspace)
-  ALL_OBJFILES (objfile)
+  {
+    struct objfile *objfile;
+
+    set_current_program_space (pspace);
+
+    ALL_OBJFILES (objfile)
     {
-      struct breakpoint *b;
-      struct minimal_symbol *m;
+      const char *const longjmp_names[]
+       = { "longjmp", "_longjmp", "siglongjmp", "_siglongjmp" };
+      const int num_longjmp_names
+       = sizeof (longjmp_names) / sizeof (longjmp_names[0]);
+      int i;
+      struct gdbarch *gdbarch;
 
-      if (!gdbarch_get_longjmp_target_p (get_objfile_arch (objfile)))
+      gdbarch = get_objfile_arch (objfile);
+      if (!gdbarch_get_longjmp_target_p (gdbarch))
        continue;
 
-      set_current_program_space (pspace);
+      for (i = 0; i < num_longjmp_names; i++)
+       {
+         struct breakpoint *b;
+         struct minimal_symbol *m;
+         const char *func_name;
 
-      m = lookup_minimal_symbol_text (func_name, objfile);
-      if (m == NULL)
-        continue;
+         func_name = longjmp_names[i];
+         m = lookup_minimal_symbol_text (func_name, objfile);
+         if (m == NULL)
+           continue;
 
-      b = create_internal_breakpoint (get_objfile_arch (objfile),
-                                     SYMBOL_VALUE_ADDRESS (m),
-                                      bp_longjmp_master);
-      b->addr_string = xstrdup (func_name);
-      b->enable_state = bp_disabled;
+         b = create_internal_breakpoint (gdbarch,
+                                         SYMBOL_VALUE_ADDRESS (m),
+                                         bp_longjmp_master);
+         b->addr_string = xstrdup (func_name);
+         b->enable_state = bp_disabled;
+       }
     }
+  }
   update_global_location_list (1);
 
   do_cleanups (old_chain);
 }
 
-/* Create a master std::terminate breakpoint.  The actual function
-   looked for is named FUNC_NAME.  */
+/* Create a master std::terminate breakpoint.  */
 static void
-create_std_terminate_master_breakpoint (const char *func_name)
+create_std_terminate_master_breakpoint (void)
 {
   struct program_space *pspace;
   struct objfile *objfile;
   struct cleanup *old_chain;
+  const char *const func_name = "std::terminate()";
 
   old_chain = save_current_program_space ();
 
@@ -2462,12 +2479,9 @@ update_breakpoints_after_exec (void)
       }
   }
   /* FIXME what about longjmp breakpoints?  Re-create them here?  */
-  create_overlay_event_breakpoint ("_ovly_debug_event");
-  create_longjmp_master_breakpoint ("longjmp");
-  create_longjmp_master_breakpoint ("_longjmp");
-  create_longjmp_master_breakpoint ("siglongjmp");
-  create_longjmp_master_breakpoint ("_siglongjmp");
-  create_std_terminate_master_breakpoint ("std::terminate()");
+  create_overlay_event_breakpoint ();
+  create_longjmp_master_breakpoint ();
+  create_std_terminate_master_breakpoint ();
   create_exception_master_breakpoint ();
 }
 
@@ -10719,12 +10733,9 @@ breakpoint_re_set (void)
 
   do_cleanups (old_chain);
 
-  create_overlay_event_breakpoint ("_ovly_debug_event");
-  create_longjmp_master_breakpoint ("longjmp");
-  create_longjmp_master_breakpoint ("_longjmp");
-  create_longjmp_master_breakpoint ("siglongjmp");
-  create_longjmp_master_breakpoint ("_siglongjmp");
-  create_std_terminate_master_breakpoint ("std::terminate()");
+  create_overlay_event_breakpoint ();
+  create_longjmp_master_breakpoint ();
+  create_std_terminate_master_breakpoint ();
   create_exception_master_breakpoint ();
 }
 \f