Use ui_out_redirect_pop in more places
This changes ui_out_redirect_pop to also perform the redirection, and then updates several sites to use this, rather than explicit redirects.
This commit is contained in:
parent
55a6603404
commit
992aeed80b
7 changed files with 18 additions and 43 deletions
|
@ -14058,18 +14058,9 @@ save_breakpoints (const char *filename, int from_tty,
|
|||
{
|
||||
fp.puts (" commands\n");
|
||||
|
||||
current_uiout->redirect (&fp);
|
||||
try
|
||||
{
|
||||
ui_out_redirect_pop redir (current_uiout, &fp);
|
||||
print_command_lines (current_uiout, tp->commands.get (), 2);
|
||||
}
|
||||
catch (const gdb_exception &ex)
|
||||
{
|
||||
current_uiout->redirect (NULL);
|
||||
throw;
|
||||
}
|
||||
|
||||
current_uiout->redirect (NULL);
|
||||
fp.puts (" end\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -999,10 +999,10 @@ gdbscm_breakpoint_commands (SCM self)
|
|||
|
||||
string_file buf;
|
||||
|
||||
current_uiout->redirect (&buf);
|
||||
gdbscm_gdb_exception exc {};
|
||||
try
|
||||
{
|
||||
ui_out_redirect_pop redir (current_uiout, &buf);
|
||||
print_command_lines (current_uiout, breakpoint_commands (bp), 0);
|
||||
}
|
||||
catch (const gdb_exception &except)
|
||||
|
@ -1010,7 +1010,6 @@ gdbscm_breakpoint_commands (SCM self)
|
|||
exc = unpack (except);
|
||||
}
|
||||
|
||||
current_uiout->redirect (NULL);
|
||||
GDBSCM_HANDLE_GDB_EXCEPTION (exc);
|
||||
result = gdbscm_scm_from_c_string (buf.c_str ());
|
||||
|
||||
|
|
|
@ -607,8 +607,7 @@ ioscm_with_output_to_port_worker (SCM port, SCM thunk, enum oport oport,
|
|||
gdb_stderr = port_file.get ();
|
||||
else
|
||||
{
|
||||
current_uiout->redirect (port_file.get ());
|
||||
redirect_popper.emplace (current_uiout);
|
||||
redirect_popper.emplace (current_uiout, port_file.get ());
|
||||
|
||||
gdb_stdout = port_file.get ();
|
||||
}
|
||||
|
|
|
@ -816,7 +816,7 @@ mi_tsv_modified (const struct trace_state_variable *tsv)
|
|||
gdb_printf (mi->event_channel,
|
||||
"tsv-modified");
|
||||
|
||||
mi_uiout->redirect (mi->event_channel);
|
||||
ui_out_redirect_pop redir (mi_uiout, mi->event_channel);
|
||||
|
||||
mi_uiout->field_string ("name", tsv->name);
|
||||
mi_uiout->field_string ("initial",
|
||||
|
@ -824,8 +824,6 @@ mi_tsv_modified (const struct trace_state_variable *tsv)
|
|||
if (tsv->value_known)
|
||||
mi_uiout->field_string ("current", plongest (tsv->value));
|
||||
|
||||
mi_uiout->redirect (NULL);
|
||||
|
||||
gdb_flush (mi->event_channel);
|
||||
}
|
||||
}
|
||||
|
@ -844,7 +842,7 @@ mi_print_breakpoint_for_event (struct mi_interp *mi, breakpoint *bp)
|
|||
break if anything is output to mi_uiout prior to calling the
|
||||
breakpoint_created notifications. So, we use
|
||||
ui_out_redirect. */
|
||||
mi_uiout->redirect (mi->event_channel);
|
||||
ui_out_redirect_pop redir (mi_uiout, mi->event_channel);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -857,8 +855,6 @@ mi_print_breakpoint_for_event (struct mi_interp *mi, breakpoint *bp)
|
|||
{
|
||||
exception_print (gdb_stderr, ex);
|
||||
}
|
||||
|
||||
mi_uiout->redirect (NULL);
|
||||
}
|
||||
|
||||
/* Emit notification about a created breakpoint. */
|
||||
|
@ -1090,12 +1086,10 @@ mi_solib_loaded (struct so_list *solib)
|
|||
|
||||
gdb_printf (mi->event_channel, "library-loaded");
|
||||
|
||||
uiout->redirect (mi->event_channel);
|
||||
ui_out_redirect_pop redir (uiout, mi->event_channel);
|
||||
|
||||
mi_output_solib_attribs (uiout, solib);
|
||||
|
||||
uiout->redirect (NULL);
|
||||
|
||||
gdb_flush (mi->event_channel);
|
||||
}
|
||||
}
|
||||
|
@ -1118,7 +1112,7 @@ mi_solib_unloaded (struct so_list *solib)
|
|||
|
||||
gdb_printf (mi->event_channel, "library-unloaded");
|
||||
|
||||
uiout->redirect (mi->event_channel);
|
||||
ui_out_redirect_pop redir (uiout, mi->event_channel);
|
||||
|
||||
uiout->field_string ("id", solib->so_original_name);
|
||||
uiout->field_string ("target-name", solib->so_original_name);
|
||||
|
@ -1128,8 +1122,6 @@ mi_solib_unloaded (struct so_list *solib)
|
|||
uiout->field_fmt ("thread-group", "i%d", current_inferior ()->num);
|
||||
}
|
||||
|
||||
uiout->redirect (NULL);
|
||||
|
||||
gdb_flush (mi->event_channel);
|
||||
}
|
||||
}
|
||||
|
@ -1157,13 +1149,11 @@ mi_command_param_changed (const char *param, const char *value)
|
|||
|
||||
gdb_printf (mi->event_channel, "cmd-param-changed");
|
||||
|
||||
mi_uiout->redirect (mi->event_channel);
|
||||
ui_out_redirect_pop redir (mi_uiout, mi->event_channel);
|
||||
|
||||
mi_uiout->field_string ("param", param);
|
||||
mi_uiout->field_string ("value", value);
|
||||
|
||||
mi_uiout->redirect (NULL);
|
||||
|
||||
gdb_flush (mi->event_channel);
|
||||
}
|
||||
}
|
||||
|
@ -1193,7 +1183,7 @@ mi_memory_changed (struct inferior *inferior, CORE_ADDR memaddr,
|
|||
|
||||
gdb_printf (mi->event_channel, "memory-changed");
|
||||
|
||||
mi_uiout->redirect (mi->event_channel);
|
||||
ui_out_redirect_pop redir (mi_uiout, mi->event_channel);
|
||||
|
||||
mi_uiout->field_fmt ("thread-group", "i%d", inferior->num);
|
||||
mi_uiout->field_core_addr ("addr", target_gdbarch (), memaddr);
|
||||
|
@ -1210,8 +1200,6 @@ mi_memory_changed (struct inferior *inferior, CORE_ADDR memaddr,
|
|||
mi_uiout->field_string ("type", "code");
|
||||
}
|
||||
|
||||
mi_uiout->redirect (NULL);
|
||||
|
||||
gdb_flush (mi->event_channel);
|
||||
}
|
||||
}
|
||||
|
@ -1243,8 +1231,7 @@ mi_user_selected_context_changed (user_selected_what selection)
|
|||
|
||||
mi_uiout = top_level_interpreter ()->interp_ui_out ();
|
||||
|
||||
mi_uiout->redirect (mi->event_channel);
|
||||
ui_out_redirect_pop redirect_popper (mi_uiout);
|
||||
ui_out_redirect_pop redirect_popper (mi_uiout, mi->event_channel);
|
||||
|
||||
target_terminal::scoped_restore_terminal_state term_state;
|
||||
target_terminal::ours_for_output ();
|
||||
|
|
|
@ -548,19 +548,17 @@ bppy_get_commands (PyObject *self, void *closure)
|
|||
|
||||
string_file stb;
|
||||
|
||||
current_uiout->redirect (&stb);
|
||||
try
|
||||
{
|
||||
ui_out_redirect_pop redir (current_uiout, &stb);
|
||||
print_command_lines (current_uiout, breakpoint_commands (bp), 0);
|
||||
}
|
||||
catch (const gdb_exception &except)
|
||||
{
|
||||
current_uiout->redirect (NULL);
|
||||
gdbpy_convert_exception (except);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
current_uiout->redirect (NULL);
|
||||
return host_string_to_python_string (stb.c_str ()).release ();
|
||||
}
|
||||
|
||||
|
|
|
@ -735,8 +735,7 @@ execute_fn_to_ui_file (struct ui_file *file, std::function<void(void)> fn)
|
|||
scoped_restore save_async = make_scoped_restore (¤t_ui->async, 0);
|
||||
|
||||
{
|
||||
current_uiout->redirect (file);
|
||||
ui_out_redirect_pop redirect_popper (current_uiout);
|
||||
ui_out_redirect_pop redirect_popper (current_uiout, file);
|
||||
|
||||
scoped_restore save_stdout
|
||||
= make_scoped_restore (&gdb_stdout, file);
|
||||
|
|
|
@ -428,15 +428,17 @@ private:
|
|||
struct ui_out *m_uiout;
|
||||
};
|
||||
|
||||
/* On destruction, pop the last redirection by calling the uiout's
|
||||
/* On construction, redirect a uiout to a given stream. On
|
||||
destruction, pop the last redirection by calling the uiout's
|
||||
redirect method with a NULL parameter. */
|
||||
class ui_out_redirect_pop
|
||||
{
|
||||
public:
|
||||
|
||||
ui_out_redirect_pop (ui_out *uiout)
|
||||
ui_out_redirect_pop (ui_out *uiout, ui_file *stream)
|
||||
: m_uiout (uiout)
|
||||
{
|
||||
m_uiout->redirect (stream);
|
||||
}
|
||||
|
||||
~ui_out_redirect_pop ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue