This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[1/2] more OO, Ada exception catchpoints: move catch exception/assert commands to ada-lang.c.


Move the implementation and registration of the
"catch exception/assert" commands to ada-lang.c.

Done in a separate patch to avoid mixing code motion
with code changes, for easier review.

Pedro Alves

2011-06-22  Pedro Alves  <pedro@codesourcery.com>

	gdb/
	* ada-lang.c: Include arch-utils.h.
	(ada_decode_exception_location): Make static.
	(catch_ada_exception_command): Moved here from breakpoint.c.
	(ada_decode_assert_location): Make static.
	(catch_assert_command): Moved here from breakpoint.c.
	(_initialize_ada_lang): Install the exception and assert
	catchpoint commands here.
	* ada-lang.h (ada_decode_exception_location)
	(ada_decode_assert_location): Delete declarations.
	* breakpoint.c (CATCH_PERMANENT, CATCH_TEMPORARY): Moved to
	breakpoint.h.
	(create_ada_exception_breakpoint): Make extern.
	(catch_ada_exception_command, catch_assert_command): Moved to
	ada-lang.c.
	(add_catch_command): Make extern.
	(_initilize_breakpoint): Don't install the exception and assert
	catchpoint commands here.
	* breakpoint.h (CATCH_PERMANENT, CATCH_TEMPORARY): Moved from
	breakpoint.c
	(add_catch_command, create_ada_exception_breakpoint): Declare.

---
 gdb/ada-lang.c   |   66 ++++++++++++++++++++++++++++++++++++++++++++++++-
 gdb/ada-lang.h   |   11 --------
 gdb/breakpoint.c |   73 +------------------------------------------------------
 gdb/breakpoint.h |   30 ++++++++++++++++++++++
 4 files changed, 96 insertions(+), 84 deletions(-)

Index: src/gdb/ada-lang.c
===================================================================
--- src.orig/gdb/ada-lang.c	2011-06-21 16:41:09.000000000 +0100
+++ src/gdb/ada-lang.c	2011-06-21 17:59:31.925377766 +0100
@@ -61,6 +61,7 @@
 #include "psymtab.h"
 #include "value.h"
 #include "mi/mi-common.h"
+#include "arch-utils.h"
 
 /* Define whether or not the C operator '/' truncates towards zero for
    differently signed operands (truncation direction is undefined in C).
@@ -11339,7 +11340,7 @@ ada_exception_sal (enum exception_catchp
    See ada_exception_sal for a description of all the remaining
    function arguments of this function.  */
 
-struct symtab_and_line
+static struct symtab_and_line
 ada_decode_exception_location (char *args, char **addr_string,
                                char **exp_string, char **cond_string,
                                struct expression **cond,
@@ -11352,7 +11353,33 @@ ada_decode_exception_location (char *arg
                             cond, ops);
 }
 
-struct symtab_and_line
+/* Implement the "catch exception" command.  */
+
+static void
+catch_ada_exception_command (char *arg, int from_tty,
+			     struct cmd_list_element *command)
+{
+  struct gdbarch *gdbarch = get_current_arch ();
+  int tempflag;
+  struct symtab_and_line sal;
+  char *addr_string = NULL;
+  char *exp_string = NULL;
+  char *cond_string = NULL;
+  struct expression *cond = NULL;
+  struct breakpoint_ops *ops = NULL;
+
+  tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
+
+  if (!arg)
+    arg = "";
+  sal = ada_decode_exception_location (arg, &addr_string, &exp_string,
+                                       &cond_string, &cond, &ops);
+  create_ada_exception_breakpoint (gdbarch, sal, addr_string, exp_string,
+                                   cond_string, cond, ops, tempflag,
+                                   from_tty);
+}
+
+static struct symtab_and_line
 ada_decode_assert_location (char *args, char **addr_string,
                             struct breakpoint_ops **ops)
 {
@@ -11370,6 +11397,26 @@ ada_decode_assert_location (char *args,
                             ops);
 }
 
+/* Implement the "catch assert" command.  */
+
+static void
+catch_assert_command (char *arg, int from_tty,
+		      struct cmd_list_element *command)
+{
+  struct gdbarch *gdbarch = get_current_arch ();
+  int tempflag;
+  struct symtab_and_line sal;
+  char *addr_string = NULL;
+  struct breakpoint_ops *ops = NULL;
+
+  tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
+
+  if (!arg)
+    arg = "";
+  sal = ada_decode_assert_location (arg, &addr_string, &ops);
+  create_ada_exception_breakpoint (gdbarch, sal, addr_string, NULL, NULL, NULL,
+				   ops, tempflag, from_tty);
+}
                                 /* Operators */
 /* Information about operators given special treatment in functions
    below.  */
@@ -11942,6 +11989,21 @@ this incurs a slight performance penalty
 this option to \"off\" unless necessary."),
                             NULL, NULL, &set_ada_list, &show_ada_list);
 
+  add_catch_command ("exception", _("\
+Catch Ada exceptions, when raised.\n\
+With an argument, catch only exceptions with the given name."),
+		     catch_ada_exception_command,
+                     NULL,
+		     CATCH_PERMANENT,
+		     CATCH_TEMPORARY);
+  add_catch_command ("assert", _("\
+Catch failed Ada assertions, when raised.\n\
+With an argument, catch only exceptions with the given name."),
+		     catch_assert_command,
+                     NULL,
+		     CATCH_PERMANENT,
+		     CATCH_TEMPORARY);
+
   varsize_limit = 65536;
 
   obstack_init (&symbol_list_obstack);
Index: src/gdb/ada-lang.h
===================================================================
--- src.orig/gdb/ada-lang.h	2011-06-21 16:40:03.000000000 +0100
+++ src/gdb/ada-lang.h	2011-06-21 16:41:09.825379390 +0100
@@ -387,15 +387,4 @@ extern int ada_build_task_list (int warn
 
 extern int ada_exception_catchpoint_p (struct breakpoint *b);
   
-extern struct symtab_and_line
-  ada_decode_exception_location (char *args, char **addr_string,
-                                 char **exp_string, char **cond_string,
-                                 struct expression **cond,
-                                 struct breakpoint_ops **ops);
-
-extern struct symtab_and_line
-  ada_decode_assert_location (char *args, char **addr_string,
-                              struct breakpoint_ops **ops);
-
-
 #endif
Index: src/gdb/breakpoint.c
===================================================================
--- src.orig/gdb/breakpoint.c	2011-06-21 16:41:09.000000000 +0100
+++ src/gdb/breakpoint.c	2011-06-21 17:59:56.075377758 +0100
@@ -76,10 +76,6 @@
 #include "mi/mi-common.h"
 #include "python/python.h"
 
-/* Arguments to pass as context to some catch command handlers.  */
-#define CATCH_PERMANENT ((void *) (uintptr_t) 0)
-#define CATCH_TEMPORARY ((void *) (uintptr_t) 1)
-
 /* Prototypes for local functions.  */
 
 static void enable_delete_command (char *, int);
@@ -10029,9 +10025,7 @@ catch_throw_command (char *arg, int from
   catch_exception_command_1 (EX_EVENT_THROW, arg, tempflag, from_tty);
 }
 
-/* Create a breakpoint struct for Ada exception catchpoints.  */
-
-static void
+void
 create_ada_exception_breakpoint (struct gdbarch *gdbarch,
 				 struct symtab_and_line sal,
                                  char *addr_string,
@@ -10082,32 +10076,6 @@ create_ada_exception_breakpoint (struct
   update_global_location_list (1);
 }
 
-/* Implement the "catch exception" command.  */
-
-static void
-catch_ada_exception_command (char *arg, int from_tty,
-			     struct cmd_list_element *command)
-{
-  struct gdbarch *gdbarch = get_current_arch ();
-  int tempflag;
-  struct symtab_and_line sal;
-  char *addr_string = NULL;
-  char *exp_string = NULL;
-  char *cond_string = NULL;
-  struct expression *cond = NULL;
-  struct breakpoint_ops *ops = NULL;
-
-  tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
-
-  if (!arg)
-    arg = "";
-  sal = ada_decode_exception_location (arg, &addr_string, &exp_string,
-                                       &cond_string, &cond, &ops);
-  create_ada_exception_breakpoint (gdbarch, sal, addr_string, exp_string,
-                                   cond_string, cond, ops, tempflag,
-                                   from_tty);
-}
-
 /* Cleanup function for a syscall filter list.  */
 static void
 clean_up_filters (void *arg)
@@ -10206,27 +10174,6 @@ this architecture yet."));
 				   &catch_syscall_breakpoint_ops);
 }
 
-/* Implement the "catch assert" command.  */
-
-static void
-catch_assert_command (char *arg, int from_tty,
-		      struct cmd_list_element *command)
-{
-  struct gdbarch *gdbarch = get_current_arch ();
-  int tempflag;
-  struct symtab_and_line sal;
-  char *addr_string = NULL;
-  struct breakpoint_ops *ops = NULL;
-
-  tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
-
-  if (!arg)
-    arg = "";
-  sal = ada_decode_assert_location (arg, &addr_string, &ops);
-  create_ada_exception_breakpoint (gdbarch, sal, addr_string, NULL, NULL, NULL,
-				   ops, tempflag, from_tty);
-}
-
 static void
 catch_command (char *arg, int from_tty)
 {
@@ -12961,9 +12908,7 @@ static struct cmd_list_element *catch_cm
 /* List of subcommands for "tcatch".  */
 static struct cmd_list_element *tcatch_cmdlist;
 
-/* Like add_cmd, but add the command to both the "catch" and "tcatch"
-   lists, and pass some additional user data to the command function.  */
-static void
+void
 add_catch_command (char *name, char *docstring,
 		   void (*sfunc) (char *args, int from_tty,
 				  struct cmd_list_element *command),
@@ -13329,20 +13274,6 @@ Arguments, if given, should be one or mo
 		     catch_syscall_completer,
 		     CATCH_PERMANENT,
 		     CATCH_TEMPORARY);
-  add_catch_command ("exception", _("\
-Catch Ada exceptions, when raised.\n\
-With an argument, catch only exceptions with the given name."),
-		     catch_ada_exception_command,
-                     NULL,
-		     CATCH_PERMANENT,
-		     CATCH_TEMPORARY);
-  add_catch_command ("assert", _("\
-Catch failed Ada assertions, when raised.\n\
-With an argument, catch only exceptions with the given name."),
-		     catch_assert_command,
-                     NULL,
-		     CATCH_PERMANENT,
-		     CATCH_TEMPORARY);
 
   c = add_com ("watch", class_breakpoint, watch_command, _("\
 Set a watchpoint for an expression.\n\
Index: src/gdb/breakpoint.h
===================================================================
--- src.orig/gdb/breakpoint.h	2011-06-21 16:41:09.000000000 +0100
+++ src/gdb/breakpoint.h	2011-06-21 17:59:31.925377766 +0100
@@ -984,6 +984,36 @@ extern void awatch_command_wrapper (char
 extern void rwatch_command_wrapper (char *, int, int);
 extern void tbreak_command (char *, int);
 
+/* Arguments to pass as context to some catch command handlers.  */
+#define CATCH_PERMANENT ((void *) (uintptr_t) 0)
+#define CATCH_TEMPORARY ((void *) (uintptr_t) 1)
+
+/* Like add_cmd, but add the command to both the "catch" and "tcatch"
+   lists, and pass some additional user data to the command
+   function.  */
+
+extern void
+  add_catch_command (char *name, char *docstring,
+		     void (*sfunc) (char *args, int from_tty,
+				    struct cmd_list_element *command),
+		     char **(*completer) (struct cmd_list_element *cmd,
+					  char *text, char *word),
+		     void *user_data_catch,
+		     void *user_data_tcatch);
+
+/* Create a breakpoint struct for Ada exception catchpoints.  */
+
+extern void
+  create_ada_exception_breakpoint (struct gdbarch *gdbarch,
+				   struct symtab_and_line sal,
+				   char *addr_string,
+				   char *exp_string,
+				   char *cond_string,
+				   struct expression *cond,
+				   struct breakpoint_ops *ops,
+				   int tempflag,
+				   int from_tty);
+
 extern int create_breakpoint (struct gdbarch *gdbarch, char *arg,
 			      char *cond_string, int thread,
 			      int parse_condition_and_thread,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]