[2/3] Introduce process_stratum_target
Commit Message
Tom> What if I added a protected constructor to target_ops that took the
Tom> stratum as an argument? Would there be a problem with that?
Like this. If it's reasonable I'll rebase it on top of yours after it
goes in.
Tom
commit 207fb6d5368f6406c536e8dee356ee1564e4d494
Author: Tom Tromey <tom@tromey.com>
Date: Thu Nov 29 16:04:37 2018 -0700
Add target_ops constructor
This adds a protected target_ops constructor that sets the to_stratum
member, and updates subclasses to invoke it.
gdb/ChangeLog
2018-11-29 Tom Tromey <tom@tromey.com>
* spu-multiarch.c (spu_multiarch_target::spu_multiarch_target):
Update.
* ravenscar-thread.c
(ravenscar_thread_target::ravenscar_thread_target): Update.
* bsd-uthread.c (bsd_uthread_target::bsd_uthread_target): Update.
* sol-thread.c (sol_thread_target::sol_thread_target): Update.
* aix-thread.c (aix_thread_target::aix_thread_target): Update.
* bsd-kvm.c (bsd_kvm_target::bsd_kvm_target): Update.
* tracefile.c (tracefile_target::tracefile_target): Update.
* target.h (struct target_ops) <target_ops>: New constructor.
(struct memory_breakpoint_target) <memory_breakpoint_target>:
Likewise.
(test_target_ops::test_target_ops): Update.
* target.c (dummy_target::dummy_target): Update.
(debug_target::debug_target): Update.
* remote.c (remote_target::remote_target): Update.
* remote-sim.c (gdbsim_target::gdbsim_target): Update.
* record-full.c
(record_full_base_target::record_full_base_target): Update.
* record-btrace.c (record_btrace_target::record_btrace_target):
Update.
* linux-thread-db.c (thread_db_target::thread_db_target): Update.
* inf-child.c (inf_child_target::inf_child_target): Update.
* exec.c (exec_target::exec_target): Update.
* corelow.c (core_target::core_target): Update.
* bfd-target.c (target_bfd::target_bfd): Update.
@@ -1,3 +1,32 @@
+2018-11-29 Tom Tromey <tom@tromey.com>
+
+ * spu-multiarch.c (spu_multiarch_target::spu_multiarch_target):
+ Update.
+ * ravenscar-thread.c
+ (ravenscar_thread_target::ravenscar_thread_target): Update.
+ * bsd-uthread.c (bsd_uthread_target::bsd_uthread_target): Update.
+ * sol-thread.c (sol_thread_target::sol_thread_target): Update.
+ * aix-thread.c (aix_thread_target::aix_thread_target): Update.
+ * bsd-kvm.c (bsd_kvm_target::bsd_kvm_target): Update.
+ * tracefile.c (tracefile_target::tracefile_target): Update.
+ * target.h (struct target_ops) <target_ops>: New constructor.
+ (struct memory_breakpoint_target) <memory_breakpoint_target>:
+ Likewise.
+ (test_target_ops::test_target_ops): Update.
+ * target.c (dummy_target::dummy_target): Update.
+ (debug_target::debug_target): Update.
+ * remote.c (remote_target::remote_target): Update.
+ * remote-sim.c (gdbsim_target::gdbsim_target): Update.
+ * record-full.c
+ (record_full_base_target::record_full_base_target): Update.
+ * record-btrace.c (record_btrace_target::record_btrace_target):
+ Update.
+ * linux-thread-db.c (thread_db_target::thread_db_target): Update.
+ * inf-child.c (inf_child_target::inf_child_target): Update.
+ * exec.c (exec_target::exec_target): Update.
+ * corelow.c (core_target::core_target): Update.
+ * bfd-target.c (target_bfd::target_bfd): Update.
+
2018-11-29 Tom Tromey <tom@tromey.com>
* valarith.c (value_x_unop): Don't set argvec[3].
@@ -118,7 +118,8 @@ class aix_thread_target final : public target_ops
{
public:
aix_thread_target ()
- { to_stratum = thread_stratum; }
+ : target_ops (thread_stratum)
+ { }
const target_info &info () const override
{ return aix_thread_target_info; }
@@ -90,9 +90,9 @@ target_bfd::get_section_table ()
}
target_bfd::target_bfd (struct bfd *abfd)
- : m_bfd (gdb_bfd_ref_ptr::new_reference (abfd))
+ : target_ops (file_stratum),
+ m_bfd (gdb_bfd_ref_ptr::new_reference (abfd))
{
- this->to_stratum = file_stratum;
m_table.sections = NULL;
m_table.sections_end = NULL;
build_section_table (abfd, &m_table.sections, &m_table.sections_end);
@@ -75,7 +75,8 @@ class bsd_kvm_target final : public target_ops
{
public:
bsd_kvm_target ()
- { this->to_stratum = process_stratum; }
+ : target_ops (process_stratum)
+ { }
const target_info &info () const override
{ return bsd_kvm_target_info; }
@@ -42,7 +42,8 @@ static const target_info bsd_uthread_target_info = {
struct bsd_uthread_target final : public target_ops
{
bsd_uthread_target ()
- { to_stratum = thread_stratum; }
+ : target_ops (thread_stratum)
+ { }
const target_info &info () const override
{ return bsd_uthread_target_info; }
@@ -131,9 +131,8 @@ private: /* per-core data */
};
core_target::core_target ()
+ : target_ops (process_stratum)
{
- to_stratum = process_stratum;
-
m_core_gdbarch = gdbarch_from_bfd (core_bfd);
/* Find a suitable core file handler to munch on core_bfd */
@@ -61,7 +61,8 @@ Specify the filename of the executable file.")
struct exec_target final : public target_ops
{
exec_target ()
- { to_stratum = file_stratum; }
+ : target_ops (file_stratum)
+ { }
const target_info &info () const override
{ return exec_target_info; }
@@ -441,7 +441,6 @@ inf_child_target::can_use_agent ()
inf_child_target::inf_child_target ()
{
- this->to_stratum = process_stratum;
}
/* See inf-child.h. */
@@ -108,8 +108,8 @@ public:
};
thread_db_target::thread_db_target ()
+ : target_ops (thread_stratum)
{
- this->to_stratum = thread_stratum;
}
static char *libthread_db_search_path;
@@ -82,7 +82,8 @@ static const target_info ravenscar_target_info = {
struct ravenscar_thread_target final : public target_ops
{
ravenscar_thread_target ()
- { to_stratum = thread_stratum; }
+ : target_ops (thread_stratum)
+ { }
const target_info &info () const override
{ return ravenscar_target_info; }
@@ -54,7 +54,8 @@ class record_btrace_target final : public target_ops
{
public:
record_btrace_target ()
- { to_stratum = record_stratum; }
+ : target_ops (record_stratum)
+ { }
const target_info &info () const override
{ return record_btrace_target_info; }
@@ -219,7 +219,8 @@ class record_full_base_target : public target_ops
{
public:
record_full_base_target ()
- { to_stratum = record_stratum; }
+ : target_ops (record_stratum)
+ { }
const target_info &info () const override = 0;
@@ -85,7 +85,7 @@ struct gdbsim_target final
: public memory_breakpoint_target<target_ops>
{
gdbsim_target ()
- { to_stratum = process_stratum; }
+ { }
const target_info &info () const override
{ return gdbsim_target_info; }
@@ -408,8 +408,8 @@ class remote_target : public target_ops
{
public:
remote_target ()
+ : target_ops (process_stratum)
{
- to_stratum = process_stratum;
}
~remote_target () override;
@@ -79,7 +79,8 @@ class sol_thread_target final : public target_ops
{
public:
sol_thread_target ()
- { this->to_stratum = thread_stratum; }
+ : target_ops (thread_stratum)
+ { }
const target_info &info () const override
{ return thread_db_target_info; }
@@ -45,7 +45,8 @@ static const target_info spu_multiarch_target_info = {
struct spu_multiarch_target final : public target_ops
{
spu_multiarch_target ()
- { to_stratum = arch_stratum; };
+ : spu_multiarch_target (arch_stratum)
+ { }
const target_info &info () const override
{ return spu_multiarch_target_info; }
@@ -3330,13 +3330,13 @@ static const target_info dummy_target_info = {
};
dummy_target::dummy_target ()
+ : target_ops (dummy_stratum)
{
- to_stratum = dummy_stratum;
}
debug_target::debug_target ()
+ : target_ops (debug_stratum)
{
- to_stratum = debug_stratum;
}
const target_info &
@@ -431,6 +431,15 @@ struct target_info
struct target_ops
{
+ protected:
+
+ explicit target_ops (enum strata stratum)
+ : to_stratum (stratum)
+ {
+ }
+
+ public:
+
/* To the target under this one. */
target_ops *beneath () const;
@@ -2419,6 +2428,15 @@ extern int memory_insert_breakpoint (struct target_ops *,
template <typename BaseTarget>
struct memory_breakpoint_target : public BaseTarget
{
+protected:
+
+ memory_breakpoint_target ()
+ : BaseTarget (process_stratum)
+ {
+ }
+
+public:
+
int insert_breakpoint (struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt) override
{ return memory_insert_breakpoint (this, gdbarch, bp_tgt); }
@@ -2584,9 +2602,8 @@ class test_target_ops : public target_ops
{
public:
test_target_ops ()
- : target_ops {}
+ : target_ops (process_stratum)
{
- to_stratum = process_stratum;
}
const target_info &info () const override;
@@ -471,8 +471,8 @@ tracefile_target::get_trace_status (struct trace_status *ts)
}
tracefile_target::tracefile_target ()
+ : target_ops (process_stratum)
{
- this->to_stratum = process_stratum;
}
void