From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31036 invoked by alias); 20 Jan 2002 17:19:34 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 30966 invoked from network); 20 Jan 2002 17:19:32 -0000 Received: from unknown (HELO public.xfree86.org) (204.152.184.37) by sources.redhat.com with SMTP; 20 Jan 2002 17:19:32 -0000 Received: from localhost (takis@localhost) by public.xfree86.org (8.11.6/8.11.6) with ESMTP id g0KHJU403818; Sun, 20 Jan 2002 09:19:30 -0800 (PST) (envelope-from takis@public.xfree86.org) Date: Sun, 20 Jan 2002 11:20:00 -0000 From: Takis Psarogiannakopoulos To: kevinb@redhat.com cc: msnyder@redhat.com, gdb@sources.redhat.com, binutils@sources.redhat.com Subject: RE:Re: GDB 5.1/Core files and ptids (CONT) Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2002-01/txt/msg00402.txt.bz2 On Fri, 18 Jan 2002, Kevin Buettner wrote: > > Yep, I agree. As I pointed out to Takis in an earlier message, I think > the right way to fix it is to modify both corelow.c on the GDB side > and elf.c on the bfd side. > > My suggestion was that instead of naming sections .reg/PIDLWP where > PIDLWP is a combined (numeric) pid and lwp identifier that these > sections instead be named .reg/PID+LWP where PID is the pid and LWP is > the lwp. > > When the LWP doesn't exist or is simply zero, we simply use .reg/PID > as before. (Or we could use .reg/PID+0. It doesn't really matter > so long as both sides are in agreement.) > Hi Kevin, Below is a core from omniORB. Take a look. My GDB 5.1 will say: ========================================================================= (gdb) info threads * 5 -> PID: 14546 DG/UX Kernel LWP: 4 0x08058b77 in fde_split (linear=0x801de790, erratic=0x801de798) at frame.c:313 4 -> PID: 14546 DG/UX Kernel LWP: 3 0x801ac4dc in __nsl_accept () from /usr/dglib/libnsl.so.1 3 -> PID: 14546 DG/UX Kernel LWP: 2 0x801d67eb in __dg_kfc () from /usr/dglib/libthread.so.1 2 -> PID: 14546 DG/UX Kernel LWP: 1 0x801d67eb in __dg_kfc () from /usr/dglib/libthread.so.1 1 -> PID: 14546 DG/UX Kernel LWP: 0 0x801d67eb in __dg_kfc () from /usr/dglib/libthread.so.1 Current language: auto; currently c (gdb) info threads-status * 5 -> PID: 14546 DG/UX Kernel LWP: 4 eligible,dumping-core,caught-signal,detached 4 -> PID: 14546 DG/UX Kernel LWP: 3 eligible 3 -> PID: 14546 DG/UX Kernel LWP: 2 frozen,cond-wait(0x80673c8)-mutex(0x80673a4) 2 -> PID: 14546 DG/UX Kernel LWP: 1 frozen,cond-wait(0x8067334)-mutex(0x8067310) 1 -> PID: 14546 DG/UX Kernel LWP: 0 frozen,cond-wait(0x80177184)-mutex(0x80177160) (gdb) thread 1 [Switching to thread 1 (-> PID: 14546 DG/UX Kernel LWP: 0)]#0 0x801d67eb in __dg_kfc () from /usr/dglib/libthread.so.1 (gdb) info lwp-status DG/UX Kernel based LWP status space: PID / LWP ID : 14546 / 0 LWP Group ID : 0 Last on CPU ID : 2 LWP Kernel state : LWP is waiting on the user-level condition variable at address 0x80177184, with associated mutex 0x80177160 LWP is marked as user frozen and cannot run at user level Stack info : NO dedicated stack LWP sched is : LOCAL Sched policy : SCHED_OTHER Sched priority : 2047 Stop-on-store bmaps : Bit map num 0 is : 0x0 Bit map num 1 is : 0x0 (gdb) quit ===================================================================== As you can see if we put a conditional if ( (elf_tdata (abfd)->core_lwpid) == 0) inside bfd/elf.c/elfcore_make_ptid_str(abfd) for DG/UX OS at least we are loosing a thread. Below is what I worked out for GDB 5.1. It will patch elf.c and corelow.c. according to your suggestions. If this is acceptable someone should check it in at least for the upcoming GDB 5.x.x. ===================================================================== diff -rcN /target/GDB/gdb-5.1/bfd/elf.c gdb-5.1/bfd/elf.c *** /target/GDB/gdb-5.1/bfd/elf.c Sun Jan 20 16:54:02 2002 --- gdb-5.1/bfd/elf.c Sat Jun 30 04:05:12 2001 *************** *** 5349,5365 **** + (elf_tdata (abfd)->core_pid)); } - static char * - elfcore_make_ptid_str (abfd) - bfd *abfd; - { - static char ptid_buf[40]; - - sprintf (ptid_buf, "%d+%ld", (elf_tdata (abfd)->core_pid), - (elf_tdata (abfd)->core_lwpid) ); - return ptid_buf; - } - /* If there isn't a section called NAME, make one, using data from SECT. Note, this function will generate a reference to NAME, so you shouldn't deallocate or --- 5349,5354 ---- *************** *** 5391,5398 **** actually creates up to two pseudosections: - For the single-threaded case, a section named NAME, unless such a section already exists. ! - For the multi-threaded case, a section named "NAME/PID+LWPID", where ! PID is prepared by elfcore_make_ptid_str (abfd). Both pseudosections have identical contents. */ boolean _bfd_elfcore_make_pseudosection (abfd, name, size, filepos) --- 5380,5387 ---- actually creates up to two pseudosections: - For the single-threaded case, a section named NAME, unless such a section already exists. ! - For the multi-threaded case, a section named "NAME/PID", where ! PID is elfcore_make_pid (abfd). Both pseudosections have identical contents. */ boolean _bfd_elfcore_make_pseudosection (abfd, name, size, filepos) *************** *** 5407,5413 **** /* Build the section name. */ ! sprintf (buf, "%s/%s", name, elfcore_make_ptid_str (abfd)); threaded_name = bfd_alloc (abfd, strlen (buf) + 1); if (threaded_name == NULL) return false; --- 5396,5402 ---- /* Build the section name. */ ! sprintf (buf, "%s/%d", name, elfcore_make_pid (abfd)); threaded_name = bfd_alloc (abfd, strlen (buf) + 1); if (threaded_name == NULL) return false; *************** *** 5699,5705 **** /* Make a ".reg/999" section. */ ! sprintf (buf, ".reg/%s", elfcore_make_ptid_str (abfd)); name = bfd_alloc (abfd, strlen (buf) + 1); if (name == NULL) return false; --- 5688,5694 ---- /* Make a ".reg/999" section. */ ! sprintf (buf, ".reg/%d", elfcore_make_pid (abfd)); name = bfd_alloc (abfd, strlen (buf) + 1); if (name == NULL) return false; *************** *** 5728,5734 **** /* Make a ".reg2/999" section */ ! sprintf (buf, ".reg2/%s", elfcore_make_ptid_str (abfd)); name = bfd_alloc (abfd, strlen (buf) + 1); if (name == NULL) return false; --- 5717,5723 ---- /* Make a ".reg2/999" section */ ! sprintf (buf, ".reg2/%d", elfcore_make_pid (abfd)); name = bfd_alloc (abfd, strlen (buf) + 1); if (name == NULL) return false; diff -rcN /target/GDB/gdb-5.1/gdb/corelow.c gdb-5.1/gdb/corelow.c *** /target/GDB/gdb-5.1/gdb/corelow.c Sun Jan 20 17:00:59 2002 --- gdb-5.1/gdb/corelow.c Tue May 15 00:03:36 2001 *************** *** 234,262 **** static void add_to_thread_list (bfd *abfd, asection *asect, PTR reg_sect_arg) { ! int p_id, count; ! long t_id; asection *reg_sect = (asection *) reg_sect_arg; if (strncmp (bfd_section_name (abfd, asect), ".reg/", 5) != 0) return; ! count = sscanf(bfd_section_name (abfd, asect), ".reg/%d+%ld", &p_id, &t_id); ! #if defined(DEBUG) ! if ( count == 2 ) ! printf("Adding thread PID=%d+LWPID=%ld \n", p_id, t_id); ! else if ( count == 1) ! printf("Adding thread PID=%d+LWPID=? not found lwpid\n", p_id); ! #endif /* DEBUG */ ! ! add_thread ( ptid_build (p_id, t_id, 0) ); /* Warning, Will Robinson, looking at BFD private data! */ if (reg_sect != NULL && asect->filepos == reg_sect->filepos) /* Did we find .reg? */ ! inferior_ptid = ptid_build (p_id, t_id, 0); /* Yes, make it current */ } /* This routine opens and sets up the core file bfd. */ --- 234,254 ---- static void add_to_thread_list (bfd *abfd, asection *asect, PTR reg_sect_arg) { ! int thread_id; asection *reg_sect = (asection *) reg_sect_arg; if (strncmp (bfd_section_name (abfd, asect), ".reg/", 5) != 0) return; ! thread_id = atoi (bfd_section_name (abfd, asect) + 5); ! add_thread (pid_to_ptid (thread_id)); /* Warning, Will Robinson, looking at BFD private data! */ if (reg_sect != NULL && asect->filepos == reg_sect->filepos) /* Did we find .reg? */ ! inferior_ptid = pid_to_ptid (thread_id); /* Yes, make it current */ } /* This routine opens and sets up the core file bfd. */ *************** *** 415,422 **** char *contents; if (PIDGET (inferior_ptid)) ! sprintf (section_name, "%s/%d+%ld", name, ! PIDGET(inferior_ptid), TIDGET(inferior_ptid) ); else strcpy (section_name, name); --- 407,413 ---- char *contents; if (PIDGET (inferior_ptid)) ! sprintf (section_name, "%s/%d", name, PIDGET (inferior_ptid)); else strcpy (section_name, name); ========================================================================