diff options
author | Tom Tromey <tom@tromey.com> | 2019-01-28 10:51:01 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-03-06 16:04:31 -0700 |
commit | a7b1986e13c60f2a10721863ef684a18daccaaf7 (patch) | |
tree | c6eb0b745c9f69010b7137fa07461a14bf6d945c /gdb/gcore.c | |
parent | 0ccf4211fdec30fab46a5552ecfbe8e7ca98d50f (diff) | |
download | fsf-binutils-gdb-a7b1986e13c60f2a10721863ef684a18daccaaf7.zip fsf-binutils-gdb-a7b1986e13c60f2a10721863ef684a18daccaaf7.tar.gz fsf-binutils-gdb-a7b1986e13c60f2a10721863ef684a18daccaaf7.tar.bz2 |
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 <tom@tromey.com>
* gcore.c (write_gcore_file): Use SCOPE_EXIT.
Diffstat (limited to 'gdb/gcore.c')
-rw-r--r-- | gdb/gcore.c | 20 |
1 files changed, 3 insertions, 17 deletions
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 <algorithm> #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. |