/* Generate a core file for the inferior process.
- Copyright (C) 2001-2014 Free Software Foundation, Inc.
+ Copyright (C) 2001-2015 Free Software Foundation, Inc.
This file is part of GDB.
#include "completer.h"
#include "gcore.h"
#include "cli/cli-decode.h"
-#include "gdb_assert.h"
#include <fcntl.h>
#include "regcache.h"
#include "regset.h"
return obfd;
}
-/* write_gcore_file -- helper for gcore_command (exported).
- Compose and write the corefile data to the core file. */
-
+/* write_gcore_file_1 -- do the actual work of write_gcore_file. */
-void
-write_gcore_file (bfd *obfd)
+static void
+write_gcore_file_1 (bfd *obfd)
{
struct cleanup *cleanup;
void *note_data = NULL;
do_cleanups (cleanup);
}
+/* write_gcore_file -- helper for gcore_command (exported).
+ Compose and write the corefile data to the core file. */
+
+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);
+}
+
static void
do_bfd_delete_cleanup (void *arg)
{
- bfd *obfd = arg;
+ bfd *obfd = (bfd *) arg;
const char *filename = obfd->filename;
- gdb_bfd_unref (arg);
+ gdb_bfd_unref ((bfd *) arg);
unlink (filename);
}
int p_type = 0;
/* FIXME: these constants may only be applicable for ELF. */
- if (strncmp (bfd_section_name (obfd, osec), "load", 4) == 0)
+ if (startswith (bfd_section_name (obfd, osec), "load"))
p_type = PT_LOAD;
- else if (strncmp (bfd_section_name (obfd, osec), "note", 4) == 0)
+ else if (startswith (bfd_section_name (obfd, osec), "note"))
p_type = PT_NOTE;
else
p_type = PT_NULL;
gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read,
int write, int exec, int modified, void *data)
{
- bfd *obfd = data;
+ bfd *obfd = (bfd *) data;
asection *osec;
flagword flags = SEC_ALLOC | SEC_HAS_CONTENTS | SEC_LOAD;
return;
/* Only interested in "load" sections. */
- if (strncmp ("load", bfd_section_name (obfd, osec), 4) != 0)
+ if (!startswith (bfd_section_name (obfd, osec), "load"))
return;
size = min (total_size, MAX_COPY_BYTES);