+2014-02-19 Tom Tromey <tromey@redhat.com>
+
+ * arm-linux-nat.c (arm_linux_read_description): Delegate when
+ needed.
+ * corelow.c (core_read_description): Delegate when needed.
+ * remote.c (remote_read_description): Delegate when needed.
+ * target-delegates.c: Rebuild.
+ * target.c (target_read_description): Rewrite.
+ * target.h (struct target_ops) <to_read_description>: Update
+ comment. Use TARGET_DEFAULT_RETURN.
+
2014-02-19 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
if (target_auxv_search (ops, AT_HWCAP, &arm_hwcap) != 1)
{
- return NULL;
+ return ops->beneath->to_read_description (ops->beneath);
}
if (arm_hwcap & HWCAP_IWMMXT)
return result;
}
- return NULL;
+ return ops->beneath->to_read_description (ops->beneath);
}
/* Information describing the hardware breakpoint capabilities. */
core_read_description (struct target_ops *target)
{
if (core_gdbarch && gdbarch_core_read_description_p (core_gdbarch))
- return gdbarch_core_read_description (core_gdbarch,
- target, core_bfd);
+ {
+ const struct target_desc *result;
+
+ result = gdbarch_core_read_description (core_gdbarch,
+ target, core_bfd);
+ if (result != NULL)
+ return result;
+ }
- return NULL;
+ return target->beneath->to_read_description (target->beneath);
}
static char *
/* Do not try this during initial connection, when we do not know
whether there is a running but stopped thread. */
if (!target_has_execution || ptid_equal (inferior_ptid, null_ptid))
- return NULL;
+ return target->beneath->to_read_description (target->beneath);
if (!VEC_empty (remote_g_packet_guess_s, data->guesses))
{
an architecture, but it's too tricky to do safely. */
}
- return NULL;
+ return target->beneath->to_read_description (target->beneath);
}
/* Remote file transfer support. This is host-initiated I/O, not
tcomplain ();
}
+static const struct target_desc *
+delegate_read_description (struct target_ops *self)
+{
+ self = self->beneath;
+ return self->to_read_description (self);
+}
+
+static const struct target_desc *
+tdefault_read_description (struct target_ops *self)
+{
+ return 0;
+}
+
static ptid_t
delegate_get_ada_task_ptid (struct target_ops *self, long arg1, long arg2)
{
ops->to_flash_erase = delegate_flash_erase;
if (ops->to_flash_done == NULL)
ops->to_flash_done = delegate_flash_done;
+ if (ops->to_read_description == NULL)
+ ops->to_read_description = delegate_read_description;
if (ops->to_get_ada_task_ptid == NULL)
ops->to_get_ada_task_ptid = delegate_get_ada_task_ptid;
if (ops->to_auxv_parse == NULL)
ops->to_memory_map = tdefault_memory_map;
ops->to_flash_erase = tdefault_flash_erase;
ops->to_flash_done = tdefault_flash_done;
+ ops->to_read_description = tdefault_read_description;
ops->to_get_ada_task_ptid = default_get_ada_task_ptid;
ops->to_auxv_parse = default_auxv_parse;
ops->to_search_memory = default_search_memory;
(int (*) (CORE_ADDR, gdb_byte *, int, int,
struct mem_attrib *, struct target_ops *))
nomemory);
- current_target.to_read_description = NULL;
#undef de_fault
const struct target_desc *
target_read_description (struct target_ops *target)
{
- struct target_ops *t;
-
- for (t = target; t != NULL; t = t->beneath)
- if (t->to_read_description != NULL)
- {
- const struct target_desc *tdesc;
-
- tdesc = t->to_read_description (t);
- if (tdesc)
- return tdesc;
- }
-
- return NULL;
+ return target->to_read_description (target);
}
/* This implements a basic search of memory, reading target memory and
void (*to_flash_done) (struct target_ops *)
TARGET_DEFAULT_NORETURN (tcomplain ());
- /* Describe the architecture-specific features of this target.
- Returns the description found, or NULL if no description
- was available. */
- const struct target_desc *(*to_read_description) (struct target_ops *ops);
+ /* Describe the architecture-specific features of this target. If
+ OPS doesn't have a description, this should delegate to the
+ "beneath" target. Returns the description found, or NULL if no
+ description was available. */
+ const struct target_desc *(*to_read_description) (struct target_ops *ops)
+ TARGET_DEFAULT_RETURN (0);
/* Build the PTID of the thread on which a given task is running,
based on LWP and THREAD. These values are extracted from the