Support R_SPARC_WDISP10 and R_SPARC_H34.
[external/binutils.git] / gdb / cli / cli-script.c
index 459ea5a..cfa1c77 100644 (file)
@@ -1,8 +1,6 @@
 /* GDB CLI command scripting.
 
-   Copyright (c) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008,
-   2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (c) 1986-2002, 2004-2012 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -35,6 +33,7 @@
 #include "gdb_assert.h"
 
 #include "python/python.h"
+#include "interps.h"
 
 /* Prototypes for local functions.  */
 
@@ -317,13 +316,13 @@ execute_user_command (struct cmd_list_element *c, char *args)
   static int user_call_depth = 0;
   extern int max_user_call_depth;
 
-  old_chain = setup_user_args (args);
-
   cmdlines = c->user_commands;
   if (cmdlines == 0)
     /* Null command */
     return;
 
+  old_chain = setup_user_args (args);
+
   if (++user_call_depth > max_user_call_depth)
     error (_("Max user call depth exceeded -- command aborted."));
 
@@ -338,6 +337,9 @@ execute_user_command (struct cmd_list_element *c, char *args)
      not confused with Insight.  */
   in_user_command = 1;
 
+  make_cleanup_restore_integer (&interpreter_async);
+  interpreter_async = 0;
+
   command_nest_depth++;
   while (cmdlines)
     {
@@ -598,6 +600,7 @@ void
 while_command (char *arg, int from_tty)
 {
   struct command_line *command = NULL;
+  struct cleanup *old_chain;
 
   control_level = 1;
   command = get_command_line (while_control, arg);
@@ -605,8 +608,13 @@ while_command (char *arg, int from_tty)
   if (command == NULL)
     return;
 
+  old_chain = make_cleanup_restore_integer (&interpreter_async);
+  interpreter_async = 0;
+
   execute_control_command_untraced (command);
   free_command_lines (&command);
+
+  do_cleanups (old_chain);
 }
 
 /* "if" command support.  Execute either the true or false arm depending
@@ -616,6 +624,7 @@ void
 if_command (char *arg, int from_tty)
 {
   struct command_line *command = NULL;
+  struct cleanup *old_chain;
 
   control_level = 1;
   command = get_command_line (if_control, arg);
@@ -623,8 +632,13 @@ if_command (char *arg, int from_tty)
   if (command == NULL)
     return;
 
+  old_chain = make_cleanup_restore_integer (&interpreter_async);
+  interpreter_async = 0;
+
   execute_control_command_untraced (command);
   free_command_lines (&command);
+
+  do_cleanups (old_chain);
 }
 
 /* Cleanup */
@@ -1589,19 +1603,6 @@ source_cleanup_lines (void *args)
   source_file_name = p->old_file;
 }
 
-struct wrapped_read_command_file_args
-{
-  FILE *stream;
-};
-
-static void
-wrapped_read_command_file (struct ui_out *uiout, void *data)
-{
-  struct wrapped_read_command_file_args *args = data;
-
-  read_command_file (args->stream);
-}
-
 /* Used to implement source_command.  */
 
 void
@@ -1613,11 +1614,9 @@ script_from_file (FILE *stream, const char *file)
   if (stream == NULL)
     internal_error (__FILE__, __LINE__, _("called with NULL file pointer!"));
 
-  old_cleanups = make_cleanup_fclose (stream);
-
   old_lines.old_line = source_line_number;
   old_lines.old_file = source_file_name;
-  make_cleanup (source_cleanup_lines, &old_lines);
+  old_cleanups = make_cleanup (source_cleanup_lines, &old_lines);
   source_line_number = 0;
   source_file_name = file;
   /* This will get set every time we read a line.  So it won't stay ""
@@ -1625,12 +1624,12 @@ script_from_file (FILE *stream, const char *file)
   error_pre_print = "";
 
   {
-    struct gdb_exception e;
-    struct wrapped_read_command_file_args args;
+    volatile struct gdb_exception e;
 
-    args.stream = stream;
-    e = catch_exception (uiout, wrapped_read_command_file, &args,
-                        RETURN_MASK_ERROR);
+    TRY_CATCH (e, RETURN_MASK_ERROR)
+      {
+       read_command_file (stream);
+      }
     switch (e.reason)
       {
       case 0:
@@ -1641,7 +1640,6 @@ script_from_file (FILE *stream, const char *file)
        throw_error (e.error,
                     _("%s:%d: Error in sourced command file:\n%s"),
                     source_file_name, source_line_number, e.message);
-       break;  /* lint */
       default:
        internal_error (__FILE__, __LINE__, _("bad reason"));
       }
@@ -1675,7 +1673,7 @@ show_user_1 (struct cmd_list_element *c, char *prefix, char *name,
     return;
   fprintf_filtered (stream, "User command \"%s%s\":\n", prefix, name);
 
-  print_command_lines (uiout, cmdlines, 1);
+  print_command_lines (current_uiout, cmdlines, 1);
   fputs_filtered ("\n", stream);
 }