From 91fe0229e03f82921be927a66762bdc7d4e08d68 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 13 Dec 2013 13:33:08 -0700 Subject: [PATCH 07/11] convert to_detach --- gdb/make-target-delegates | 3 ++- gdb/target-delegates.c | 9 +++++++++ gdb/target.c | 17 ++++------------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/gdb/make-target-delegates b/gdb/make-target-delegates index 296ea5e..89a0920 100755 --- a/gdb/make-target-delegates +++ b/gdb/make-target-delegates @@ -13,7 +13,8 @@ 'to_stopped_by_watchpoint' => 1, 'to_stopped_data_address' => 1, 'to_xfer_partial' => 1, - 'to_supports_btrace' => 1 + 'to_supports_btrace' => 1, + 'to_detach' => 1 ); # The line we search for in target.h that marks where we should start diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index b4a35cb..1bfbde6 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_detach (struct target_ops *self, const char *arg1, int arg2) +{ + self = self->beneath; + self->to_detach (self, arg1, arg2); +} + +static void delegate_resume (struct target_ops *self, ptid_t arg1, int arg2, enum gdb_signal arg3) { self = self->beneath; @@ -90,6 +97,8 @@ delegate_supports_btrace (struct target_ops *self) static void install_delegators (struct target_ops *ops) { + if (ops->to_detach == NULL) + ops->to_detach = delegate_detach; if (ops->to_resume == NULL) ops->to_resume = delegate_resume; if (ops->to_wait == NULL) diff --git a/gdb/target.c b/gdb/target.c index c992cf3..dc14c60 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -2597,19 +2597,10 @@ target_detach (const char *args, int from_tty) prepare_for_detach (); - for (t = current_target.beneath; t != NULL; t = t->beneath) - { - if (t->to_detach != NULL) - { - t->to_detach (t, args, from_tty); - if (targetdebug) - fprintf_unfiltered (gdb_stdlog, "target_detach (%s, %d)\n", - args, from_tty); - return; - } - } - - internal_error (__FILE__, __LINE__, _("could not find a target to detach")); + current_target.to_detach (¤t_target, args, from_tty); + if (targetdebug) + fprintf_unfiltered (gdb_stdlog, "target_detach (%s, %d)\n", + args, from_tty); } void -- 1.8.1.4