From patchwork Fri Oct 16 14:48:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Ristovski X-Patchwork-Id: 9187 Received: (qmail 10688 invoked by alias); 16 Oct 2015 14:48:45 -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 9779 invoked by uid 89); 16 Oct 2015 14:48:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: smtp-a01.blackberry.com Received: from smtp-a01.blackberry.com (HELO smtp-a01.blackberry.com) (208.65.78.90) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 16 Oct 2015 14:48:43 +0000 Received: from mhs101cnc.rim.net ([10.65.141.79]) by mhs210cnc-app.rim.net with ESMTP; 16 Oct 2015 10:48:41 -0400 Received: from unknown (HELO [10.222.109.89]) ([10.65.140.253]) by mhs101cnc.rim.net with ESMTP; 16 Oct 2015 14:48:42 +0000 Subject: Re: [PATCH] gdbserver: Reset current_thread when its process is removed. To: Pedro Alves , "gdb-patches@sourceware.org" References: <1444919808-22088-1-git-send-email-aristovski@qnx.com> <561FD2B2.6070509@redhat.com> <5620FE5F.4000006@qnx.com> <562103DC.70605@redhat.com> From: Aleksandar Ristovski Message-ID: <56210E49.9010304@qnx.com> Date: Fri, 16 Oct 2015 10:48:41 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <562103DC.70605@redhat.com> On 15-10-16 10:04 AM, Pedro Alves wrote: > On 10/16/2015 02:40 PM, Aleksandar Ristovski wrote: > >> +static int >> +thread_pid_matches_callback (struct inferior_list_entry *entry, void *args) >> +{ > > ... > >> +static struct thread_info * >> +find_thread_process (const struct process_info *const process) >> +{ > > OK with intro comments added. > Like this? diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c index fe47a72..72a3ef1 100644 --- a/gdb/gdbserver/inferiors.c +++ b/gdb/gdbserver/inferiors.c @@ -141,12 +141,18 @@ find_thread_ptid (ptid_t ptid) return (struct thread_info *) find_inferior_id (&all_threads, ptid); } +/* Predicate function for matching thread entry's pid to the given + pid value passed by address in ARGS. */ + static int thread_pid_matches_callback (struct inferior_list_entry *entry, void *args) { return (ptid_get_pid (entry->id) == *(pid_t *)args); } +/* Find a thread associated with the given PROCESS, or NULL if no + such thread exists. */ + static struct thread_info * find_thread_process (const struct process_info *const process) {