|
From: <sv...@va...> - 2005-11-12 00:13:24
|
Author: tom
Date: 2005-11-12 00:13:20 +0000 (Sat, 12 Nov 2005)
New Revision: 5092
Log:
Add named constants for si_code values to replace the magic numbers.
Modified:
trunk/coregrind/m_signals.c
trunk/include/vki-linux.h
Modified: trunk/coregrind/m_signals.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_signals.c 2005-11-11 18:35:32 UTC (rev 5091)
+++ trunk/coregrind/m_signals.c 2005-11-12 00:13:20 UTC (rev 5092)
@@ -1015,8 +1015,8 @@
switch(sigNo) {
case VKI_SIGSEGV:
switch(info->si_code) {
- case 1: event =3D "Access not within mapped region"; break;
- case 2: event =3D "Bad permissions for mapped region"; break;
+ case VKI_SEGV_MAPERR: event =3D "Access not within mapped region"; =
break;
+ case VKI_SEGV_ACCERR: event =3D "Bad permissions for mapped region"=
; break;
case 128:
/* General Protection Fault: The CPU/kernel
isn't telling us anything useful, but this
@@ -1038,35 +1038,35 @@
=20
case VKI_SIGILL:
switch(info->si_code) {
- case 1: event =3D "Illegal opcode"; break;
- case 2: event =3D "Illegal operand"; break;
- case 3: event =3D "Illegal addressing mode"; break;
- case 4: event =3D "Illegal trap"; break;
- case 5: event =3D "Privileged opcode"; break;
- case 6: event =3D "Privileged register"; break;
- case 7: event =3D "Coprocessor error"; break;
- case 8: event =3D "Internal stack error"; break;
+ case VKI_ILL_ILLOPC: event =3D "Illegal opcode"; break;
+ case VKI_ILL_ILLOPN: event =3D "Illegal operand"; break;
+ case VKI_ILL_ILLADR: event =3D "Illegal addressing mode"; break;
+ case VKI_ILL_ILLTRP: event =3D "Illegal trap"; break;
+ case VKI_ILL_PRVOPC: event =3D "Privileged opcode"; break;
+ case VKI_ILL_PRVREG: event =3D "Privileged register"; break;
+ case VKI_ILL_COPROC: event =3D "Coprocessor error"; break;
+ case VKI_ILL_BADSTK: event =3D "Internal stack error"; break;
}
break;
=20
case VKI_SIGFPE:
switch (info->si_code) {
- case 1: event =3D "Integer divide by zero"; break;
- case 2: event =3D "Integer overflow"; break;
- case 3: event =3D "FP divide by zero"; break;
- case 4: event =3D "FP overflow"; break;
- case 5: event =3D "FP underflow"; break;
- case 6: event =3D "FP inexact"; break;
- case 7: event =3D "FP invalid operation"; break;
- case 8: event =3D "FP subscript out of range"; break;
+ case VKI_FPE_INTDIV: event =3D "Integer divide by zero"; break;
+ case VKI_FPE_INTOVF: event =3D "Integer overflow"; break;
+ case VKI_FPE_FLTDIV: event =3D "FP divide by zero"; break;
+ case VKI_FPE_FLTOVF: event =3D "FP overflow"; break;
+ case VKI_FPE_FLTUND: event =3D "FP underflow"; break;
+ case VKI_FPE_FLTRES: event =3D "FP inexact"; break;
+ case VKI_FPE_FLTINV: event =3D "FP invalid operation"; break;
+ case VKI_FPE_FLTSUB: event =3D "FP subscript out of range"; break;
}
break;
=20
case VKI_SIGBUS:
switch (info->si_code) {
- case 1: event =3D "Invalid address alignment"; break;
- case 2: event =3D "Non-existent physical address"; break;
- case 3: event =3D "Hardware error"; break;
+ case VKI_BUS_ADRALN: event =3D "Invalid address alignment"; break;
+ case VKI_BUS_ADRERR: event =3D "Non-existent physical address"; bre=
ak;
+ case VKI_BUS_OBJERR: event =3D "Hardware error"; break;
}
break;
}
@@ -1249,7 +1249,7 @@
vg_assert(VG_(threads)[tid].status =3D=3D VgTs_Runnable);
=20
info.si_signo =3D VKI_SIGILL;
- info.si_code =3D 1; /* jrs: no idea what this should be */
+ info.si_code =3D VKI_ILL_ILLOPC; /* jrs: no idea what this should be =
*/
info._sifields._sigfault._addr =3D (void*)addr;
=20
resume_scheduler(tid);
@@ -1563,7 +1563,7 @@
"seg=3D%p-%p",
info->si_code, fault, tid, esp, seg->start, seg->end);
}
- if (info->si_code =3D=3D 1 /* SEGV_MAPERR */
+ if (info->si_code =3D=3D VKI_SEGV_MAPERR
&& seg
&& seg->kind =3D=3D SkResvn
&& seg->smode =3D=3D SmUpper
Modified: trunk/include/vki-linux.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/include/vki-linux.h 2005-11-11 18:35:32 UTC (rev 5091)
+++ trunk/include/vki-linux.h 2005-11-12 00:13:20 UTC (rev 5092)
@@ -431,6 +431,8 @@
} _sifields;
} vki_siginfo_t;
=20
+#define __VKI_SI_FAULT 0
+
/*
* si_code values
* Digital reserves positive values for kernel-generated signals.
@@ -439,6 +441,43 @@
#define VKI_SI_TKILL -6 /* sent by tkill system call */
=20
/*
+ * SIGILL si_codes
+ */
+#define VKI_ILL_ILLOPC (__VKI_SI_FAULT|1) /* illegal opcode */
+#define VKI_ILL_ILLOPN (__VKI_SI_FAULT|2) /* illegal operand */
+#define VKI_ILL_ILLADR (__VKI_SI_FAULT|3) /* illegal addressing mode */
+#define VKI_ILL_ILLTRP (__VKI_SI_FAULT|4) /* illegal trap */
+#define VKI_ILL_PRVOPC (__VKI_SI_FAULT|5) /* privileged opcode */
+#define VKI_ILL_PRVREG (__VKI_SI_FAULT|6) /* privileged register */
+#define VKI_ILL_COPROC (__VKI_SI_FAULT|7) /* coprocessor error */
+#define VKI_ILL_BADSTK (__VKI_SI_FAULT|8) /* internal stack error */
+
+/*
+ * SIGFPE si_codes
+ */
+#define VKI_FPE_INTDIV (__VKI_SI_FAULT|1) /* integer divide by zero */
+#define VKI_FPE_INTOVF (__VKI_SI_FAULT|2) /* integer overflow */
+#define VKI_FPE_FLTDIV (__VKI_SI_FAULT|3) /* floating point divide by ze=
ro */
+#define VKI_FPE_FLTOVF (__VKI_SI_FAULT|4) /* floating point overflow */
+#define VKI_FPE_FLTUND (__VKI_SI_FAULT|5) /* floating point underflow */
+#define VKI_FPE_FLTRES (__VKI_SI_FAULT|6) /* floating point inexact resu=
lt */
+#define VKI_FPE_FLTINV (__VKI_SI_FAULT|7) /* floating point invalid oper=
ation */
+#define VKI_FPE_FLTSUB (__VKI_SI_FAULT|8) /* subscript out of range */
+
+/*
+ * SIGSEGV si_codes
+ */
+#define VKI_SEGV_MAPERR (__VKI_SI_FAULT|1) /* address not mapped to obje=
ct */
+#define VKI_SEGV_ACCERR (__VKI_SI_FAULT|2) /* invalid permissions for ma=
pped object */
+
+/*
+ * SIGBUS si_codes
+ */
+#define VKI_BUS_ADRALN (__VKI_SI_FAULT|1) /* invalid address alignment *=
/
+#define VKI_BUS_ADRERR (__VKI_SI_FAULT|2) /* non-existant physical addre=
ss */
+#define VKI_BUS_OBJERR (__VKI_SI_FAULT|3) /* object specific hardware er=
ror */
+
+/*
* This works because the alignment is ok on all current architectures
* but we leave open this being overridden in the future
*/
|