From patchwork Fri Oct 6 11:03:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Djordje Todorovic X-Patchwork-Id: 23373 Received: (qmail 30902 invoked by alias); 6 Oct 2017 11:04:02 -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 30515 invoked by uid 89); 6 Oct 2017 11:04:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail.rt-rk.com Received: from mx2.rt-rk.com (HELO mail.rt-rk.com) (89.216.37.149) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Oct 2017 11:03:57 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 09E311A2044; Fri, 6 Oct 2017 13:03:54 +0200 (CEST) Received: from [10.10.13.94] (unknown [10.10.13.94]) by mail.rt-rk.com (Postfix) with ESMTPSA id E61B71A1DEC; Fri, 6 Oct 2017 13:03:53 +0200 (CEST) From: Djordje Todorovic Subject: [PATCH 4/4] BFD: Extract PID from MIPS core dump file To: "Maciej W. Rozycki" Cc: binutils@sourceware.org, gdb-patches@sourceware.org, "nemanja.popov@rt-rk.com" , petar.jovanovic@rt-rk.com, "Ananthakrishna Sowda (asowda)" , Nikola Prica Message-ID: Date: Fri, 6 Oct 2017 13:03:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 The patch which adds reading PID from Linux core PRPSINFO. Please notice that I have corrected the offset for MIPS o32 and MIPS n32 from the first iteration. MIPS o32 and n32 uses exactly the same struct elf_prpsinfo as you have mentioned. The kernel struct elf_prpsinfo on MIPS o32 looks as following: (top-gdb-mipso32) ptype struct elf_prpsinfo type = struct elf_prpsinfo { char pr_state; char pr_sname; char pr_zomb; char pr_nice; unsigned long pr_flag; long pr_uid; long pr_gid; int pr_pid; int pr_ppid; int pr_pgrp; int pr_sid; char pr_fname[16]; char pr_psargs[80]; } and, as you also mentioned, the offset of PID is: (top-gdb-mipso32) print /d &((struct elf_prpsinfo *)0)->pr_pid $1 = 16 From 6ef7b5c46efe881dc3421b2ea990131211dfc518 Mon Sep 17 00:00:00 2001 From: Djordje Todorovic Date: Wed, 4 Oct 2017 15:07:28 +0200 Subject: [PATCH 4/4] BFD: Extract PID from MIPS core dump file 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. 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(+) diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 48a2083..6b64527 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -2353,6 +2353,8 @@ elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) 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 diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c index 354e4cb..10d6880 100644 --- a/bfd/elf64-mips.c +++ b/bfd/elf64-mips.c @@ -4228,6 +4228,8 @@ elf64_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) 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 diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c index 07793b6..5621621 100644 --- a/bfd/elfn32-mips.c +++ b/bfd/elfn32-mips.c @@ -3558,6 +3558,8 @@ elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) 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