From: Tom Tromey Date: Mon, 28 Jan 2019 17:51:01 +0000 (-0700) Subject: Use SCOPE_EXIT in write_gcore_file X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a7b1986e13c60f2a10721863ef684a18daccaaf7;p=binutils-gdb.git Use SCOPE_EXIT in write_gcore_file This replaces a TRY/CATCH in write_gcore_file with a use of SCOPE_EXIT instead. I find that this is simpler to understand. 2019-03-06 Tom Tromey * gcore.c (write_gcore_file): Use SCOPE_EXIT. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 066761d76d0..9e03e85e2c6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2019-03-06 Tom Tromey + + * gcore.c (write_gcore_file): Use SCOPE_EXIT. + 2019-03-06 Tom Tromey * utils.h (free_current_contents): Don't declare. diff --git a/gdb/gcore.c b/gdb/gcore.c index d47b2baec4e..21d9ee88671 100644 --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -37,6 +37,7 @@ #include #include "common/gdb_unlinker.h" #include "common/byte-vector.h" +#include "common/scope-exit.h" /* The largest amount of memory to read from the target at once. We must throttle it to limit the amount of memory used by GDB during @@ -114,24 +115,9 @@ write_gcore_file_1 (bfd *obfd) void write_gcore_file (bfd *obfd) { - struct gdb_exception except = exception_none; - target_prepare_to_generate_core (); - - TRY - { - write_gcore_file_1 (obfd); - } - CATCH (e, RETURN_MASK_ALL) - { - except = e; - } - END_CATCH - - target_done_generating_core (); - - if (except.reason < 0) - throw_exception (except); + SCOPE_EXIT { target_done_generating_core (); }; + write_gcore_file_1 (obfd); } /* gcore_command -- implements the 'gcore' command.