From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26719 invoked by alias); 20 Aug 2014 09:06:20 -0000 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 Received: (qmail 26704 invoked by uid 89); 20 Aug 2014 09:06:19 -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 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 20 Aug 2014 09:06:18 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7K96Fdc004821 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Aug 2014 05:06:15 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s7K96DoI015870; Wed, 20 Aug 2014 05:06:14 -0400 Message-ID: <53F46504.2080705@redhat.com> Date: Wed, 20 Aug 2014 09:06:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Sreejith M M CC: gdb@sourceware.org Subject: Re: Thread names in gdb7.7(using info threads command) References: <53F37099.9070307@redhat.com> <53F37252.7070304@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-08/txt/msg00090.txt.bz2 On 08/20/2014 07:08 AM, Sreejith M M wrote: > Thanks Pedro for the reply. > > To make things clearer, I get the thread names when I do live > debugging( Run the image from gdb and crash) > I am not getting the information only when I independently run the > image and take the core dump to be analyzed in gdb. > > What my question is , whether coredump will have the required > information or not. Unfortunately, the Linux core dump format is underdocumented. You'll have to web search and read sources to get more familiar with it, sorry. Start by looking at /usr/include/linux/elfcore.h, and looking at bfd's and gdb's sources for the structures defined there. Look around for info on core notes (NT_PRPSINFO, etc.). The elfutils sources would also be another good source. As to whether the info is there or not, I'm not sure; you'll have to experiment. Try using "eu-readelf -n" on the core, and see if the thread name is there somewhere. I think it might end up in PRPSINFO/fname, but I'm not 100% sure, and my time budget doesn't allow for investigating further at this point, sorry. > Why I am asking this again is because I did not > understand how a gdb patch (as you have mentioned) can read the right > data from core dump. Could you please explain a bit more? > > PS: I am newbie to gdb and dont understand the code quite well. If you > can give some pointers, I will try to implement the patch if it is > useful. See the target_thread_name calls in gdb/thread.c. When debugging against a live target, that ends up calling into linux-nat.c:linux_nat_thread_name, which extracts the thread name out of /proc/PID/task/TID/comm. When debugging a core dump, that target_thread_name call ends up in the corelow.c target_ops implementation instead. You'll need to add a to_thread_name hook to core_ops, that then calls info bfd to get the thread name somehow, assuming the info is indeed there. >> Or maybe it is, in NT_PRPSINFO / prpsinfo->pr_fname ? In that case, >> all we'd need is a gdb patch to make use of it. See the >> target_thread_name target method. We'd need an implementation in >> corelow.c. Thanks, Pedro Alves