This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/2] mi_load_progress: Restore current_uiout using a scoped_restore
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: <gdb-patches at sourceware dot org>
- Cc: Simon Marchi <simon dot marchi at ericsson dot com>
- Date: Sun, 10 Sep 2017 14:55:20 +0200
- Subject: [PATCH 2/2] mi_load_progress: Restore current_uiout using a scoped_restore
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=simon dot marchi at ericsson dot com;
- References: <1505048120-32214-1-git-send-email-simon.marchi@ericsson.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
Simply use a scoped_restore instead of manually saving and restoring
current_uiout.
I ran the tests in the gdb.mi directory, although I don't think that
there is a test that exercises this code. I tried the load and
-target-load when connected to gdbserver, and it seemed fine. I am not
sure how I can further test this.
gdb/ChangeLog:
* mi/mi-main.c (mi_load_progress): Restore current_uiout using a
scoped_restore.
---
gdb/mi/mi-main.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 0359dc1..c06ef18 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -2324,13 +2324,11 @@ mi_load_progress (const char *section_name,
static steady_clock::time_point last_update;
static char *previous_sect_name = NULL;
int new_section;
- struct ui_out *saved_uiout;
struct mi_interp *mi = (struct mi_interp *) current_interpreter ();
/* This function is called through deprecated_show_load_progress
which means uiout may not be correct. Fix it for the duration
of this function. */
- saved_uiout = current_uiout;
std::unique_ptr<ui_out> uiout;
@@ -2344,7 +2342,8 @@ mi_load_progress (const char *section_name,
else
return;
- current_uiout = uiout.get ();
+ scoped_restore save_uiout
+ = make_scoped_restore (¤t_uiout, uiout.get ());
new_section = (previous_sect_name ?
strcmp (previous_sect_name, section_name) : 1);
@@ -2386,8 +2385,6 @@ mi_load_progress (const char *section_name,
fputs_unfiltered ("\n", mi->raw_stdout);
gdb_flush (mi->raw_stdout);
}
-
- current_uiout = saved_uiout;
}
static void
--
2.7.4