Introduce and use gdb::unlinker
authorTom Tromey <tom@tromey.com>
Mon, 21 Nov 2016 23:26:20 +0000 (16:26 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 11 Jan 2017 02:14:11 +0000 (19:14 -0700)
commitbef155c3e8a995fcdb1c2ba5aba012eb653d9f30
tree50b429ebc20397db99dbb753e5ce9f72fe7e9fde
parent192b62ce0b4bb5c61188f570e127a26d2c32f716
Introduce and use gdb::unlinker

This introduces a new class, gdb::unlinker, that unlinks a file in the
destructor.  The user of this class has the option to preserve the
file instead, by calling the "keep" method.

This patch then changes the spots in gdb that use unlink in a cleanup
to use this class instead.  In one spot I went ahead and removed all
the cleanups from the function.

This fixes one latent bug -- do_bfd_delete_cleanup could refer to
freed memory, by decref'ing the BFD before using its filename.

2017-01-10  Tom Tromey  <tom@tromey.com>

* record-full.c (record_full_save_cleanups): Remove.
(record_full_save): Use gdb::unlinker.
* gcore.c (do_bfd_delete_cleanup): Remove.
(gcore_command): Use gdb::unlinker, unique_xmalloc_ptr.  Remove
cleanups.
* dwarf2read.c (unlink_if_set): Remove.
(write_psymtabs_to_index): Use gdb::unlinker.
* common/gdb_unlinker.h: New file.
gdb/ChangeLog
gdb/common/gdb_unlinker.h [new file with mode: 0644]
gdb/dwarf2read.c
gdb/gcore.c
gdb/record-full.c
This page took 0.039823 seconds and 4 git commands to generate.