From: Tom Tromey Date: Mon, 28 Jan 2019 17:51:01 +0000 (-0700) Subject: Use SCOPE_EXIT in write_gcore_file X-Git-Tag: binutils-2_33~1912 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a7b1986e13c60f2a10721863ef684a18daccaaf7;p=platform%2Fupstream%2Fbinutils.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 066761d..9e03e85 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 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. * utils.c (free_current_contents): Remove. diff --git a/gdb/gcore.c b/gdb/gcore.c index d47b2ba..21d9ee8 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.