[3/7] Eliminate catch(...) in execute_fn_to_string

Message ID 20240827140021.32660-3-tdevries@suse.de
State Committed
Headers
Series [1/7] Handle ^C in gnu_source_highlight_test |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom de Vries Aug. 27, 2024, 2 p.m. UTC
  Remove duplicate code in execute_fn_to_string using SCOPE_EXIT.

Tested on aarch64-linux.
---
 gdb/top.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
  

Comments

Tom Tromey Sept. 23, 2024, 5:48 p.m. UTC | #1
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> Remove duplicate code in execute_fn_to_string using SCOPE_EXIT.
Tom> Tested on aarch64-linux.

Ok.
Approved-By: Tom Tromey <tom@tromey.com>

Tom
  

Patch

diff --git a/gdb/top.c b/gdb/top.c
index d6bf1d448d5..eae54aae1ff 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -632,19 +632,9 @@  execute_fn_to_string (std::string &res, std::function<void(void)> fn,
 {
   string_file str_file (term_out);
 
-  try
-    {
-      execute_fn_to_ui_file (&str_file, fn);
-    }
-  catch (...)
-    {
-      /* Finally.  */
-      res = str_file.release ();
-      throw;
-    }
+  SCOPE_EXIT { res = str_file.release (); };
 
-  /* And finally.  */
-  res = str_file.release ();
+  execute_fn_to_ui_file (&str_file, fn);
 }
 
 /* See top.h.  */