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.
This commit is contained in:
Tom Tromey
2019-01-28 10:51:01 -07:00
parent 0ccf4211fd
commit a7b1986e13
2 changed files with 7 additions and 17 deletions

View File

@@ -1,3 +1,7 @@
2019-03-06 Tom Tromey <tom@tromey.com>
* gcore.c (write_gcore_file): Use SCOPE_EXIT.
2019-03-06 Tom Tromey <tom@tromey.com> 2019-03-06 Tom Tromey <tom@tromey.com>
* utils.h (free_current_contents): Don't declare. * utils.h (free_current_contents): Don't declare.

View File

@@ -37,6 +37,7 @@
#include <algorithm> #include <algorithm>
#include "common/gdb_unlinker.h" #include "common/gdb_unlinker.h"
#include "common/byte-vector.h" #include "common/byte-vector.h"
#include "common/scope-exit.h"
/* The largest amount of memory to read from the target at once. We /* 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 must throttle it to limit the amount of memory used by GDB during
@@ -114,24 +115,9 @@ write_gcore_file_1 (bfd *obfd)
void void
write_gcore_file (bfd *obfd) write_gcore_file (bfd *obfd)
{ {
struct gdb_exception except = exception_none;
target_prepare_to_generate_core (); target_prepare_to_generate_core ();
SCOPE_EXIT { target_done_generating_core (); };
TRY
{
write_gcore_file_1 (obfd); 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);
} }
/* gcore_command -- implements the 'gcore' command. /* gcore_command -- implements the 'gcore' command.