Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 May 2005 22:01:32 GMT
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 76523 for review
Message-ID:  <200505042201.j44M1Wiv089995@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=76523

Change 76523 by peter@peter_hammer on 2005/05/04 22:00:55

	Do valid 32 bit coredumps for 32 bit apps so that gdb can
	read them.

Affected files ...

.. //depot/projects/hammer/sys/amd64/ia32/ia32_reg.c#1 add
.. //depot/projects/hammer/sys/compat/ia32/ia32_reg.h#1 add
.. //depot/projects/hammer/sys/conf/files.amd64#68 edit
.. //depot/projects/hammer/sys/kern/imgact_elf.c#27 edit

Differences ...

==== //depot/projects/hammer/sys/conf/files.amd64#68 (text+ko) ====

@@ -185,6 +185,7 @@
 # IA32 binary support
 #
 #amd64/ia32/ia32_exception.S	optional	compat_ia32
+amd64/ia32/ia32_reg.c		optional	compat_ia32
 amd64/ia32/ia32_signal.c	optional	compat_ia32
 amd64/ia32/ia32_sigtramp.S	optional	compat_ia32
 amd64/ia32/ia32_syscall.c	optional	compat_ia32

==== //depot/projects/hammer/sys/kern/imgact_elf.c#27 (text+ko) ====

@@ -66,6 +66,11 @@
 #include <machine/elf.h>
 #include <machine/md_var.h>
 
+#if defined(__amd64__) && __ELF_WORD_SIZE == 32
+#include <machine/fpu.h>
+#include <compat/ia32/ia32_reg.h>
+#endif
+
 #define OLD_EI_BRAND	8
 
 static int __elfN(check_header)(const Elf_Ehdr *hdr);
@@ -1124,17 +1129,31 @@
 	    td)); /* XXXKSE */
 }
 
+#if defined(__amd64__) && __ELF_WORD_SIZE == 32
+typedef struct prstatus32 elf_prstatus_t;
+typedef struct prpsinfo32 elf_prpsinfo_t;
+typedef struct fpreg32 elf_prfpregset_t;
+typedef struct fpreg32 elf_fpregset_t;
+typedef struct reg32 elf_gregset_t;
+#else
+typedef prstatus_t elf_prstatus_t;
+typedef prpsinfo_t elf_prpsinfo_t;
+typedef prfpregset_t elf_prfpregset_t;
+typedef prfpregset_t elf_fpregset_t;
+typedef gregset_t elf_gregset_t;
+#endif
+
 static void
 __elfN(puthdr)(struct thread *td, void *dst, size_t *off, int numsegs)
 {
 	struct {
-		prstatus_t status;
-		prfpregset_t fpregset;
-		prpsinfo_t psinfo;
+		elf_prstatus_t status;
+		elf_prfpregset_t fpregset;
+		elf_prpsinfo_t psinfo;
 	} *tempdata;
-	prstatus_t *status;
-	prfpregset_t *fpregset;
-	prpsinfo_t *psinfo;
+	elf_prstatus_t *status;
+	elf_prfpregset_t *fpregset;
+	elf_prpsinfo_t *psinfo;
 	struct proc *p;
 	struct thread *thr;
 	size_t ehoff, noteoff, notesz, phoff;
@@ -1166,7 +1185,7 @@
 
 	if (dst != NULL) {
 		psinfo->pr_version = PRPSINFO_VERSION;
-		psinfo->pr_psinfosz = sizeof(prpsinfo_t);
+		psinfo->pr_psinfosz = sizeof(elf_prpsinfo_t);
 		strlcpy(psinfo->pr_fname, p->p_comm, sizeof(psinfo->pr_fname));
 		/*
 		 * XXX - We don't fill in the command line arguments properly
@@ -1188,14 +1207,19 @@
 	while (thr != NULL) {
 		if (dst != NULL) {
 			status->pr_version = PRSTATUS_VERSION;
-			status->pr_statussz = sizeof(prstatus_t);
-			status->pr_gregsetsz = sizeof(gregset_t);
-			status->pr_fpregsetsz = sizeof(fpregset_t);
+			status->pr_statussz = sizeof(elf_prstatus_t);
+			status->pr_gregsetsz = sizeof(elf_gregset_t);
+			status->pr_fpregsetsz = sizeof(elf_fpregset_t);
 			status->pr_osreldate = osreldate;
 			status->pr_cursig = p->p_sig;
 			status->pr_pid = thr->td_tid;
+#if defined(__amd64__) && __ELF_WORD_SIZE == 32
+			fill_regs32(thr, &status->pr_reg);
+			fill_fpregs32(thr, fpregset);
+#else
 			fill_regs(thr, &status->pr_reg);
 			fill_fpregs(thr, fpregset);
+#endif
 		}
 		__elfN(putnote)(dst, off, "FreeBSD", NT_PRSTATUS, status,
 		    sizeof *status);
@@ -1241,7 +1265,11 @@
 		ehdr->e_ident[EI_ABIVERSION] = 0;
 		ehdr->e_ident[EI_PAD] = 0;
 		ehdr->e_type = ET_CORE;
+#if defined(__amd64__) && __ELF_WORD_SIZE == 32
+		ehdr->e_machine = EM_386;
+#else
 		ehdr->e_machine = ELF_ARCH;
+#endif
 		ehdr->e_version = EV_CURRENT;
 		ehdr->e_entry = 0;
 		ehdr->e_phoff = phoff;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200505042201.j44M1Wiv089995>