summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-08-14 12:15:01 +0000
committerkib <kib@FreeBSD.org>2012-08-14 12:15:01 +0000
commit92b79b92fb839b664e41c671fcfd29ebfe578dc4 (patch)
tree080fe1902f5d341c66e9a38440d49b82b606b56e
parent11621fbf7f3f18c2e71e0074b0e680b15336b0bf (diff)
downloadFreeBSD-src-92b79b92fb839b664e41c671fcfd29ebfe578dc4.zip
FreeBSD-src-92b79b92fb839b664e41c671fcfd29ebfe578dc4.tar.gz
Add a hackish debugging facility to provide a bit of information about
reason for generated trap. The dump of basic signal information and 8 bytes of the faulting instruction are printed on the controlling terminal of the process, if the machdep.uprintf_signal syscal is enabled. The print is the only practical way to debug traps from a.out processes I am aware of. Because I have to reimplement it each time I debug an issue with a.out support on amd64, commit the hack to main tree. MFC after: 1 week
-rw-r--r--sys/amd64/amd64/trap.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index d035a7e..62533cb 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -176,9 +176,14 @@ static int panic_on_nmi = 1;
SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RW,
&panic_on_nmi, 0, "Panic on NMI");
TUNABLE_INT("machdep.panic_on_nmi", &panic_on_nmi);
-static int prot_fault_translation = 0;
+static int prot_fault_translation;
SYSCTL_INT(_machdep, OID_AUTO, prot_fault_translation, CTLFLAG_RW,
- &prot_fault_translation, 0, "Select signal to deliver on protection fault");
+ &prot_fault_translation, 0,
+ "Select signal to deliver on protection fault");
+static int uprintf_signal;
+SYSCTL_INT(_machdep, OID_AUTO, uprintf_signal, CTLFLAG_RW,
+ &uprintf_signal, 0,
+ "Print debugging information on trap signal to ctty");
/*
* Exception, fault, and trap interface to the FreeBSD kernel.
@@ -610,6 +615,19 @@ trap(struct trapframe *frame)
ksi.ksi_code = ucode;
ksi.ksi_trapno = type;
ksi.ksi_addr = (void *)addr;
+ if (uprintf_signal) {
+ uprintf("pid %d comm %s: signal %d err %lx code %d type %d "
+ "addr 0x%lx <%02x %02x %02x %02x %02x %02x %02x %02x>\n",
+ p->p_pid, p->p_comm, i, frame->tf_err, ucode, type, addr,
+ fubyte((void *)(frame->tf_rip + 0)),
+ fubyte((void *)(frame->tf_rip + 1)),
+ fubyte((void *)(frame->tf_rip + 2)),
+ fubyte((void *)(frame->tf_rip + 3)),
+ fubyte((void *)(frame->tf_rip + 4)),
+ fubyte((void *)(frame->tf_rip + 5)),
+ fubyte((void *)(frame->tf_rip + 6)),
+ fubyte((void *)(frame->tf_rip + 7)));
+ }
trapsignal(td, &ksi);
user:
OpenPOWER on IntegriCloud