Use SCOPE_EXIT in write_gcore_file
authorTom Tromey <tom@tromey.com>
Mon, 28 Jan 2019 17:51:01 +0000 (10:51 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 6 Mar 2019 23:04:31 +0000 (16:04 -0700)
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.

gdb/ChangeLog
gdb/gcore.c

index 066761d76d05e3218e3f5020999d002702105ef9..9e03e85e2c6ee333c1df681515f358b38fc4e885 100644 (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>
 
        * utils.h (free_current_contents): Don't declare.
index d47b2baec4e9b424fb645e9fd6af033738534f6e..21d9ee886718e71b3ae6e6c180e53574bced6e52 100644 (file)
@@ -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.
This page took 0.02782 seconds and 4 git commands to generate.