From patchwork Wed Nov 8 21:23:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 24167 Received: (qmail 6656 invoked by alias); 8 Nov 2017 21:24:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 6583 invoked by uid 89); 8 Nov 2017 21:24:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=ham version=3.3.2 spammy=35626 X-Spam-User: qpsmtpd, 2 recipients X-HELO: 19pmail.ess.barracuda.com Received: from 19pmail.ess.barracuda.com (HELO 19pmail.ess.barracuda.com) (64.235.154.230) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 08 Nov 2017 21:24:40 +0000 Received: from MIPSMAIL01.mipstec.com (mailrelay.mips.com [12.201.5.28]) by mx1412.ess.rzc.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Wed, 08 Nov 2017 21:23:41 +0000 Received: from [10.20.78.183] (10.20.78.183) by mips01.mipstec.com (10.20.43.31) with Microsoft SMTP Server id 14.3.361.1; Wed, 8 Nov 2017 13:23:36 -0800 Date: Wed, 8 Nov 2017 21:23:25 +0000 From: "Maciej W. Rozycki" To: Pedro Alves CC: Djordje Todorovic , , , "nemanja.popov@rt-rk.com" , , "Ananthakrishna Sowda (asowda)" , Nikola Prica Subject: [committed v7 2/3] BFD: Extract PID from MIPS core dump file In-Reply-To: Message-ID: References: <74618d56-fa31-4cfe-329f-6a9078bac92b@rt-rk.com> <724f0bc9-6744-a915-d19d-77db7e9ce514@rt-rk.com> <64ad38a4-b8ae-912e-45d6-7048135ada2e@rt-rk.com> <8475f0b7-969d-3c27-27f2-a4944e58e954@rt-rk.com> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 X-BESS-ID: 1510176138-452060-12340-78171-4 X-BESS-VER: 2017.14.1-r1710272128 X-BESS-Apparent-Source-IP: 12.201.5.28 X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.186733 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS59374 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 From: Djordje Todorovic On MIPS o32, n32 and n64 platforms, PID information was not correctly propagated from core dump file to internal GDB structures. This patch fixes that behavior. A correct PID is needed by `libthread_db' library supplied with glibc repository revisions before commit c579f48edba8 ("Remove cached PID/TID in clone") or released versions before 2.25 for GDB to fetch value of TLS variable from core file. bfd/ChangeLog: * elf32-mips.c (elf32_mips_grok_psinfo): Extract core->pid. * elf64-mips.c (elf64_mips_grok_psinfo): Likewise. * elfn32-mips.c (elf32_mips_grok_psinfo): Likewise. --- bfd/elf32-mips.c | 2 ++ bfd/elf64-mips.c | 2 ++ bfd/elfn32-mips.c | 2 ++ 3 files changed, 6 insertions(+) Index: binutils/bfd/elf32-mips.c =================================================================== --- binutils.orig/bfd/elf32-mips.c 2017-11-08 21:05:36.456371632 +0000 +++ binutils/bfd/elf32-mips.c 2017-11-08 21:05:37.530049782 +0000 @@ -2353,6 +2353,8 @@ elf32_mips_grok_psinfo (bfd *abfd, Elf_I return FALSE; case 128: /* Linux/MIPS elf_prpsinfo */ + elf_tdata (abfd)->core->pid + = bfd_get_32 (abfd, note->descdata + 16); elf_tdata (abfd)->core->program = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16); elf_tdata (abfd)->core->command Index: binutils/bfd/elf64-mips.c =================================================================== --- binutils.orig/bfd/elf64-mips.c 2017-11-08 21:05:36.474538851 +0000 +++ binutils/bfd/elf64-mips.c 2017-11-08 21:05:37.538147336 +0000 @@ -4228,6 +4228,8 @@ elf64_mips_grok_psinfo (bfd *abfd, Elf_I return FALSE; case 136: /* Linux/MIPS - N64 kernel elf_prpsinfo */ + elf_tdata (abfd)->core->pid + = bfd_get_32 (abfd, note->descdata + 24); elf_tdata (abfd)->core->program = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16); elf_tdata (abfd)->core->command Index: binutils/bfd/elfn32-mips.c =================================================================== --- binutils.orig/bfd/elfn32-mips.c 2017-11-08 21:05:36.489887759 +0000 +++ binutils/bfd/elfn32-mips.c 2017-11-08 21:05:37.562322680 +0000 @@ -3562,6 +3562,8 @@ elf32_mips_grok_psinfo (bfd *abfd, Elf_I return FALSE; case 128: /* Linux/MIPS elf_prpsinfo */ + elf_tdata (abfd)->core->pid + = bfd_get_32 (abfd, note->descdata + 16); elf_tdata (abfd)->core->program = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16); elf_tdata (abfd)->core->command