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 | |
parent | 0ccf4211fdec30fab46a5552ecfbe8e7ca98d50f (diff) | |
download | gdb-a7b1986e13c60f2a10721863ef684a18daccaaf7.zip gdb-a7b1986e13c60f2a10721863ef684a18daccaaf7.tar.gz 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.
-rw-r--r-- | gdb/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/gcore.c | 20 |
2 files changed, 7 insertions, 17 deletions
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 <tom@tromey.com> + * gcore.c (write_gcore_file): Use SCOPE_EXIT. + +2019-03-06 Tom Tromey <tom@tromey.com> + * 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 <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. |