aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-12-13 14:16:57 -0700
committerTom Tromey <tromey@redhat.com>2014-02-19 07:47:01 -0700
commite9a2920092f392f61bcffebc390e0ce0c2cc1b99 (patch)
tree526b766373d1cd88114784a3778a14e253589211
parent09da0d0ae79ea019e04e5a44b5095f5addecaa24 (diff)
downloadgdb-e9a2920092f392f61bcffebc390e0ce0c2cc1b99.zip
gdb-e9a2920092f392f61bcffebc390e0ce0c2cc1b99.tar.gz
gdb-e9a2920092f392f61bcffebc390e0ce0c2cc1b99.tar.bz2
convert to_attach
2014-02-19 Tom Tromey <tromey@redhat.com> * target-delegates.c: Rebuild. * target.c (init_dummy_target): Don't initialize to_attach. (target_attach): Unconditionally delegate. * target.h (struct target_ops) <to_attach>: Use TARGET_DEFAULT_FUNC.
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/target-delegates.c10
-rw-r--r--gdb/target.c21
-rw-r--r--gdb/target.h3
4 files changed, 24 insertions, 18 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 62c429d..06e2635 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,6 +1,14 @@
2014-02-19 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
+ * target.c (init_dummy_target): Don't initialize to_attach.
+ (target_attach): Unconditionally delegate.
+ * target.h (struct target_ops) <to_attach>: Use
+ TARGET_DEFAULT_FUNC.
+
+2014-02-19 Tom Tromey <tromey@redhat.com>
+
+ * target-delegates.c: Rebuild.
* target.c (target_detach): Unconditionally delegate.
(init_dummy_target): Don't initialize to_detach.
* target.h (struct target_ops) <to_detach>: Use
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index f3b8b4d..119d3ec 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -4,6 +4,13 @@
/* To regenerate this file, run:*/
/* make-target-delegates target.h > target-delegates.c */
static void
+delegate_attach (struct target_ops *self, char *arg1, int arg2)
+{
+ self = self->beneath;
+ self->to_attach (self, arg1, arg2);
+}
+
+static void
delegate_detach (struct target_ops *self, const char *arg1, int arg2)
{
self = self->beneath;
@@ -150,6 +157,8 @@ tdefault_supports_btrace (struct target_ops *self)
static void
install_delegators (struct target_ops *ops)
{
+ if (ops->to_attach == NULL)
+ ops->to_attach = delegate_attach;
if (ops->to_detach == NULL)
ops->to_detach = delegate_detach;
if (ops->to_resume == NULL)
@@ -181,6 +190,7 @@ install_delegators (struct target_ops *ops)
static void
install_dummy_methods (struct target_ops *ops)
{
+ ops->to_attach = find_default_attach;
ops->to_detach = tdefault_detach;
ops->to_resume = tdefault_resume;
ops->to_wait = tdefault_wait;
diff --git a/gdb/target.c b/gdb/target.c
index 5bab9cf..ba8ca23 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3806,7 +3806,6 @@ init_dummy_target (void)
dummy_target.to_shortname = "None";
dummy_target.to_longname = "None";
dummy_target.to_doc = "";
- dummy_target.to_attach = find_default_attach;
dummy_target.to_create_inferior = find_default_create_inferior;
dummy_target.to_supports_non_stop = find_default_supports_non_stop;
dummy_target.to_supports_disable_randomization
@@ -3853,22 +3852,10 @@ target_close (struct target_ops *targ)
void
target_attach (char *args, int from_tty)
{
- struct target_ops *t;
-
- for (t = current_target.beneath; t != NULL; t = t->beneath)
- {
- if (t->to_attach != NULL)
- {
- t->to_attach (t, args, from_tty);
- if (targetdebug)
- fprintf_unfiltered (gdb_stdlog, "target_attach (%s, %d)\n",
- args, from_tty);
- return;
- }
- }
-
- internal_error (__FILE__, __LINE__,
- _("could not find a target to attach"));
+ current_target.to_attach (&current_target, args, from_tty);
+ if (targetdebug)
+ fprintf_unfiltered (gdb_stdlog, "target_attach (%s, %d)\n",
+ args, from_tty);
}
int
diff --git a/gdb/target.h b/gdb/target.h
index 4af0c88..b3f8a8e 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -403,7 +403,8 @@ struct target_ops
to xfree everything (including the "struct target_ops"). */
void (*to_xclose) (struct target_ops *targ);
void (*to_close) (struct target_ops *);
- void (*to_attach) (struct target_ops *ops, char *, int);
+ void (*to_attach) (struct target_ops *ops, char *, int)
+ TARGET_DEFAULT_FUNC (find_default_attach);
void (*to_post_attach) (struct target_ops *, int);
void (*to_detach) (struct target_ops *ops, const char *, int)
TARGET_DEFAULT_IGNORE ();