From patchwork Sun Dec 31 05:50:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 25159 Received: (qmail 104238 invoked by alias); 31 Dec 2017 05:58:19 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 84790 invoked by uid 89); 31 Dec 2017 05:52:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=deemed, H*MI:sk:1514699 X-HELO: sesbmg22.ericsson.net Received: from sesbmg22.ericsson.net (HELO sesbmg22.ericsson.net) (193.180.251.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 31 Dec 2017 05:51:43 +0000 Received: from ESESSHC005.ericsson.se (Unknown_Domain [153.88.183.33]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id D3.3F.27591.CEA784A5; Sun, 31 Dec 2017 06:51:41 +0100 (CET) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.33) with Microsoft SMTP Server (TLS) id 14.3.352.0; Sun, 31 Dec 2017 06:51:14 +0100 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from elxacz23q12.lan (192.222.251.162) by DBXPR07MB318.eurprd07.prod.outlook.com (2a01:111:e400:941d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.4; Sun, 31 Dec 2017 05:51:12 +0000 From: Simon Marchi To: CC: Simon Marchi Subject: [PATCH 2/3] Pass inferior down to target_detach and to_detach Date: Sun, 31 Dec 2017 00:50:53 -0500 Message-ID: <1514699454-18587-2-git-send-email-simon.marchi@ericsson.com> In-Reply-To: <1514699454-18587-1-git-send-email-simon.marchi@ericsson.com> References: <1514699454-18587-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 X-ClientProxiedBy: BN6PR16CA0042.namprd16.prod.outlook.com (2603:10b6:405:14::28) To DBXPR07MB318.eurprd07.prod.outlook.com (2a01:111:e400:941d::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a0e4d0a2-574b-43ae-f468-08d550128015 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:DBXPR07MB318; X-Microsoft-Exchange-Diagnostics: 1; DBXPR07MB318; 3:pjY+BuSYo5hQv/0eCsXP1vBg2Isix9N7o2Wi62ya/y9zRZ26pic/KLrOvEpI9eb2v+64PxG0+a5wlUg3uWt0VbsVZUaX2g2ndkNZ50TRol4x+yuQl6N/CWOLDT2Ho6htGXBLfObJp68kj1gW7hTQ9kRDdEDNOz3fAl1XRYMRWSGq2JoTXSw1IO2b+pKpYGGqGU+O79rQcsLa0WYGANrdMwV2LxN2KGZEjKBJ83h5qjeDfkk+NI3sDde2Cn8uBoFu; 25:kVD0Cv+DhV9MmHU/rmcpjKJqDdzQ8nIupDz87ElCmHFuBwXQ7kv3MfRBHDJ6qJThwwIS7Vs5mrMpV1Uuak4HNQpMSOdKVmGJNWLuFnvTmybQzp1aoOeX9yM/r5x+izh1lH93evVbtSrmsrOa50k4dHt80rRjT2Fj9US2RvF396/5cw9YQtmrnBKH3usmM6igs6pC/E8DdbGOD3wQMLJNwS1iw61XO4GAv5xFvtqhdgttGtUbNHbL0o5zS8bTWjBWCxqvAJ0Az/rQegIYWrnN1XxA6wkm06I8tNtc97T8nAmbc5N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Ew0SRs9dIbZW78vo0zs0WJfouhYbe5nKySiQ6Fs33nRnLwj/yfYXJY6uNVNkg2jJjmjg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3231023)(944501075)(93006095)(93001095)(10201501046)(3002001)(6041268)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011); SRVR:DBXPR07MB318; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:DBXPR07MB318; X-Forefront-PRVS: 0538A71254 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(376002)(346002)(39860400002)(396003)(39380400002)(199004)(189003)(54534003)(316002)(21086003)(53936002)(81156014)(2906002)(305945005)(8676002)(81166006)(5660300001)(48376002)(7736002)(16526018)(4326008)(2351001)(575784001)(25786009)(16586007)(2950100002)(478600001)(107886003)(6486002)(86362001)(50466002)(2361001)(105586002)(6666003)(5890100001)(68736007)(106356001)(6916009)(69596002)(50226002)(386003)(36756003)(6116002)(8936002)(76176011)(66066001)(3846002)(47776003)(97736004)(52116002)(59450400001)(6506007)(51416003)(6512007); DIR:OUT; SFP:1101; SCL:1; SRVR:DBXPR07MB318; H:elxacz23q12.lan; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DBXPR07MB318; 23:7/8kQztt1s0I9wlH1gBIwwIXCO2rnh6cDSbLj7nC8f?= =?us-ascii?Q?lhkrqCY8ld8i9YOneHnOk8CuN+L0mZN/n6QuT+knpaCuprtrCZ4Qedxo7scd?= =?us-ascii?Q?b0BIlXvPUDCjA1/20/NmG4SRWNPEnE9M95GmzNU0zXAaeTR1J19Q2mCqqRxV?= =?us-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g0SJLPT3PZoM6ppc3tu4gHuzoRkiu2ardok/imXjlB9Ki6zprO0yEfhnN38YWFow7TsOposOLNwyW850GewQ9omtjhzJ+28ygV28U76qZ8SvqL+DiAUmKdGAFa/Hpm24Sqi3jVhrgmBmAcZP/bmxTfkSd/y2XhyX50w7e28cSY73Yozu2HXILmJo SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Dec 2017 05:51:12.6349 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a0e4d0a2-574b-43ae-f468-08d550128015 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBXPR07MB318 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes The to_detach target_ops method implementations are currently expected to work on current_inferior/inferior_ptid. In order to make things more explicit, and remove some "shadow" parameter passing through globals, this patch adds an "inferior" parameter to to_detach. Implementations will be expected to use this instead of relying on the global. However, to keep things simple, this patch only does the minimum that is necessary to add the parameter. The following patch gives an example of how one such implementation would be adapted. If the approach is deemed good, we can then look into adapting more implementations. Until then, they'll continue to work as they do currently. gdb/ChangeLog: * target.h (struct target_ops) : Add inferior parameter. (target_detach): Likewise. * target.c (dispose_inferior): Pass inferior down. (target_detach): Likewise. * aix-thread.c (aix_thread_detach): Likewise. * corefile.c (core_file_command): Pass current_inferior() down. * corelow.c (core_detach): Add inferior parameter. * darwin-nat.c (darwin_detach): Likewise. * gnu-nat.c (gnu_detach): Likewise. * inf-ptrace.c (inf_ptrace_detach): Likewise. * infcmd.c (detach_command): Pass current_inferior() down to target_detach. * infrun.c (follow_fork_inferior): Pass parent_inf to target_detach. (handle_vfork_child_exec_or_exit): Pass inf->vfork_parent to target_detach. * linux-nat.c (linux_nat_detach): Add inferior parameter. * linux-thread-db.c (thread_db_detach): Likewise. * nto-procfs.c (procfs_detach): Likewise. * procfs.c (procfs_detach): Likewise. * record.c (record_detach): Likewise. * record.h (struct inferior): Forward-declare. (record_detach): Add inferior parameter. * remote-sim.c (gdbsim_detach): Likewise. * remote.c (remote_detach_1): Likewise. (remote_detach): Likewise. (extended_remote_detach): Likewise. * sol-thread.c (sol_thread_detach): Likewise. * target-debug.h (target_debug_print_inferior_p): New macro. * target-delegates.c: Re-generate. * top.c (kill_or_detach): Pass inferior down to target_detach. * windows-nat.c (windows_detach): Add inferior parameter. --- gdb/aix-thread.c | 4 ++-- gdb/corefile.c | 2 +- gdb/corelow.c | 2 +- gdb/darwin-nat.c | 3 +-- gdb/gnu-nat.c | 2 +- gdb/inf-ptrace.c | 2 +- gdb/infcmd.c | 2 +- gdb/infrun.c | 4 ++-- gdb/linux-nat.c | 2 +- gdb/linux-thread-db.c | 4 ++-- gdb/nto-procfs.c | 2 +- gdb/procfs.c | 2 +- gdb/record.c | 4 ++-- gdb/record.h | 3 ++- gdb/remote-sim.c | 4 ++-- gdb/remote.c | 10 +++++----- gdb/sol-thread.c | 4 ++-- gdb/target-debug.h | 2 ++ gdb/target-delegates.c | 14 ++++++++------ gdb/target.c | 6 +++--- gdb/target.h | 4 ++-- gdb/top.c | 2 +- gdb/windows-nat.c | 2 +- 23 files changed, 45 insertions(+), 41 deletions(-) diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c index adb3a83..242df11 100644 --- a/gdb/aix-thread.c +++ b/gdb/aix-thread.c @@ -981,12 +981,12 @@ aix_thread_inferior_created (struct target_ops *ops, int from_tty) /* Detach from the process attached to by aix_thread_attach(). */ static void -aix_thread_detach (struct target_ops *ops, int from_tty) +aix_thread_detach (struct target_ops *ops, inferior *inf, int from_tty) { struct target_ops *beneath = find_target_beneath (ops); pd_disable (); - beneath->to_detach (beneath, from_tty); + beneath->to_detach (beneath, inf, from_tty); } /* Tell the inferior process to continue running thread PID if != -1 diff --git a/gdb/corefile.c b/gdb/corefile.c index 434c64a..c4e0bad 100644 --- a/gdb/corefile.c +++ b/gdb/corefile.c @@ -68,7 +68,7 @@ core_file_command (const char *filename, int from_tty) gdb_assert (core_target != NULL); if (!filename) - (core_target->to_detach) (core_target, from_tty); + (core_target->to_detach) (core_target, current_inferior (), from_tty); else (core_target->to_open) (filename, from_tty); } diff --git a/gdb/corelow.c b/gdb/corelow.c index 2894c96..0f7da4b 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -464,7 +464,7 @@ core_open (const char *arg, int from_tty) } static void -core_detach (struct target_ops *ops, int from_tty) +core_detach (struct target_ops *ops, inferior *inf, int from_tty) { unpush_target (ops); reinit_frame_cache (); diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index 1b64536..cf02bad 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -1938,10 +1938,9 @@ darwin_attach (struct target_ops *ops, const char *args, int from_tty) previously attached. It *might* work if the program was started via fork. */ static void -darwin_detach (struct target_ops *ops, int from_tty) +darwin_detach (struct target_ops *ops, inferior *inf, int from_tty) { pid_t pid = ptid_get_pid (inferior_ptid); - struct inferior *inf = current_inferior (); darwin_inferior *priv = get_darwin_inferior (inf); kern_return_t kret; int res; diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index caa8c3d..db79bab 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2253,7 +2253,7 @@ gnu_attach (struct target_ops *ops, const char *args, int from_tty) previously attached. It *might* work if the program was started via fork. */ static void -gnu_detach (struct target_ops *ops, int from_tty) +gnu_detach (struct target_ops *ops, inferior *inf, int from_tty) { int pid; diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c index 8633108..766a660 100644 --- a/gdb/inf-ptrace.c +++ b/gdb/inf-ptrace.c @@ -244,7 +244,7 @@ inf_ptrace_post_attach (struct target_ops *self, int pid) /* Detach from the inferior. If FROM_TTY is non-zero, be chatty about it. */ static void -inf_ptrace_detach (struct target_ops *ops, int from_tty) +inf_ptrace_detach (struct target_ops *ops, inferior *inf, int from_tty) { pid_t pid = ptid_get_pid (inferior_ptid); diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 3aa2ced..e5bceb4 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -2976,7 +2976,7 @@ detach_command (const char *args, int from_tty) disconnect_tracing (); - target_detach (from_tty); + target_detach (current_inferior (), from_tty); /* The current inferior process was just detached successfully. Get rid of breakpoints that no longer make sense. Note we don't do diff --git a/gdb/infrun.c b/gdb/infrun.c index c4d168c..7d71ad5 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -606,7 +606,7 @@ holding the child stopped. Try \"set detach-on-fork\" or \ target_pid_to_str (process_ptid)); } - target_detach (0); + target_detach (parent_inf, 0); } /* Note that the detach above makes PARENT_INF dangling. */ @@ -976,7 +976,7 @@ handle_vfork_child_exec_or_exit (int exec) } } - target_detach (0); + target_detach (inf->vfork_parent, 0); /* Put it back. */ inf->pspace = pspace; diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 3290ed5..9a54397 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1507,7 +1507,7 @@ detach_callback (struct lwp_info *lp, void *data) } static void -linux_nat_detach (struct target_ops *ops, int from_tty) +linux_nat_detach (struct target_ops *ops, inferior *inf, int from_tty) { int pid; struct lwp_info *main_lwp; diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index ed41640..ddb010e 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -1090,13 +1090,13 @@ record_thread (struct thread_db_info *info, } static void -thread_db_detach (struct target_ops *ops, int from_tty) +thread_db_detach (struct target_ops *ops, inferior *inf, int from_tty) { struct target_ops *target_beneath = find_target_beneath (ops); delete_thread_db_info (ptid_get_pid (inferior_ptid)); - target_beneath->to_detach (target_beneath, from_tty); + target_beneath->to_detach (target_beneath, inf, from_tty); /* NOTE: From this point on, inferior_ptid is null_ptid. */ diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c index 5094eb4..a56a7ce 100644 --- a/gdb/nto-procfs.c +++ b/gdb/nto-procfs.c @@ -943,7 +943,7 @@ procfs_xfer_partial (struct target_ops *ops, enum target_object object, on signals, etc. We'd better not have left any breakpoints in the program or it'll die when it hits one. */ static void -procfs_detach (struct target_ops *ops, int from_tty) +procfs_detach (struct target_ops *ops, inferior *inf, int from_tty) { int pid; diff --git a/gdb/procfs.c b/gdb/procfs.c index f6f9ab0..cc8dce4 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -1924,7 +1924,7 @@ procfs_attach (struct target_ops *ops, const char *args, int from_tty) } static void -procfs_detach (struct target_ops *ops, int from_tty) +procfs_detach (struct target_ops *ops, inferior *inf, int from_tty) { int pid = ptid_get_pid (inferior_ptid); diff --git a/gdb/record.c b/gdb/record.c index 6e1af91..fad28cd 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -187,7 +187,7 @@ record_disconnect (struct target_ops *t, const char *args, int from_tty) /* See record.h. */ void -record_detach (struct target_ops *t, int from_tty) +record_detach (struct target_ops *t, inferior *inf, int from_tty) { gdb_assert (t->to_stratum == record_stratum); @@ -196,7 +196,7 @@ record_detach (struct target_ops *t, int from_tty) record_stop (t); record_unpush (t); - target_detach (from_tty); + target_detach (inf, from_tty); } /* See record.h. */ diff --git a/gdb/record.h b/gdb/record.h index bee1142..3f6583d 100644 --- a/gdb/record.h +++ b/gdb/record.h @@ -24,6 +24,7 @@ #include "common/enum-flags.h" struct cmd_list_element; +struct inferior; extern unsigned int record_debug; @@ -88,7 +89,7 @@ extern void record_goto (const char *arg); extern void record_disconnect (struct target_ops *, const char *, int); /* The default "to_detach" target method for record targets. */ -extern void record_detach (struct target_ops *, int); +extern void record_detach (struct target_ops *, inferior *, int); /* The default "to_mourn_inferior" target method for record targets. */ extern void record_mourn_inferior (struct target_ops *); diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 8eaadcb..7e586fa 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -77,7 +77,7 @@ static void gdbsim_open (const char *args, int from_tty); static void gdbsim_close (struct target_ops *self); -static void gdbsim_detach (struct target_ops *ops, int from_tty); +static void gdbsim_detach (struct target_ops *ops, inferior *inf, int from_tty); static void gdbsim_prepare_to_store (struct target_ops *self, struct regcache *regcache); @@ -820,7 +820,7 @@ gdbsim_close (struct target_ops *self) Use this when you want to detach and do something else with your gdb. */ static void -gdbsim_detach (struct target_ops *ops, int from_tty) +gdbsim_detach (struct target_ops *ops, inferior *inf, int from_tty) { if (remote_debug) fprintf_unfiltered (gdb_stdlog, "gdbsim_detach\n"); diff --git a/gdb/remote.c b/gdb/remote.c index 3fcd279..90eabd8 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -5125,7 +5125,7 @@ remote_detach_pid (int pid) one. */ static void -remote_detach_1 (int from_tty) +remote_detach_1 (int from_tty, inferior *inf) { int pid = ptid_get_pid (inferior_ptid); struct remote_state *rs = get_remote_state (); @@ -5161,15 +5161,15 @@ remote_detach_1 (int from_tty) } static void -remote_detach (struct target_ops *ops, int from_tty) +remote_detach (struct target_ops *ops, inferior *inf, int from_tty) { - remote_detach_1 (from_tty); + remote_detach_1 (from_tty, inf); } static void -extended_remote_detach (struct target_ops *ops, int from_tty) +extended_remote_detach (struct target_ops *ops, inferior *inf, int from_tty) { - remote_detach_1 (from_tty); + remote_detach_1 (from_tty, inf); } /* Target follow-fork function for remote targets. On entry, and diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index 4765ff3..acf0da2 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -348,14 +348,14 @@ lwp_to_thread (ptid_t lwp) program was started via the normal ptrace (PTRACE_TRACEME). */ static void -sol_thread_detach (struct target_ops *ops, int from_tty) +sol_thread_detach (struct target_ops *ops, inferior *inf, int from_tty) { struct target_ops *beneath = find_target_beneath (ops); sol_thread_active = 0; inferior_ptid = pid_to_ptid (ptid_get_pid (main_ph.ptid)); unpush_target (ops); - beneath->to_detach (beneath, from_tty); + beneath->to_detach (beneath, inf, from_tty); } /* Resume execution of process PTID. If STEP is nozero, then just diff --git a/gdb/target-debug.h b/gdb/target-debug.h index 27e5a55..d8d2c48 100644 --- a/gdb/target-debug.h +++ b/gdb/target-debug.h @@ -170,6 +170,8 @@ target_debug_do_print (host_address_to_string (X.get ())) #define target_debug_print_gdb_array_view_const_int(X) \ target_debug_do_print (host_address_to_string (X.data ())) +#define target_debug_print_inferior_p(inf) \ + target_debug_do_print (host_address_to_string (inf)) static void target_debug_print_struct_target_waitstatus_p (struct target_waitstatus *status) diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index 6bb7d7f..bc84791 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -28,26 +28,28 @@ debug_post_attach (struct target_ops *self, int arg1) } static void -delegate_detach (struct target_ops *self, int arg1) +delegate_detach (struct target_ops *self, inferior *arg1, int arg2) { self = self->beneath; - self->to_detach (self, arg1); + self->to_detach (self, arg1, arg2); } static void -tdefault_detach (struct target_ops *self, int arg1) +tdefault_detach (struct target_ops *self, inferior *arg1, int arg2) { } static void -debug_detach (struct target_ops *self, int arg1) +debug_detach (struct target_ops *self, inferior *arg1, int arg2) { fprintf_unfiltered (gdb_stdlog, "-> %s->to_detach (...)\n", debug_target.to_shortname); - debug_target.to_detach (&debug_target, arg1); + debug_target.to_detach (&debug_target, arg1, arg2); fprintf_unfiltered (gdb_stdlog, "<- %s->to_detach (", debug_target.to_shortname); target_debug_print_struct_target_ops_p (&debug_target); fputs_unfiltered (", ", gdb_stdlog); - target_debug_print_int (arg1); + target_debug_print_inferior_p (arg1); + fputs_unfiltered (", ", gdb_stdlog); + target_debug_print_int (arg2); fputs_unfiltered (")\n", gdb_stdlog); } diff --git a/gdb/target.c b/gdb/target.c index 728cab8..a9ee175 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -2108,7 +2108,7 @@ dispose_inferior (struct inferior *inf, void *args) if (target_has_execution) target_kill (); else - target_detach (0); + target_detach (inf, 0); } return 0; @@ -2144,7 +2144,7 @@ target_preopen (int from_tty) /* See target.h. */ void -target_detach (int from_tty) +target_detach (inferior *inf, int from_tty) { if (gdbarch_has_global_breakpoints (target_gdbarch ())) /* Don't remove global breakpoints here. They're removed on @@ -2157,7 +2157,7 @@ target_detach (int from_tty) prepare_for_detach (); - current_target.to_detach (¤t_target, from_tty); + current_target.to_detach (¤t_target, inf, from_tty); } void diff --git a/gdb/target.h b/gdb/target.h index efd0311..3ed6350 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -440,7 +440,7 @@ struct target_ops void (*to_attach) (struct target_ops *ops, const char *, int); void (*to_post_attach) (struct target_ops *, int) TARGET_DEFAULT_IGNORE (); - void (*to_detach) (struct target_ops *ops, int) + void (*to_detach) (struct target_ops *ops, inferior *, int) TARGET_DEFAULT_IGNORE (); void (*to_disconnect) (struct target_ops *, const char *, int) TARGET_DEFAULT_NORETURN (tcomplain ()); @@ -1326,7 +1326,7 @@ extern void target_announce_detach (int from_tty); in the program or it'll die when it hits one. FROM_TTY says whether to be verbose or not. */ -extern void target_detach (int from_tty); +extern void target_detach (inferior *inf, int from_tty); /* Disconnect from the current target without resuming it (leaving it waiting for a debugger). */ diff --git a/gdb/top.c b/gdb/top.c index 61055cf..2c78e4e 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1485,7 +1485,7 @@ kill_or_detach (struct inferior *inf, void *args) if (target_has_execution) { if (inf->attach_flag) - target_detach (qt->from_tty); + target_detach (inf, qt->from_tty); else target_kill (); } diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 6a6cd08..266f710 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1931,7 +1931,7 @@ windows_attach (struct target_ops *ops, const char *args, int from_tty) } static void -windows_detach (struct target_ops *ops, int from_tty) +windows_detach (struct target_ops *ops, inferior *inf, int from_tty) { int detached = 1;