From patchwork Wed May 21 21:40:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 1067 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 8DD76360098 for ; Wed, 21 May 2014 14:40:21 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14314964) id 452AD41C5BAFC; Wed, 21 May 2014 14:40:20 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx20.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx20.g.dreamhost.com (Postfix) with ESMTPS id CB8D441CBD80A for ; Wed, 21 May 2014 14:40:19 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=lT2V+UCyHUcpnf7FvI+i9ceawvrS8fuvVTStHij+eTCvKebqh++Uh d704VVGP8pi4X/Q1nFOA0PdcqT0ixu4kFXVtuv69by0ATwttEVuApvAMsffH6kfh xjyYixbJKXrfYjpSx3ygA9I7yYCVcKhLQKUmtchcw+W6LfY9WGeCJs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=7pPpnc/FBA2EbdwTYewfGilmT7A=; b=STgQzjwME3Ry/vyPV4yEvhTY1dBu 9h8mE4yPABrqKKqI0HajcO4Jsj5GaRL7eS5P/L0u6uziekPxzpb5kp7mpYNzafBC HDVJiA7MYKam5nk7cIz2pO6XiUfYu8osHdkeXLAvowvvyqUYPKBBQWrKEzvsRejW 3cVwJLv8xPrc0is= Received: (qmail 31900 invoked by alias); 21 May 2014 21:40:18 -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 31888 invoked by uid 89); 21 May 2014 21:40:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 May 2014 21:40:16 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4LLeFi0018236 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 21 May 2014 17:40:15 -0400 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s4LLeDCl000306 for ; Wed, 21 May 2014 17:40:14 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [ob/pushed] Native targets: Add inf-child.c:inf_child_mourn_inferior and use it. Date: Wed, 21 May 2014 22:40:12 +0100 Message-Id: <1400708412-462-1-git-send-email-palves@redhat.com> X-DH-Original-To: gdb@patchwork.siddhesh.in Most ports do the same thing in the tail of their mourn routine - call generic_mourn_inferior+inf_child_maybe_unpush_target. This factors that out to a convenience function. More could be done, but this converts only the really obvious ones. Tested by building GDB on x86_64 Fedora 20, mingw32 and djgpp. The rest is untested, but I think a patch can't get more obvious. gdb/ 2014-05-21 Pedro Alves * inf-child.c (inf_child_mourn_inferior): New function. * inf-child.h (inf_child_mourn_inferior): New declaration. * darwin-nat.c (darwin_mourn_inferior): Use inf_child_mourn_inferior. * gnu-nat.c (gnu_mourn_inferior): Likewise. * inf-ptrace.c (inf_ptrace_mourn_inferior): Likewise. * inf-ttrace.c (inf_ttrace_mourn_inferior): Likewise. * nto-procfs.c (procfs_mourn_inferior): Likewise. * windows-nat.c (windows_mourn_inferior): Likewise. --- gdb/ChangeLog | 12 ++++++++++++ gdb/darwin-nat.c | 3 +-- gdb/gnu-nat.c | 3 +-- gdb/inf-child.c | 7 +++++++ gdb/inf-child.h | 4 ++++ gdb/inf-ptrace.c | 4 +--- gdb/inf-ttrace.c | 3 +-- gdb/nto-procfs.c | 3 +-- gdb/windows-nat.c | 3 +-- 9 files changed, 29 insertions(+), 13 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 24de5fa..d9c9c13 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2014-05-21 Pedro Alves + + * inf-child.c (inf_child_mourn_inferior): New function. + * inf-child.h (inf_child_mourn_inferior): New declaration. + * darwin-nat.c (darwin_mourn_inferior): Use + inf_child_mourn_inferior. + * gnu-nat.c (gnu_mourn_inferior): Likewise. + * inf-ptrace.c (inf_ptrace_mourn_inferior): Likewise. + * inf-ttrace.c (inf_ttrace_mourn_inferior): Likewise. + * nto-procfs.c (procfs_mourn_inferior): Likewise. + * windows-nat.c (windows_mourn_inferior): Likewise. + 2014-05-21 Doug Evans * scm-breakpoint.c (breakpoint_functions): Fix typo. diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index f3d510d..160329b 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -1268,8 +1268,7 @@ darwin_mourn_inferior (struct target_ops *ops) xfree (inf->private); inf->private = NULL; - generic_mourn_inferior (); - inf_child_maybe_unpush_target (ops); + inf_child_mourn_inferior (ops); } static void diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index 3317215..516e83d 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2080,8 +2080,7 @@ gnu_mourn_inferior (struct target_ops *ops) { inf_debug (gnu_current_inf, "rip"); inf_detach (gnu_current_inf); - generic_mourn_inferior (); - inf_child_maybe_unpush_target (ops); + inf_child_mourn_inferior (ops); } diff --git a/gdb/inf-child.c b/gdb/inf-child.c index a3c4fe4..dbadde8 100644 --- a/gdb/inf-child.c +++ b/gdb/inf-child.c @@ -159,6 +159,13 @@ inf_child_close (struct target_ops *target) inf_child_explicitly_opened = 0; } +void +inf_child_mourn_inferior (struct target_ops *ops) +{ + generic_mourn_inferior (); + inf_child_maybe_unpush_target (ops); +} + /* See inf-child.h. */ void diff --git a/gdb/inf-child.h b/gdb/inf-child.h index 3f00ab6..b2692ca 100644 --- a/gdb/inf-child.h +++ b/gdb/inf-child.h @@ -36,6 +36,10 @@ extern void store_waitstatus (struct target_waitstatus *, int); extern void inf_child_open_target (struct target_ops *target, char *arg, int from_tty); +/* To be called by the native target's to_mourn_inferior routine. */ + +extern void inf_child_mourn_inferior (struct target_ops *ops); + /* Unpush the target if it wasn't explicitly open with "target native" and there are no live inferiors left. Note: if calling this as a result of a mourn or detach, the current inferior shall already diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c index cc4921b..4736fbd 100644 --- a/gdb/inf-ptrace.c +++ b/gdb/inf-ptrace.c @@ -174,9 +174,7 @@ inf_ptrace_mourn_inferior (struct target_ops *ops) only report its exit status to its original parent. */ waitpid (ptid_get_pid (inferior_ptid), &status, 0); - generic_mourn_inferior (); - - inf_child_maybe_unpush_target (ops); + inf_child_mourn_inferior (ops); } /* Attach to the process specified by ARGS. If FROM_TTY is non-zero, diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c index 96105dc..ee55515 100644 --- a/gdb/inf-ttrace.c +++ b/gdb/inf-ttrace.c @@ -696,8 +696,7 @@ inf_ttrace_mourn_inferior (struct target_ops *ops) } inf_ttrace_page_dict.count = 0; - generic_mourn_inferior (); - inf_child_maybe_unpush_target (ops); + inf_child_mourn_inferior (ops); } /* Assuming we just attached the debugger to a new inferior, create diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c index 8a241a8..2ce9563 100644 --- a/gdb/nto-procfs.c +++ b/gdb/nto-procfs.c @@ -1027,8 +1027,7 @@ procfs_mourn_inferior (struct target_ops *ops) } inferior_ptid = null_ptid; init_thread_list (); - generic_mourn_inferior (); - inf_child_maybe_unpush_target (ops); + inf_child_mourn_inferior (ops); } /* This function breaks up an argument string into an argument diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index fe43c24..88844fe 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -2368,8 +2368,7 @@ windows_mourn_inferior (struct target_ops *ops) CHECK (CloseHandle (current_process_handle)); open_process_used = 0; } - generic_mourn_inferior (); - inf_child_maybe_unpush_target (ops); + inf_child_mourn_inferior (ops); } /* Send a SIGINT to the process group. This acts just like the user typed a