From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21878 invoked by alias); 11 Dec 2012 12:22:33 -0000 Received: (qmail 21834 invoked by uid 22791); 11 Dec 2012 12:22:29 -0000 X-SWARE-Spam-Status: No, hits=-7.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_XS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 11 Dec 2012 12:22:15 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBBCMDee019683 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 11 Dec 2012 07:22:13 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qBBCMBSv006285; Tue, 11 Dec 2012 07:22:12 -0500 Message-ID: <50C72573.5060305@redhat.com> Date: Tue, 11 Dec 2012 12:22:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Joel Brobecker CC: gdb-patches@sourceware.org Subject: Re: [PATCH 1/2] Put a NT_PSTATUS note on solaris cores. References: <50C6115C.4090509@redhat.com> <20121210180216.3932.48633.stgit@brno.lan> <20121211030352.GB13565@adacore.com> In-Reply-To: <20121211030352.GB13565@adacore.com> Content-Type: multipart/mixed; boundary="------------030307040200020404070004" 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: 2012-12/txt/msg00318.txt.bz2 This is a multi-part message in MIME format. --------------030307040200020404070004 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 1464 On 12/11/2012 03:03 AM, Joel Brobecker wrote: > Tested on sparc-solaris, but it seems to have no effect yet: > > (gdb) core core.10498 > [New LWP 1] > Core was generated by `/[...]/simple_main'. > Program terminated with signal 5, Trace/breakpoint trap. > #0 simple_main () at simple_main.adb:4 > 4 simple.test_simple; > (gdb) info inferiors > Num Description Executable > * 1 LWP 0 /[...]/simple_main > > And after the patch: > > (gdb) core core.15731 > [New LWP 1] > Core was generated by `/[...]/simple_main'. > Program terminated with signal 5, Trace/breakpoint trap. > #0 simple_main () at simple_main.adb:4 > 4 simple.test_simple; > (gdb) info inferiors > Num Description Executable > * 1 LWP 0 /[...]/simple_main > > I can see that the second core file is bigger, but I am lacking > the time to investigate this further at the moment. Maybe I am > doing the wrong test? You're doing the right test. The issue is that core_pid_to_str calls into the gdbarch_core_pid_to_str, and that isn't expecting to be passed a "process pid" instead of an "LWP pid". Could you try this one when you have a chance? This is rebased on top of current mainline, so it restores the elfcore_write_pstatus call that the Unixware-excise patch removed. I made sure it builds with --enable-targets=all. Thanks! -- Pedro Alves --------------030307040200020404070004 Content-Type: text/x-patch; name="nt_pstatus.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="nt_pstatus.diff" Content-length: 3232 commit 76583bee66b1faa3bfcf6de6f95e38dacc93d45a Author: Pedro Alves Date: Mon Dec 10 17:52:55 2012 +0000 Put a NT_PSTATUS note on solaris cores. This is based on the patch I once posted at: http://sourceware.org/ml/gdb-patches/2009-10/msg00188.html Rationale: This patch makes is so that cores generated with gdb's gcore on solaris also get an NT_PSTATUS note. It is from this note that gdb can extract the original pid of the process from the core. From higher up on procfs.c, we see that pstatus_t is assumed to be defined when NEW_PROC_API is defined, so this should be safe to not break builds on supported hosts. Older Solaris not using the the new proc api are unaffected. I had applied the patch back in 2009, and then shortly afterwards backed it out, because it broke Solaris builds. A patch to bfd this depended on was missing: http://sourceware.org/ml/gdb-patches/2009-10/msg00214.html The bfd patch went in 2010-01-04, but I never got back to pushing the GDB bit in. The user visible change is just that GDB will know the real PID the process that dumped core had (visible in "info inferiors"). 2012-12-11 Pedro Alves Pedro Alves gdb/ * procfs.c (procfs_make_note_section) [NEW_PROC_API]: Output a NT_PSTATUS note. * sol2-tdep.c (sol2_core_pid_to_str): Print process IDs differently from LWP IDs. v2: - restore elfcore_write_pstatus call. - make sol2_core_pid_to_str aware or process ids vs lwp ids. diff --git a/gdb/procfs.c b/gdb/procfs.c index fa18b46..1c5cc13 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -5507,6 +5507,13 @@ procfs_make_note_section (bfd *obfd, int *note_size) stop_signal = find_stop_signal (); +#ifdef NEW_PROC_API + fill_gregset (get_current_regcache (), &gregs, -1); + note_data = elfcore_write_pstatus (obfd, note_data, note_size, + PIDGET (inferior_ptid), + stop_signal, &gregs); +#endif + thread_args.obfd = obfd; thread_args.note_data = note_data; thread_args.note_size = note_size; diff --git a/gdb/sol2-tdep.c b/gdb/sol2-tdep.c index e93758d..e292b8d 100644 --- a/gdb/sol2-tdep.c +++ b/gdb/sol2-tdep.c @@ -43,7 +43,29 @@ char * sol2_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid) { static char buf[80]; + struct inferior *inf; + int pid; - xsnprintf (buf, sizeof buf, "LWP %ld", ptid_get_lwp (ptid)); - return buf; + /* Check whether we're printing an LWP (gdb thread) or a + process. */ + pid = ptid_get_lwp (ptid); + if (pid != 0) + { + /* A thread. */ + xsnprintf (buf, sizeof buf, "LWP %ld", ptid_get_lwp (ptid)); + return buf; + } + + /* GDB didn't use to put a NT_PSTATUS note in Solaris cores. If + that's missing, then we're dealing with a fake PID corelow.c made + up. */ + inf = find_inferior_pid (ptid_get_pid (ptid)); + if (inf == NULL || inf->fake_pid_p) + { + xsnprintf (buf, sizeof buf, ""); + return buf; + } + + /* Not fake; print as usual. */ + return normal_pid_to_str (ptid); } --------------030307040200020404070004--