Factor out mi_ui_out instantiation logic
authorSimon Marchi <simon.marchi@polymtl.ca>
Wed, 13 Mar 2019 17:25:43 +0000 (13:25 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 13 Mar 2019 17:26:37 +0000 (13:26 -0400)
commit8e5e5494f8653dd83ce1413d141e26c09dddab7b
tree273ab6f0a666474856f34ff1e0d6e617dd4506e7
parent1dbade7441b9f32d6ba9aa1d44da5f28c44282fa
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.
gdb/ChangeLog
gdb/mi/mi-interp.c
gdb/mi/mi-main.c
gdb/mi/mi-out.c
gdb/mi/mi-out.h
This page took 0.033377 seconds and 4 git commands to generate.