Subject: Re: md_coredump
To: Paul Kranenburg <pk@cs.few.eur.nl>
From: Chris G. Demetriou <cgd@postgres.Berkeley.EDU>
List: port-sparc
Date: 05/21/1994 02:51:29
> 
> > 
> > you need a struct md_coredump.
> > 
> > 
> > for the sparc, theo, you'll have to do something special, but you're
> > used to that...
> > 
> 
> I am in fact working on a core dump header that would allow much cleaner
> core file handling by debuggers. I have it working on the sparc as a matter
> of fact, using the following. Now, what would other ports like to see in
> the generic `struct core'? The new core file layout provides for three
> `sections': machine dependent cpu state, the data segment and the stack
> segment (in that order). The cpu state includes eg. the processor registers
> (on the sparc, it is a `struct trapframe' + a `struct fpstate' for instance).
> 
> <sys/core.h> :
> 
> #define CORE_MAGIC	0x11223344 - hmm,
> 
> struct core {
> 	u_long	c_magic;		/* */
> 	u_long	c_hdrsize;		/* Size of core header (machdep algn) */
> 	u_long	c_mid;			/* Machine id */
> 	char	c_name[MAXCOMLEN+1];	/* Copy of p->p_comm */
> 	u_long	c_cpusize;		/* Size of machine dependent segment */
> 	u_long	c_tsize;		/* Size of text */
> 	u_long	c_dsize;		/* Size of data */
> 	u_long	c_ssize;		/* Size of stack */
> 	u_long	c_signo;		/* Killing signal */
> 	u_long	c_ucode;		/* Hmm ? */
> };
> 
> 
> for reference, here's the relevant part of <arch/sparc/sparc/vm_machdep.c> :
> 
> [ appropriate changes have to be made to kern_sig.c as well]
> 
> /*
>  * cpu_coredump is called to write a core dump header.
>  * (should this be defined elsewhere?  machdep.c?)
>  */
> int
> cpu_coredump(p, vp, cred, cp)
> 	struct proc *p;
> 	struct vnode *vp;
> 	struct ucred *cred;
> 	struct core *cp;
> {
> 	int error;
> 	register struct user *up = p->p_addr;
> 	struct cpustate {
> 		struct trapframe tf;
> 		struct fpstate fp;
> 	} cpustate;
> 
> 	cp->c_hdrsize = roundup(sizeof(*cp), sizeof(double));
> 	cp->c_cpusize = sizeof(cpustate);
> 	cp->c_mid = htonl(MID_SPARC);
> 
> 	cpustate.tf = *p->p_md.md_tf;
> 	if (p->p_md.md_fpstate)
> 		cpustate.fp = *p->p_md.md_fpstate;
> 	else
> 		bzero((caddr_t)&cpustate.fp, sizeof(struct fpstate));
> 
> 	error = (vn_rdwr(UIO_WRITE, vp, (caddr_t)cp, cp->c_hdrsize, (off_t)0,
> 	    UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, (int *)NULL, p));
> 	if (error)
> 		return error;
> 
> 	return (vn_rdwr(UIO_WRITE, vp, (caddr_t)&cpustate, sizeof(cpustate),
> 	    (off_t)cp->c_hdrsize,
> 	    UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, (int *)NULL, p));
> }
 

------------------------------------------------------------------------------