public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, MIPS] Extract PID from core dump file
@ 2017-06-05  9:14 Djordje Todorovic
  2017-06-15 23:37 ` Maciej W. Rozycki
  0 siblings, 1 reply; 8+ messages in thread
From: Djordje Todorovic @ 2017-06-05  9:14 UTC (permalink / raw)
  To: binutils; +Cc: nemanja.popov, nikola.prica, petar.jovanovic, asowda, ibaev

There is already a thread for this but it is not correct ([PATCH, MIPS] 
Extract PID from core file by Michael Eager).  As author in this thread 
says it was only tested on MIPS32 (N32) . This patch is tested on MIPS32 
and MIPS64 executables and both points for setting pid in 
bfd/elf32-mips.c and bfd/elf64-mips.c is hit respectively. It is also 
checked in Linux kernel and the size of pid is the same as size of int.

It can be found in the source of Linux kernel:
include/uapi/asm-generic/posix_types.h
...
#ifndef __kernel_pid_t
typedef int        __kernel_pid_t;
#endif
...

 From 79272bae0b10fa35b640d4006045f389e9a85849 Mon Sep 17 00:00:00 2001
From: Djordje Todorovic <djordje.todorovic@rt-rk.com>
Date: Fri, 2 Jun 2017 13:16:00 +0200
Subject: [PATCH] Extract PID from MIPS core dump file

bfd/ChangeLog:

     * elf32-mips.c (elf32_mips_grok_psinfo): Extract core->pid.
     * elf64-mips.c (elf64_mips_grok_psinfo): Likewise.
---
  bfd/ChangeLog    | 5 +++++
  bfd/elf32-mips.c | 2 ++
  bfd/elf64-mips.c | 2 ++
  3 files changed, 9 insertions(+)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 27a1e8c..392b131 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2017-06-02  Djordje Todorovic  <djordje.todorovic@rt-rk.com>
+
+    * elf32-mips.c (elf32_mips_grok_psinfo): Extract core->pid.
+    * elf64-mips.c (elf64_mips_grok_psinfo): Likewise.
+
  2017-06-01  John Baldwin  <jhb@FreeBSD.org>

      * elf.c (elfcore_grok_freebsd_psinfo): Use ELF header class to
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index 8c1a68eb..9ec2818 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 + 24);
      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 e95db2c..6c7fc6d 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -4242,6 +4242,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
-- 
1.9.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-09-28 11:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-05  9:14 [PATCH, MIPS] Extract PID from core dump file Djordje Todorovic
2017-06-15 23:37 ` Maciej W. Rozycki
2017-06-19 13:21   ` Djordje Todorovic
2017-07-11 13:30     ` Djordje
2017-07-18 12:05       ` Maciej W. Rozycki
2017-08-16 10:42     ` Maciej W. Rozycki
2017-08-24 14:09       ` Djordje Todorovic
2017-09-28 11:56         ` Maciej W. Rozycki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).