# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 6b1d39a56c2be5dbc2290f508d24eac750111cf4
# Parent b5b7a9d9fc56dd1d0adb5766124b0e57bc016f57
Add debugging flag for domains to make domu debugging a run-time option
Signed-off-by: Kip Macy kmacy@xxxxxxxxxxx
diff -r b5b7a9d9fc56 -r 6b1d39a56c2b
tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c
--- a/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c
Thu Dec 15 20:02:21 2005
+++ b/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c
Thu Dec 15 20:50:12 2005
@@ -231,11 +231,6 @@
if (myxcwait(xc_handle, current_domid, &w, 0))
return -1;
- if (w & (DOMFLAGS_SHUTDOWN|DOMFLAGS_DYING)) {
- *status = 'W';
- return 0;
- }
-
linux_set_inferior();
*status = 'T';
diff -r b5b7a9d9fc56 -r 6b1d39a56c2b tools/libxc/xc_ptrace.c
--- a/tools/libxc/xc_ptrace.c Thu Dec 15 20:02:21 2005
+++ b/tools/libxc/xc_ptrace.c Thu Dec 15 20:50:12 2005
@@ -344,8 +344,6 @@
int cpu, index;
void *addr = (char *)eaddr;
void *data = (char *)edata;
-
- op.interface_version = DOM0_INTERFACE_VERSION;
cpu = (request != PTRACE_ATTACH) ? domid_tid : 0;
@@ -434,6 +432,13 @@
}
}
}
+ if ( request == PTRACE_DETACH )
+ {
+ op.cmd = DOM0_SETDEBUGGING;
+ op.u.setdebugging.domain = current_domid;
+ op.u.setdebugging.enable = 0;
+ retval = do_dom0_op(xc_handle, &op);
+ }
regs_valid = 0;
xc_domain_unpause(xc_handle, current_domid > 0 ? current_domid :
-current_domid);
break;
@@ -453,10 +458,15 @@
printf("domain currently paused\n");
} else
retval = xc_domain_pause(xc_handle, current_domid);
- if (get_online_cpumap(xc_handle, &op.u.getdomaininfo, &cpumap))
- printf("get_online_cpumap failed\n");
- if (online_cpumap != cpumap)
- online_vcpus_changed(cpumap);
+ op.cmd = DOM0_SETDEBUGGING;
+ op.u.setdebugging.domain = current_domid;
+ op.u.setdebugging.enable = 1;
+ retval = do_dom0_op(xc_handle, &op);
+
+ if (get_online_cpumap(xc_handle, &op.u.getdomaininfo, &cpumap))
+ printf("get_online_cpumap failed\n");
+ if (online_cpumap != cpumap)
+ online_vcpus_changed(cpumap);
break;
case PTRACE_SETFPREGS:
diff -r b5b7a9d9fc56 -r 6b1d39a56c2b xen/Rules.mk
--- a/xen/Rules.mk Thu Dec 15 20:02:21 2005
+++ b/xen/Rules.mk Thu Dec 15 20:50:12 2005
@@ -6,7 +6,6 @@
debug ?= n
perfc ?= n
perfc_arrays?= n
-domu_debug ?= n
crash_debug ?= n
XEN_ROOT=$(BASEDIR)/..
@@ -54,10 +53,6 @@
CFLAGS += -g -DVERBOSE
endif
-ifeq ($(domu_debug),y)
-CFLAGS += -DDOMU_DEBUG
-endif
-
ifeq ($(crash_debug),y)
CFLAGS += -g -DCRASH_DEBUG
endif
diff -r b5b7a9d9fc56 -r 6b1d39a56c2b xen/common/dom0_ops.c
--- a/xen/common/dom0_ops.c Thu Dec 15 20:02:21 2005
+++ b/xen/common/dom0_ops.c Thu Dec 15 20:50:12 2005
@@ -577,6 +577,22 @@
}
}
break;
+ case DOM0_SETDEBUGGING:
+ {
+ struct domain *d;
+ ret = -ESRCH;
+ d = find_domain_by_id(op->u.setdebugging.domain);
+ if ( d != NULL )
+ {
+ if ( op->u.setdebugging.enable )
+ set_bit(_DOMF_debugging, &d->domain_flags);
+ else
+ clear_bit(_DOMF_debugging, &d->domain_flags);
+ put_domain(d);
+ ret = 0;
+ }
+ }
+ break;
#ifdef PERF_COUNTERS
case DOM0_PERFCCONTROL:
diff -r b5b7a9d9fc56 -r 6b1d39a56c2b xen/include/asm-x86/debugger.h
--- a/xen/include/asm-x86/debugger.h Thu Dec 15 20:02:21 2005
+++ b/xen/include/asm-x86/debugger.h Thu Dec 15 20:50:12 2005
@@ -30,6 +30,8 @@
#ifndef __X86_DEBUGGER_H__
#define __X86_DEBUGGER_H__
+#include <xen/sched.h>
+#include <asm/regs.h>
#include <asm/processor.h>
/* The main trap handlers use these helper macros which include early bail. */
@@ -41,9 +43,10 @@
#if defined(CRASH_DEBUG)
extern int __trap_to_cdb(struct cpu_user_regs *r);
-#define debugger_trap_entry(_v, _r) (0)
-static inline int debugger_trap_fatal(
+#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);
@@ -51,60 +54,52 @@
}
/* 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 defined(DOMU_DEBUG)
+#elif 0
-#include <xen/sched.h>
-#include <asm/regs.h>
+extern int kdb_trap(int, int, struct cpu_user_regs *);
+
+static inline int __debugger_trap_entry(
+ unsigned int vector, struct cpu_user_regs *regs)
+{
+ return 0;
+}
+
+static inline int __debugger_trap_fatal(
+ unsigned int vector, struct cpu_user_regs *regs)
+{
+ return kdb_trap(vector, 0, regs);
+}
+
+/* Int3 is a trivial way to gather cpu_user_regs context. */
+#define __debugger_trap_immediate() __asm__ __volatile__ ( "int3" )
+
+#else
+
+#define __debugger_trap_entry(_v, _r) (0)
+#define __debugger_trap_fatal(_v, _r) (0)
+#define __debugger_trap_immediate() ((void)0)
+
+#endif
static inline int debugger_trap_entry(
unsigned int vector, struct cpu_user_regs *regs)
{
struct vcpu *v = current;
- if ( !KERNEL_MODE(v, regs) || (v->domain->domain_id == 0) )
- return 0;
-
- switch ( vector )
+ if ( KERNEL_MODE(v, regs) &&
+ test_bit(_DOMF_debugging, &v->domain->domain_flags) &&
+ ((vector == TRAP_int3) || (vector == TRAP_debug)) )
{
- case TRAP_int3:
- case TRAP_debug:
domain_pause_for_debugger();
return 1;
}
- return 0;
+ return __debugger_trap_entry(vector, regs);
}
-#define debugger_trap_fatal(_v, _r) (0)
-#define debugger_trap_immediate()
-
-#elif 0
-
-extern int kdb_trap(int, int, struct cpu_user_regs *);
-
-static inline int debugger_trap_entry(
- unsigned int vector, struct cpu_user_regs *regs)
-{
- return 0;
-}
-
-static inline int debugger_trap_fatal(
- unsigned int vector, struct cpu_user_regs *regs)
-{
- return kdb_trap(vector, 0, regs);
-}
-
-/* Int3 is a trivial way to gather cpu_user_regs context. */
-#define debugger_trap_immediate() __asm__ __volatile__ ( "int3" );
-
-#else
-
-#define debugger_trap_entry(_v, _r) (0)
-#define debugger_trap_fatal(_v, _r) (0)
-#define debugger_trap_immediate()
-
-#endif
+#define debugger_trap_fatal(v, r) (__debugger_trap_fatal(v, r))
+#define debugger_trap_immediate() (__debugger_trap_immediate())
#endif /* __X86_DEBUGGER_H__ */
diff -r b5b7a9d9fc56 -r 6b1d39a56c2b xen/include/public/dom0_ops.h
--- a/xen/include/public/dom0_ops.h Thu Dec 15 20:02:21 2005
+++ b/xen/include/public/dom0_ops.h Thu Dec 15 20:50:12 2005
@@ -403,6 +403,12 @@
domid_t domain;
xen_domain_handle_t handle;
} dom0_setdomainhandle_t;
+
+#define DOM0_SETDEBUGGING 45
+typedef struct {
+ domid_t domain;
+ uint8_t enable;
+} dom0_setdebugging_t;
typedef struct {
uint32_t cmd;
@@ -440,7 +446,8 @@
dom0_platform_quirk_t platform_quirk;
dom0_physical_memory_map_t physical_memory_map;
dom0_max_vcpus_t max_vcpus;
- dom0_setdomainhandle_t setdomainhandle;
+ dom0_setdomainhandle_t setdomainhandle;
+ dom0_setdebugging_t setdebugging;
uint8_t pad[128];
} u;
} dom0_op_t;
diff -r b5b7a9d9fc56 -r 6b1d39a56c2b xen/include/xen/sched.h
--- a/xen/include/xen/sched.h Thu Dec 15 20:02:21 2005
+++ b/xen/include/xen/sched.h Thu Dec 15 20:50:12 2005
@@ -393,6 +393,10 @@
/* Domain is paused by controller software. */
#define _DOMF_ctrl_pause 6
#define DOMF_ctrl_pause (1UL<<_DOMF_ctrl_pause)
+ /* Domain is being debugged by controller software. */
+#define _DOMF_debugging 7
+#define DOMF_debugging (1UL<<_DOMF_debugging)
+
static inline int domain_runnable(struct vcpu *v)
{
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|