From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23088 invoked by alias); 22 Sep 2011 17:11:41 -0000 Received: (qmail 23077 invoked by uid 22791); 22 Sep 2011 17:11:40 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 22 Sep 2011 17:11:21 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=EU1-MAIL.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1R6mnw-0004Ue-D2 from pedro_alves@mentor.com ; Thu, 22 Sep 2011 10:11:20 -0700 Received: from scottsdale.localnet ([172.16.63.104]) by EU1-MAIL.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 22 Sep 2011 18:11:19 +0100 From: Pedro Alves To: gdb@sourceware.org Subject: Re: Thread exit error : gdb7.2 in FreeBSD (built from ports) Date: Thu, 22 Sep 2011 17:11:00 -0000 User-Agent: KMail/1.13.6 (Linux/2.6.38-11-generic; KDE/4.7.0; x86_64; ; ) Cc: Jusctsch References: <32463912.post@talk.nabble.com> <32503829.post@talk.nabble.com> <32503830.post@talk.nabble.com> In-Reply-To: <32503830.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201109221811.16620.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-09/txt/msg00097.txt.bz2 On Thursday 22 September 2011 17:34:27, Jusctsch wrote: > At this point, our inferior_ptid is the thread we planned on deleting, so we > don't delete it and flag it as exited. It does do some cleanup however, and > dips back into fbsd-threads.c a few times... Let's continue. > > GDB on Application > > infrun: target_wait (-1, status) = > infrun: 1461 [Thread 831ff4900 (LWP 100269 BMC Event Log m)], > infrun: status->kind = stopped, signal = SIGTRAP > infrun: infwait_normal_state > infrun: TARGET_WAITKIND_STOPPED > infrun: stop_pc = 0x801b169c1 > > GDB on GDB > > Breakpoint 5, get_current_frame () at frame.c:1177 > 1177 error (_("Invalid selected thread.")); > > (gdb) > (gdb) p inferior_ptid > $6 = {pid = 1461, lwp = 0, tid = 100269} > (gdb) I still don't understand this. If this thread has exited before, then why is the backend reporting a TARGET_WAITKIND_STOPPED for it now? Did a new thread reappear later out of nothing that reuses the same ID, description and all? If by magic that's the case, then it's this bit in infrun.c:handle_inferior_event: /* If it's a new process, add it to the thread database. */ ecs->new_thread_event = (!ptid_equal (ecs->ptid, inferior_ptid) && !ptid_equal (ecs->ptid, minus_one_ptid) && !in_thread_list (ecs->ptid)); if (ecs->ws.kind != TARGET_WAITKIND_EXITED && ecs->ws.kind != TARGET_WAITKIND_SIGNALLED && ecs->new_thread_event) add_thread (ecs->ptid); in_thread_list returns true for an exited thread, but we should end up in add_thread as well if ecs->ptid is in the thread list marked exited. -- Pedro Alves