ia64/xen-unstable
changeset 10479:f7eb907d9bcd
[XEN] New function dump_execution_state() displays
current register and stack state of local CPU.
Use this to extend the 'd' debug key to be more useful.
Signed-off-by: Keir Fraser <keir@xensource.com>
current register and stack state of local CPU.
Use this to extend the 'd' debug key to be more useful.
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kfraser@dhcp93.uk.xensource.com |
---|---|
date | Mon Jun 19 13:06:10 2006 +0100 (2006-06-19) |
parents | f3561b1ee7a3 |
children | a27f56a0ff43 |
files | xen/arch/x86/traps.c xen/common/keyhandler.c xen/include/asm-x86/processor.h |
line diff
1.1 --- a/xen/arch/x86/traps.c Mon Jun 19 11:44:25 2006 +0100 1.2 +++ b/xen/arch/x86/traps.c Mon Jun 19 13:06:10 2006 +0100 1.3 @@ -487,6 +487,21 @@ asmlinkage int do_invalid_op(struct cpu_ 1.4 1.5 if ( unlikely(!guest_mode(regs)) ) 1.6 { 1.7 + char sig[5]; 1.8 + /* Signature (ud2; .ascii "dbg") indicates dump state and continue. */ 1.9 + if ( (__copy_from_user(sig, (char *)regs->eip, sizeof(sig)) == 0) && 1.10 + (memcmp(sig, "\xf\xb""dbg", sizeof(sig)) == 0) ) 1.11 + { 1.12 + show_execution_state(regs); 1.13 + regs->eip += sizeof(sig); 1.14 + return EXCRET_fault_fixed; 1.15 + } 1.16 + printk("%02x %02x %02x %02x %02x\n", 1.17 + (unsigned char)sig[0], 1.18 + (unsigned char)sig[1], 1.19 + (unsigned char)sig[2], 1.20 + (unsigned char)sig[3], 1.21 + (unsigned char)sig[4]); 1.22 DEBUGGER_trap_fatal(TRAP_invalid_op, regs); 1.23 show_execution_state(regs); 1.24 panic("CPU%d FATAL TRAP: vector = %d (invalid opcode)\n",
2.1 --- a/xen/common/keyhandler.c Mon Jun 19 11:44:25 2006 +0100 2.2 +++ b/xen/common/keyhandler.c Mon Jun 19 13:06:10 2006 +0100 2.3 @@ -87,10 +87,28 @@ static void show_handlers(unsigned char 2.4 key_table[i].desc); 2.5 } 2.6 2.7 +static void __dump_execstate(void *unused) 2.8 +{ 2.9 + dump_execution_state(); 2.10 +} 2.11 + 2.12 static void dump_registers(unsigned char key, struct cpu_user_regs *regs) 2.13 { 2.14 + unsigned int cpu; 2.15 + 2.16 printk("'%c' pressed -> dumping registers\n", key); 2.17 - show_execution_state(regs); 2.18 + 2.19 + /* Get local execution state out immediately, in case we get stuck. */ 2.20 + printk("\n*** Dumping CPU%d state: ***\n", smp_processor_id()); 2.21 + show_execution_state(regs); 2.22 + 2.23 + for_each_online_cpu ( cpu ) 2.24 + { 2.25 + if ( cpu == smp_processor_id() ) 2.26 + continue; 2.27 + printk("\n*** Dumping CPU%d state: ***\n", cpu); 2.28 + on_selected_cpus(cpumask_of_cpu(cpu), __dump_execstate, NULL, 1, 1); 2.29 + } 2.30 } 2.31 2.32 static void halt_machine(unsigned char key, struct cpu_user_regs *regs)
3.1 --- a/xen/include/asm-x86/processor.h Mon Jun 19 11:44:25 2006 +0100 3.2 +++ b/xen/include/asm-x86/processor.h Mon Jun 19 13:06:10 2006 +0100 3.3 @@ -535,6 +535,11 @@ void show_execution_state(struct cpu_use 3.4 void show_page_walk(unsigned long addr); 3.5 asmlinkage void fatal_trap(int trapnr, struct cpu_user_regs *regs); 3.6 3.7 +/* Dumps current register and stack state. */ 3.8 +#define dump_execution_state() \ 3.9 + /* NB. Needs interrupts enabled else we end up in fatal_trap(). */ \ 3.10 + __asm__ __volatile__ ( "pushf ; sti ; ud2 ; .ascii \"dbg\" ; popf" ) 3.11 + 3.12 extern void mtrr_ap_init(void); 3.13 extern void mtrr_bp_init(void); 3.14