From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9803 invoked by alias); 6 Aug 2010 16:48:23 -0000 Received: (qmail 9792 invoked by uid 22791); 6 Aug 2010 16:48:21 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM X-Spam-Check-By: sourceware.org Received: from mail-wy0-f169.google.com (HELO mail-wy0-f169.google.com) (74.125.82.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 06 Aug 2010 16:48:16 +0000 Received: by wyg36 with SMTP id 36so8959261wyg.0 for ; Fri, 06 Aug 2010 09:48:13 -0700 (PDT) Received: by 10.227.12.223 with SMTP id y31mr10792558wby.193.1281113293308; Fri, 06 Aug 2010 09:48:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.186.205 with HTTP; Fri, 6 Aug 2010 09:47:53 -0700 (PDT) In-Reply-To: <201008061057.03037.pedro@codesourcery.com> References: <201008061057.03037.pedro@codesourcery.com> From: Hui Zhu Date: Fri, 06 Aug 2010 16:48:00 -0000 Message-ID: Subject: Re: [RFA]corelow.c: Add tid to add_to_thread_list To: Pedro Alves Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-08/txt/msg00074.txt.bz2 On Fri, Aug 6, 2010 at 17:57, Pedro Alves wrote: > On Friday 06 August 2010 03:55:51, Hui Zhu wrote: > >> 2010-08-06 =A0Hui Zhu =A0 >> >> =A0 =A0 =A0 * corelow.c(add_to_thread_list): Add tid. >> >> --- >> =A0corelow.c | =A0 10 ++++++++-- >> =A01 file changed, 8 insertions(+), 2 deletions(-) >> >> --- a/corelow.c >> +++ b/corelow.c >> @@ -244,7 +244,7 @@ add_to_thread_list (bfd *abfd, asection >> =A0{ >> =A0 =A0ptid_t ptid; >> =A0 =A0int core_tid; >> - =A0int pid, lwpid; >> + =A0int pid, lwpid, tid; >> =A0 =A0asection *reg_sect =3D (asection *) reg_sect_arg; >> >> =A0 =A0if (strncmp (bfd_section_name (abfd, asect), ".reg/", 5) !=3D 0) >> @@ -278,7 +278,13 @@ add_to_thread_list (bfd *abfd, asection >> =A0 =A0if (current_inferior ()->pid =3D=3D 0) >> =A0 =A0 =A0inferior_appeared (current_inferior (), pid); >> >> - =A0ptid =3D ptid_build (pid, lwpid, 0); >> + =A0tid =3D 0; >> + =A0do >> + =A0 =A0{ >> + =A0 =A0 =A0ptid =3D ptid_build (pid, lwpid, tid); >> + =A0 =A0 =A0tid ++; >> + =A0 =A0} >> + =A0while (find_thread_ptid (ptid)); >> >> =A0 =A0add_thread (ptid); > > Sorry, no. =A0It's not a good idea to have the corelow target > using both the lwpid and the tid fields. =A0It leaves no room for a > thread_stratum target on top to use. =A0Going by what someone > said on the other thread: > >> The goal was always that something could post process the output of >> the kernel crashdump and create something that is gdb compatible. =A0It >> looks to me like it would take just a moment to strip out all of the >> idle threads. > > What are exactly these "threads" with no PID? =A0How useful is it for gdb > to expose them as threads? =A0Are these the idle threads, one per core, n= ot > associated with any process? =A0Are we talking about a regular process co= re > dump, or some other core dump? =A0From the comment quoted above, it appea= rs > that it would be expected that something just stripped out / ignored > these "threads"/notes. =A0Say, a post processor tool, or bfd, or gdb. The root cause about this issue is the idle thread's pid is 0. If more than one cpu is in idle and each cpu will be a thread in core file, we got a core file that have some thread ptid is same. For now, gdb cannot handle it: struct thread_info * add_thread_silent (ptid_t ptid) { struct thread_info *tp; tp =3D find_thread_ptid (ptid); if (tp) /* Found an old thread with the same id. It has to be dead, otherwise we wouldn't be adding a new thread with the same id. The OS is reusing this id --- delete it, and recreate a new one. */ I make a patch that can ignore the same ptid thread and output a warning. > > BTW, with this particular patch, you've only gotten past this one > problem, but, you'll be tripping on others. =A0For example, all register > accesses for lwpid=3DXXX,tid=3D0, lwpid=3DXXX,tid=3D1, lwpid=3DXXX,tid=3D= 2, etc., > will be going to the same .reg/XXX section. Yes, that is a trouble. 2010-08-07 Hui Zhu * corelow.c(add_to_thread_list): Ignore the thread if already a ptid is in thread list. --- corelow.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/corelow.c +++ b/corelow.c @@ -279,6 +279,12 @@ add_to_thread_list (bfd *abfd, asection inferior_appeared (current_inferior (), pid); ptid =3D ptid_build (pid, lwpid, 0); + if (find_thread_ptid (ptid)) + { + warning (_("Get more than one thread ptid is %s. Ignore it."), + target_pid_to_str (ptid)); + return; + } add_thread (ptid);