gdb/
* gcore.c (do_bfd_delete_cleanup): New function. (gcore_command): Use it. Discard the cleanup after success. (gcore_copy_callback): Delete dead code.
This commit is contained in:
parent
e76ab67fec
commit
14d1346bd3
|
@ -1,3 +1,9 @@
|
||||||
|
2010-02-16 Daniel Jacobowitz <dan@codesourcery.com>
|
||||||
|
|
||||||
|
* gcore.c (do_bfd_delete_cleanup): New function.
|
||||||
|
(gcore_command): Use it. Discard the cleanup after success.
|
||||||
|
(gcore_copy_callback): Delete dead code.
|
||||||
|
|
||||||
2010-02-16 Daniel Jacobowitz <dan@codesourcery.com>
|
2010-02-16 Daniel Jacobowitz <dan@codesourcery.com>
|
||||||
|
|
||||||
* symfile.c (addr_info_make_relative): Always use
|
* symfile.c (addr_info_make_relative): Always use
|
||||||
|
|
22
gdb/gcore.c
22
gdb/gcore.c
|
@ -102,6 +102,16 @@ write_gcore_file (bfd *obfd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_bfd_delete_cleanup (void *arg)
|
||||||
|
{
|
||||||
|
bfd *obfd = arg;
|
||||||
|
const char *filename = obfd->filename;
|
||||||
|
|
||||||
|
bfd_close (arg);
|
||||||
|
unlink (filename);
|
||||||
|
}
|
||||||
|
|
||||||
/* gcore_command -- implements the 'gcore' command.
|
/* gcore_command -- implements the 'gcore' command.
|
||||||
Generate a core file from the inferior process. */
|
Generate a core file from the inferior process. */
|
||||||
|
|
||||||
|
@ -132,8 +142,8 @@ gcore_command (char *args, int from_tty)
|
||||||
/* Open the output file. */
|
/* Open the output file. */
|
||||||
obfd = create_gcore_bfd (corefilename);
|
obfd = create_gcore_bfd (corefilename);
|
||||||
|
|
||||||
/* Need a cleanup that will close the file (FIXME: delete it?). */
|
/* Need a cleanup that will close and delete the file. */
|
||||||
old_chain = make_cleanup_bfd_close (obfd);
|
old_chain = make_cleanup (do_bfd_delete_cleanup, obfd);
|
||||||
|
|
||||||
/* Call worker function. */
|
/* Call worker function. */
|
||||||
write_gcore_file (obfd);
|
write_gcore_file (obfd);
|
||||||
|
@ -141,9 +151,8 @@ gcore_command (char *args, int from_tty)
|
||||||
/* Succeeded. */
|
/* Succeeded. */
|
||||||
fprintf_filtered (gdb_stdout, "Saved corefile %s\n", corefilename);
|
fprintf_filtered (gdb_stdout, "Saved corefile %s\n", corefilename);
|
||||||
|
|
||||||
/* Clean-ups will close the output file and free malloc memory. */
|
discard_cleanups (old_chain);
|
||||||
do_cleanups (old_chain);
|
bfd_close (obfd);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long
|
static unsigned long
|
||||||
|
@ -521,9 +530,6 @@ gcore_copy_callback (bfd *obfd, asection *osec, void *ignored)
|
||||||
|
|
||||||
size = min (total_size, MAX_COPY_BYTES);
|
size = min (total_size, MAX_COPY_BYTES);
|
||||||
memhunk = xmalloc (size);
|
memhunk = xmalloc (size);
|
||||||
/* ??? This is crap since xmalloc should never return NULL. */
|
|
||||||
if (memhunk == NULL)
|
|
||||||
error (_("Not enough memory to create corefile."));
|
|
||||||
old_chain = make_cleanup (xfree, memhunk);
|
old_chain = make_cleanup (xfree, memhunk);
|
||||||
|
|
||||||
while (total_size > 0)
|
while (total_size > 0)
|
||||||
|
|
Loading…
Reference in New Issue