/* Core dump and executable file functions below target vector, for GDB.
- Copyright (C) 1986-2018 Free Software Foundation, Inc.
+ Copyright (C) 1986-2019 Free Software Foundation, Inc.
This file is part of GDB.
#include "arch-utils.h"
#include <signal.h>
#include <fcntl.h>
-#ifdef HAVE_SYS_FILE_H
-#include <sys/file.h> /* needed for F_OK and friends */
-#endif
#include "frame.h" /* required by inferior.h */
#include "inferior.h"
#include "infrun.h"
#include "command.h"
#include "bfd.h"
#include "target.h"
+#include "process-stratum-target.h"
#include "gdbcore.h"
#include "gdbthread.h"
#include "regcache.h"
#include "objfiles.h"
#include "gdb_bfd.h"
#include "completer.h"
-#include "filestuff.h"
+#include "common/filestuff.h"
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
N_("Use a core file as a target. Specify the filename of the core file.")
};
-class core_target final : public target_ops
+class core_target final : public process_stratum_target
{
public:
core_target ();
const char *thread_name (struct thread_info *) override;
+ bool has_all_memory () override { return false; }
bool has_memory () override;
bool has_stack () override;
bool has_registers () override;
+ bool has_execution (ptid_t) override { return false; }
+
bool info_proc (const char *, enum info_proc_what) override;
/* A few helpers. */
void get_core_register_section (struct regcache *regcache,
const struct regset *regset,
const char *name,
- int min_size,
+ int section_min_size,
int which,
const char *human_name,
bool required);
core_target::core_target ()
{
- to_stratum = process_stratum;
-
m_core_gdbarch = gdbarch_from_bfd (core_bfd);
/* Find a suitable core file handler to munch on core_bfd */
{
const char *p;
int siggy;
- struct cleanup *old_chain;
int scratch_chan;
int flags;
push_target (target);
target_holder.release ();
- /* Do this before acknowledging the inferior, so if
- post_create_inferior throws (can happen easilly if you're loading
- a core file with the wrong exec), we aren't left with threads
- from the previous inferior. */
- init_thread_list ();
-
inferior_ptid = null_ptid;
/* Need to flush the register cache (and the frame cache) from a
core_target::get_core_register_section (struct regcache *regcache,
const struct regset *regset,
const char *name,
- int min_size,
+ int section_min_size,
int which,
const char *human_name,
bool required)
}
size = bfd_section_size (core_bfd, section);
- if (size < min_size)
+ if (size < section_min_size)
{
warning (_("Section `%s' in core file too small."),
section_name.c_str ());
return;
}
- if (size != min_size && !variable_size_section)
+ if (size != section_min_size && !variable_size_section)
{
warning (_("Unexpected size of section `%s' in core file."),
section_name.c_str ());
register note section. */
static void
-get_core_registers_cb (const char *sect_name, int size,
+get_core_registers_cb (const char *sect_name, int supply_size, int collect_size,
const struct regset *regset,
const char *human_name, void *cb_data)
{
auto *data = (get_core_registers_cb_data *) cb_data;
bool required = false;
+ bool variable_size_section = (regset != NULL
+ && regset->flags & REGSET_VARIABLE_SIZE);
+
+ if (!variable_size_section)
+ gdb_assert (supply_size == collect_size);
if (strcmp (sect_name, ".reg") == 0)
{
/* The 'which' parameter is only used when no regset is provided.
Thus we just set it to -1. */
data->target->get_core_register_section (data->regcache, regset, sect_name,
- size, -1, human_name, required);
+ supply_size, -1, human_name,
+ required);
}
/* Get the registers out of a core file. This is the machine-