]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] cleanup debugger hooks
authorAnton Blanchard <anton@samba.org>
Fri, 13 Feb 2004 23:30:34 +0000 (15:30 -0800)
committerAnton Blanchard <anton@samba.org>
Fri, 13 Feb 2004 23:30:34 +0000 (15:30 -0800)
Theres still more to do here, but at least the ifdef mess is gone. No
more checking for NULL before calling functions, that was playing with
fire. Oh yeah and lots more deletions :)

Clean up the debugger hooks, it was way too easy to screw up.
And we did. And Linus hit it.

- create CONFIG_DEBUGGER so we can enable kernel debugging options but not
  have any trace of debugger gunk.
- remove a bunch of xmon prototypes so no one gets the urge to call them
- Use die() instead of panic in a number of places, it gives us much better
  debug information.
- Get rid of the ifdef madness

15 files changed:
arch/ppc64/Kconfig
arch/ppc64/kernel/open_pic.c
arch/ppc64/kernel/ppc_ksyms.c
arch/ppc64/kernel/setup.c
arch/ppc64/kernel/smp.c
arch/ppc64/kernel/traps.c
arch/ppc64/kernel/xics.c
arch/ppc64/mm/fault.c
arch/ppc64/mm/init.c
arch/ppc64/xmon/start.c
arch/ppc64/xmon/xmon.c
include/asm-ppc64/ppcdebug.h
include/asm-ppc64/smp.h
include/asm-ppc64/system.h
include/asm-ppc64/xmon.h [deleted file]

index 54d6bd501f4865ae3fad9c1dca3fc5ac5f4c344a..a434f2885ed2de4db71ab9931173cec545356396 100644 (file)
@@ -356,9 +356,16 @@ config MAGIC_SYSRQ
          keys are documented in <file:Documentation/sysrq.txt>. Don't say Y
          unless you really know what this hack does.
 
+config DEBUGGER
+       bool "Enable debugger hooks"
+       depends on DEBUG_KERNEL
+       help
+         Include in-kernel hooks for kernel debuggers. Unless you are
+         intending to debug the kernel, say N here.
+
 config XMON
        bool "Include xmon kernel debugger"
-       depends on DEBUG_KERNEL
+       depends on DEBUGGER
        help
          Include in-kernel hooks for the xmon kernel monitor/debugger.
          Unless you are intending to debug the kernel, say N here.
index c7114c8bffc9a2ffce3c82e9127749847c0d09aa..73442c26402eda2d528ba565c3b4576ba420860b 100644 (file)
@@ -645,9 +645,9 @@ void openpic_request_IPIs(void)
        request_irq(openpic_vec_ipi+1, openpic_ipi_action, SA_INTERRUPT,
                   "IPI1 (reschedule)", 0);
        request_irq(openpic_vec_ipi+2, openpic_ipi_action, SA_INTERRUPT,
-                  "IPI2 (invalidate tlb)", 0);
+                  "IPI2 (unused)", 0);
        request_irq(openpic_vec_ipi+3, openpic_ipi_action, SA_INTERRUPT,
-                  "IPI3 (xmon break)", 0);
+                  "IPI3 (debugger break)", 0);
 
        for ( i = 0; i < OPENPIC_NUM_IPI ; i++ )
                openpic_enable_ipi(openpic_vec_ipi+i);
index 72fb5691fc125a3298a5030c5c704a14945652c5..d098ebdbb922ae6b9652a7c234dd598342571047 100644 (file)
@@ -206,25 +206,6 @@ EXPORT_SYMBOL(timer_interrupt);
 EXPORT_SYMBOL(irq_desc);
 EXPORT_SYMBOL(get_wchan);
 EXPORT_SYMBOL(console_drivers);
-#ifdef CONFIG_XMON
-EXPORT_SYMBOL(xmon);
-#endif
-
-#ifdef CONFIG_DEBUG_KERNEL
-extern void (*debugger)(struct pt_regs *regs);
-extern int (*debugger_bpt)(struct pt_regs *regs);
-extern int (*debugger_sstep)(struct pt_regs *regs);
-extern int (*debugger_iabr_match)(struct pt_regs *regs);
-extern int (*debugger_dabr_match)(struct pt_regs *regs);
-extern void (*debugger_fault_handler)(struct pt_regs *regs);
-
-EXPORT_SYMBOL(debugger);
-EXPORT_SYMBOL(debugger_bpt);
-EXPORT_SYMBOL(debugger_sstep);
-EXPORT_SYMBOL(debugger_iabr_match);
-EXPORT_SYMBOL(debugger_dabr_match);
-EXPORT_SYMBOL(debugger_fault_handler);
-#endif
 
 EXPORT_SYMBOL(tb_ticks_per_usec);
 EXPORT_SYMBOL(paca);
index b51a1c0513ed94e35160771f799df80c74953937..f59df0822673418cb887136f45d5e7c25a348b10 100644 (file)
@@ -42,6 +42,7 @@
 #include <asm/sections.h>
 #include <asm/btext.h>
 #include <asm/nvram.h>
+#include <asm/system.h>
 
 extern unsigned long klimit;
 /* extern void *stab; */
@@ -79,10 +80,6 @@ unsigned long decr_overclock_proc0_set = 0;
 
 int powersave_nap;
 
-#ifdef CONFIG_XMON
-extern void xmon_map_scc(void);
-#endif
-
 char saved_command_line[256];
 unsigned char aux_device_present;
 
@@ -159,15 +156,11 @@ void setup_system(unsigned long r3, unsigned long r4, unsigned long r5,
                  unsigned long r6, unsigned long r7)
 {
 #ifdef CONFIG_PPC_PSERIES
-        unsigned int ret, i;
+       unsigned int ret, i;
 #endif
 
 #ifdef CONFIG_XMON_DEFAULT
-       debugger = xmon;
-       debugger_bpt = xmon_bpt;
-       debugger_sstep = xmon_sstep;
-       debugger_iabr_match = xmon_iabr_match;
-       debugger_dabr_match = xmon_dabr_match;
+       xmon_init();
 #endif
 
 #ifdef CONFIG_PPC_ISERIES
@@ -601,13 +594,15 @@ void __init setup_arch(char **cmdline_p)
        calibrate_delay = ppc64_calibrate_delay;
 
        ppc64_boot_msg(0x12, "Setup Arch");
+
 #ifdef CONFIG_XMON
-       xmon_map_scc();
-       if (strstr(cmd_line, "xmon"))
-               xmon(0);
+       if (strstr(cmd_line, "xmon")) {
+               /* ensure xmon is enabled */
+               xmon_init();
+               debugger(0);
+       }
 #endif /* CONFIG_XMON */
 
-
        /*
         * Set cache line size based on type of cpu as a default.
         * Systems with OF can look in the properties on the cpu node(s)
index 36746aefb1d2936832336ee6e1c132a7f5b60781..a1c60332aa86fc42095d0d51220bed5a6155104b 100644 (file)
@@ -49,6 +49,7 @@
 #include <asm/machdep.h>
 #include <asm/xics.h>
 #include <asm/cputable.h>
+#include <asm/system.h>
 
 int smp_threads_ready;
 unsigned long cache_decay_ticks;
@@ -394,7 +395,7 @@ void smp_local_timer_interrupt(struct pt_regs * regs)
 
 void smp_message_recv(int msg, struct pt_regs *regs)
 {
-       switch( msg ) {
+       switch(msg) {
        case PPC_MSG_CALL_FUNCTION:
                smp_call_function_interrupt();
                break;
@@ -407,11 +408,11 @@ void smp_message_recv(int msg, struct pt_regs *regs)
                /* spare */
                break;
 #endif
-#ifdef CONFIG_XMON
-       case PPC_MSG_XMON_BREAK:
-               xmon(regs);
+#ifdef CONFIG_DEBUGGER
+       case PPC_MSG_DEBUGGER_BREAK:
+               debugger(regs);
                break;
-#endif /* CONFIG_XMON */
+#endif
        default:
                printk("SMP %d: smp_message_recv(): unknown msg %d\n",
                       smp_processor_id(), msg);
@@ -424,12 +425,12 @@ void smp_send_reschedule(int cpu)
        smp_message_pass(cpu, PPC_MSG_RESCHEDULE, 0, 0);
 }
 
-#ifdef CONFIG_XMON
-void smp_send_xmon_break(int cpu)
+#ifdef CONFIG_DEBUGGER
+void smp_send_debugger_break(int cpu)
 {
-       smp_message_pass(cpu, PPC_MSG_XMON_BREAK, 0, 0);
+       smp_message_pass(cpu, PPC_MSG_DEBUGGER_BREAK, 0, 0);
 }
-#endif /* CONFIG_XMON */
+#endif
 
 static void stop_this_cpu(void *dummy)
 {
@@ -507,10 +508,7 @@ int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
                        printk("smp_call_function on cpu %d: other cpus not "
                               "responding (%d)\n", smp_processor_id(),
                               atomic_read(&data.started));
-#ifdef CONFIG_DEBUG_KERNEL
-                       if (debugger)
-                               debugger(0);
-#endif
+                       debugger(0);
                        goto out;
                }
        }
@@ -525,10 +523,7 @@ int smp_call_function (void (*func) (void *info), void *info, int nonatomic,
                                       smp_processor_id(),
                                       atomic_read(&data.finished),
                                       atomic_read(&data.started));
-#ifdef CONFIG_DEBUG_KERNEL
-                               if (debugger)
-                                       debugger(0);
-#endif
+                               debugger(0);
                                goto out;
                        }
                }
index 6df8cfca3ba075e557482a644394437564f82c69..e27fe5e668054013728be96a2ebdf5e2b971be0f 100644 (file)
@@ -45,13 +45,20 @@ extern void bad_page_fault(struct pt_regs *, unsigned long, int);
 extern int fwnmi_active;
 #endif
 
-#ifdef CONFIG_DEBUG_KERNEL
-void (*debugger)(struct pt_regs *regs);
-int (*debugger_bpt)(struct pt_regs *regs);
-int (*debugger_sstep)(struct pt_regs *regs);
-int (*debugger_iabr_match)(struct pt_regs *regs);
-int (*debugger_dabr_match)(struct pt_regs *regs);
-void (*debugger_fault_handler)(struct pt_regs *regs);
+#ifdef CONFIG_DEBUGGER
+int (*__debugger)(struct pt_regs *regs);
+int (*__debugger_bpt)(struct pt_regs *regs);
+int (*__debugger_sstep)(struct pt_regs *regs);
+int (*__debugger_iabr_match)(struct pt_regs *regs);
+int (*__debugger_dabr_match)(struct pt_regs *regs);
+int (*__debugger_fault_handler)(struct pt_regs *regs);
+
+EXPORT_SYMBOL(__debugger);
+EXPORT_SYMBOL(__debugger_bpt);
+EXPORT_SYMBOL(__debugger_sstep);
+EXPORT_SYMBOL(__debugger_iabr_match);
+EXPORT_SYMBOL(__debugger_dabr_match);
+EXPORT_SYMBOL(__debugger_fault_handler);
 #endif
 
 /*
@@ -88,11 +95,9 @@ static void
 _exception(int signr, siginfo_t *info, struct pt_regs *regs)
 {
        if (!user_mode(regs)) {
-#ifdef CONFIG_DEBUG_KERNEL
-               if (debugger)
-                       debugger(regs);
-#endif
-               die("Exception in kernel mode", regs, signr);
+               if (debugger(regs))
+                       return;
+               die("Exception in kernel mode\n", regs, signr);
        }
 
        force_sig_info(signr, info, current);
@@ -146,12 +151,8 @@ SystemResetException(struct pt_regs *regs)
        }
 #endif
 
-#ifdef CONFIG_DEBUG_KERNEL
-       if (debugger)
-               debugger(regs);
-       else
-#endif
-               panic("System Reset");
+       if (!debugger(regs))
+               die("System Reset", regs, 0);
 
        /* Must die if the interrupt is not recoverable */
        if (!(regs->msr & MSR_RI))
@@ -228,23 +229,12 @@ MachineCheckException(struct pt_regs *regs)
        }
 #endif
 
-#ifdef CONFIG_DEBUG_KERNEL
-       if (debugger_fault_handler) {
-               debugger_fault_handler(regs);
+       if (debugger_fault_handler(regs))
                return;
-       }
-       if (debugger)
-               debugger(regs);
-#endif
-       console_verbose();
-       spin_lock_irq(&die_lock);
-       bust_spinlocks(1);
-       printk("Machine check in kernel mode.\n");
-       printk("Caused by (from SRR1=%lx): ", regs->msr);
-       show_regs(regs);
-       bust_spinlocks(0);
-       spin_unlock_irq(&die_lock);
-       panic("Unrecoverable Machine Check");
+       if (debugger(regs))
+               return;
+
+       die("Machine check in kernel mode", regs, 0);
 }
 
 void
@@ -267,10 +257,8 @@ InstructionBreakpointException(struct pt_regs *regs)
 {
        siginfo_t info;
 
-#ifdef CONFIG_DEBUG_KERNEL
-       if (debugger_iabr_match && debugger_iabr_match(regs))
+       if (debugger_iabr_match(regs))
                return;
-#endif
        info.si_signo = SIGTRAP;
        info.si_errno = 0;
        info.si_code = TRAP_BRKPT;
@@ -372,12 +360,8 @@ ProgramCheckException(struct pt_regs *regs)
 {
        siginfo_t info;
 
-#ifdef CONFIG_DEBUG_KERNEL
-       if (debugger_fault_handler) {
-               debugger_fault_handler(regs);
+       if (debugger_fault_handler(regs))
                return;
-       }
-#endif
 
        if (regs->msr & 0x100000) {
                /* IEEE FP exception */
@@ -394,10 +378,9 @@ ProgramCheckException(struct pt_regs *regs)
        } else if (regs->msr & 0x20000) {
                /* trap exception */
 
-#ifdef CONFIG_DEBUG_KERNEL
-               if (debugger_bpt && debugger_bpt(regs))
+               if (debugger_bpt(regs))
                        return;
-#endif
+
                if (check_bug_trap(regs)) {
                        regs->nip += 4;
                        return;
@@ -421,17 +404,13 @@ ProgramCheckException(struct pt_regs *regs)
 void
 KernelFPUnavailableException(struct pt_regs *regs)
 {
-       printk("Illegal floating point used in kernel (task=0x%p, "
-               "pc=0x%016lx, trap=0x%lx)\n", current, regs->nip, regs->trap);
-       panic("Unrecoverable FP Unavailable Exception in Kernel");
+       die("Unrecoverable FP Unavailable Exception in Kernel", regs, 0);
 }
 
 void
 KernelAltivecUnavailableException(struct pt_regs *regs)
 {
-       printk("Illegal VMX/Altivec used in kernel (task=0x%p, "
-               "pc=0x%016lx, trap=0x%lx)\n", current, regs->nip, regs->trap);
-       panic("Unrecoverable VMX/Altivec Unavailable Exception in Kernel");
+       die("Unrecoverable VMX/Altivec Unavailable Exception in Kernel", regs, 0);
 }
 
 void
@@ -441,10 +420,9 @@ SingleStepException(struct pt_regs *regs)
 
        regs->msr &= ~MSR_SE;  /* Turn off 'trace' bit */
 
-#ifdef CONFIG_DEBUG_KERNEL
-       if (debugger_sstep && debugger_sstep(regs))
+       if (debugger_sstep(regs))
                return;
-#endif
+
        info.si_signo = SIGTRAP;
        info.si_errno = 0;
        info.si_code = TRAP_TRACE;
index 05ca227ace39cb98b78b8819325e2338b40d56a7..ecda4a4898c26e42ae7ab31215c999c73638da52 100644 (file)
@@ -353,11 +353,11 @@ irqreturn_t xics_ipi_action(int irq, void *dev_id, struct pt_regs *regs)
                        smp_message_recv(PPC_MSG_MIGRATE_TASK, regs);
                }
 #endif
-#ifdef CONFIG_XMON
-               if (test_and_clear_bit(PPC_MSG_XMON_BREAK,
+#ifdef CONFIG_DEBUGGER
+               if (test_and_clear_bit(PPC_MSG_DEBUGGER_BREAK,
                                       &xics_ipi_message[cpu].value)) {
                        mb();
-                       smp_message_recv(PPC_MSG_XMON_BREAK, regs);
+                       smp_message_recv(PPC_MSG_DEBUGGER_BREAK, regs);
                }
 #endif
        }
index 64e1a9852e9611a3d411814a1bb8b03f221d472e..4fd5100acff1867bccfd6ad0e650f5549797b9ba 100644 (file)
 #include <asm/system.h>
 #include <asm/uaccess.h>
 
-#include <asm/ppcdebug.h>
-
-#ifdef CONFIG_DEBUG_KERNEL
-int debugger_kernel_faults = 1;
-#endif
-
 void bad_page_fault(struct pt_regs *, unsigned long, int);
 
 /*
@@ -60,13 +54,10 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,
        unsigned long code = SEGV_MAPERR;
        unsigned long is_write = error_code & 0x02000000;
 
-#ifdef CONFIG_DEBUG_KERNEL
-       if (debugger_fault_handler && (regs->trap == 0x300 ||
-                                      regs->trap == 0x380)) {
-               debugger_fault_handler(regs);
-               return;
+       if (regs->trap == 0x300 || regs->trap == 0x380) {
+               if (debugger_fault_handler(regs))
+                       return;
        }
-#endif
 
        /* On a kernel SLB miss we can only check for a valid exception entry */
        if (!user_mode(regs) && (regs->trap == 0x380)) {
@@ -74,13 +65,10 @@ void do_page_fault(struct pt_regs *regs, unsigned long address,
                return;
        }
 
-#ifdef CONFIG_DEBUG_KERNEL
        if (error_code & 0x00400000) {
-               /* DABR match */
                if (debugger_dabr_match(regs))
                        return;
        }
-#endif
 
        if (in_atomic() || mm == NULL) {
                bad_page_fault(regs, address, SIGSEGV);
@@ -149,11 +137,6 @@ bad_area:
                info.si_errno = 0;
                info.si_code = code;
                info.si_addr = (void *) address;
-#ifdef CONFIG_XMON
-               ifppcdebug(PPCDBG_SIGNALXMON)
-                       PPCDBG_ENTER_DEBUGGER_REGS(regs);
-#endif
-
                force_sig_info(SIGSEGV, &info, current);
                return;
        }
@@ -207,9 +190,7 @@ bad_page_fault(struct pt_regs *regs, unsigned long address, int sig)
        }
 
        /* kernel has accessed a bad area */
-#ifdef CONFIG_DEBUG_KERNEL
-       if (debugger_kernel_faults && debugger)
-               debugger(regs);
-#endif
+       if (debugger(regs))
+               return;
        die("Kernel access of bad area", regs, sig);
 }
index 9cf45d7541576fb86478622a72682337da7c1078..b2ffe51c8b4db5e7f6b14f7b3763e5f022f0e532 100644 (file)
@@ -59,6 +59,7 @@
 #include <asm/cputable.h>
 #include <asm/ppcdebug.h>
 #include <asm/sections.h>
+#include <asm/system.h>
 
 #ifdef CONFIG_PPC_ISERIES
 #include <asm/iSeries/iSeries_dma.h>
@@ -691,11 +692,7 @@ void __init do_init_bootmem(void)
        bootmap_pages = bootmem_bootmap_pages(total_pages);
 
        start = (unsigned long)__a2p(lmb_alloc(bootmap_pages<<PAGE_SHIFT, PAGE_SIZE));
-       if (start == 0) {
-               udbg_printf("do_init_bootmem: failed to allocate a bitmap.\n");
-               udbg_printf("\tbootmap_pages = 0x%lx.\n", bootmap_pages);
-               PPCDBG_ENTER_DEBUGGER(); 
-       }
+       BUG_ON(!start);
 
        boot_mapsize = init_bootmem(start >> PAGE_SHIFT, total_pages);
 
index c0c416c34dff362d9c70aed5c27864b28acb93a7..0a68c8799b6bf077905c4e45759740f41868609b 100644 (file)
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/sysrq.h>
+#include <linux/init.h>
 #include <asm/machdep.h>
 #include <asm/io.h>
 #include <asm/page.h>
 #include <asm/prom.h>
 #include <asm/processor.h>
 #include <asm/udbg.h>
-
-extern void xmon_printf(const char *fmt, ...);
-
-#define TB_SPEED       25000000
-
-static inline unsigned int readtb(void)
-{
-       unsigned int ret;
-
-       asm volatile("mftb %0" : "=r" (ret) :);
-       return ret;
-}
+#include <asm/system.h>
 
 #ifdef CONFIG_MAGIC_SYSRQ
 
 static void sysrq_handle_xmon(int key, struct pt_regs *pt_regs,
                              struct tty_struct *tty) 
 {
-       xmon(pt_regs);
+       /* ensure xmon is enabled */
+       xmon_init();
+       debugger(pt_regs);
 }
 
 static struct sysrq_key_op sysrq_xmon_op = 
@@ -45,16 +37,13 @@ static struct sysrq_key_op sysrq_xmon_op =
        .action_msg =   "Entering xmon\n",
 };
 
-#endif /* CONFIG_MAGIC_SYSRQ */
-
-void
-xmon_map_scc(void)
+static int __init setup_xmon_sysrq(void)
 {
-#ifdef CONFIG_MAGIC_SYSRQ
-       /* This maybe isn't the best place to register sysrq 'x' */
        __sysrq_put_key_op('x', &sysrq_xmon_op);
-#endif /* CONFIG_MAGIC_SYSRQ */
+       return 0;
 }
+__initcall(setup_xmon_sysrq);
+#endif /* CONFIG_MAGIC_SYSRQ */
 
 int
 xmon_write(void *handle, void *ptr, int nb)
@@ -62,8 +51,6 @@ xmon_write(void *handle, void *ptr, int nb)
        return udbg_write(ptr, nb);
 }
 
-int xmon_wants_key;
-
 int
 xmon_read(void *handle, void *ptr, int nb)
 {
@@ -80,11 +67,6 @@ void *xmon_stdin;
 void *xmon_stdout;
 void *xmon_stderr;
 
-void
-xmon_init(void)
-{
-}
-
 int
 xmon_putc(int c, void *f)
 {
index 16ebf3dccc6609b00d3108a79fb69c1a804c6a54..57e1b03c65466b6340f502c46533e3694361701a 100644 (file)
@@ -73,11 +73,10 @@ static struct bpt iabr;
 static unsigned bpinstr = 0x7fe00008;  /* trap */
 
 /* Prototypes */
-extern void (*debugger_fault_handler)(struct pt_regs *);
 static int cmds(struct pt_regs *);
 static int mread(unsigned long, void *, int);
 static int mwrite(unsigned long, void *, int);
-static void handle_fault(struct pt_regs *);
+static int handle_fault(struct pt_regs *);
 static void byterev(unsigned char *, int);
 static void memex(void);
 static int bsesc(void);
@@ -235,7 +234,7 @@ static inline void disable_surveillance(void)
 #endif
 }
 
-void
+int
 xmon(struct pt_regs *excp)
 {
        struct pt_regs regs;
@@ -342,6 +341,8 @@ xmon(struct pt_regs *excp)
        cpu_clear(smp_processor_id(), cpus_in_xmon);
 #endif /* CONFIG_SMP */
        set_msrd(msr);          /* restore interrupt enable */
+
+       return 0;
 }
 
 int
@@ -627,7 +628,7 @@ static void cpu_cmd(void)
                printf("stopping all cpus\n");
                /* interrupt other cpu(s) */
                cpu = MSG_ALL_BUT_SELF;
-               smp_send_xmon_break(cpu);
+               smp_send_debugger_break(cpu);
                return;
        }
        termch = cmd;
@@ -1052,8 +1053,8 @@ cacheflush(void)
        nflush = 1;
        scanhex(&nflush);
        nflush = (nflush + L1_CACHE_BYTES - 1) / L1_CACHE_BYTES;
-       if( setjmp(bus_error_jmp) == 0 ) {
-               debugger_fault_handler = handle_fault;
+       if (setjmp(bus_error_jmp) == 0) {
+               __debugger_fault_handler = handle_fault;
                sync();
 
                if (cmd != 'i') {
@@ -1067,7 +1068,7 @@ cacheflush(void)
                /* wait a little while to see if we get a machine check */
                __delay(200);
        }
-       debugger_fault_handler = 0;
+       __debugger_fault_handler = 0;
 }
 
 unsigned long
@@ -1088,7 +1089,7 @@ read_spr(int n)
        code = (unsigned long (*)(void)) opd;
 
        if (setjmp(bus_error_jmp) == 0) {
-               debugger_fault_handler = handle_fault;
+               __debugger_fault_handler = handle_fault;
                sync();
 
                ret = code();
@@ -1100,7 +1101,7 @@ read_spr(int n)
                printf("*** Error reading spr %x\n", n);
        }
 
-       debugger_fault_handler = 0;
+       __debugger_fault_handler = 0;
 
        return ret;
 }
@@ -1122,7 +1123,7 @@ write_spr(int n, unsigned long val)
        code = (unsigned long (*)(unsigned long)) opd;
 
        if (setjmp(bus_error_jmp) == 0) {
-               debugger_fault_handler = handle_fault;
+               __debugger_fault_handler = handle_fault;
                sync();
 
                code(val);
@@ -1134,7 +1135,7 @@ write_spr(int n, unsigned long val)
                printf("*** Error writing spr %x\n", n);
        }
 
-       debugger_fault_handler = 0;
+       __debugger_fault_handler = 0;
 }
 
 static unsigned long regno;
@@ -1213,7 +1214,7 @@ mread(unsigned long adrs, void *buf, int size)
 
        n = 0;
        if (setjmp(bus_error_jmp) == 0) {
-               debugger_fault_handler = handle_fault;
+               __debugger_fault_handler = handle_fault;
                sync();
                p = (char *)adrs;
                q = (char *)buf;
@@ -1238,7 +1239,7 @@ mread(unsigned long adrs, void *buf, int size)
                __delay(200);
                n = size;
        }
-       debugger_fault_handler = 0;
+       __debugger_fault_handler = 0;
        return n;
 }
 
@@ -1250,7 +1251,7 @@ mwrite(unsigned long adrs, void *buf, int size)
 
        n = 0;
        if (setjmp(bus_error_jmp) == 0) {
-               debugger_fault_handler = handle_fault;
+               __debugger_fault_handler = handle_fault;
                sync();
                p = (char *) adrs;
                q = (char *) buf;
@@ -1277,14 +1278,14 @@ mwrite(unsigned long adrs, void *buf, int size)
        } else {
                printf("*** Error writing address %x\n", adrs + n);
        }
-       debugger_fault_handler = 0;
+       __debugger_fault_handler = 0;
        return n;
 }
 
 static int fault_type;
 static char *fault_chars[] = { "--", "**", "##" };
 
-static void
+static int
 handle_fault(struct pt_regs *regs)
 {
        switch (regs->trap) {
@@ -1300,6 +1301,8 @@ handle_fault(struct pt_regs *regs)
        }
 
        longjmp(bus_error_jmp, 1);
+
+       return 0;
 }
 
 #define SWAP(a, b, t)  ((t) = (a), (a) = (b), (b) = (t))
@@ -1913,7 +1916,7 @@ void __xmon_print_symbol(const char *fmt, unsigned long address)
        char namebuf[128];
 
        if (setjmp(bus_error_jmp) == 0) {
-               debugger_fault_handler = handle_fault;
+               __debugger_fault_handler = handle_fault;
                sync();
                name = kallsyms_lookup(address, &size, &offset, &modname,
                                       namebuf);
@@ -1924,7 +1927,7 @@ void __xmon_print_symbol(const char *fmt, unsigned long address)
                name = "symbol lookup failed";
        }
 
-       debugger_fault_handler = 0;
+       __debugger_fault_handler = 0;
 
        if (!name) {
                char addrstr[sizeof("0x%lx") + (BITS_PER_LONG*3/10)];
@@ -2037,6 +2040,15 @@ static void dump_stab(void)
        }
 }
 
+void xmon_init(void)
+{
+       __debugger = xmon;
+       __debugger_bpt = xmon_bpt;
+       __debugger_sstep = xmon_sstep;
+       __debugger_iabr_match = xmon_iabr_match;
+       __debugger_dabr_match = xmon_dabr_match;
+}
+
 void dump_segments(void)
 {
        if (cur_cpu_spec->cpu_features & CPU_FTR_SLB)
index 91c31d5284ee834f530d23da7b1677338974a4b9..862ae6df6b0b65148ec1660bb8f5eb92e4ab821c 100644 (file)
@@ -95,11 +95,6 @@ extern char *trace_names[64];
 #define ppcdebugset(FLAGS) (udbg_ifdebug(FLAGS))
 #define PPCDBG_BINFMT (test_thread_flag(TIF_32BIT) ? PPCDBG_BINFMT32 : PPCDBG_BINFMT64)
 
-#ifdef CONFIG_XMON
-#define PPCDBG_ENTER_DEBUGGER() xmon(0)
-#define PPCDBG_ENTER_DEBUGGER_REGS(X) xmon(X)
-#endif
-
 #else
 #define PPCDBG(...) do {;} while (0)
 #define PPCDBGCALL(FLAGS,FUNCTION) do {;} while (0)
@@ -107,12 +102,4 @@ extern char *trace_names[64];
 #define ppcdebugset(FLAGS) (0)
 #endif /* CONFIG_PPCDBG */
 
-#ifndef PPCDBG_ENTER_DEBUGGER
-#define PPCDBG_ENTER_DEBUGGER() do {;} while(0)
-#endif
-
-#ifndef PPCDBG_ENTER_DEBUGGER_REGS
-#define PPCDBG_ENTER_DEBUGGER_REGS(A) do {;} while(0)
-#endif
-
 #endif /*__PPCDEBUG_H */
index c54f858b3b852f43d73058d4904e9f3c91f0e5b2..7c8fae309721dff49c37c9b95ab4f7459d124251 100644 (file)
@@ -29,8 +29,7 @@
 #ifdef CONFIG_SMP
 
 extern void smp_message_pass(int target, int msg, unsigned long data, int wait);
-extern void smp_send_tlb_invalidate(int);
-extern void smp_send_xmon_break(int cpu);
+extern void smp_send_debugger_break(int cpu);
 struct pt_regs;
 extern void smp_message_recv(int, struct pt_regs *);
 
@@ -63,17 +62,22 @@ extern cpumask_t cpu_available_map;
  * in /proc/interrupts will be wrong!!! --Troy */
 #define PPC_MSG_CALL_FUNCTION   0
 #define PPC_MSG_RESCHEDULE      1
+/* This is unused now */
+#if 0
 #define PPC_MSG_MIGRATE_TASK    2
-#define PPC_MSG_XMON_BREAK      3
+#endif
+#define PPC_MSG_DEBUGGER_BREAK  3
 
 void smp_init_iSeries(void);
 void smp_init_pSeries(void);
 
 #endif /* !(CONFIG_SMP) */
-#endif /* __ASSEMBLY__ */
 
 #define get_hard_smp_processor_id(CPU) (paca[(CPU)].xHwProcNum)
-#define set_hard_smp_processor_id(CPU, VAL) do { (paca[(CPU)].xHwProcNum = VAL); } while (0)
+#define set_hard_smp_processor_id(CPU, VAL) \
+       do { (paca[(CPU)].xHwProcNum = VAL); } while (0)
+
+#endif /* __ASSEMBLY__ */
 
 #endif /* !(_PPC64_SMP_H) */
 #endif /* __KERNEL__ */
index 2a88765fd6003992476e5eac868333b5498f7660..7080a2c3cb23f9f8775fc72357b539bc5a135e6e 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/config.h>
+#include <linux/compiler.h>
 #include <asm/page.h>
 #include <asm/processor.h>
 #include <asm/hw_irq.h>
 #define smp_read_barrier_depends()  do { } while(0)
 #endif /* CONFIG_SMP */
 
-#ifdef CONFIG_DEBUG_KERNEL
-extern void (*debugger)(struct pt_regs *regs);
-extern int (*debugger_bpt)(struct pt_regs *regs);
-extern int (*debugger_sstep)(struct pt_regs *regs);
-extern int (*debugger_iabr_match)(struct pt_regs *regs);
-extern int (*debugger_dabr_match)(struct pt_regs *regs);
-extern void (*debugger_fault_handler)(struct pt_regs *regs);
+#ifdef CONFIG_DEBUGGER
+
+extern int (*__debugger)(struct pt_regs *regs);
+extern int (*__debugger_bpt)(struct pt_regs *regs);
+extern int (*__debugger_sstep)(struct pt_regs *regs);
+extern int (*__debugger_iabr_match)(struct pt_regs *regs);
+extern int (*__debugger_dabr_match)(struct pt_regs *regs);
+extern int (*__debugger_fault_handler)(struct pt_regs *regs);
+
+#define DEBUGGER_BOILERPLATE(__NAME) \
+static inline int __NAME(struct pt_regs *regs) \
+{ \
+       if (unlikely(__ ## __NAME)) \
+               return __ ## __NAME(regs); \
+       return 0; \
+}
+
+DEBUGGER_BOILERPLATE(debugger)
+DEBUGGER_BOILERPLATE(debugger_bpt)
+DEBUGGER_BOILERPLATE(debugger_sstep)
+DEBUGGER_BOILERPLATE(debugger_iabr_match)
+DEBUGGER_BOILERPLATE(debugger_dabr_match)
+DEBUGGER_BOILERPLATE(debugger_fault_handler)
+
+#ifdef CONFIG_XMON
+extern void xmon_init(void);
+#endif
+
 #else
-#define debugger(regs)                 do { } while (0)
+#define debugger(regs)                 0
 #define debugger_bpt(regs)             0
 #define debugger_sstep(regs)           0
 #define debugger_iabr_match(regs)      0
 #define debugger_dabr_match(regs)      0
-#define debugger_fault_handler         ((void (*)(struct pt_regs *))0)
-#endif
-
-#ifdef CONFIG_XMON
-extern void xmon_irq(int, void *, struct pt_regs *);
-
-extern void xmon(struct pt_regs *regs);
-extern int xmon_bpt(struct pt_regs *regs);
-extern int xmon_sstep(struct pt_regs *regs);
-extern int xmon_iabr_match(struct pt_regs *regs);
-extern int xmon_dabr_match(struct pt_regs *regs);
-extern void (*xmon_fault_handler)(struct pt_regs *regs);
+#define debugger_fault_handler(regs)   0
 #endif
 
 extern void show_regs(struct pt_regs * regs);
diff --git a/include/asm-ppc64/xmon.h b/include/asm-ppc64/xmon.h
deleted file mode 100644 (file)
index 042b83e..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __PPC_XMON_H
-#define __PPC_XMON_H
-#ifdef __KERNEL__
-
-struct pt_regs;
-
-extern void xmon(struct pt_regs *excp);
-extern void xmon_printf(const char *fmt, ...);
-extern void xmon_map_scc(void);
-extern int xmon_bpt(struct pt_regs *regs);
-extern int xmon_sstep(struct pt_regs *regs);
-extern int xmon_iabr_match(struct pt_regs *regs);
-extern int xmon_dabr_match(struct pt_regs *regs);
-extern void (*xmon_fault_handler)(struct pt_regs *regs);
-
-#endif
-#endif