From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28071 invoked by alias); 11 May 2002 14:25:47 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 28057 invoked from network); 11 May 2002 14:25:45 -0000 Received: from unknown (HELO walton.kettenis.dyndns.org) (213.93.114.42) by sources.redhat.com with SMTP; 11 May 2002 14:25:45 -0000 Received: from elgar.kettenis.dyndns.org (elgar.kettenis.dyndns.org [192.168.0.2]) by walton.kettenis.dyndns.org (8.11.6/8.11.6) with ESMTP id g4BEQwk03985; Sat, 11 May 2002 16:26:58 +0200 (CEST) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: (from kettenis@localhost) by elgar.kettenis.dyndns.org (8.11.6/8.11.6) id g4BEPjg50553; Sat, 11 May 2002 16:25:45 +0200 (CEST) (envelope-from kettenis) Date: Sat, 11 May 2002 07:25:00 -0000 From: Mark Kettenis Message-Id: <200205111425.g4BEPjg50553@elgar.kettenis.dyndns.org> To: binutils@sources.redhat.com CC: gdb-patches@sources.redhat.com Subject: [PATCH] Add FreeBSD/i386 core file note support X-SW-Source: 2002-05/txt/msg00389.txt.bz2 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 * 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