cdb: split cdb into arch independet/dependet part
PATCH 1/1 cdb: split cdb into arch independet/dependet part
split cdb into arch independent/dependet part. This is needed for cdb on xen/ia64 which I will post later.
xen/arch/x86/cdb.c +18 -348
@@ -1,40 +1,12 @@ -/* Simple hacked-up version of pdb for use in post-mortem debugging of -Xen and domain 0. This should be a little cleaner, hopefully. Note -that we can't share a serial line with PDB. */ -/* We try to avoid assuming much about what the rest of the system is -doing. In particular, dynamic memory allocation is out of the -question. */ -/* Resuming after we've stopped used to work, but more through luck -than any actual intention. It doesn't at the moment. */ -#include <xen/lib.h> -#include <asm/uaccess.h> -#include <xen/spinlock.h> -#include <xen/serial.h> -#include <xen/irq.h> +/* +* x86-specific cdb routines +*/ #include <asm/debugger.h> -#include <xen/init.h> -#include <xen/smp.h> -#include <xen/console.h> -#include <asm/apic.h> - -/* Printk isn't particularly safe just after we've trapped to the -debugger. so avoid it. */ -#define dbg_printk (...) - -static char opt_cdb[30 ] ="none" ; -string_param ("cdb" , opt_cdb); - -struct xendbg_context { -int serhnd; -u8 reply_csum; -int currently_attached:1 ; -};/* Like copy_from_user, but safe to call with interrupts disabled. -Trust me, and don't look behind the curtain. */ -static unsigned -dbg_copy_from_user (void *dest,const void *src,unsigned len) +unsigned +xendbg_arch_copy_from_user (void *dest,const void *src,unsigned len) {int __d0, __d1, __d2;ASSERT (!local_irq_is_enabled ());
@@ -60,117 +32,6 @@return __d2; } -static void -xendbg_put_char (u8 data,struct xendbg_context *ctx) -{ - ctx->reply_csum += data; -serial_putc (ctx->serhnd, data); -} - -static int -hex_char_val (unsigned char c) -{ -if (c >='0' && c <='9' ) -return c -'0' ; -else if (c >='a' && c <='f' ) -return c -'a' +10 ; -else if (c >='A' && c <='F' ) -return c -'A' +10 ; -else -BUG (); -return -1 ; -} - -/* Receive a command. Returns -1 on csum error, 0 otherwise. */ -/* Does not acknowledge. */ -static int -attempt_receive_packet (char *recv_buf,struct xendbg_context *ctx) -{ -int count; -u8 csum; -u8 received_csum; -u8 ch; - -/* Skip over everything up to the first '$' */ -while ((ch =serial_getc (ctx->serhnd)) !='$' ) - ; - csum =0 ; -for (count =0 ; count <4096 ; count++) { - ch =serial_getc (ctx->serhnd); -if (ch =='#' ) -break ; - recv_buf[count] = ch; - csum += ch; - } -if (count ==4096 ) { -dbg_printk ("WARNING: GDB sent a stupidly big packet.\n" ); -return -1 ; - } - recv_buf[count] =0 ; - received_csum =hex_char_val (serial_getc (ctx->serhnd)) *16 + -hex_char_val (serial_getc (ctx->serhnd)); -if (received_csum == csum) { -return 0 ; - }else { -return -1 ; - } -} - -/* Send a string of bytes to the debugger. */ -static void -xendbg_send (const char *buf,int count,struct xendbg_context *ctx) -{ -int x; -for (x =0 ; x < count; x++) -xendbg_put_char (buf[x], ctx); -} - -/* Receive a command, discarding up to ten packets with csum -* errors. Acknowledges all received packets. */ -static int -receive_command (char *recv_buf,struct xendbg_context *ctx) -{ -int r; -int count; - - count =0 ; -do { - r =attempt_receive_packet (recv_buf, ctx); -if (r <0 ) -xendbg_put_char ('-' , ctx); -else -xendbg_put_char ('+' , ctx); - count++; - }while (r <0 && count <10 ); -return r; -} - -static void -xendbg_start_reply (struct xendbg_context *ctx) -{ -xendbg_put_char ('$' , ctx); - ctx->reply_csum =0 ; -} - -/* Return 0 if the reply was successfully received, !0 otherwise. */ -static int -xendbg_finish_reply (struct xendbg_context *ctx) -{ -char ch; -char buf[3 ]; - -sprintf (buf,"%.02x\n" , ctx->reply_csum); - -xendbg_put_char ('#' , ctx); -xendbg_send (buf,2 , ctx); - - ch =serial_getc (ctx->serhnd); -if (ch =='+' ) -return 0 ; -else -return 1 ; -} -/* Swap the order of the bytes in a work. */ static inline unsigned bswab32 (unsigned val)
@@ -181,43 +42,8 @@ (((val >>24 ) &0xff ) <<0 ); } -static int -handle_memory_read_command (unsigned long addr,unsigned long length, -struct xendbg_context *ctx) -{ -int x; -unsigned char val; -int r; -char buf[2 ]; - -dbg_printk ("Memory read starting at %lx, length %lx.\n" , addr, - length); -xendbg_start_reply (ctx); -for (x =0 ; x < length; x++) { - r =dbg_copy_from_user (&val, (void *)(addr + x),1 ); -if (r !=0 ) { -dbg_printk ("Error reading from %lx.\n" , addr + x); -break ; - } -sprintf (buf,"%.02x" , val); -xendbg_send (buf,2 , ctx); - } -if (x ==0 ) -xendbg_send ("E05" ,3 , ctx); -dbg_printk ("Read done.\n" ); -return xendbg_finish_reply (ctx); -} - -static int -xendbg_send_reply (const char *buf,struct xendbg_context *ctx) -{ -xendbg_start_reply (ctx); -xendbg_send (buf,strlen (buf), ctx); -return xendbg_finish_reply (ctx); -} - -static int -handle_register_read_command (struct cpu_user_regs *regs,struct xendbg_context *ctx) +int +xendbg_arch_handle_register_read_command (struct cpu_user_regs *regs,struct xendbg_context *ctx) {char buf[121 ];
@@ -242,173 +68,17 @@return xendbg_send_reply (buf, ctx); } -static int -process_command (char *received_packet,struct cpu_user_regs *regs, -struct xendbg_context *ctx) +int +xendbg_arch_handle_register_get_command (unsigned long regnum,struct cpu_user_regs *regs,struct xendbg_context *ctx) { -char *ptr; -unsigned long addr, length; -int retry; -int counter; -int resume =0 ; - -/* Repeat until gdb acks the reply */ - counter =0 ; -do { -switch (received_packet[0 ]) { -case 'g' :/* Read registers */ - retry =handle_register_read_command (regs, ctx); -ASSERT (!local_irq_is_enabled ()); -break ; -case 'm' :/* Read memory */ - addr =simple_strtoul (received_packet +1 , &ptr,16 ); -if (ptr == received_packet +1 || - ptr[0 ] !=',' ) { -xendbg_send_reply ("E03" , ctx); -return 0 ; - } - length =simple_strtoul (ptr +1 , &ptr,16 ); -if (ptr[0 ] !=0 ) { -xendbg_send_reply ("E04" , ctx); -return 0 ; - } - retry = -handle_memory_read_command (addr, - length, - ctx); -ASSERT (!local_irq_is_enabled ()); -break ; -case 'G' :/* Write registers */ -case 'M' :/* Write memory */ - retry =xendbg_send_reply ("E02" , ctx); -break ; -case 'D' : - resume =1 ; - ctx->currently_attached =0 ; - retry =xendbg_send_reply ("" , ctx); -break ; -case 'c' :/* Resume at current address */ - ctx->currently_attached =1 ; - resume =1 ; - retry =0 ; -break ; -case 'Z' :/* We need to claim to support these or gdb -won't let you continue the process. */ -case 'z' : - retry =xendbg_send_reply ("OK" , ctx); -break ; - -case 's' :/* Single step */ -case '?' : - retry =xendbg_send_reply ("S01" , ctx); -break ; -default : - retry =xendbg_send_reply ("" , ctx); -break ; - } - counter++; - }while (retry ==1 && counter <10 ); -if (retry) { -dbg_printk ("WARNING: gdb disappeared when we were trying to send it a reply.\n" ); -return 1 ; - } -return resume; +return xendbg_send_reply ("" , ctx); } -static struct xendbg_context -xdb_ctx = { - serhnd :-1 -}; - -int -__trap_to_cdb (struct cpu_user_regs *regs) -{ -int resume =0 ; -int r; -static atomic_t xendbg_running =ATOMIC_INIT (1 ); -static char recv_buf[4096 ]; -unsigned flags; - -if (xdb_ctx.serhnd <0 ) { -dbg_printk ("Debugger not ready yet.\n" ); -return 0 ; - } - -/* We rely on our caller to ensure we're only on one processor -* at a time... We should probably panic here, but given that -* we're a debugger we should probably be a little tolerant of -* things going wrong. */ -/* We don't want to use a spin lock here, because we're doing -two distinct things: - -1 -- we don't want to run on more than one processor at a time, -and -2 -- we want to do something sensible if we re-enter ourselves. - -Spin locks are good for 1, but useless for 2. */ -if (!atomic_dec_and_test (&xendbg_running)) { -printk ("WARNING WARNING WARNING: Avoiding recursive xendbg.\n" ); -atomic_inc (&xendbg_running); -return 0 ; - } - -smp_send_stop (); - -/* Try to make things a little more stable by disabling -interrupts while we're here. */ -local_irq_save (flags); - -watchdog_disable (); -console_start_sync (); - -/* Shouldn't really do this, but otherwise we stop for no -obvious reason, which is Bad */ -printk ("Waiting for GDB to attach to XenDBG\n" ); - -/* If gdb is already attached, tell it we've stopped again. */ -if (xdb_ctx.currently_attached) { -do { - r =xendbg_send_reply ("S01" , &xdb_ctx); - }while (r !=0 ); - } - -while (resume ==0 ) { -ASSERT (!local_irq_is_enabled ()); - r =receive_command (recv_buf, &xdb_ctx); -ASSERT (!local_irq_is_enabled ()); -if (r <0 ) { -dbg_printk ("GDB disappeared, trying to resume Xen...\n" ); - resume =1 ; - }else { -ASSERT (!local_irq_is_enabled ()); - resume =process_command (recv_buf, regs, &xdb_ctx); -ASSERT (!local_irq_is_enabled ()); - } - } - -console_end_sync (); -watchdog_enable (); -atomic_inc (&xendbg_running); - -local_irq_restore (flags); - -return 0 ; -} - -static int -initialize_xendbg (void ) -{ -if (!strcmp (opt_cdb,"none" )) -return 0 ; - xdb_ctx.serhnd =serial_parse_handle (opt_cdb); -if (xdb_ctx.serhnd ==-1 ) -panic ("Can't parse %s as CDB serial info.\n" , opt_cdb); - -/* Acknowledge any spurious GDB packets. */ -xendbg_put_char ('+' , &xdb_ctx); - -printk ("Xendbg initialised.\n" ); -return 0 ; -} - -__initcall (initialize_xendbg); +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* End: +*/
xen/common/Makefile +3 -0
@@ -3,6 +3,9 @@ ifneq ($(perfc),y) OBJS := $(subst perfc.o,,$(OBJS)) +endif +ifneq ($(crash_debug),y) +OBJS := $(patsubst cdb.o,,$(OBJS)) endif default: common.o
xen/include/asm-x86/debugger.h +2 -0
@@ -41,6 +41,8 @@if (debugger_trap_fatal (_v, _r) )return EXCRET_fault_fixed;#if defined(CRASH_DEBUG ) + +#include <xen/debugger.h> extern int __trap_to_cdb (struct cpu_user_regs *r);
xen/common/cdb.c new file +369 -0
369 lines not on this page · raw message
xen/include/xen/debugger.h new file +18 -0
@@ -0,0 +1,18 @@ +#ifndef __XEN_DEBUGGER_H__ +#define __XEN_DEBUGGER_H__ + +struct xendbg_context { +int serhnd; +u8 reply_csum; +int currently_attached:1 ; +}; + +/* interface to arch specific routines */ +int xendbg_send_reply (const char *buf,struct xendbg_context *ctx); + +/* arch specific routines */ +unsigned int xendbg_arch_copy_from_user (void *dest,const void *src,unsigned len); +int xendbg_arch_handle_register_read_command (struct cpu_user_regs *regs,struct xendbg_context *ctx); +int xendbg_arch_handle_register_get_command (unsigned long regnum,struct cpu_user_regs *regs,struct xendbg_context *ctx); + +#endif /* __XEN_DEBUGGER_H__ */
Signature · 1 line
yamahata
# HG changeset patch
# User [email protected]
# Node ID b1068ef4ffb0e37efccf4bec2ed5ae242807add6 # Parent 45fdc28bd5e0dd1eb551d5004ea3cae72bd76f5a split cdb into arch independent/dependet part. some code clean up.
xen/arch/x86/cdb.c +18 -348
391 lines not on this page · raw message
xen/common/Makefile +3 -0
@@ -3,6 +3,9 @@ ifneq ($(perfc),y) OBJS := $(subst perfc.o,,$(OBJS)) +endif +ifneq ($(crash_debug),y) +OBJS := $(patsubst cdb.o,,$(OBJS)) endif default: common.o
xen/include/asm-x86/debugger.h +2 -0
@@ -41,6 +41,8 @@if (debugger_trap_fatal (_v, _r) )return EXCRET_fault_fixed;#if defined(CRASH_DEBUG ) + +#include <xen/debugger.h> extern int __trap_to_cdb (struct cpu_user_regs *r);
xen/common/cdb.c new file +369 -0
369 lines not on this page · raw message
xen/include/xen/debugger.h new file +18 -0
@@ -0,0 +1,18 @@ +#ifndef __XEN_DEBUGGER_H__ +#define __XEN_DEBUGGER_H__ + +struct xendbg_context { +int serhnd; +u8 reply_csum; +int currently_attached:1 ; +}; + +/* interface to arch specific routines */ +int xendbg_send_reply (const char *buf,struct xendbg_context *ctx); + +/* arch specific routines */ +unsigned int xendbg_arch_copy_from_user (void *dest,const void *src,unsigned len); +int xendbg_arch_handle_register_read_command (struct cpu_user_regs *regs,struct xendbg_context *ctx); +int xendbg_arch_handle_register_get_command (unsigned long regnum,struct cpu_user_regs *regs,struct xendbg_context *ctx); + +#endif /* __XEN_DEBUGGER_H__ */
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
PATCH 1/1 cdb for xen/ia64
cdb for xen/ia64.
stolen from kgdb the routine which gets register value. this includes a bug fix of kgdb/ia64.
xen/arch/ia64/Makefile +4 -0
@@ -22,6 +22,10 @@ memset.o strlen.o memcpy_mck.o \ __divsi3.o __udivsi3.o __modsi3.o __umodsi3.o \ __divdi3.o __udivdi3.o __moddi3.o __umoddi3.o + +ifeq ($(crash_debug),y) +OBJS += cdb.o +endif # xen stack unwinder # unwind_decoder.c is included in unwind.c
xen/arch/ia64/vmx/vmx_process.c +8 -0
@@ -41,6 +41,7 @@#include <asm/regionreg.h> #include <asm/privop.h> #include <asm/ia64_int.h> +#include <asm/debugger.h> //#include <asm/hpsim_ssc.h> #include <asm/dom_fw.h> #include <asm/vmx_vcpu.h>
@@ -107,6 +108,13 @@if (running_on_sim)do_ssc (vcpu_get_gr_nat (current,36 ), regs);else do_ssc (vcpu_get_gr_nat (current,36 ), regs); } +#endif +#ifdef CRASH_DEBUG +if ((iim ==0 || iim ==CDB_BREAK_NUM ) && !user_mode (regs)) { +if (iim ==0 ) +show_registers (regs); +debugger_trap_fatal (0 /* don't care */ , regs); + } else#endif if (iim == d->arch.breakimm) {struct ia64_pal_retval y;
xen/arch/ia64/xen/hyperprivop.S +1 -0
@@ -12,6 +12,7 @@ #include <asm/offsets.h> #include <asm/processor.h> #include <asm/system.h> +#include <asm/debugger.h> #include <public/arch-ia64.h>
xen/arch/ia64/xen/ivt.S +1 -0
@@ -15,6 +15,7 @@ #define sys_call_table 0 #define sys_ni_syscall 0 #include <asm/vhpt.h> +#include <asm/debugger.h> #endif /* * arch/ia64/kernel/ivt.S
xen/arch/ia64/xen/process.c +10 -2
@@ -31,6 +31,7 @@#include <asm/dom_fw.h> #include "hpsim_ssc.h" #include <xen/multicall.h> +#include <asm/debugger.h> extern unsigned long vcpu_get_itir_on_fault (struct vcpu *,UINT64 );extern void die_if_kernel (char *str,struct pt_regs *regs,long err);
@@ -662,7 +663,7 @@ ia64_handle_break (unsigned long ifa, struct pt_regs *regs, unsigned long isr, unsigned long iim) { struct domain *d = (struct domain *) current->domain; -struct vcpu *v = (struct domain *) current; +struct vcpu *v = current;extern unsigned long running_on_sim;if (first_break) {
@@ -673,7 +674,14 @@if (iim ==0x80001 || iim ==0x80002 ) {//FIXME: don't hardcode constant if (running_on_sim)do_ssc (vcpu_get_gr (current,36 ), regs);else do_ssc (vcpu_get_gr (current,36 ), regs); - } + } +#ifdef CRASH_DEBUG + else if ((iim == 0 || iim == CDB_BREAK_NUM) && !user_mode(regs)) { +if (iim ==0 ) +show_registers (regs); +debugger_trap_fatal (0 /* don't care */ , regs); + } +#endif else if (iim == d->arch.breakimm) {/* by default, do not continue */ v->arch.hypercall_continuation =0 ;
xen/arch/ia64/xen/xenmisc.c +6 -0
@@ -18,6 +18,7 @@#include <xen/softirq.h> #include <public/sched.h> #include <asm/vhpt.h> +#include <asm/debugger.h> efi_memory_desc_t ia64_efi_io_md;EXPORT_SYMBOL (ia64_efi_io_md);
@@ -357,6 +358,11 @@va_end (args);printf (buf);if (regs)show_registers (regs); +if (regs) { +debugger_trap_fatal (0 /* don't care */ , regs); + }else { +debugger_trap_immediate (); + }domain_pause_by_systemcontroller (current->domain); v->domain->shutdown_code = SHUTDOWN_crash;set_bit (_DOMF_shutdown, v->domain->domain_flags);
xen/include/asm-ia64/debugger.h +66 -1
78 lines not on this page · raw message
xen/arch/ia64/xen/cdb.c new file +652 -0
652 lines not on this page · raw message
Signature · 1 line
yamahata
# HG changeset patch
# User [email protected]
# Node ID 0722cc73a7a25ec2fcb1ac31667f2546d7c0a448 # Parent b1068ef4ffb0e37efccf4bec2ed5ae242807add6 implemented cdb for ia64.
stolen from kgdb the routine which gets register value. this includes a bug fix of kgdb/ia64.
xen/arch/ia64/Makefile +4 -0
@@ -22,6 +22,10 @@ memset.o strlen.o memcpy_mck.o \ __divsi3.o __udivsi3.o __modsi3.o __umodsi3.o \ __divdi3.o __udivdi3.o __moddi3.o __umoddi3.o + +ifeq ($(crash_debug),y) +OBJS += cdb.o +endif # xen stack unwinder # unwind_decoder.c is included in unwind.c
xen/arch/ia64/vmx/vmx_process.c +8 -0
@@ -41,6 +41,7 @@#include <asm/regionreg.h> #include <asm/privop.h> #include <asm/ia64_int.h> +#include <asm/debugger.h> //#include <asm/hpsim_ssc.h> #include <asm/dom_fw.h> #include <asm/vmx_vcpu.h>
@@ -107,6 +108,13 @@if (running_on_sim)do_ssc (vcpu_get_gr_nat (current,36 ), regs);else do_ssc (vcpu_get_gr_nat (current,36 ), regs); } +#endif +#ifdef CRASH_DEBUG +if ((iim ==0 || iim ==CDB_BREAK_NUM ) && !user_mode (regs)) { +if (iim ==0 ) +show_registers (regs); +debugger_trap_fatal (0 /* don't care */ , regs); + } else#endif if (iim == d->arch.breakimm) {struct ia64_pal_retval y;
xen/arch/ia64/xen/hyperprivop.S +1 -0
@@ -12,6 +12,7 @@ #include <asm/offsets.h> #include <asm/processor.h> #include <asm/system.h> +#include <asm/debugger.h> #include <public/arch-ia64.h>
xen/arch/ia64/xen/ivt.S +1 -0
@@ -15,6 +15,7 @@ #define sys_call_table 0 #define sys_ni_syscall 0 #include <asm/vhpt.h> +#include <asm/debugger.h> #endif /* * arch/ia64/kernel/ivt.S
xen/arch/ia64/xen/process.c +10 -2
@@ -31,6 +31,7 @@#include <asm/dom_fw.h> #include "hpsim_ssc.h" #include <xen/multicall.h> +#include <asm/debugger.h> extern unsigned long vcpu_get_itir_on_fault (struct vcpu *,UINT64 );extern void die_if_kernel (char *str,struct pt_regs *regs,long err);
@@ -662,7 +663,7 @@ ia64_handle_break (unsigned long ifa, struct pt_regs *regs, unsigned long isr, unsigned long iim) { struct domain *d = (struct domain *) current->domain; -struct vcpu *v = (struct domain *) current; +struct vcpu *v = current;extern unsigned long running_on_sim;if (first_break) {
@@ -673,7 +674,14 @@if (iim ==0x80001 || iim ==0x80002 ) {//FIXME: don't hardcode constant if (running_on_sim)do_ssc (vcpu_get_gr (current,36 ), regs);else do_ssc (vcpu_get_gr (current,36 ), regs); - } + } +#ifdef CRASH_DEBUG + else if ((iim == 0 || iim == CDB_BREAK_NUM) && !user_mode(regs)) { +if (iim ==0 ) +show_registers (regs); +debugger_trap_fatal (0 /* don't care */ , regs); + } +#endif else if (iim == d->arch.breakimm) {/* by default, do not continue */ v->arch.hypercall_continuation =0 ;
xen/arch/ia64/xen/xenmisc.c +6 -0
@@ -18,6 +18,7 @@#include <xen/softirq.h> #include <public/sched.h> #include <asm/vhpt.h> +#include <asm/debugger.h> efi_memory_desc_t ia64_efi_io_md;EXPORT_SYMBOL (ia64_efi_io_md);
@@ -357,6 +358,11 @@va_end (args);printf (buf);if (regs)show_registers (regs); +if (regs) { +debugger_trap_fatal (0 /* don't care */ , regs); + }else { +debugger_trap_immediate (); + }domain_pause_by_systemcontroller (current->domain); v->domain->shutdown_code = SHUTDOWN_crash;set_bit (_DOMF_shutdown, v->domain->domain_flags);
xen/include/asm-ia64/debugger.h +66 -1
78 lines not on this page · raw message
xen/arch/ia64/xen/cdb.c new file +652 -0
652 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
PATCH 1/1 gdbstub for xen/ia64 (was Re: [Xen-ia64-devel] [PATCH] cdb for xen/ia64)
gdbstub for xen/ia64
catched up recent common gdbstub and kgdb/ia64.
# HG changeset patch
# User [email protected]
# Node ID aeebe099dae6d13beebd8c879dc011d5a1e4ff78 # Parent ea582eba5cd2bc3edc3c1dd7416a902c574602d2 ia64 specific part of gdbstub.
xen/arch/ia64/Makefile +4 -0
@@ -22,6 +22,10 @@ memset.o strlen.o memcpy_mck.o \ __divsi3.o __udivsi3.o __modsi3.o __umodsi3.o \ __divdi3.o __udivdi3.o __moddi3.o __umoddi3.o + +ifeq ($(crash_debug),y) +OBJS += gdbstub.o +endif # xen stack unwinder # unwind_decoder.c is included in unwind.c
xen/arch/ia64/vmx/vmx_process.c +9 -0
@@ -41,6 +41,7 @@#include <asm/regionreg.h> #include <asm/privop.h> #include <asm/ia64_int.h> +#include <asm/debugger.h> //#include <asm/hpsim_ssc.h> #include <asm/dom_fw.h> #include <asm/vmx_vcpu.h>
@@ -107,6 +108,14 @@if (running_on_sim)do_ssc (vcpu_get_gr_nat (current,36 ), regs);else do_ssc (vcpu_get_gr_nat (current,36 ), regs); } +#endif +#ifdef CRASH_DEBUG +if ((iim ==0 || iim ==CDB_BREAK_NUM ) && !user_mode (regs) && +IS_VMM_ADDRESS (regs->cr_iip)) { +if (iim ==0 ) +show_registers (regs); +debugger_trap_fatal (0 /* don't care */ , regs); + } else#endif if (iim == d->arch.breakimm) {struct ia64_pal_retval y;
xen/arch/ia64/xen/hyperprivop.S +7 -1
@@ -12,6 +12,7 @@ #include <asm/offsets.h> #include <asm/processor.h> #include <asm/system.h> +#include <asm/debugger.h> #include <public/arch-ia64.h>
@@ -549,7 +550,12 @@ (p7) br.spnt.many 1f ;; cmp.eq p7,p0=r17,r0 (p7) br.spnt.few dispatch_break_fault ;; -1: +#ifdef CRASH_DEBUG + movl r21=CDB_BREAK_NUM ;; + cmp.eq p7,p0=r17,r21 +(p7) br.spnt.few dispatch_break_fault ;; +#endif +1: #if 1 /* special handling in case running on simulator */ movl r20=first_break;; ld4 r23=[r20];;
xen/arch/ia64/xen/ivt.S +8 -0
@@ -15,6 +15,7 @@ #define sys_call_table 0 #define sys_ni_syscall 0 #include <asm/vhpt.h> +#include <asm/debugger.h> #endif /* * arch/ia64/kernel/ivt.S
@@ -841,6 +842,13 @@ ;; cmp.eq p7,p0=r17,r0 (p7) br.spnt.few dispatch_break_fault ;; +#ifdef CRASH_DEBUG + // panic can occur before domain0 is created. + // in such case referencing XSI_PSR_IC causes nested_dtlb_miss + movl r18=CDB_BREAK_NUM ;; + cmp.eq p7,p0=r17,r18 ;; +(p7) br.spnt.few dispatch_break_fault ;; +#endif movl r18=XSI_PSR_IC ;; ld8 r19=[r18]
xen/arch/ia64/xen/process.c +10 -2
@@ -31,6 +31,7 @@#include <asm/dom_fw.h> #include "hpsim_ssc.h" #include <xen/multicall.h> +#include <asm/debugger.h> extern unsigned long vcpu_get_itir_on_fault (struct vcpu *,UINT64 );extern void die_if_kernel (char *str,struct pt_regs *regs,long err);
@@ -652,7 +653,7 @@ ia64_handle_break (unsigned long ifa, struct pt_regs *regs, unsigned long isr, unsigned long iim) { struct domain *d = (struct domain *) current->domain; -struct vcpu *v = (struct domain *) current; +struct vcpu *v = current;extern unsigned long running_on_sim;if (first_break) {
@@ -663,7 +664,14 @@if (iim ==0x80001 || iim ==0x80002 ) {//FIXME: don't hardcode constant if (running_on_sim)do_ssc (vcpu_get_gr (current,36 ), regs);else do_ssc (vcpu_get_gr (current,36 ), regs); - } + } +#ifdef CRASH_DEBUG + else if ((iim == 0 || iim == CDB_BREAK_NUM) && !user_mode(regs)) { +if (iim ==0 ) +show_registers (regs); +debugger_trap_fatal (0 /* don't care */ , regs); + } +#endif else if (iim == d->arch.breakimm) {/* by default, do not continue */ v->arch.hypercall_continuation =0 ;
xen/arch/ia64/xen/xenmisc.c +6 -0
@@ -18,6 +18,7 @@#include <xen/softirq.h> #include <public/sched.h> #include <asm/vhpt.h> +#include <asm/debugger.h> efi_memory_desc_t ia64_efi_io_md;EXPORT_SYMBOL (ia64_efi_io_md);
@@ -356,6 +357,11 @@va_end (args);printf (buf);if (regs)show_registers (regs); +if (regs) { +debugger_trap_fatal (0 /* don't care */ , regs); + }else { +debugger_trap_immediate (); + }domain_pause_by_systemcontroller (current->domain); v->domain->shutdown_code = SHUTDOWN_crash;set_bit (_DOMF_shutdown, v->domain->domain_flags);
xen/common/Makefile +3 -0
@@ -3,6 +3,9 @@ ifneq ($(perfc),y) OBJS := $(subst perfc.o,,$(OBJS)) +endif +ifneq ($(crash_debug),y) +OBJS := $(patsubst cdb.o,,$(OBJS)) endif ifneq ($(crash_debug),y) OBJS := $(patsubst gdbstub.o,,$(OBJS))
xen/include/asm-ia64/debugger.h +66 -1
78 lines not on this page · raw message
xen/arch/ia64/xen/gdbstub.c new file +811 -0
811 lines not on this page · raw message
Signature · 1 line
yamahata
# HG changeset patch
# User [email protected]
# Node ID aeebe099dae6d13beebd8c879dc011d5a1e4ff78 # Parent ea582eba5cd2bc3edc3c1dd7416a902c574602d2 ia64 specific part of gdbstub.
xen/arch/ia64/Makefile +4 -0
@@ -22,6 +22,10 @@ memset.o strlen.o memcpy_mck.o \ __divsi3.o __udivsi3.o __modsi3.o __umodsi3.o \ __divdi3.o __udivdi3.o __moddi3.o __umoddi3.o + +ifeq ($(crash_debug),y) +OBJS += gdbstub.o +endif # xen stack unwinder # unwind_decoder.c is included in unwind.c
xen/arch/ia64/vmx/vmx_process.c +9 -0
@@ -41,6 +41,7 @@#include <asm/regionreg.h> #include <asm/privop.h> #include <asm/ia64_int.h> +#include <asm/debugger.h> //#include <asm/hpsim_ssc.h> #include <asm/dom_fw.h> #include <asm/vmx_vcpu.h>
@@ -107,6 +108,14 @@if (running_on_sim)do_ssc (vcpu_get_gr_nat (current,36 ), regs);else do_ssc (vcpu_get_gr_nat (current,36 ), regs); } +#endif +#ifdef CRASH_DEBUG +if ((iim ==0 || iim ==CDB_BREAK_NUM ) && !user_mode (regs) && +IS_VMM_ADDRESS (regs->cr_iip)) { +if (iim ==0 ) +show_registers (regs); +debugger_trap_fatal (0 /* don't care */ , regs); + } else#endif if (iim == d->arch.breakimm) {struct ia64_pal_retval y;
xen/arch/ia64/xen/hyperprivop.S +7 -1
@@ -12,6 +12,7 @@ #include <asm/offsets.h> #include <asm/processor.h> #include <asm/system.h> +#include <asm/debugger.h> #include <public/arch-ia64.h>
@@ -549,7 +550,12 @@ (p7) br.spnt.many 1f ;; cmp.eq p7,p0=r17,r0 (p7) br.spnt.few dispatch_break_fault ;; -1: +#ifdef CRASH_DEBUG + movl r21=CDB_BREAK_NUM ;; + cmp.eq p7,p0=r17,r21 +(p7) br.spnt.few dispatch_break_fault ;; +#endif +1: #if 1 /* special handling in case running on simulator */ movl r20=first_break;; ld4 r23=[r20];;
xen/arch/ia64/xen/ivt.S +8 -0
@@ -15,6 +15,7 @@ #define sys_call_table 0 #define sys_ni_syscall 0 #include <asm/vhpt.h> +#include <asm/debugger.h> #endif /* * arch/ia64/kernel/ivt.S
@@ -841,6 +842,13 @@ ;; cmp.eq p7,p0=r17,r0 (p7) br.spnt.few dispatch_break_fault ;; +#ifdef CRASH_DEBUG + // panic can occur before domain0 is created. + // in such case referencing XSI_PSR_IC causes nested_dtlb_miss + movl r18=CDB_BREAK_NUM ;; + cmp.eq p7,p0=r17,r18 ;; +(p7) br.spnt.few dispatch_break_fault ;; +#endif movl r18=XSI_PSR_IC ;; ld8 r19=[r18]
xen/arch/ia64/xen/process.c +10 -2
@@ -31,6 +31,7 @@#include <asm/dom_fw.h> #include "hpsim_ssc.h" #include <xen/multicall.h> +#include <asm/debugger.h> extern unsigned long vcpu_get_itir_on_fault (struct vcpu *,UINT64 );extern void die_if_kernel (char *str,struct pt_regs *regs,long err);
@@ -652,7 +653,7 @@ ia64_handle_break (unsigned long ifa, struct pt_regs *regs, unsigned long isr, unsigned long iim) { struct domain *d = (struct domain *) current->domain; -struct vcpu *v = (struct domain *) current; +struct vcpu *v = current;extern unsigned long running_on_sim;if (first_break) {
@@ -663,7 +664,14 @@if (iim ==0x80001 || iim ==0x80002 ) {//FIXME: don't hardcode constant if (running_on_sim)do_ssc (vcpu_get_gr (current,36 ), regs);else do_ssc (vcpu_get_gr (current,36 ), regs); - } + } +#ifdef CRASH_DEBUG + else if ((iim == 0 || iim == CDB_BREAK_NUM) && !user_mode(regs)) { +if (iim ==0 ) +show_registers (regs); +debugger_trap_fatal (0 /* don't care */ , regs); + } +#endif else if (iim == d->arch.breakimm) {/* by default, do not continue */ v->arch.hypercall_continuation =0 ;
xen/arch/ia64/xen/xenmisc.c +6 -0
@@ -18,6 +18,7 @@#include <xen/softirq.h> #include <public/sched.h> #include <asm/vhpt.h> +#include <asm/debugger.h> efi_memory_desc_t ia64_efi_io_md;EXPORT_SYMBOL (ia64_efi_io_md);
@@ -356,6 +357,11 @@va_end (args);printf (buf);if (regs)show_registers (regs); +if (regs) { +debugger_trap_fatal (0 /* don't care */ , regs); + }else { +debugger_trap_immediate (); + }domain_pause_by_systemcontroller (current->domain); v->domain->shutdown_code = SHUTDOWN_crash;set_bit (_DOMF_shutdown, v->domain->domain_flags);
xen/common/Makefile +3 -0
@@ -3,6 +3,9 @@ ifneq ($(perfc),y) OBJS := $(subst perfc.o,,$(OBJS)) +endif +ifneq ($(crash_debug),y) +OBJS := $(patsubst cdb.o,,$(OBJS)) endif ifneq ($(crash_debug),y) OBJS := $(patsubst gdbstub.o,,$(OBJS))
xen/include/asm-ia64/debugger.h +66 -1
78 lines not on this page · raw message
xen/arch/ia64/xen/gdbstub.c new file +811 -0
811 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 1 line · Isaku Yamahata
split cdb into arch independent/dependet part.
What does "cdb" mean? Perhaps this is a good opportunity to rename the file to something like "gdbstub". Within function names, I am ok with "xendbg", but would again prefer "gdb".
I've done something similar for the PowerPC port (see http://xenbits.xensource.com/ext/xenppc-unstable.hg?cmd=file;filenode=e5b74ffbc35667adbe0fc2cf263bdae46d90e3ed;file=xen/common/gdbstub.c). I don't claim that code is ideal, but it's working enough to let me focus on other things. I have a few requests for your arch-neutral code...
Review
Quoted 2 lines
(quoted diff) +2
-0+int +__trap_to_cdb(struct cpu_user_regs *regs)
Please have this take an extra argument. We can make it an opaque "cookie" if necessary. On PowerPC, we have more than one exception handler wired up to drop into GDB. The same thing is probably useful on other architectures as well, e.g. drop into GDB if somebody branches to 0 in the hypervisor. This extra argument indicates the source of the exception, and is translated by an arch-specific hook into a signal number. This allows us to provide signals like SIGSEGV to indicate bad memory references.
Please provide arch-specific entry() and exit() hooks. On PowerPC, we save and restore the CPU timers in these.
int __trap_to_cdb(struct cpu_user_regs *regs, ulong cookie)
{
arch_xendbg_entry(regs);
signal = arch_xendbg_signal(regs, cookie);
...
arch_xendbg_exit(regs);
}I see that some commands, such as 's', 'G', and 'M' are unimplemented. Instead of rejecting them in the arch-neutral section, please have that done in the arch-specific section. For example, we have implemented all of those commands in PPC code.
Review
Quoted 1 line
(quoted diff) +1
-0+ retry = xendbg_arch_handle_register_get_command(addr, regs, ctx);
I hope we can name these something shorter...
Quoted 1 line
+__initcall(initialize_xendbg);
I believe this should be an explicit call from architecture code. initcall is far too late for some early debugging, and only the architecture code knows when this call can be made.
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center
Quoted 3 lines · Hollis Blanchard
What does "cdb" mean? Perhaps this is a good opportunity to rename the file to something like "gdbstub". Within function names, I am ok with "xendbg", but would again prefer "gdb".
I just followed the original x86 way.
If a kind of clean up patch is accepted, I am also ok with any prefix.
PPC gdbstub has more functionality than x86, ia64.
So if there is no objections, I will make a patch based on gdb stub in ppc repository using "gdb" prefix.
Signature · 1 line
yamahata
Quoted 6 lines · Isaku Yamahata
I just followed the original x86 way.
If a kind of clean up patch is accepted, I am also ok with any prefix.PPC gdbstub has more functionality than x86, ia64.
So if there is no objections, I will make a patch based on gdb stub in ppc repository using "gdb" prefix.
Please do.
-- Keir
Hi.
attached the updated one. I tested only very roughly. Hollis, is this patch ok for ppc version?
thanks.
Signature · 1 line
yamahata
# HG changeset patch
# User [email protected]
# Node ID f373e06cd2e728537f8c748ef7cfa9da7c418bbf
# Parent bfcdf4099d232bd6668436621581c328a6afcf09
clean up cdb.
renamed cdb to gdbstub and split it into arch dependent/neutral part.
xen/arch/x86/Makefile +1 -1
@@ -32,7 +32,7 @@ OBJS := $(subst $(TARGET_SUBARCH)/xen.lds.o,,$(OBJS)) ifneq ($(crash_debug),y) -OBJS := $(patsubst cdb%.o,,$(OBJS)) +OBJS := $(patsubst gdbstub%.o,,$(OBJS)) endif default: $(TARGET)
xen/arch/x86/x86_32/xen.lds.S +5 -0
@@ -21,6 +21,11 @@ _text = .; /* Text and read-only data */ .text : { *(.text) + . = ALIGN(32); + __gdbstub_text_start = . ; + *(.gdbstub.text) + __gdbstub_text_end = . ; + . = ALIGN(32) ; *(.fixup) *(.gnu.warning) } :text =0x9090
xen/common/Makefile +3 -0
@@ -3,6 +3,9 @@ ifneq ($(perfc),y) OBJS := $(subst perfc.o,,$(OBJS)) +endif +ifneq ($(crash_debug),y) +OBJS := $(patsubst gdbstub.o,,$(OBJS)) endif default: common.o
xen/include/asm-x86/debugger.h +6 -4
@@ -42,19 +42,19 @@#if defined(CRASH_DEBUG ) -extern int __trap_to_cdb (struct cpu_user_regs *r); +#include <xen/gdb.h> #define __debugger_trap_entry (_v, _r) (0)static inline int __debugger_trap_fatal (unsigned int vector,struct cpu_user_regs *regs) { - (void )__trap_to_cdb (regs); + (void )__trap_to_gdb (regs, vector);return (vector == TRAP_int3);/* int3 is harmless */ }/* Int3 is a trivial way to gather cpu_user_regs context. */ -#define __debugger_trap_immediate () __asm__ __volatile__ ( "int3" ); +#define debugger_trap_immediate () __asm__ __volatile__ ( "int3" );#elif 0
@@ -73,7 +73,7 @@ }/* Int3 is a trivial way to gather cpu_user_regs context. */ -#define __debugger_trap_immediate () __asm__ __volatile__ ( "int3" ) +#define debugger_trap_immediate () __asm__ __volatile__ ( "int3" )#else
@@ -100,6 +100,8 @@ }#define debugger_trap_fatal (v, r) (__debugger_trap_fatal(v, r)) +#ifndef debugger_trap_immediate#define debugger_trap_immediate () (__debugger_trap_immediate()) +#endif #endif /* __X86_DEBUGGER_H__ */
xen/arch/x86/gdbstub.c new file +146 -0
146 lines not on this page · raw message
xen/common/gdbstub.c new file +596 -0
596 lines not on this page · raw message
xen/include/xen/gdb.h new file +87 -0
87 lines not on this page · raw message
xen/arch/x86/cdb.c deleted +0 -414
414 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 3 lines · Isaku Yamahata
attached the updated one. I tested only very roughly. Hollis, is this patch ok for ppc version?
Thanks Isaku! This whole patch has whitespace issues though; please replace your tabs with 4 spaces.
Quoted 5 lines
xen/arch/x86/x86_32/xen.lds.S +5
-0+ . = ALIGN(32); + __gdbstub_text_start = . ; + *(.gdbstub.text) + __gdbstub_text_end = . ; + . = ALIGN(32) ;
...
xen/include/xen/gdb.h line 29
Quoted 4 lines
xen/include/xen/gdb.h new file +4
-0+/* Append this to the declaration of any function needed to be used by +* the gdb stub. Any functions marked with this will not be allowed +* to have a breakpoint set in them. */ +#define __gdbstub __attribute__((section(".gdbstub.text")))
These make sense if we want to avoid setting a breakpoint in GDB stub code or code called by the GDB stub, such as serial output. However, these symbols aren't currently used. (You probably inherited this from the PPC stub.) At least it's worth a TODO comment, possibly in gdb_cmd_write_mem(): we shouldn't be writing to memory between those two symbols.
xen/common/gdbstub.c line 63
Quoted 3 lines
xen/common/gdbstub.c new file +3
-0+/* XXX move to some shared location... */ +char +hex2char (unsigned long x)
With hex2char, char2hex, str2hex, str2ulong, I expect that they will be needed in the arch-specific gdb backends. Actually I guess they just need to be added to gdbstub.h; I'm not sure why I added that comment.
Quoted 2 lines
(quoted diff) +1
-0+ for (ctx->in_bytes = 0; ctx->in_bytes < sizeof(ctx->in_buf);ctx->in_bytes++) {
Exceeds 80 chars.
xen/common/gdbstub.c line 165
Quoted 9 lines
xen/common/gdbstub.c new file +9
-0+#ifdef CONFIG_GDB_NO_CSUM +return 0 ; +#else +if (received_csum == csum) { +return 0 ; + }else { +return -1 ; + } +#endif
What is this about? As far as I know, the GDB protocol unconditionally requires the checksum.
Quoted 1 line
xen/common/gdbstub.c new file +1
-0+//XXX optimization to use best native load size
...
xen/common/gdbstub.c line 340
Quoted 1 line
xen/common/gdbstub.c new file +1
-0+//XXX optimization to use best native store size
I think it's reasonable to leave it up to the arch code to decide what size access to use, so these comments could go.
xen/common/gdbstub.c line 470
Quoted 5 lines
xen/common/gdbstub.c new file +5
-0+ .signum = 1, + + .in_bytes = 0, + + .out_offset = 0,
Blank lines.
Quoted 3 lines
xen/common/gdbstub.c new file +3
-0+/* Try to make things a little more stable by disabling +interrupts while we're here. */ +local_irq_save (flags);
...
xen/common/gdbstub.c line 551
Quoted 1 line
xen/common/gdbstub.c new file +1
-0+local_irq_restore (flags);
Shouldn't we enter __trap_to_gdb with interrupts disabled already? That's how it's done on PPC, I believe x86 can choose in the IDT, and I'm sure IA64 can too?
Hmm, actually, how does this interact with interrupt-driven ns16550?
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center
Quoted 7 lines · Hollis Blanchard
Quoted 3 lines
xen/common/gdbstub.c new file +3
-0+/* Try to make things a little more stable by disabling +interrupts while we're here. */ +local_irq_save (flags);...
xen/common/gdbstub.c line 551
Quoted 1 line
xen/common/gdbstub.c new file +1
-0+local_irq_restore (flags);Shouldn't we enter
__trap_to_gdbwith interrupts disabled already? That's how it's done on PPC, I believe x86 can choose in the IDT, and I'm sure IA64 can too?
That's true if it's a hardware-generated trap to debugger. Breakpoint exceptions, manual calls to trap into the debugger, etc all might enter the stub with ints enabled. So irqsave/restore is a reasonable safeguard.
Quoted 1 line
Hmm, actually, how does this interact with interrupt-driven ns16550?
The serial subsystem supports a synchronous polled mode of operation. You can put a COM port in polled mode by calling serial_start_sync().
-- Keir
Hi.
Thanks for your review.
I updated the patch following your comments except the interrupt-related related comment.
I included your signed-off-by to the patch, is it ok?
Quoted 2 lines · Hollis Blanchard
Thanks Isaku! This whole patch has whitespace issues though; please replace your tabs with 4 spaces.
untabified.
Quoted 6 lines
Quoted 5 lines
(quoted diff) +5
-0+ . = ALIGN(32); + __gdbstub_text_start = . ; + *(.gdbstub.text) + __gdbstub_text_end = . ; + . = ALIGN(32) ;...
Quoted 11 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+/* Append this to the declaration of any function needed to be used by + * the gdb stub. Any functions marked with this will not be allowed + * to have a breakpoint set in them. */ +#define __gdbstub __attribute__((section(".gdbstub.text")))These make sense if we want to avoid setting a breakpoint in GDB stub code or code called by the GDB stub, such as serial output. However, these symbols aren't currently used. (You probably inherited this from the PPC stub.) At least it's worth a TODO comment, possibly in
gdb_cmd_write_mem(): we shouldn't be writing to memory between those two symbols.
added __gdbstub_text_start, __gdbstub_text_end declarations and a comment above gdb_cmd_write_mem()
Quoted 7 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+/* XXX move to some shared location... */ +char +hex2char(unsigned long x)With hex2char, char2hex, str2hex, str2ulong, I expect that they will be needed in the arch-specific gdb backends. Actually I guess they just need to be added to
gdbstub.h; I'm not sure why I added that comment.
added protptypes to gdb.h and removed two XXX comments.
Quoted 3 lines
Quoted 2 lines
(quoted diff) +1
-0+ for (ctx->in_bytes = 0; ctx->in_bytes < sizeof(ctx->in_buf);ctx->in_bytes++) {
Exceeds 80 chars.
fixed.
Quoted 11 lines
Review
Quoted 9 lines
(quoted diff) +9
-0+#ifdef CONFIG_GDB_NO_CSUM + return 0; +#else + if (received_csum == csum) { + return 0; + } else { + return -1; + } +#endifWhat is this about? As far as I know, the GDB protocol unconditionally requires the checksum.
removed.
Quoted 5 lines
Quoted 1 line
(quoted diff) +1
-0+ //XXX optimization to use best native load size...
Review
Quoted 1 line
(quoted diff) +1
-0+ //XXX optimization to use best native store sizeI think it's reasonable to leave it up to the arch code to decide what size access to use, so these comments could go.
removed these comments.
Quoted 7 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ .signum = 1, + + .in_bytes = 0, + + .out_offset = 0,Blank lines.
removed blank lines.
Quoted 8 lines
Quoted 3 lines
(quoted diff) +3
-0+ /* Try to make things a little more stable by disabling + interrupts while we're here. */ + local_irq_save(flags);...
Review
Quoted 1 line
(quoted diff) +1
-0+ local_irq_restore(flags);Shouldn't we enter
__trap_to_gdbwith interrupts disabled already? That's how it's done on PPC, I believe x86 can choose in the IDT, and I'm sure IA64 can too?
Left as it was.
As Keir explained, it is a good safe guard.
Signature · 1 line
yamahata
# HG changeset patch
# User [email protected]
# Node ID 3ca0840ea69e85a5693220b54e17368c8b6ddf69
# Parent 9d72a5b18107a3482157b2d6b816a4324a5f8ad4
clean up cdb.
renamed cdb to gdbstub and split it into arch dependent/neutral part.
xen/arch/x86/Makefile +1 -1
@@ -32,7 +32,7 @@ OBJS := $(subst $(TARGET_SUBARCH)/xen.lds.o,,$(OBJS)) ifneq ($(crash_debug),y) -OBJS := $(patsubst cdb%.o,,$(OBJS)) +OBJS := $(patsubst gdbstub%.o,,$(OBJS)) endif default: $(TARGET)
xen/arch/x86/x86_32/xen.lds.S +5 -0
@@ -21,6 +21,11 @@ _text = .; /* Text and read-only data */ .text : { *(.text) + . = ALIGN(32); + __gdbstub_text_start = .; + *(.gdbstub.text) + __gdbstub_text_end = .; + . = ALIGN(32); *(.fixup) *(.gnu.warning) } :text =0x9090
xen/common/Makefile +3 -0
@@ -3,6 +3,9 @@ ifneq ($(perfc),y) OBJS := $(subst perfc.o,,$(OBJS)) +endif +ifneq ($(crash_debug),y) +OBJS := $(patsubst gdbstub.o,,$(OBJS)) endif default: common.o
xen/include/asm-x86/debugger.h +6 -4
@@ -42,19 +42,19 @@#if defined(CRASH_DEBUG ) -extern int __trap_to_cdb (struct cpu_user_regs *r); +#include <xen/gdb.h> #define __debugger_trap_entry (_v, _r) (0)static inline int __debugger_trap_fatal (unsigned int vector,struct cpu_user_regs *regs) { - (void )__trap_to_cdb (regs); + (void )__trap_to_gdb (regs, vector);return (vector == TRAP_int3);/* int3 is harmless */ }/* Int3 is a trivial way to gather cpu_user_regs context. */ -#define __debugger_trap_immediate () __asm__ __volatile__ ( "int3" ); +#define debugger_trap_immediate () __asm__ __volatile__ ( "int3" );#elif 0
@@ -73,7 +73,7 @@ }/* Int3 is a trivial way to gather cpu_user_regs context. */ -#define __debugger_trap_immediate () __asm__ __volatile__ ( "int3" ) +#define debugger_trap_immediate () __asm__ __volatile__ ( "int3" )#else
@@ -100,6 +100,8 @@ }#define debugger_trap_fatal (v, r) (__debugger_trap_fatal(v, r)) +#ifndef debugger_trap_immediate#define debugger_trap_immediate () (__debugger_trap_immediate()) +#endif #endif /* __X86_DEBUGGER_H__ */
xen/arch/x86/gdbstub.c new file +146 -0
146 lines not on this page · raw message
xen/common/gdbstub.c new file +589 -0
589 lines not on this page · raw message
xen/include/xen/gdb.h new file +92 -0
92 lines not on this page · raw message
xen/arch/x86/cdb.c deleted +0 -414
414 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 13 lines · Isaku Yamahata
Quoted 4 lines
Quoted 4 lines
+/* Append this to the declaration of any function needed to be used by
+ * the gdb stub. Any functions marked with this will not be allowed
+ * to have a breakpoint set in them. */Quoted 8 lines
Quoted 1 line
+#define
__gdbstub__attribute__((section(".gdbstub.text")))These make sense if we want to avoid setting a breakpoint in GDB stub code or code called by the GDB stub, such as serial output. However, these symbols aren't currently used. (You probably inherited this from the PPC stub.) At least it's worth a TODO comment, possibly in
gdb_cmd_write_mem(): we shouldn't be writing to memory between those two symbols.
Quoted 2 lines
added
__gdbstub_text_start,__gdbstub_text_enddeclarations and a comment abovegdb_cmd_write_mem()
Is this really worthwhile? The gdbstub will be using calling functions outside this range, so it's not a comprehensive solution for disallowing breakpoints in gdb mode. For that I think you'd need to clear all breakpoints on entry to gdbstub and re-set them on exit.
I'd prefer to avoid extra section directives unless they're clearly useful.
-- Keir
Quoted 7 lines · Keir Fraser
Is this really worthwhile? The gdbstub will be using calling functions outside this range, so it's not a comprehensive solution for disallowing breakpoints in gdb mode. For that I think you'd need to clear all breakpoints on entry to gdbstub and re-set them on exit.
I'd prefer to avoid extra section directives unless they're clearly useful.
The current gdbstub doesn't support breakpoints anyway,
and it is beyond my purpose to implement such functionality. So I removed the __gdbstub related code and toss this issue to those who want/implement breakpoints in the future.
Signature · 1 line
yamahata
# HG changeset patch
# User [email protected]
# Node ID a5aa872297f5a5195b2cef1bb4ac6f3cd9bd3195
# Parent ef88c2db00ad5076594dc5921e14db89bdf6cb7e
clean up cdb.
renamed cdb to gdbstub and split it into arch dependent/neutral part.
xen/arch/x86/Makefile +1 -1
@@ -32,7 +32,7 @@ OBJS := $(subst $(TARGET_SUBARCH)/xen.lds.o,,$(OBJS)) ifneq ($(crash_debug),y) -OBJS := $(patsubst cdb%.o,,$(OBJS)) +OBJS := $(patsubst gdbstub%.o,,$(OBJS)) endif default: $(TARGET)
xen/common/Makefile +3 -0
@@ -3,6 +3,9 @@ ifneq ($(perfc),y) OBJS := $(subst perfc.o,,$(OBJS)) +endif +ifneq ($(crash_debug),y) +OBJS := $(patsubst gdbstub.o,,$(OBJS)) endif default: common.o
xen/include/asm-x86/debugger.h +6 -4
@@ -42,19 +42,19 @@#if defined(CRASH_DEBUG ) -extern int __trap_to_cdb (struct cpu_user_regs *r); +#include <xen/gdb.h> #define __debugger_trap_entry (_v, _r) (0)static inline int __debugger_trap_fatal (unsigned int vector,struct cpu_user_regs *regs) { - (void )__trap_to_cdb (regs); + (void )__trap_to_gdb (regs, vector);return (vector == TRAP_int3);/* int3 is harmless */ }/* Int3 is a trivial way to gather cpu_user_regs context. */ -#define __debugger_trap_immediate () __asm__ __volatile__ ( "int3" ); +#define debugger_trap_immediate () __asm__ __volatile__ ( "int3" );#elif 0
@@ -73,7 +73,7 @@ }/* Int3 is a trivial way to gather cpu_user_regs context. */ -#define __debugger_trap_immediate () __asm__ __volatile__ ( "int3" ) +#define debugger_trap_immediate () __asm__ __volatile__ ( "int3" )#else
@@ -100,6 +100,8 @@ }#define debugger_trap_fatal (v, r) (__debugger_trap_fatal(v, r)) +#ifndef debugger_trap_immediate#define debugger_trap_immediate () (__debugger_trap_immediate()) +#endif #endif /* __X86_DEBUGGER_H__ */
xen/arch/x86/gdbstub.c new file +146 -0
146 lines not on this page · raw message
xen/common/gdbstub.c new file +585 -0
585 lines not on this page · raw message
xen/include/xen/gdb.h new file +85 -0
85 lines not on this page · raw message
xen/arch/x86/cdb.c deleted +0 -414
414 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel