diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2019-03-13 13:25:43 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2019-03-13 13:26:37 -0400 |
commit | 8e5e5494f8653dd83ce1413d141e26c09dddab7b (patch) | |
tree | 273ab6f0a666474856f34ff1e0d6e617dd4506e7 /gdb/mi/mi-main.c | |
parent | 1dbade7441b9f32d6ba9aa1d44da5f28c44282fa (diff) | |
download | gdb-8e5e5494f8653dd83ce1413d141e26c09dddab7b.zip gdb-8e5e5494f8653dd83ce1413d141e26c09dddab7b.tar.gz gdb-8e5e5494f8653dd83ce1413d141e26c09dddab7b.tar.bz2 |
Factor out mi_ui_out instantiation logic
When re-reviewing this [1] I noticed that there were two spots encoding
the logic of instantiating an mi_ui_out object based on the interpreter
name ("mi", "mi1", "mi2" or "mi3"):
- mi_interp::init
- mi_load_progress
Both encode the logic to choose what the default version is when the
interpreter name is "mi". I had forgotten the one in mi_load_progress.
Therefore, I propose extracting that logic to a single function. I
started to add a new overload of mi_out_new, then realized the current
mi_out_new wasn't very useful, being just a thing wrapper around "new
mi_ui_out". So I ended up with just an mi_out_new function taking the
interp name as parameter.
I ran the gdb.mi tests, and verified manually the behavior (including
the load command).
[1] https://sourceware.org/ml/gdb-patches/2019-01/msg00427.html
gdb/ChangeLog:
* mi/mi-out.h (mi_out_new): Change parameter to const char *.
* mi/mi-out.c (mi_out_new): Change parameter to const char *,
instantiate mi_ui_out based on interpreter name.
* mi/mi-interp.c (mi_interp::init): Use the new mi_out_new.
* mi/mi-main.c (mi_load_progress): Likewise.
Diffstat (limited to 'gdb/mi/mi-main.c')
-rw-r--r-- | gdb/mi/mi-main.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 46bc928..f4e5e48 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -2173,16 +2173,8 @@ mi_load_progress (const char *section_name, which means uiout may not be correct. Fix it for the duration of this function. */ - std::unique_ptr<ui_out> uiout; - - if (current_interp_named_p (INTERP_MI) - || current_interp_named_p (INTERP_MI2)) - uiout.reset (mi_out_new (2)); - else if (current_interp_named_p (INTERP_MI1)) - uiout.reset (mi_out_new (1)); - else if (current_interp_named_p (INTERP_MI3)) - uiout.reset (mi_out_new (3)); - else + std::unique_ptr<ui_out> uiout (mi_out_new (current_interpreter ()->name ())); + if (uiout == nullptr) return; scoped_restore save_uiout |