aboutsummaryrefslogtreecommitdiff
path: root/gdb/stack.c
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2021-10-09 18:58:30 +0200
committerTom de Vries <tdevries@suse.de>2021-10-09 18:58:30 +0200
commit84a6adfd4c7bc9e99a270b8a111da7218a0e89a5 (patch)
tree2c9335466ee4a93d7d2b907a4e6f3f1a8fecd2af /gdb/stack.c
parentfa9ce2c143ce7ee6bc4f22a0577fe5c0858beddd (diff)
downloadgdb-84a6adfd4c7bc9e99a270b8a111da7218a0e89a5.zip
gdb-84a6adfd4c7bc9e99a270b8a111da7218a0e89a5.tar.gz
gdb-84a6adfd4c7bc9e99a270b8a111da7218a0e89a5.tar.bz2
[gdb] Make execute_command_to_string return string on throw
The pattern for using execute_command_to_string is: ... std::string output; output = execute_fn_to_string (fn, term_out); ... This results in a problem when using it in a try/catch: ... try { output = execute_fn_to_string (fn, term_out) } catch (const gdb_exception &e) { /* Use output. */ } ... If an expection was thrown during execute_fn_to_string, then the output remains unassigned, while it could be worthwhile to known what output was generated by gdb before the expection was thrown. Fix this by returning the string using a parameter instead: ... execute_fn_to_string (output, fn, term_out) ... Also add a variant without string parameter, to support places where the function is used while ignoring the result: ... execute_fn_to_string (fn, term_out) ... Tested on x86_64-linux.
Diffstat (limited to 'gdb/stack.c')
-rw-r--r--gdb/stack.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/stack.c b/gdb/stack.c
index 8b29ab5..bedadb0 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -3028,8 +3028,8 @@ frame_apply_command_count (const char *which_command,
set to the selected frame. */
scoped_restore_current_thread restore_fi_current_frame;
- cmd_result = execute_command_to_string
- (cmd, from_tty, gdb_stdout->term_out ());
+ execute_command_to_string
+ (cmd_result, cmd, from_tty, gdb_stdout->term_out ());
}
fi = get_selected_frame (_("frame apply "
"unable to get selected frame."));