/* GDB CLI command scripting.
- Copyright (C) 1986-2018 Free Software Foundation, Inc.
+ Copyright (C) 1986-2019 Free Software Foundation, Inc.
This file is part of GDB.
#include "extension.h"
#include "interps.h"
#include "compile/compile.h"
-#include "common/gdb_string_view.h"
+#include "gdbsupport/gdb_string_view.h"
#include "python/python.h"
#include "guile/guile.h"
static void do_define_command (const char *comname, int from_tty,
const counted_command_line *commands);
-static char *read_next_line (void);
+static const char *read_next_line ();
/* Level of control structure when reading. */
static int control_level;
}
/* An if command. Recursively print both arms before
- continueing. */
+ continuing. */
if (list->control_type == if_control)
{
uiout->field_fmt (NULL, "if %s", list->line);
execute_user_command (struct cmd_list_element *c, const char *args)
{
counted_command_line cmdlines_copy;
- extern unsigned int max_user_call_depth;
/* Ensure that the user commands can't be deleted while they are
executing. */
enum command_control_type
execute_control_command (struct command_line *cmd, int from_tty)
{
+ if (!current_uiout->is_mi_like_p ())
+ return execute_control_command_1 (cmd, from_tty);
+
/* Make sure we use the console uiout. It's possible that we are executing
breakpoint commands while running the MI interpreter. */
interp *console = interp_lookup (current_ui, INTERP_CONSOLE);
recurse_read_control_structure whenever we need to read commands
from stdin. */
-static char *
-read_next_line (void)
+static const char *
+read_next_line ()
{
struct ui *ui = current_ui;
char *prompt_ptr, control_prompt[256];
if (validator)
{
- TRY
+ try
{
validator ((*command)->line);
}
- CATCH (ex, RETURN_MASK_ALL)
+ catch (const gdb_exception &ex)
{
free_command_lines (command);
- throw_exception (ex);
+ throw;
}
- END_CATCH
}
/* Nothing special. */
END_MESSAGE);
}
else
- {
- printf_unfiltered ("%s\n%s\n", prompt_arg, END_MESSAGE);
- gdb_flush (gdb_stdout);
- }
+ printf_unfiltered ("%s\n%s\n", prompt_arg, END_MESSAGE);
}
scoped_restore restore_line_number
= make_scoped_restore (&source_line_number, 0);
- scoped_restore resotre_file
- = make_scoped_restore (&source_file_name, file);
+ scoped_restore restore_file
+ = make_scoped_restore<std::string, const std::string &> (&source_file_name,
+ file);
scoped_restore save_async = make_scoped_restore (¤t_ui->async, 0);
- TRY
+ try
{
read_command_file (stream);
}
- CATCH (e, RETURN_MASK_ERROR)
+ catch (const gdb_exception_error &e)
{
/* Re-throw the error, but with the file name information
prepended. */
throw_error (e.error,
_("%s:%d: Error in sourced command file:\n%s"),
- source_file_name, source_line_number, e.message);
+ source_file_name.c_str (), source_line_number,
+ e.what ());
}
- END_CATCH
}
/* Print the definition of user command C to STREAM. Or, if C is a