Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <kettenis@chello.nl>
To: binutils@sources.redhat.com
Cc: gdb-patches@sources.redhat.com
Subject: [PATCH] Add FreeBSD/i386 core file note support
Date: Sat, 11 May 2002 07:25:00 -0000	[thread overview]
Message-ID: <200205111425.g4BEPjg50553@elgar.kettenis.dyndns.org> (raw)

This patch adds support for FreeBSD/i386 core file notes.  The FreeBSD
notes are distinguished based on the name of the note, which has been
FreeBSD ever since support for ELF core dumps was first added to
FreeBSD.

OK to check this in?

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* elf32-i386.c (elf_i386_grok_prstatus): Add support for FreeBSD.
	(elf_i386_grok_psinfo): Likewise.

Index: elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.67
diff -u -p -r1.67 elf32-i386.c
--- elf32-i386.c 4 Apr 2002 19:53:36 -0000 1.67
+++ elf32-i386.c 11 May 2002 14:16:44 -0000
@@ -328,23 +328,44 @@ elf_i386_grok_prstatus (abfd, note)
   int offset;
   size_t raw_size;
 
-  switch (note->descsz)
+  if (strncmp (note->namedata, "FreeBSD", note->namesz) == 0)
     {
-      default:
+      int pr_version = bfd_get_32 (abfd, note->descdata);
+
+      if (pr_version != 1)
 	return false;
 
-      case 144:		/* Linux/i386 */
-	/* pr_cursig */
-	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
-
-	/* pr_pid */
-	elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
-
-	/* pr_reg */
-	offset = 72;
-	raw_size = 68;
+      /* pr_cursig */
+      elf_tdata (abfd)->core_signal = bfd_get_32 (abfd, note->descdata + 20);
+
+      /* pr_pid */
+      elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+
+      /* pr_reg */
+      offset = 28;
+      raw_size = bfd_get_32 (abfd, note->descdata + 8);
+    }
+  else
+    {
+      switch (note->descsz)
+	{
+	default:
+	  return false;
+
+	case 144:		/* Linux/i386 */
+	  /* pr_cursig */
+	  elf_tdata (abfd)->core_signal
+	    = bfd_get_16 (abfd, note->descdata + 12);
+
+	  /* pr_pid */
+	  elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+
+	  /* pr_reg */
+	  offset = 72;
+	  raw_size = 68;
 
-	break;
+	  break;
+	}
     }
 
   /* Make a ".reg/999" section.  */
@@ -357,16 +378,31 @@ elf_i386_grok_psinfo (abfd, note)
      bfd *abfd;
      Elf_Internal_Note *note;
 {
-  switch (note->descsz)
+  if (strncmp (note->namedata, "FreeBSD", note->namesz) == 0)
     {
-      default:
+      int pr_version = bfd_get_32 (abfd, note->descdata);
+
+      if (pr_version != 1)
 	return false;
 
-      case 124:		/* Linux/i386 elf_prpsinfo */
-	elf_tdata (abfd)->core_program
-	 = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
-	elf_tdata (abfd)->core_command
-	 = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
+      elf_tdata (abfd)->core_program
+	= _bfd_elfcore_strndup (abfd, note->descdata + 8, 17);
+      elf_tdata (abfd)->core_command
+	= _bfd_elfcore_strndup (abfd, note->descdata + 25, 81);
+    }
+  else
+    {
+      switch (note->descsz)
+	{
+	default:
+	  return false;
+
+	case 124:		/* Linux/i386 elf_prpsinfo */
+	  elf_tdata (abfd)->core_program
+	    = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
+	  elf_tdata (abfd)->core_command
+	    = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
+	}
     }
 
   /* Note that for some reason, a spurious space is tacked


             reply	other threads:[~2002-05-11 14:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-11  7:25 Mark Kettenis [this message]
2002-05-13  1:53 ` Nick Clifton
2002-05-13  7:32   ` Mark Kettenis
2002-05-18  3:23   ` David O'Brien
2002-05-18  6:56     ` Mark Kettenis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200205111425.g4BEPjg50553@elgar.kettenis.dyndns.org \
    --to=kettenis@chello.nl \
    --cc=binutils@sources.redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox