Deleted Added
full compact
__sparc_utrap.c (91174) __sparc_utrap.c (95587)
1/*-
2 * Copyright (c) 2001 Jake Burkholder.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001 Jake Burkholder.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/lib/libc/sparc64/sys/__sparc_utrap.c 91174 2002-02-23 21:37:18Z tmm $");
28__FBSDID("$FreeBSD: head/lib/libc/sparc64/sys/__sparc_utrap.c 95587 2002-04-27 21:56:28Z jake $");
29
30#include <sys/types.h>
31
32#include <machine/utrap.h>
33#include <machine/sysarch.h>
34
29
30#include <sys/types.h>
31
32#include <machine/utrap.h>
33#include <machine/sysarch.h>
34
35#include <errno.h>
36#include <signal.h>
35#include <stdio.h>
36#include <stdlib.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <unistd.h>
37
38#include "__sparc_utrap_private.h"
39
40static const char *utrap_msg[] = {
41 "reserved",
42 "instruction access exception",
43 "instruction access error",
44 "instruction access protection",

--- 27 unchanged lines hidden (view full) ---

72 "trap instruction 29",
73 "trap instruction 30",
74 "trap instruction 31",
75};
76
77void
78__sparc_utrap(struct utrapframe *uf)
79{
40
41#include "__sparc_utrap_private.h"
42
43static const char *utrap_msg[] = {
44 "reserved",
45 "instruction access exception",
46 "instruction access error",
47 "instruction access protection",

--- 27 unchanged lines hidden (view full) ---

75 "trap instruction 29",
76 "trap instruction 30",
77 "trap instruction 31",
78};
79
80void
81__sparc_utrap(struct utrapframe *uf)
82{
83 int sig;
80
81 switch (uf->uf_type) {
82 case UT_FP_EXCEPTION_IEEE_754:
83 case UT_FP_EXCEPTION_OTHER:
84
85 switch (uf->uf_type) {
86 case UT_FP_EXCEPTION_IEEE_754:
87 case UT_FP_EXCEPTION_OTHER:
84 __fpu_exception(uf);
85 UF_DONE(uf);
86 return;
88 sig = __fpu_exception(uf);
89 break;
87 case UT_ILLEGAL_INSTRUCTION:
90 case UT_ILLEGAL_INSTRUCTION:
91 sig = __emul_insn(uf);
92 break;
88 case UT_MEM_ADDRESS_NOT_ALIGNED:
89 break;
93 case UT_MEM_ADDRESS_NOT_ALIGNED:
94 break;
90 case UT_TRAP_INSTRUCTION_16:
91 UF_DONE(uf);
92 return;
93 default:
94 break;
95 }
95 default:
96 break;
97 }
96 printf("__sparc_utrap: type=%s pc=%#lx npc=%#lx\n",
97 utrap_msg[uf->uf_type], uf->uf_pc, uf->uf_npc);
98 abort();
98 if (sig) {
99 __utrap_write("__sparc_utrap: fatal ");
100 __utrap_write(utrap_msg[uf->uf_type]);
101 __utrap_write("\n");
102 __utrap_kill_self(sig);
103 }
104 UF_DONE(uf);
99}
105}
106
107void
108__utrap_write(const char *str)
109{
110 int berrno;
111
112 berrno = errno;
113 __sys_write(STDERR_FILENO, str, strlen(str));
114 errno = berrno;
115}
116
117void
118__utrap_kill_self(sig)
119{
120 int berrno;
121
122 berrno = errno;
123 __sys_kill(__sys_getpid(), sig);
124 errno = berrno;
125}
126
127void
128__utrap_panic(const char *msg)
129{
130
131 __utrap_write(msg);
132 __utrap_write("\n");
133 __utrap_kill_self(SIGKILL);
134}