sanity for floating exceptions

utzoo!decvax!ucbvax!unix-wizards utzoo!decvax!ucbvax!unix-wizards
Tue Sep 8 11:12:02 AEST 1981


>From ucsfcgl!tef at Berkeley Tue Sep  8 11:07:27 1981
Standard version 7 DOES store the floating exception code (FEC)
register in the u. area (but not the exception address pointer);
thus the reason for a floating exception is adequately saved in
the resulting core image file.  A C program for printing the
particular exception in terse english is enclosed.

Note that there are many other problems associated with floating
point exceptions that v7 does not adequately address.  If your
programs always core dumps on a floating exception you will probably
get by ok as is, but if you catch floating exceptions via signal(2)
you definitely need some kernel changes. Jim Reeds from UC Berkeley
presented an excellent paper at the Jan '81 USENIX meeting in
San Francsico discussing these problems.  Interested parites should
try to dig up a copy of same from someone who was there.

--- pfe.c ---
#include <stdio.h>
#include <sys/param.h>
#include <sys/dir.h>
#include <sys/user.h>

char *msg[] = {
	"No error.",
	"Floating op code error",
	"Floating divide by zero",
	"Integer conversion error",
	"Floating overflow",
	"Floating underflow",
	"Floating undefined",
	"Floating maintenance trap"
};

main(ac,av)
char **av;
{
	int fd, stat;
	char *corfil;
	struct user user;

	if (ac>1)
		corfil = *++av;
	else
		corfil = "core";
	if ((fd=open(corfil, 0)) < 0) {
		perror(corfil);
		exit(1);
	}
	if (read(fd, &user, sizeof(user)) != sizeof(user)) {
		fprintf(stderr, "empty core image\n");
		exit(1);
	}
	stat = user.u_fper;
	printf("%s\n", msg[stat>>1]);
}



More information about the Comp.unix.wizards mailing list