From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26273 invoked by alias); 28 Jan 2010 12:37:18 -0000 Received: (qmail 26258 invoked by uid 22791); 28 Jan 2010 12:37:18 -0000 X-SWARE-Spam-Status: No, hits=-0.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS,URIBL_BLACK X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 28 Jan 2010 12:37:14 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 606802BAB56; Thu, 28 Jan 2010 07:37:12 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id iSGMv46ynV-o; Thu, 28 Jan 2010 07:37:12 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id D09522BAB22; Thu, 28 Jan 2010 07:37:11 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 824CCF58B8; Thu, 28 Jan 2010 16:36:52 +0400 (RET) From: Joel Brobecker To: binutils@sourceware.org Cc: gdb-patches@sourceware.org Subject: [RFA] core files: wrong signal number with threaded program on sparc-solaris Date: Thu, 28 Jan 2010 12:37:00 -0000 Message-Id: <1264682189-9643-1-git-send-email-brobecker@adacore.com> 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-01/txt/msg00603.txt.bz2 From: brobecke Hello, We noticed the following problem. Given a threaded program that terminated because of a SIGABRT (and produced a core file), GDB prints the following information when loading this core file: % gdb crash (gdb) core core [...] Core was generated by `./crash'. Program terminated with signal 9, Killed. ^^^^^^^^^^^^^^^^ #0 0xffffffff7eec9128 in kill () from /lib/64/libc.so.1 The expected behavior is to tell the user that the program terminated because of a SIGABRT: Core was generated by `./crash'. Program terminated with signal 6, Aborted. #0 0xff2c559c in kill () from /lib/libc.so.1 This issue started appearing after the following change was introduced: * bfd.m4 (BFD_HAVE_SYS_PROCFS_TYPE): Define _STRUCTURE_PROC before including procfs.h. (BFD_HAVE_SYS_PROCFS_TYPE_MEMBER): Likewise. * configure.in: Added autoconf probe for the pr_fpreg member. * configure: Regenerated. * config.in: Regenerated. * elf.c: Define _STRUCTURE_PROC before including procfs.h. Basically, instead of using the NT_PRSTATUS notes, we now use the NT_LWPSTATUS ones. And what happens in our case is that we have several such notes - I suspect one per thread. The first note has a signal set to 6, whereas the next one has a signal set to 9. Interestingly, the same is true iw the NT_PRSTATUS notes, and digging a little further, I found the following code in elfcore_grok_prstatus (this is the function that handles NT_PRSTATUS notes): /* Do not overwrite the core signal if it has already been set by another thread. */ if (elf_tdata (abfd)->core_signal == 0) elf_tdata (abfd)->core_signal = prstat.pr_cursig; It looks like the same logic should be applied in elfcore_grok_lwpstatus. This is what this patch does. bfd/ChangeLog: * elf.c (elfcore_grok_lwpstatus): Do not overwrite the core signal if it has already been set. Tested on sparc-solaris by running the GDB testsuite. No regression. OK to apply? Thanks, -- Joel --- bfd/ChangeLog.GNAT | 5 +++++ bfd/elf.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletions(-) diff --git a/bfd/ChangeLog.GNAT b/bfd/ChangeLog.GNAT index ea483ec..93b4e85 100644 --- a/bfd/ChangeLog.GNAT +++ b/bfd/ChangeLog.GNAT @@ -1,3 +1,8 @@ +2010-01-28 Joel Brobecker + + * elf.c (elfcore_grok_lwpstatus): Do not overwrite the core signal + if it has already been set. + 2010-01-01 Joel Brobecker Revert a local change that was unnecessary. diff --git a/bfd/elf.c b/bfd/elf.c index aac3314..19e4695 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -7800,7 +7800,10 @@ elfcore_grok_lwpstatus (bfd *abfd, Elf_Internal_Note *note) memcpy (&lwpstat, note->descdata, sizeof (lwpstat)); elf_tdata (abfd)->core_lwpid = lwpstat.pr_lwpid; - elf_tdata (abfd)->core_signal = lwpstat.pr_cursig; + /* Do not overwrite the core signal if it has already been set by + another thread. */ + if (elf_tdata (abfd)->core_signal == 0) + elf_tdata (abfd)->core_signal = lwpstat.pr_cursig; /* Make a ".reg/999" section. */ -- 1.6.3.3