This is the mail archive of the gdb-patches@sources.redhat.com 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]

[commit] Eliminate a error_last_message() call


Now that it's possible to around an ErrorException (which includes the error message) there's no longer a need for this call to error_last_message(). Deleted.

committed,
Andrew
Index: ChangeLog
2005-01-12  Andrew Cagney  <cagney@gnu.org>

	* exceptions.c (exception_none): New variable.
	* Makefile.in: Update dependencies.
	* interps.c: Include "exceptions.h".
	(interpreter_exec_cmd, interp_exec): Update to return "struct
	exception"
	* exceptions.h (no_exception): Declare.
	* tui/tui-interp.c (tui_exec): Update to return "struct exception"
	* mi/mi-interp.c: Include "exceptions.h".
	(mi_cmd_interpreter_exec, mi_interpreter_exec): Update to return
	'struct exception".
	* cli/cli-interp.c (cli_interpreter_exec, safe_execute_command) 
	(do_captured_execute_command): Update to use catch_exception.
	* interps.h: Include "exceptions.h".
	(interp_exec_ftype, interp_exec): Return "struct exception".

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.687
diff -p -u -r1.687 Makefile.in
--- Makefile.in	12 Jan 2005 21:54:12 -0000	1.687
+++ Makefile.in	13 Jan 2005 02:34:16 -0000
@@ -714,7 +714,7 @@ inf_loop_h = inf-loop.h
 inflow_h = inflow.h $(terminal_h)
 inf_ptrace_h = inf-ptrace.h
 inf_ttrace_h = inf-ttrace.h
-interps_h = interps.h
+interps_h = interps.h $(exceptions_h)
 jv_lang_h = jv-lang.h
 kod_h = kod.h
 language_h = language.h
@@ -1758,13 +1758,13 @@ breakpoint.o: breakpoint.c $(defs_h) $(s
 	$(objfiles_h) $(source_h) $(linespec_h) $(completer_h) $(gdb_h) \
 	$(ui_out_h) $(cli_script_h) $(gdb_assert_h) $(block_h) $(solist_h) \
 	$(observer_h) $(exceptions_h) $(gdb_events_h)
-bsd-uthread.o: bsd-uthread.c $(defs_h) $(gdb_core_h) $(gdbthread_h) \
-	$(inferior_h) $(objfiles_h) $(observer_h) $(regcache_h)	\
-	$(solist_h) $(symfile_h) $(target_h) $(gdb_assert_h) \
-	$(gdb_obstack_h) $(bsd_uthread_h)
 bsd-kvm.o: bsd-kvm.c $(defs_h) $(cli_cmds_h) $(command_h) $(frame_h) \
 	$(regcache_h) $(target_h) $(value_h) $(gdbcore_h) $(gdb_assert_h) \
 	$(readline_h) $(bsd_kvm_h)
+bsd-uthread.o: bsd-uthread.c $(defs_h) $(gdbcore_h) $(gdbthread_h) \
+	$(inferior_h) $(objfiles_h) $(observer_h) $(regcache_h) $(solist_h) \
+	$(symfile_h) $(target_h) $(gdb_assert_h) $(gdb_obstack_h) \
+	$(bsd_uthread_h)
 buildsym.o: buildsym.c $(defs_h) $(bfd_h) $(gdb_obstack_h) $(symtab_h) \
 	$(symfile_h) $(objfiles_h) $(gdbtypes_h) $(gdb_assert_h) \
 	$(complaints_h) $(gdb_string_h) $(expression_h) $(bcache_h) \
@@ -1896,7 +1896,9 @@ event-loop.o: event-loop.c $(defs_h) $(e
 event-top.o: event-top.c $(defs_h) $(top_h) $(inferior_h) $(target_h) \
 	$(terminal_h) $(event_loop_h) $(event_top_h) $(interps_h) \
 	$(exceptions_h) $(gdbcmd_h) $(readline_h) $(readline_history_h)
-exceptions.o: exceptions.c
+exceptions.o: exceptions.c $(defs_h) $(exceptions_h) $(breakpoint_h) \
+	$(target_h) $(inferior_h) $(annotate_h) $(ui_out_h) $(gdb_assert_h) \
+	$(gdb_string_h)
 exec.o: exec.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) $(gdbcmd_h) \
 	$(language_h) $(symfile_h) $(objfiles_h) $(completer_h) $(value_h) \
 	$(exec_h) $(readline_h) $(gdb_string_h) $(gdbcore_h) $(gdb_stat_h) \
@@ -2109,7 +2111,7 @@ inf-ttrace.o: inf-ttrace.c $(defs_h) $(c
 	$(gdb_assert_h) $(gdb_string_h) $(inf_child_h) $(inf_ttrace_h)
 interps.o: interps.c $(defs_h) $(gdbcmd_h) $(ui_out_h) $(event_loop_h) \
 	$(event_top_h) $(interps_h) $(completer_h) $(gdb_string_h) \
-	$(gdb_events_h) $(gdb_assert_h) $(top_h)
+	$(gdb_events_h) $(gdb_assert_h) $(top_h) $(exceptions_h)
 irix5-nat.o: irix5-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) $(target_h) \
 	$(regcache_h) $(gdb_string_h) $(gregset_h) $(mips_tdep_h)
 jv-exp.o: jv-exp.c $(defs_h) $(gdb_string_h) $(expression_h) $(value_h) \
@@ -2945,7 +2947,8 @@ mi-getopt.o: $(srcdir)/mi/mi-getopt.c $(
 	$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-getopt.c
 mi-interp.o: $(srcdir)/mi/mi-interp.c $(defs_h) $(gdb_string_h) $(interps_h) \
 	$(event_top_h) $(event_loop_h) $(inferior_h) $(ui_out_h) $(top_h) \
-	$(mi_main_h) $(mi_cmds_h) $(mi_out_h) $(mi_console_h)
+	$(exceptions_h) $(mi_main_h) $(mi_cmds_h) $(mi_out_h) \
+	$(mi_console_h)
 	$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-interp.c
 mi-main.o: $(srcdir)/mi/mi-main.c $(defs_h) $(target_h) $(inferior_h) \
 	$(gdb_string_h) $(exceptions_h) $(top_h) $(gdbthread_h) $(mi_cmds_h) \
Index: exceptions.c
===================================================================
RCS file: /cvs/src/src/gdb/exceptions.c,v
retrieving revision 1.3
diff -p -u -r1.3 exceptions.c
--- exceptions.c	13 Jan 2005 00:12:49 -0000	1.3
+++ exceptions.c	13 Jan 2005 02:34:16 -0000
@@ -32,6 +32,8 @@
 #include "gdb_assert.h"
 #include "gdb_string.h"
 
+const struct exception exception_none = { 0, NO_ERROR, NULL };
+
 /* One should use catch_errors rather than manipulating these
    directly.  */
 #if defined(HAVE_SIGSETJMP)
Index: exceptions.h
===================================================================
RCS file: /cvs/src/src/gdb/exceptions.h,v
retrieving revision 1.2
diff -p -u -r1.2 exceptions.h
--- exceptions.h	13 Jan 2005 00:12:49 -0000	1.2
+++ exceptions.h	13 Jan 2005 02:34:16 -0000
@@ -62,6 +62,9 @@ struct exception
   char *message;
 };
 
+/* A pre-defined non-exception.  */
+extern const struct exception exception_none;
+
 /* Throw an exception (as described by "struct exception").  Will
    execute a LONG JUMP to the inner most containing exception handler
    established using catch_exceptions() (or similar).
Index: interps.c
===================================================================
RCS file: /cvs/src/src/gdb/interps.c,v
retrieving revision 1.8
diff -p -u -r1.8 interps.c
--- interps.c	13 Sep 2004 18:26:30 -0000	1.8
+++ interps.c	13 Jan 2005 02:34:17 -0000
@@ -42,6 +42,7 @@
 #include "gdb-events.h"
 #include "gdb_assert.h"
 #include "top.h"		/* For command_loop.  */
+#include "exceptions.h"
 
 struct interp
 {
@@ -304,14 +305,14 @@ interp_exec_p (struct interp *interp)
   return interp->procs->exec_proc != NULL;
 }
 
-int
+struct exception
 interp_exec (struct interp *interp, const char *command_str)
 {
   if (interp->procs->exec_proc != NULL)
     {
       return interp->procs->exec_proc (interp->data, command_str);
     }
-  return 0;
+  return exception_none;
 }
 
 /* A convenience routine that nulls out all the
@@ -398,7 +399,8 @@ interpreter_exec_cmd (char *args, int fr
 
   for (i = 1; i < nrules; i++)
     {
-      if (!interp_exec (interp_to_use, prules[i]))
+      struct exception e = interp_exec (interp_to_use, prules[i]);
+      if (!e.reason)
 	{
 	  interp_set (old_interp);
 	  interp_set_quiet (interp_to_use, old_quiet);
Index: interps.h
===================================================================
RCS file: /cvs/src/src/gdb/interps.h,v
retrieving revision 1.6
diff -p -u -r1.6 interps.h
--- interps.h	18 Feb 2004 19:01:36 -0000	1.6
+++ interps.h	13 Jan 2005 02:34:17 -0000
@@ -24,6 +24,8 @@
 #ifndef INTERPS_H
 #define INTERPS_H
 
+#include "exceptions.h"
+
 struct ui_out;
 struct interp;
 
@@ -31,14 +33,15 @@ extern int interp_resume (struct interp 
 extern int interp_suspend (struct interp *interp);
 extern int interp_prompt_p (struct interp *interp);
 extern int interp_exec_p (struct interp *interp);
-extern int interp_exec (struct interp *interp, const char *command);
+extern struct exception interp_exec (struct interp *interp,
+				     const char *command);
 extern int interp_quiet_p (struct interp *interp);
 
 typedef void *(interp_init_ftype) (void);
 typedef int (interp_resume_ftype) (void *data);
 typedef int (interp_suspend_ftype) (void *data);
 typedef int (interp_prompt_p_ftype) (void *data);
-typedef int (interp_exec_ftype) (void *data, const char *command);
+typedef struct exception (interp_exec_ftype) (void *data, const char *command);
 typedef void (interp_command_loop_ftype) (void *data);
 
 struct interp_procs
Index: cli/cli-interp.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-interp.c,v
retrieving revision 1.5
diff -p -u -r1.5 cli-interp.c
--- cli/cli-interp.c	12 Jan 2005 18:31:34 -0000	1.5
+++ cli/cli-interp.c	13 Jan 2005 02:34:17 -0000
@@ -34,9 +34,8 @@ struct ui_out *cli_uiout;
 /* These are the ui_out and the interpreter for the console interpreter. */
 
 /* Longjmp-safe wrapper for "execute_command" */
-static int do_captured_execute_command (struct ui_out *uiout, void *data);
-static enum gdb_rc safe_execute_command (struct ui_out *uiout, char *command,
-					 int from_tty);
+static struct exception safe_execute_command (struct ui_out *uiout,
+					      char *command, int from_tty);
 struct captured_execute_command_args
 {
   char *command;
@@ -93,11 +92,11 @@ cli_interpreter_display_prompt_p (void *
     return 1;
 }
 
-static int
+static struct exception
 cli_interpreter_exec (void *data, const char *command_str)
 {
-  int result;
   struct ui_file *old_stream;
+  struct exception result;
 
   /* FIXME: cagney/2003-02-01: Need to const char *propogate
      safe_execute_command.  */
@@ -115,23 +114,22 @@ cli_interpreter_exec (void *data, const 
   return result;
 }
 
-static int
+static void
 do_captured_execute_command (struct ui_out *uiout, void *data)
 {
   struct captured_execute_command_args *args =
     (struct captured_execute_command_args *) data;
   execute_command (args->command, args->from_tty);
-  return GDB_RC_OK;
 }
 
-static enum gdb_rc
+static struct exception
 safe_execute_command (struct ui_out *uiout, char *command, int from_tty)
 {
   struct captured_execute_command_args args;
   args.command = command;
   args.from_tty = from_tty;
-  return catch_exceptions (uiout, do_captured_execute_command, &args,
-			   NULL, RETURN_MASK_ALL);
+  return catch_exception (uiout, do_captured_execute_command, &args,
+			  RETURN_MASK_ALL);
 }
 
 
Index: mi/mi-interp.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-interp.c,v
retrieving revision 1.11
diff -p -u -r1.11 mi-interp.c
--- mi/mi-interp.c	13 Sep 2004 18:26:31 -0000	1.11
+++ mi/mi-interp.c	13 Jan 2005 02:34:17 -0000
@@ -27,7 +27,7 @@
 #include "inferior.h"
 #include "ui-out.h"
 #include "top.h"
-
+#include "exceptions.h"
 #include "mi-main.h"
 #include "mi-cmds.h"
 #include "mi-out.h"
@@ -145,13 +145,14 @@ mi_interpreter_suspend (void *data)
   return 1;
 }
 
-static int
+static struct exception
 mi_interpreter_exec (void *data, const char *command)
 {
+  static struct exception ok;
   char *tmp = alloca (strlen (command) + 1);
   strcpy (tmp, command);
   mi_execute_command_wrapper (tmp);
-  return 1;
+  return exception_none;
 }
 
 /* Never display the default gdb prompt in mi case.  */
@@ -236,12 +237,15 @@ mi_cmd_interpreter_exec (char *command, 
          since that is what the cli expects - before running the command,
          and then set it back to 0 when we are done. */
       sync_execution = 1;
-      if (interp_exec (interp_to_use, argv[i]) < 0)
-	{
-	  mi_error_message = error_last_message ();
-	  result = MI_CMD_ERROR;
-	  break;
-	}
+      {
+	struct exception e = interp_exec (interp_to_use, argv[i]);
+	if (e.reason < 0)
+	  {
+	    mi_error_message = e.message;
+	    result = MI_CMD_ERROR;
+	    break;
+	  }
+      }
       xfree (buff);
       do_exec_error_cleanups (ALL_CLEANUPS);
       sync_execution = 0;
Index: tui/tui-interp.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui-interp.c,v
retrieving revision 1.6
diff -p -u -r1.6 tui-interp.c
--- tui/tui-interp.c	12 Jan 2005 18:31:35 -0000	1.6
+++ tui/tui-interp.c	13 Jan 2005 02:34:17 -0000
@@ -106,7 +106,7 @@ tui_display_prompt_p (void *data)
     return 1;
 }
 
-static int
+static struct exception
 tui_exec (void *data, const char *command_str)
 {
   internal_error (__FILE__, __LINE__, "tui_exec called");

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