From patchwork Fri Mar 18 21:15:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 11415 Received: (qmail 97615 invoked by alias); 18 Mar 2016 21:15:27 -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 97600 invoked by uid 89); 18 Mar 2016 21:15:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.4 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=destroyed, H*F:U*ak, gdb711, gdb-7.11 X-HELO: mga01.intel.com Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 18 Mar 2016 21:15:25 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 18 Mar 2016 14:15:24 -0700 X-ExtLoop1: 1 Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.35]) by fmsmga001.fm.intel.com with ESMTP; 18 Mar 2016 14:15:24 -0700 Received: by tassilo.localdomain (Postfix, from userid 1000) id 510F030269B; Fri, 18 Mar 2016 14:15:24 -0700 (PDT) Date: Fri, 18 Mar 2016 14:15:24 -0700 From: Andi Kleen To: gdb-patches@gcc.gnu.org Subject: [PATCH] Fix debugging with destroyed TLS Message-ID: <20160318211524.GA17830@tassilo.jf.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) This is a fix for https://sourceware.org/bugzilla/show_bug.cgi?id=19684 I have some code that overwrites FS on x86-64. This breaks debugging in gdb, because every operation tries to read the thread number, but fails because TLS is not available. I just replaced the error with a warning. Seems to work fine as far as I can tell, all the callers seem to handle a NULL return. Patch against 7.11, but I expect it will apply to master too. I don't have commit access. -Andi 2016-03-18 Andi Kleen * linux-thread-db.c (thread_from_lwp): Only warn when LWP cannot be determined. --- gdb-7.11/gdb/linux-thread-db.c 2016-02-09 19:19:39.000000000 -0800 +++ gdb-7.11-hacked/gdb/linux-thread-db.c 2016-02-24 08:30:49.455778307 -0800 @@ -354,13 +354,19 @@ thread_from_lwp (ptid_t ptid) err = info->td_ta_map_lwp2thr_p (info->thread_agent, ptid_get_lwp (ptid), &th); if (err != TD_OK) - error (_("Cannot find user-level thread for LWP %ld: %s"), + { + warning (_("Cannot find user-level thread for LWP %ld: %s"), ptid_get_lwp (ptid), thread_db_err_str (err)); + return NULL; + } err = info->td_thr_get_info_p (&th, &ti); if (err != TD_OK) - error (_("thread_get_info_callback: cannot get thread info: %s"), + { + warning (_("thread_get_info_callback: cannot get thread info: %s"), thread_db_err_str (err)); + return NULL; + } /* Fill the cache. */ tp = find_thread_ptid (ptid);