Introduce process_stratum_target
This adds a base class that all process_stratum targets inherit from. default_thread_address_space/default_thread_architecture only make sense for process_stratum targets, so they are transformed to process_stratum_target methods/overrides. gdb/ChangeLog: 2018-11-30 Pedro Alves <palves@redhat.com> * Makefile.in (COMMON_SFILES): Add process-stratum-target.c. * bsd-kvm.c: Include "process-stratum-target.h". (bsd_kvm_target): Now inherits from process_stratum_target. (bsd_kvm_target::bsd_kvm_target): Default it. * corelow.c: Include "process-stratum-target.h". (core_target): Now inherits from process_stratum_target. (core_target::core_target): Don't set to_stratum here. * inf-child.c (inf_child_target::inf_child_target): Delete. * inf-child.h: Include "process-stratum-target.h". (inf_child_target): Inherit from process_stratum_target. (inf_child_target) <inf_child_target>: Default it. <can_async_p, supports_non_stop, supports_disable_randomization>: Delete overrides. * process-stratum-target.c: New file. * process-stratum-target.h: New file. * remote-sim.c: Include "process-stratum-target.h". (gdbsim_target): Inherit from process_stratum_target. <gdbsim_target>: Default it. * remote.c: Include "process-stratum-target.h". (remote_target): Inherit from process_stratum_target. <remote_target>: Default it. * target.c (default_thread_address_space) (default_thread_architecture): Delete. * target.h (target_ops) <thread_architecture>: Now returns NULL by default. <thread_address_space>: Ditto. * test-target.h: Include "process-stratum-target.h" instead of "target.h". (test_target_ops): Inherit from process_stratum_target. <test_target_ops>: Default it. * tracefile.c (tracefile_target::tracefile_target): Delete. * tracefile.h: Include "process-stratum-target.h". (tracefile_target): Inherit from process_stratum_target. <tracefile_target>: Default it. * target-delegates.c: Regenerate.
This commit is contained in:
parent
c180496d2a
commit
3b3dac9b3f
|
@ -1,3 +1,41 @@
|
|||
2018-11-30 Pedro Alves <palves@redhat.com>
|
||||
|
||||
* Makefile.in (COMMON_SFILES): Add process-stratum-target.c.
|
||||
* bsd-kvm.c: Include "process-stratum-target.h".
|
||||
(bsd_kvm_target): Now inherits from process_stratum_target.
|
||||
(bsd_kvm_target::bsd_kvm_target): Default it.
|
||||
* corelow.c: Include "process-stratum-target.h".
|
||||
(core_target): Now inherits from process_stratum_target.
|
||||
(core_target::core_target): Don't set to_stratum here.
|
||||
* inf-child.c (inf_child_target::inf_child_target): Delete.
|
||||
* inf-child.h: Include "process-stratum-target.h".
|
||||
(inf_child_target): Inherit from process_stratum_target.
|
||||
(inf_child_target) <inf_child_target>: Default it.
|
||||
<can_async_p, supports_non_stop, supports_disable_randomization>:
|
||||
Delete overrides.
|
||||
* process-stratum-target.c: New file.
|
||||
* process-stratum-target.h: New file.
|
||||
* remote-sim.c: Include "process-stratum-target.h".
|
||||
(gdbsim_target): Inherit from process_stratum_target.
|
||||
<gdbsim_target>: Default it.
|
||||
* remote.c: Include "process-stratum-target.h".
|
||||
(remote_target): Inherit from process_stratum_target.
|
||||
<remote_target>: Default it.
|
||||
* target.c (default_thread_address_space)
|
||||
(default_thread_architecture): Delete.
|
||||
* target.h (target_ops) <thread_architecture>: Now returns NULL by
|
||||
default.
|
||||
<thread_address_space>: Ditto.
|
||||
* test-target.h: Include "process-stratum-target.h" instead of
|
||||
"target.h".
|
||||
(test_target_ops): Inherit from process_stratum_target.
|
||||
<test_target_ops>: Default it.
|
||||
* tracefile.c (tracefile_target::tracefile_target): Delete.
|
||||
* tracefile.h: Include "process-stratum-target.h".
|
||||
(tracefile_target): Inherit from process_stratum_target.
|
||||
<tracefile_target>: Default it.
|
||||
* target-delegates.c: Regenerate.
|
||||
|
||||
2018-11-30 Pedro Alves <palves@redhat.com>
|
||||
|
||||
* Makefile.in (COMMON_SFILES): Add test-target.c.
|
||||
|
|
|
@ -1075,6 +1075,7 @@ COMMON_SFILES = \
|
|||
parse.c \
|
||||
printcmd.c \
|
||||
probe.c \
|
||||
process-stratum-target.c \
|
||||
producer.c \
|
||||
progspace.c \
|
||||
progspace-and-thread.c \
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "frame.h"
|
||||
#include "regcache.h"
|
||||
#include "target.h"
|
||||
#include "process-stratum-target.h"
|
||||
#include "value.h"
|
||||
#include "gdbcore.h"
|
||||
#include "inferior.h" /* for get_exec_file */
|
||||
|
@ -71,11 +72,10 @@ static const target_info bsd_kvm_target_info = {
|
|||
Optionally specify the filename of a core dump.")
|
||||
};
|
||||
|
||||
class bsd_kvm_target final : public target_ops
|
||||
class bsd_kvm_target final : public process_stratum_target
|
||||
{
|
||||
public:
|
||||
bsd_kvm_target ()
|
||||
{ this->to_stratum = process_stratum; }
|
||||
bsd_kvm_target () = default;
|
||||
|
||||
const target_info &info () const override
|
||||
{ return bsd_kvm_target_info; }
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "command.h"
|
||||
#include "bfd.h"
|
||||
#include "target.h"
|
||||
#include "process-stratum-target.h"
|
||||
#include "gdbcore.h"
|
||||
#include "gdbthread.h"
|
||||
#include "regcache.h"
|
||||
|
@ -61,7 +62,7 @@ static const target_info core_target_info = {
|
|||
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 ();
|
||||
|
@ -132,8 +133,6 @@ private: /* per-core data */
|
|||
|
||||
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 */
|
||||
|
|
|
@ -439,11 +439,6 @@ inf_child_target::can_use_agent ()
|
|||
return agent_loaded_p ();
|
||||
}
|
||||
|
||||
inf_child_target::inf_child_target ()
|
||||
{
|
||||
this->to_stratum = process_stratum;
|
||||
}
|
||||
|
||||
/* See inf-child.h. */
|
||||
|
||||
void
|
||||
|
|
|
@ -21,15 +21,16 @@
|
|||
#define INF_CHILD_H
|
||||
|
||||
#include "target.h"
|
||||
#include "process-stratum-target.h"
|
||||
|
||||
/* A prototype child target. The client can override it with local
|
||||
methods. */
|
||||
|
||||
class inf_child_target
|
||||
: public memory_breakpoint_target<target_ops>
|
||||
: public memory_breakpoint_target<process_stratum_target>
|
||||
{
|
||||
public:
|
||||
inf_child_target ();
|
||||
inf_child_target () = default;
|
||||
~inf_child_target () override = 0;
|
||||
|
||||
const target_info &info () const override;
|
||||
|
@ -69,12 +70,6 @@ public:
|
|||
|
||||
void post_attach (int) override;
|
||||
|
||||
/* We must default these because they must be implemented by any
|
||||
target that can run. */
|
||||
bool can_async_p () override { return false; }
|
||||
bool supports_non_stop () override { return false; }
|
||||
bool supports_disable_randomization () override { return false; }
|
||||
|
||||
char *pid_to_exec_file (int pid) override;
|
||||
|
||||
bool has_all_memory () override;
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/* Abstract base class inherited by all process_stratum targets
|
||||
|
||||
Copyright (C) 2018 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GDB.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "defs.h"
|
||||
#include "process-stratum-target.h"
|
||||
#include "inferior.h"
|
||||
|
||||
process_stratum_target::~process_stratum_target ()
|
||||
{
|
||||
}
|
||||
|
||||
struct address_space *
|
||||
process_stratum_target::thread_address_space (ptid_t ptid)
|
||||
{
|
||||
/* Fall-back to the "main" address space of the inferior. */
|
||||
inferior *inf = find_inferior_ptid (ptid);
|
||||
|
||||
if (inf == NULL || inf->aspace == NULL)
|
||||
internal_error (__FILE__, __LINE__,
|
||||
_("Can't determine the current "
|
||||
"address space of thread %s\n"),
|
||||
target_pid_to_str (ptid));
|
||||
|
||||
return inf->aspace;
|
||||
}
|
||||
|
||||
struct gdbarch *
|
||||
process_stratum_target::thread_architecture (ptid_t ptid)
|
||||
{
|
||||
inferior *inf = find_inferior_ptid (ptid);
|
||||
gdb_assert (inf != NULL);
|
||||
return inf->gdbarch;
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/* Abstract base class inherited by all process_stratum targets
|
||||
|
||||
Copyright (C) 2018 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GDB.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef PROCESS_STRATUM_TARGET_H
|
||||
#define PROCESS_STRATUM_TARGET_H
|
||||
|
||||
#include "target.h"
|
||||
|
||||
/* Abstract base class inherited by all process_stratum targets. */
|
||||
|
||||
class process_stratum_target : public target_ops
|
||||
{
|
||||
public:
|
||||
process_stratum_target ()
|
||||
{
|
||||
to_stratum = process_stratum;
|
||||
}
|
||||
|
||||
~process_stratum_target () override = 0;
|
||||
|
||||
/* We must default these because they must be implemented by any
|
||||
target that can run. */
|
||||
bool can_async_p () override { return false; }
|
||||
bool supports_non_stop () override { return false; }
|
||||
bool supports_disable_randomization () override { return false; }
|
||||
|
||||
/* This default implementation returns the inferior's address
|
||||
space. */
|
||||
struct address_space *thread_address_space (ptid_t ptid) override;
|
||||
|
||||
/* This default implementation always returns target_gdbarch (). */
|
||||
struct gdbarch *thread_architecture (ptid_t ptid) override;
|
||||
};
|
||||
|
||||
#endif /* !defined (PROCESS_STRATUM_TARGET_H) */
|
|
@ -31,6 +31,7 @@
|
|||
#include <setjmp.h>
|
||||
#include "terminal.h"
|
||||
#include "target.h"
|
||||
#include "process-stratum-target.h"
|
||||
#include "gdbcore.h"
|
||||
#include "gdb/callback.h"
|
||||
#include "gdb/remote-sim.h"
|
||||
|
@ -82,10 +83,9 @@ static const target_info gdbsim_target_info = {
|
|||
};
|
||||
|
||||
struct gdbsim_target final
|
||||
: public memory_breakpoint_target<target_ops>
|
||||
: public memory_breakpoint_target<process_stratum_target>
|
||||
{
|
||||
gdbsim_target ()
|
||||
{ to_stratum = process_stratum; }
|
||||
gdbsim_target () = default;
|
||||
|
||||
const target_info &info () const override
|
||||
{ return gdbsim_target_info; }
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "bfd.h"
|
||||
#include "symfile.h"
|
||||
#include "target.h"
|
||||
#include "process-stratum-target.h"
|
||||
/*#include "terminal.h" */
|
||||
#include "gdbcmd.h"
|
||||
#include "objfiles.h"
|
||||
|
@ -404,13 +405,10 @@ static const target_info remote_target_info = {
|
|||
remote_doc
|
||||
};
|
||||
|
||||
class remote_target : public target_ops
|
||||
class remote_target : public process_stratum_target
|
||||
{
|
||||
public:
|
||||
remote_target ()
|
||||
{
|
||||
to_stratum = process_stratum;
|
||||
}
|
||||
remote_target () = default;
|
||||
~remote_target () override;
|
||||
|
||||
const target_info &info () const override
|
||||
|
|
|
@ -2808,7 +2808,7 @@ target_ops::thread_architecture (ptid_t arg0)
|
|||
struct gdbarch *
|
||||
dummy_target::thread_architecture (ptid_t arg0)
|
||||
{
|
||||
return default_thread_architecture (this, arg0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct gdbarch *
|
||||
|
@ -2834,7 +2834,7 @@ target_ops::thread_address_space (ptid_t arg0)
|
|||
struct address_space *
|
||||
dummy_target::thread_address_space (ptid_t arg0)
|
||||
{
|
||||
return default_thread_address_space (this, arg0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct address_space *
|
||||
|
|
30
gdb/target.c
30
gdb/target.c
|
@ -82,16 +82,10 @@ static int default_verify_memory (struct target_ops *self,
|
|||
const gdb_byte *data,
|
||||
CORE_ADDR memaddr, ULONGEST size);
|
||||
|
||||
static struct address_space *default_thread_address_space
|
||||
(struct target_ops *self, ptid_t ptid);
|
||||
|
||||
static void tcomplain (void) ATTRIBUTE_NORETURN;
|
||||
|
||||
static struct target_ops *find_default_run_target (const char *);
|
||||
|
||||
static struct gdbarch *default_thread_architecture (struct target_ops *ops,
|
||||
ptid_t ptid);
|
||||
|
||||
static int dummy_find_memory_regions (struct target_ops *self,
|
||||
find_memory_region_ftype ignore1,
|
||||
void *ignore2);
|
||||
|
@ -2567,22 +2561,6 @@ target_get_osdata (const char *type)
|
|||
return target_read_stralloc (t, TARGET_OBJECT_OSDATA, type);
|
||||
}
|
||||
|
||||
static struct address_space *
|
||||
default_thread_address_space (struct target_ops *self, ptid_t ptid)
|
||||
{
|
||||
struct inferior *inf;
|
||||
|
||||
/* Fall-back to the "main" address space of the inferior. */
|
||||
inf = find_inferior_ptid (ptid);
|
||||
|
||||
if (inf == NULL || inf->aspace == NULL)
|
||||
internal_error (__FILE__, __LINE__,
|
||||
_("Can't determine the current "
|
||||
"address space of thread %s\n"),
|
||||
target_pid_to_str (ptid));
|
||||
|
||||
return inf->aspace;
|
||||
}
|
||||
|
||||
/* Determine the current address space of thread PTID. */
|
||||
|
||||
|
@ -3180,14 +3158,6 @@ default_watchpoint_addr_within_range (struct target_ops *target,
|
|||
return addr >= start && addr < start + length;
|
||||
}
|
||||
|
||||
static struct gdbarch *
|
||||
default_thread_architecture (struct target_ops *ops, ptid_t ptid)
|
||||
{
|
||||
inferior *inf = find_inferior_ptid (ptid);
|
||||
gdb_assert (inf != NULL);
|
||||
return inf->gdbarch;
|
||||
}
|
||||
|
||||
/* See target.h. */
|
||||
|
||||
target_ops *
|
||||
|
|
13
gdb/target.h
13
gdb/target.h
|
@ -882,18 +882,13 @@ struct target_ops
|
|||
to_thread_architecture would return SPU, otherwise PPC32 or PPC64).
|
||||
This is architecture used to perform decr_pc_after_break adjustment,
|
||||
and also determines the frame architecture of the innermost frame.
|
||||
ptrace operations need to operate according to target_gdbarch ().
|
||||
|
||||
The default implementation always returns target_gdbarch (). */
|
||||
ptrace operations need to operate according to target_gdbarch (). */
|
||||
virtual struct gdbarch *thread_architecture (ptid_t)
|
||||
TARGET_DEFAULT_FUNC (default_thread_architecture);
|
||||
TARGET_DEFAULT_RETURN (NULL);
|
||||
|
||||
/* Determine current address space of thread PTID.
|
||||
|
||||
The default implementation always returns the inferior's
|
||||
address space. */
|
||||
/* Determine current address space of thread PTID. */
|
||||
virtual struct address_space *thread_address_space (ptid_t)
|
||||
TARGET_DEFAULT_FUNC (default_thread_address_space);
|
||||
TARGET_DEFAULT_RETURN (NULL);
|
||||
|
||||
/* Target file operations. */
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef TEST_TARGET_H
|
||||
#define TEST_TARGET_H
|
||||
|
||||
#include "target.h"
|
||||
#include "process-stratum-target.h"
|
||||
|
||||
#if GDB_SELF_TEST
|
||||
namespace selftests {
|
||||
|
@ -28,14 +28,10 @@ namespace selftests {
|
|||
/* A mock process_stratum target_ops that doesn't read/write registers
|
||||
anywhere. */
|
||||
|
||||
class test_target_ops : public target_ops
|
||||
class test_target_ops : public process_stratum_target
|
||||
{
|
||||
public:
|
||||
test_target_ops ()
|
||||
: target_ops {}
|
||||
{
|
||||
to_stratum = process_stratum;
|
||||
}
|
||||
test_target_ops () = default;
|
||||
|
||||
const target_info &info () const override;
|
||||
|
||||
|
|
|
@ -470,11 +470,6 @@ tracefile_target::get_trace_status (struct trace_status *ts)
|
|||
return -1;
|
||||
}
|
||||
|
||||
tracefile_target::tracefile_target ()
|
||||
{
|
||||
this->to_stratum = process_stratum;
|
||||
}
|
||||
|
||||
void
|
||||
_initialize_tracefile (void)
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "tracepoint.h"
|
||||
#include "target.h"
|
||||
#include "process-stratum-target.h"
|
||||
|
||||
struct trace_file_writer;
|
||||
|
||||
|
@ -116,10 +117,10 @@ extern struct trace_file_writer *tfile_trace_file_writer_new (void);
|
|||
|
||||
/* Base class for tracefile related targets. */
|
||||
|
||||
class tracefile_target : public target_ops
|
||||
class tracefile_target : public process_stratum_target
|
||||
{
|
||||
public:
|
||||
tracefile_target ();
|
||||
tracefile_target () = default;
|
||||
|
||||
int get_trace_status (trace_status *ts) override;
|
||||
bool has_all_memory () override;
|
||||
|
|
Loading…
Reference in New Issue