Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Add FreeBSD/i386 core file note support
@ 2002-05-11  7:25 Mark Kettenis
  2002-05-13  1:53 ` Nick Clifton
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Kettenis @ 2002-05-11  7:25 UTC (permalink / raw)
  To: binutils; +Cc: gdb-patches

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


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

end of thread, other threads:[~2002-05-18 13:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-11  7:25 [PATCH] Add FreeBSD/i386 core file note support Mark Kettenis
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox