/* Core dump and executable file functions below target vector, for GDB.
- Copyright (C) 1986-2016 Free Software Foundation, Inc.
+ Copyright (C) 1986-2017 Free Software Foundation, Inc.
This file is part of GDB.
int siggy;
struct cleanup *old_chain;
char *temp;
- bfd *temp_bfd;
int scratch_chan;
int flags;
char *filename;
if (scratch_chan < 0)
perror_with_name (filename);
- temp_bfd = gdb_bfd_fopen (filename, gnutarget,
- write_files ? FOPEN_RUB : FOPEN_RB,
- scratch_chan);
+ gdb_bfd_ref_ptr temp_bfd (gdb_bfd_fopen (filename, gnutarget,
+ write_files ? FOPEN_RUB : FOPEN_RB,
+ scratch_chan));
if (temp_bfd == NULL)
perror_with_name (filename);
- if (!bfd_check_format (temp_bfd, bfd_core)
- && !gdb_check_format (temp_bfd))
+ if (!bfd_check_format (temp_bfd.get (), bfd_core)
+ && !gdb_check_format (temp_bfd.get ()))
{
/* Do it after the err msg */
/* FIXME: should be checking for errors from bfd_close (for one
thing, on error it does not free all the storage associated
with the bfd). */
- make_cleanup_bfd_unref (temp_bfd);
error (_("\"%s\" is not a core dump: %s"),
filename, bfd_errmsg (bfd_get_error ()));
}
do_cleanups (old_chain);
unpush_target (&core_ops);
- core_bfd = temp_bfd;
+ core_bfd = temp_bfd.release ();
old_chain = make_cleanup (core_close_cleanup, 0 /*ignore*/);
core_gdbarch = gdbarch_from_bfd (core_bfd);
them to core_vec->core_read_registers, as the register set numbered
WHICH.
- If inferior_ptid's lwp member is zero, do the single-threaded
- thing: look for a section named NAME. If inferior_ptid's lwp
+ If ptid's lwp member is zero, do the single-threaded
+ thing: look for a section named NAME. If ptid's lwp
member is non-zero, do the multi-threaded thing: look for a section
named "NAME/LWP", where LWP is the shortest ASCII decimal
- representation of inferior_ptid's lwp member.
+ representation of ptid's lwp member.
HUMAN_NAME is a human-readable name for the kind of registers the
NAME section contains, for use in error messages.
struct bfd_section *section;
bfd_size_type size;
char *contents;
+ bool variable_size_section = (regset != NULL
+ && regset->flags & REGSET_VARIABLE_SIZE);
+ ptid_t ptid = regcache_get_ptid (regcache);
xfree (section_name);
- if (ptid_get_lwp (inferior_ptid))
+ if (ptid_get_lwp (ptid))
section_name = xstrprintf ("%s/%ld", name,
- ptid_get_lwp (inferior_ptid));
+ ptid_get_lwp (ptid));
else
section_name = xstrdup (name);
warning (_("Section `%s' in core file too small."), section_name);
return;
}
- if (size != min_size && !(regset->flags & REGSET_VARIABLE_SIZE))
+ if (size != min_size && !variable_size_section)
{
warning (_("Unexpected size of section `%s' in core file."),
section_name);
return 0;
}
+/* Implement the to_remove_breakpoint method. */
+
+static int
+core_remove_breakpoint (struct target_ops *ops, struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt,
+ enum remove_bp_reason reason)
+{
+ return 0;
+}
+
/* Okay, let's be honest: threads gleaned from a core file aren't
exactly lively, are they? On the other hand, if we don't claim
return buf;
}
+static const char *
+core_thread_name (struct target_ops *self, struct thread_info *thr)
+{
+ if (core_gdbarch
+ && gdbarch_core_thread_name_p (core_gdbarch))
+ return gdbarch_core_thread_name (core_gdbarch, thr);
+ return NULL;
+}
+
static int
core_has_memory (struct target_ops *ops)
{
core_ops.to_xfer_partial = core_xfer_partial;
core_ops.to_files_info = core_files_info;
core_ops.to_insert_breakpoint = ignore;
- core_ops.to_remove_breakpoint = ignore;
+ core_ops.to_remove_breakpoint = core_remove_breakpoint;
core_ops.to_thread_alive = core_thread_alive;
core_ops.to_read_description = core_read_description;
core_ops.to_pid_to_str = core_pid_to_str;
+ core_ops.to_thread_name = core_thread_name;
core_ops.to_stratum = process_stratum;
core_ops.to_has_memory = core_has_memory;
core_ops.to_has_stack = core_has_stack;