17 #include <linux/kernel.h>
21 #include <linux/signal.h>
22 #include <linux/ptrace.h>
24 #include <asm/current.h>
25 #include <asm/processor.h>
26 #include <asm/machdep.h>
27 #include <asm/debug.h>
28 #include <linux/slab.h>
35 static struct hard_trap_info
39 } hard_trap_info[] = {
50 #if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
52 #if defined(CONFIG_FSL_BOOKE)
71 #if defined(CONFIG_8xx)
77 #if defined(CONFIG_PPC64)
94 static int computeSignal(
unsigned int tt)
96 struct hard_trap_info *ht;
98 for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
120 static int kgdb_call_nmi_hook(
struct pt_regs *
regs)
129 smp_send_debugger_break();
134 static int kgdb_debugger(
struct pt_regs *regs)
154 static int kgdb_singlestep(
struct pt_regs *regs)
157 struct thread_info *backup_current_thread_info = \
173 thread_info = (
struct thread_info *)(regs->
gpr[1] & ~(
THREAD_SIZE-1));
176 if (thread_info != exception_thread_info) {
178 memcpy(backup_current_thread_info, exception_thread_info,
sizeof *thread_info);
179 memcpy(exception_thread_info, thread_info,
sizeof *thread_info);
184 if (thread_info != exception_thread_info)
186 memcpy(exception_thread_info, backup_current_thread_info,
sizeof *thread_info);
191 static int kgdb_iabr_match(
struct pt_regs *regs)
201 static int kgdb_dabr_match(
struct pt_regs *regs)
211 #define PACK64(ptr, src) do { *(ptr++) = (src); } while (0)
213 #define PACK32(ptr, src) do { \
215 ptr32 = (u32 *)ptr; \
216 *(ptr32++) = (src); \
217 ptr = (unsigned long *)ptr32; \
224 unsigned long *
ptr = gdb_regs;
230 for (reg = 0; reg < 3; reg++)
237 for (reg = 14; reg < 32; reg++)
240 #ifdef CONFIG_FSL_BOOKE
242 for (reg = 0; reg < 32; reg++)
249 ptr += 32 * 8 /
sizeof(
long);
259 BUG_ON((
unsigned long)ptr >
260 (
unsigned long)(((
void *)gdb_regs) +
NUMREGBYTES));
263 #define GDB_SIZEOF_REG sizeof(unsigned long)
264 #define GDB_SIZEOF_REG_U32 sizeof(u32)
266 #ifdef CONFIG_FSL_BOOKE
267 #define GDB_SIZEOF_FLOAT_REG sizeof(unsigned long)
269 #define GDB_SIZEOF_FLOAT_REG sizeof(u64)
353 if (regno < 32 || regno >= 64)
357 dbg_reg_def[regno].
size);
359 if (regno >= 32 && regno < 64) {
361 #if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE)
364 dbg_reg_def[regno].size);
367 memset(mem, 0, dbg_reg_def[regno].size);
371 return dbg_reg_def[regno].name;
379 if (regno < 32 || regno >= 64)
383 dbg_reg_def[regno].
size);
385 if (regno >= 32 && regno < 64) {
387 #if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE)
389 dbg_reg_def[regno].size);
408 char *remcom_in_buffer,
char *remcom_out_buffer,
411 char *
ptr = &remcom_in_buffer[1];
414 switch (remcom_in_buffer[0]) {
427 if (remcom_in_buffer[0] ==
's') {
428 #ifdef CONFIG_PPC_ADV_DEBUG_REGS
430 mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM);
431 linux_regs->
msr |= MSR_DE;
433 linux_regs->
msr |= MSR_SE;
448 .gdb_bpt_instr = {0x7d, 0x82, 0x10, 0x08},
451 static int kgdb_not_implemented(
struct pt_regs *regs)
456 static void *old__debugger_ipi;
457 static void *old__debugger;
458 static void *old__debugger_bpt;
459 static void *old__debugger_sstep;
460 static void *old__debugger_iabr_match;
461 static void *old__debugger_dabr_match;
462 static void *old__debugger_fault_handler;
466 old__debugger_ipi = __debugger_ipi;
467 old__debugger = __debugger;
468 old__debugger_bpt = __debugger_bpt;
469 old__debugger_sstep = __debugger_sstep;
470 old__debugger_iabr_match = __debugger_iabr_match;
471 old__debugger_dabr_match = __debugger_dabr_match;
472 old__debugger_fault_handler = __debugger_fault_handler;
474 __debugger_ipi = kgdb_call_nmi_hook;
475 __debugger = kgdb_debugger;
477 __debugger_sstep = kgdb_singlestep;
478 __debugger_iabr_match = kgdb_iabr_match;
479 __debugger_dabr_match = kgdb_dabr_match;
480 __debugger_fault_handler = kgdb_not_implemented;
487 __debugger_ipi = old__debugger_ipi;
488 __debugger = old__debugger;
489 __debugger_bpt = old__debugger_bpt;
490 __debugger_sstep = old__debugger_sstep;
491 __debugger_iabr_match = old__debugger_iabr_match;
492 __debugger_dabr_match = old__debugger_dabr_match;
493 __debugger_fault_handler = old__debugger_fault_handler;