[parisc-linux-cvs] Proposal: Make user reg dumps KERN_DEBUG
Richard Hirst
rhirst@linuxcare.com
Sun, 27 May 2001 22:52:01 +0100
I think it too early to switch off register dumps on user process
faults, so I have a patch here that makes them KERN_DEBUG. With
that you can get them on the console (dmesg -n 8) and/or you can
route them to a file via etc/syslog.conf. I don't know what
will happen by default on a new install yet. I've tested this
briefly with a userland fault, and with a kernel fault. Looks
ok.
Comments please,
Richard
Index: arch/parisc/kernel/traps.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/traps.c,v
retrieving revision 1.47
diff -u -r1.47 traps.c
--- traps.c 2001/05/25 10:52:57 1.47
+++ traps.c 2001/05/27 21:41:07
@@ -42,7 +42,7 @@
#include <kdb/trap.h> /* for I_BRK_INST */
#endif /* CONFIG_KWDB */
-#undef PRINT_USER_FAULTS /* (turn this on if you want user faults to be */
+#define PRINT_USER_FAULTS /* (turn this on if you want user faults to be */
/* dumped to the console via printk) */
@@ -58,13 +58,16 @@
int kstack_depth_to_print = 24;
-static void printbinary(unsigned long x, int nbits)
+static int printbinary(char *buf, unsigned long x, int nbits)
{
unsigned long mask = 1UL << (nbits - 1);
while (mask != 0) {
- printk(mask & x ? "1" : "0");
+ *buf++ = (mask & x ? '1' : '0');
mask >>= 1;
}
+ *buf = '\0';
+
+ return nbits;
}
#ifdef __LP64__
@@ -76,43 +79,49 @@
void show_regs(struct pt_regs *regs)
{
int i;
+ char buf[128], *p;
+ char *level;
+
+ level = user_mode(regs) ? KERN_DEBUG : KERN_CRIT;
- printk("\n"); /* don't want to have that pretty register dump messed up */
+ printk("%s\n", level); /* don't want to have that pretty register dump messed up */
- printk(" YZrvWESTHLNXBCVMcbcbcbcbOGFRQPDI\nPSW: ");
- printbinary(regs->gr[0], 32);
- printk("\n");
+ printk("%s YZrvWESTHLNXBCVMcbcbcbcbOGFRQPDI\n", level);
+ printbinary(buf, regs->gr[0], 32);
+ printk("%sPSW: %s\n", level, buf);
for (i = 0; i < 32; i += 4) {
int j;
- printk("r%d-%d\t", i, i + 3);
+ p = buf;
+ p += sprintf(p, "%sr%d-%d\t", level, i, i + 3);
for (j = 0; j < 4; j++) {
- printk(" " RFMT, i + j == 0 ? 0 : regs->gr[i + j]);
+ p += sprintf(p, " " RFMT, i + j == 0 ? 0 : regs->gr[i + j]);
}
- printk("\n");
+ printk("%s\n", buf);
}
for (i = 0; i < 8; i += 4) {
int j;
- printk("sr%d-%d\t", i, i + 3);
+ p = buf;
+ p += sprintf(p, "%ssr%d-%d\t", level, i, i + 3);
for (j = 0; j < 4; j++) {
- printk(" " RFMT, regs->sr[i + j]);
+ p += sprintf(p, " " RFMT, regs->sr[i + j]);
}
- printk("\n");
+ printk("%s\n", buf);
}
#if REDICULOUSLY_VERBOSE
- for (i = 0; i < 32; i++) {
- printk("FR%2d : %016lx ", i, regs->fr[i]);
- if ((i & 1) == 1)
- printk("\n");
- }
+ for (i = 0; i < 32; i += 2)
+ printk("%sFR%2d : %016lx FR%2d : %016lx", level, i,
+ regs->fr[i], i+1, regs->fr[i+1]);
#endif
- printk("\nIASQ: " RFMT " " RFMT " IAOQ: " RFMT " " RFMT "\n",
- regs->iasq[0], regs->iasq[1], regs->iaoq[0], regs->iaoq[1]);
- printk(" IIR: %08lx ISR: " RFMT " IOR: " RFMT "\nORIG_R28: " RFMT
- "\n", regs->iir, regs->isr, regs->ior, regs->orig_r28);
+ printk("%s\n", level);
+ printk("%sIASQ: " RFMT " " RFMT " IAOQ: " RFMT " " RFMT "\n",
+ level, regs->iasq[0], regs->iasq[1], regs->iaoq[0], regs->iaoq[1]);
+ printk("%s IIR: %08lx ISR: " RFMT " IOR: " RFMT "\n",
+ level, regs->iir, regs->isr, regs->ior);
+ printk("%s ORIG_R28: " RFMT "\n", level, regs->orig_r28);
}
void
@@ -124,7 +133,7 @@
return; /* STFU */
/* XXX for debugging only */
- printk ("!!die_if_kernel: %s(%d): %s %ld\n",
+ printk (KERN_DEBUG "!!die_if_kernel: %s(%d): %s %ld\n",
current->comm, current->pid, str, err);
show_regs(regs);
#endif
@@ -174,7 +183,7 @@
case 0x00:
#ifdef PRINT_USER_FAULTS
cli();
- printk("break 0,0: pid=%d command='%s'\n",
+ printk(KERN_DEBUG "break 0,0: pid=%d command='%s'\n",
current->pid, current->comm);
#endif
die_if_kernel("Breakpoint", regs, 0);
@@ -217,7 +226,7 @@
default:
set_eiem(0);
#ifdef PRINT_USER_FAULTS
- printk("break %#08x: pid=%d command='%s'\n",
+ printk(KERN_DEBUG "break %#08x: pid=%d command='%s'\n",
iir, current->pid, current->comm);
show_regs(regs);
#endif
@@ -396,7 +405,7 @@
default:
if (user_mode(regs)) {
#ifdef PRINT_USER_FAULTS
- printk("\nhandle_interruption() pid=%d command='%s'\n",
+ printk(KERN_DEBUG "\nhandle_interruption() pid=%d command='%s'\n",
current->pid, current->comm);
show_regs(regs);
#endif
@@ -416,9 +425,9 @@
if (fault_space != regs->sr[7]) {
#ifdef PRINT_USER_FAULTS
if (fault_space == 0)
- printk("User Fault on Kernel Space ");
+ printk(KERN_DEBUG "User Fault on Kernel Space ");
else
- printk("User Fault (long pointer) ");
+ printk(KERN_DEBUG "User Fault (long pointer) ");
printk("pid=%d command='%s'\n", current->pid, current->comm);
show_regs(regs);
#endif
Index: arch/parisc/mm/fault.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/mm/fault.c,v
retrieving revision 1.28
diff -u -r1.28 fault.c
--- fault.c 2001/05/25 10:52:57 1.28
+++ fault.c 2001/05/27 21:41:09
@@ -18,7 +18,7 @@
#include <asm/uaccess.h>
-#undef PRINT_USER_FAULTS /* (turn this on if you want user faults to be */
+#define PRINT_USER_FAULTS /* (turn this on if you want user faults to be */
/* dumped to the console via printk) */
@@ -213,10 +213,11 @@
struct siginfo si;
#ifdef PRINT_USER_FAULTS
- printk("\ndo_page_fault() pid=%d command='%s' type=%d address=0x%08lx\n",
+ printk(KERN_DEBUG "\n");
+ printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%d address=0x%08lx\n",
tsk->pid, tsk->comm, code, address);
if (vma) {
- printk("vm_start = 0x%08lx, vm_end = 0x%08lx\n",
+ printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
vma->vm_start, vma->vm_end);
}
show_regs(regs);