diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/interps.c | 5 | ||||
-rw-r--r-- | gdb/interps.h | 10 | ||||
-rw-r--r-- | gdb/main.c | 2 | ||||
-rw-r--r-- | gdb/python/py-dap.c | 3 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/new-ui.exp | 5 | ||||
-rw-r--r-- | gdb/tui/tui-interp.c | 3 | ||||
-rw-r--r-- | gdb/ui.c | 2 |
7 files changed, 25 insertions, 5 deletions
diff --git a/gdb/interps.c b/gdb/interps.c index 94a982e..59c4ec5 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -187,13 +187,16 @@ interp_lookup (struct ui *ui, const char *name) /* See interps.h. */ void -set_top_level_interpreter (const char *name) +set_top_level_interpreter (const char *name, bool for_new_ui) { /* Find it. */ struct interp *interp = interp_lookup (current_ui, name); if (interp == NULL) error (_("Interpreter `%s' unrecognized"), name); + if (for_new_ui && !interp->supports_new_ui ()) + error (_("interpreter '%s' cannot be used with a new UI"), name); + /* Install it. */ interp_set (interp, true); } diff --git a/gdb/interps.h b/gdb/interps.h index bd435d7..8d80c00 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -84,6 +84,10 @@ public: virtual bool supports_command_editing () { return false; } + /* Returns true if this interpreter supports new UIs. */ + virtual bool supports_new_ui () const + { return true; } + const char *name () const { return m_name; } @@ -201,8 +205,10 @@ extern struct interp *interp_lookup (struct ui *ui, const char *name); /* Set the current UI's top level interpreter to the interpreter named NAME. Throws an error if NAME is not a known interpreter or the - interpreter fails to initialize. */ -extern void set_top_level_interpreter (const char *name); + interpreter fails to initialize. FOR_NEW_UI is true when called + from the 'new-ui' command, and causes an extra check to ensure the + interpreter is valid for a new UI. */ +extern void set_top_level_interpreter (const char *name, bool for_new_ui); /* Temporarily set the current interpreter, and reset it on destruction. */ @@ -1147,7 +1147,7 @@ captured_main_1 (struct captured_main_args *context) /* Install the default UI. All the interpreters should have had a look at things by now. Initialize the default interpreter. */ - set_top_level_interpreter (interpreter_p.c_str ()); + set_top_level_interpreter (interpreter_p.c_str (), false); /* The interpreter should have installed the real uiout by now. */ gdb_assert (current_uiout != temp_uiout.get ()); diff --git a/gdb/python/py-dap.c b/gdb/python/py-dap.c index 861514d..d5555c9 100644 --- a/gdb/python/py-dap.c +++ b/gdb/python/py-dap.c @@ -62,6 +62,9 @@ public: void pre_command_loop () override; + bool supports_new_ui () const override + { return false; } + private: std::unique_ptr<ui_out> m_ui_out; diff --git a/gdb/testsuite/gdb.base/new-ui.exp b/gdb/testsuite/gdb.base/new-ui.exp index 9716692..2dfcbf7 100644 --- a/gdb/testsuite/gdb.base/new-ui.exp +++ b/gdb/testsuite/gdb.base/new-ui.exp @@ -183,6 +183,11 @@ proc_with_prefix do_test_invalid_args {} { "Interpreter `bloop' unrecognized" \ "new-ui with bad interpreter name" + # Test that the TUI cannot be used for a new UI. + gdb_test "new-ui tui $extra_tty_name" \ + "interpreter 'tui' cannot be used with a new UI" \ + "new-ui with tui" + # Test that we can continue working normally. if ![runto_main] { return diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c index a75708b..7ebaf8f 100644 --- a/gdb/tui/tui-interp.c +++ b/gdb/tui/tui-interp.c @@ -50,6 +50,9 @@ public: void suspend () override; void exec (const char *command_str) override; ui_out *interp_ui_out () override; + + bool supports_new_ui () const override + { return false; } }; /* Cleanup the tui before exiting. */ @@ -224,7 +224,7 @@ new_ui_command (const char *args, int from_tty) current_ui = ui.get (); - set_top_level_interpreter (interpreter_name); + set_top_level_interpreter (interpreter_name, true); top_level_interpreter ()->pre_command_loop (); |