[v2,21/22] Use SCOPE_EXIT in write_gcore_file
Commit Message
This replaces a try/catch in write_gcore_file with a use of SCOPE_EXIT
instead. I find that this is simpler to understand.
gdb/ChangeLog
2019-02-27 Tom Tromey <tom@tromey.com>
* gcore.c (write_gcore_file): Use SCOPE_EXIT.
---
gdb/ChangeLog | 4 ++++
gdb/gcore.c | 19 +++----------------
2 files changed, 7 insertions(+), 16 deletions(-)
Comments
On 02/27/2019 08:18 PM, Tom Tromey wrote:
> This replaces a try/catch in write_gcore_file with a use of SCOPE_EXIT
> instead. I find that this is simpler to understand.
>
> gdb/ChangeLog
> 2019-02-27 Tom Tromey <tom@tromey.com>
>
> * gcore.c (write_gcore_file): Use SCOPE_EXIT.
You could rebase this on current master and push it in, to get it
out of the way.
You could also merge patches #1-#13, the cleanup-elimination patches
until the TRY/CATCH parts. I'll need a bit more time to comment
on those TRY/CATCH parts, so I've skipped them tonight.
Thanks,
Pedro Alves
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
Pedro> You could rebase this on current master and push it in, to get it
Pedro> out of the way.
Unless there's a need, I'd rather leave it as-is, since rebasing it
earlier means tweaking other patches earlier in the series.
Pedro> You could also merge patches #1-#13, the cleanup-elimination patches
Pedro> until the TRY/CATCH parts. I'll need a bit more time to comment
Pedro> on those TRY/CATCH parts, so I've skipped them tonight.
I don't mind waiting, it's not a super rush to get this in.
Thanks for looking through these.
Tom
>> I don't mind waiting, it's not a super rush to get this in.
>> Thanks for looking through these.
Pedro> I'd think getting the cleanups elimination patches in would be
Pedro> good for the fact that it makes it impossible for anyone else to
Pedro> end up adding new cleanups meanwhile. And, it makes the remainder
Pedro> patches a smaller self-contained series; any new repost would be
Pedro> much smaller.
Ok, I will try to do that either tonight or tomorrow.
Tom
Tom> Ok, I will try to do that either tonight or tomorrow.
Those are in now, let me know if there are problems.
thanks,
Tom
@@ -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,23 +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 (const struct gdb_exception &e)
- {
- except = e;
- }
-
- 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.