This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, MIPS] Extract PID from core file


MIPS BFD support for parsing the psinfo note record in
a core file does not extract the PID value.  Other targets
(eg., x86) do extract the PID.  MIPS Linux is different from
other targets, in that it saves the PID as a 64-bit number
(__kernel_pid_t is defined as ulong, although I can't find where).

Tested on MIPS32 (N32).

bfd/ChangeLog:
2015-06-26  Michael J. Eager  <eager@eagercon.com>

	* 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.

--
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077
>From a660a39112193aa144bb2d734a984f434ac2c52f Mon Sep 17 00:00:00 2001
From: Michael Eager <meager@cisco.com>
Date: Fri, 19 Jun 2015 13:54:16 -0700
Subject: [PATCH 2/2] BFD - Extract MIPS core PID from psinfo note

* bfd/elf32-mips.c (elf32_mips_grok_psinfo): Extract PID.
* bfd/elf64-mips.c (elf64_mips_grok_psinfo): Likewise.
* bfd/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 1de302f..ec58f31 100644
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -2233,6 +2233,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_64 (abfd, note->descdata + 12);
 	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 9d50a79..d8067f9 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -4078,6 +4078,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_64 (abfd, note->descdata + 12);
 	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 c37ff9d..27d31a8 100644
--- a/bfd/elfn32-mips.c
+++ b/bfd/elfn32-mips.c
@@ -3328,6 +3328,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_64 (abfd, note->descdata + 12);
 	elf_tdata (abfd)->core->program
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
 	elf_tdata (abfd)->core->command
-- 
2.2.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]