aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2024-09-24 13:57:55 +0200
committerTom de Vries <tdevries@suse.de>2024-09-24 13:57:55 +0200
commit58706ec737824257593cd5d1c1a4205302054209 (patch)
tree9bd3b41a47e8000993aaa124049d0cf84bb3ff2c /gdb/cli
parentf3f21aa9f90ccbcf73779b167aaee0fb6bbd3f4d (diff)
downloadbinutils-58706ec737824257593cd5d1c1a4205302054209.zip
binutils-58706ec737824257593cd5d1c1a4205302054209.tar.gz
binutils-58706ec737824257593cd5d1c1a4205302054209.tar.bz2
[gdb] Eliminate catch(...) in pipe_command
Remove duplicate code in pipe_command using SCOPE_EXIT. Tested on aarch64-linux. Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-cmds.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index fd8e277..8879d13 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1118,19 +1118,14 @@ pipe_command (const char *arg, int from_tty)
if (to_shell_command == nullptr)
error (_("Error launching \"%s\""), shell_command);
- try
- {
- stdio_file pipe_file (to_shell_command);
+ int exit_status;
+ {
+ SCOPE_EXIT { exit_status = pclose (to_shell_command); };
- execute_command_to_ui_file (&pipe_file, gdb_cmd.c_str (), from_tty);
- }
- catch (...)
- {
- pclose (to_shell_command);
- throw;
- }
+ stdio_file pipe_file (to_shell_command);
- int exit_status = pclose (to_shell_command);
+ execute_command_to_ui_file (&pipe_file, gdb_cmd.c_str (), from_tty);
+ }
if (exit_status < 0)
error (_("shell command \"%s\" failed: %s"), shell_command,