+2018-11-30 Pedro Alves <palves@redhat.com>
+
+ * aix-thread.c (aix_thread_target) <aix_thread_target>: Delete.
+ <stratum>: New override.
+ * bfd-target.c (aix_thread_target) <aix_thread_target>: Delete.
+ <stratum>: New override.
+ * bsd-uthread.c (bsd_uthread_target) <bsd_uthread_target>: Delete.
+ <stratum>: New override.
+ * exec.c (exec_target) <exec_target>: Delete.
+ <stratum>: New override.
+ * gdbarch-selftests.c (register_to_value_test): Adjust to use the
+ stratum method instead of the to_stratum field.
+ * linux-thread-db.c (thread_db_target) <thread_db_target>: Delete.
+ <stratum>: New override.
+ (thread_db_target::thread_db_target): Delete.
+ * make-target-delegates (print_class): Don't print a ctor
+ declaration. Print a stratum method override declaration.
+ * process-stratum-target.h (process_stratum_target)
+ <process_stratum_target>: Delete.
+ <stratum>: New override.
+ * ravenscar-thread.c (ravenscar_thread_target)
+ <ravenscar_thread_target>: Delete.
+ <stratum>: New override.
+ * record-btrace.c (record_btrace_target)
+ <record_btrace_target>: Delete.
+ <stratum>: New override.
+ * record-full.c (record_full_base_target)
+ <record_full_base_target>: Delete.
+ <stratum>: New override.
+ * record.c (record_disconnect, record_detach)
+ (record_mourn_inferior, record_kill): Adjust to use the stratum
+ method instead of the to_stratum field.
+ * regcache.c (cooked_read_test, cooked_write_test): Likewise.
+ * sol-thread.c (sol_thread_target)
+ <sol_thread_target>: Delete.
+ <stratum>: New override.
+ * spu-multiarch.c (spu_multiarch_target)
+ <spu_multiarch_target>: Delete.
+ <stratum>: New override.
+ * target-delegates.c: Regenerate.
+ * target.c (target_stack::push, target_stack::unpush)
+ (pop_all_targets_above, pop_all_targets_at_and_above)
+ (info_target_command, target_require_runnable)
+ (target_stack::find_beneath): Adjust to use the stratum method
+ instead of the to_stratum field.
+ (dummy_target::dummy_target): Delete.
+ (dummy_target::stratum): New.
+ (debug_target::debug_target): Delete.
+ (debug_target::stratum): New.
+ (maintenance_print_target_stack): Adjust to use the stratum method
+ instead of the to_stratum field.
+ * target.h (struct target_ops) <stratum>: New method.
+ <to_stratum>: Delete.
+ <is_pushed>: Adjust to use the stratum method
+ instead of the to_stratum field.
+
2018-11-30 Pedro Alves <palves@redhat.com>
* corelow.c (core_target) <has_all_memory, has_execution>: New
class aix_thread_target final : public target_ops
{
public:
- aix_thread_target ()
- { to_stratum = thread_stratum; }
-
const target_info &info () const override
{ return aix_thread_target_info; }
+ strata stratum () const override { return thread_stratum; }
+
void detach (inferior *, int) override;
void resume (ptid_t, int, enum gdb_signal) override;
ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
const target_info &info () const override
{ return target_bfd_target_info; }
+ strata stratum () const override { return file_stratum; }
+
void close () override;
target_xfer_status
target_bfd::target_bfd (struct bfd *abfd)
: 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);
struct bsd_uthread_target final : public target_ops
{
- bsd_uthread_target ()
- { to_stratum = thread_stratum; }
-
const target_info &info () const override
{ return bsd_uthread_target_info; }
+ strata stratum () const override { return thread_stratum; }
+
void close () override;
void mourn_inferior () override;
struct exec_target final : public target_ops
{
- exec_target ()
- { to_stratum = file_stratum; }
-
const target_info &info () const override
{ return exec_target_info; }
+ strata stratum () const override { return file_stratum; }
+
void close () override;
enum target_xfer_status xfer_partial (enum target_object object,
const char *annex,
/* Error out if debugging something, because we're going to push the
test target, which would pop any existing target. */
- if (current_top_target ()->to_stratum >= process_stratum)
+ if (current_top_target ()->stratum () >= process_stratum)
error (_("target already pushed"));
/* Create a mock environment. An inferior with a thread, with a
class thread_db_target final : public target_ops
{
public:
- thread_db_target ();
-
const target_info &info () const override
{ return thread_db_target_info; }
+ strata stratum () const override { return thread_stratum; }
+
void detach (inferior *, int) override;
ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
void resume (ptid_t, int, enum gdb_signal) override;
inferior *inf) override;
};
-thread_db_target::thread_db_target ()
-{
- this->to_stratum = thread_stratum;
-}
-
static char *libthread_db_search_path;
/* Set to non-zero if thread_db auto-loading is enabled
print "struct " . $name . " : public target_ops\n";
print "{\n";
- print " $name ();\n";
- print "\n";
print " const target_info &info () const override;\n";
print "\n";
+ print " strata stratum () const override;\n";
+ print "\n";
for $name (@delegators) {
my $return_type = $return_types{$name};
class process_stratum_target : public target_ops
{
public:
- process_stratum_target ()
- {
- to_stratum = process_stratum;
- }
-
~process_stratum_target () override = 0;
+ strata stratum () const override { return process_stratum; }
+
/* We must default these because they must be implemented by any
target that can run. */
bool can_async_p () override { return false; }
struct ravenscar_thread_target final : public target_ops
{
- ravenscar_thread_target ()
- { to_stratum = thread_stratum; }
-
const target_info &info () const override
{ return ravenscar_target_info; }
+ strata stratum () const override { return thread_stratum; }
+
ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
void resume (ptid_t, int, enum gdb_signal) override;
class record_btrace_target final : public target_ops
{
public:
- record_btrace_target ()
- { to_stratum = record_stratum; }
-
const target_info &info () const override
{ return record_btrace_target_info; }
+ strata stratum () const override { return record_stratum; }
+
void close () override;
void async (int) override;
class record_full_base_target : public target_ops
{
public:
- record_full_base_target ()
- { to_stratum = record_stratum; }
-
const target_info &info () const override = 0;
+ strata stratum () const override { return record_stratum; }
+
void close () override;
void async (int) override;
ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
void
record_disconnect (struct target_ops *t, const char *args, int from_tty)
{
- gdb_assert (t->to_stratum == record_stratum);
+ gdb_assert (t->stratum () == record_stratum);
DEBUG ("disconnect %s", t->shortname ());
void
record_detach (struct target_ops *t, inferior *inf, int from_tty)
{
- gdb_assert (t->to_stratum == record_stratum);
+ gdb_assert (t->stratum () == record_stratum);
DEBUG ("detach %s", t->shortname ());
void
record_mourn_inferior (struct target_ops *t)
{
- gdb_assert (t->to_stratum == record_stratum);
+ gdb_assert (t->stratum () == record_stratum);
DEBUG ("mourn inferior %s", t->shortname ());
void
record_kill (struct target_ops *t)
{
- gdb_assert (t->to_stratum == record_stratum);
+ gdb_assert (t->stratum () == record_stratum);
DEBUG ("kill %s", t->shortname ());
{
/* Error out if debugging something, because we're going to push the
test target, which would pop any existing target. */
- if (current_top_target ()->to_stratum >= process_stratum)
+ if (current_top_target ()->stratum () >= process_stratum)
error (_("target already pushed"));
/* Create a mock environment. An inferior with a thread, with a
{
/* Error out if debugging something, because we're going to push the
test target, which would pop any existing target. */
- if (current_top_target ()->to_stratum >= process_stratum)
+ if (current_top_target ()->stratum () >= process_stratum)
error (_("target already pushed"));
/* Create a mock environment. A process_stratum target pushed. */
class sol_thread_target final : public target_ops
{
public:
- sol_thread_target ()
- { this->to_stratum = thread_stratum; }
-
const target_info &info () const override
{ return thread_db_target_info; }
+ strata stratum () const override { return thread_stratum; }
+
void detach (inferior *, int) override;
ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
void resume (ptid_t, int, enum gdb_signal) override;
struct spu_multiarch_target final : public target_ops
{
- spu_multiarch_target ()
- { to_stratum = arch_stratum; };
-
const target_info &info () const override
{ return spu_multiarch_target_info; }
+ strata stratum () const override { return arch_stratum; }
+
void mourn_inferior () override;
void fetch_registers (struct regcache *, int) override;
struct dummy_target : public target_ops
{
- dummy_target ();
-
const target_info &info () const override;
+ strata stratum () const override;
+
void post_attach (int arg0) override;
void detach (inferior *arg0, int arg1) override;
void disconnect (const char *arg0, int arg1) override;
struct debug_target : public target_ops
{
- debug_target ();
-
const target_info &info () const override;
+ strata stratum () const override;
+
void post_attach (int arg0) override;
void detach (inferior *arg0, int arg1) override;
void disconnect (const char *arg0, int arg1) override;
target_stack::push (target_ops *t)
{
/* If there's already a target at this stratum, remove it. */
- if (m_stack[t->to_stratum] != NULL)
+ strata stratum = t->stratum ();
+
+ if (m_stack[stratum] != NULL)
{
- target_ops *prev = m_stack[t->to_stratum];
- m_stack[t->to_stratum] = NULL;
+ target_ops *prev = m_stack[stratum];
+ m_stack[stratum] = NULL;
target_close (prev);
}
/* Now add the new one. */
- m_stack[t->to_stratum] = t;
+ m_stack[stratum] = t;
- if (m_top < t->to_stratum)
- m_top = t->to_stratum;
+ if (m_top < stratum)
+ m_top = stratum;
}
/* See target.h. */
bool
target_stack::unpush (target_ops *t)
{
- if (t->to_stratum == dummy_stratum)
+ strata stratum = t->stratum ();
+
+ if (stratum == dummy_stratum)
internal_error (__FILE__, __LINE__,
_("Attempt to unpush the dummy target"));
/* Look for the specified target. Note that a target can only occur
once in the target stack. */
- if (m_stack[t->to_stratum] != t)
+ if (m_stack[stratum] != t)
{
/* If T wasn't pushed, quit. Only open targets should be
closed. */
}
/* Unchain the target. */
- m_stack[t->to_stratum] = NULL;
+ m_stack[stratum] = NULL;
- if (m_top == t->to_stratum)
- m_top = t->beneath ()->to_stratum;
+ if (m_top == stratum)
+ m_top = t->beneath ()->stratum ();
/* Finally close the target. Note we do this after unchaining, so
any target method calls from within the target_close
void
pop_all_targets_above (enum strata above_stratum)
{
- while ((int) (current_top_target ()->to_stratum) > (int) above_stratum)
+ while ((int) (current_top_target ()->stratum ()) > (int) above_stratum)
unpush_target_and_assert (current_top_target ());
}
void
pop_all_targets_at_and_above (enum strata stratum)
{
- while ((int) (current_top_target ()->to_stratum) >= (int) stratum)
+ while ((int) (current_top_target ()->stratum ()) >= (int) stratum)
unpush_target_and_assert (current_top_target ());
}
if (!t->has_memory ())
continue;
- if ((int) (t->to_stratum) <= (int) dummy_stratum)
+ if ((int) (t->stratum ()) <= (int) dummy_stratum)
continue;
if (has_all_mem)
printf_unfiltered (_("\tWhile running this, "
/* Do not worry about targets at certain strata that can not
create inferiors. Assume they will be pushed again if
necessary, and continue to the process_stratum. */
- if (t->to_stratum > process_stratum)
+ if (t->stratum () > process_stratum)
continue;
error (_("The \"%s\" target does not support \"run\". "
target_stack::find_beneath (const target_ops *t) const
{
/* Look for a non-empty slot at stratum levels beneath T's. */
- for (int stratum = t->to_stratum - 1; stratum >= 0; --stratum)
+ for (int stratum = t->stratum () - 1; stratum >= 0; --stratum)
if (m_stack[stratum] != NULL)
return m_stack[stratum];
""
};
-dummy_target::dummy_target ()
+strata
+dummy_target::stratum () const
{
- to_stratum = dummy_stratum;
+ return dummy_stratum;
}
-debug_target::debug_target ()
+strata
+debug_target::stratum () const
{
- to_stratum = debug_stratum;
+ return debug_stratum;
}
const target_info &
for (target_ops *t = current_top_target (); t != NULL; t = t->beneath ())
{
- if (t->to_stratum == debug_stratum)
+ if (t->stratum () == debug_stratum)
continue;
printf_filtered (" - %s (%s)\n", t->shortname (), t->longname ());
}
struct target_ops
{
+ /* Return this target's stratum. */
+ virtual strata stratum () const = 0;
+
/* To the target under this one. */
target_ops *beneath () const;
TARGET_DEFAULT_IGNORE ();
virtual struct target_section_table *get_section_table ()
TARGET_DEFAULT_RETURN (NULL);
- enum strata to_stratum;
/* Provide default values for all "must have" methods. */
virtual bool has_all_memory () { return false; }
/* Returns true if T is pushed on the target stack. */
bool is_pushed (target_ops *t) const
- { return at (t->to_stratum) == t; }
+ { return at (t->stratum ()) == t; }
/* Return the target at STRATUM. */
target_ops *at (strata stratum) const { return m_stack[stratum]; }