ia64/xen-unstable

changeset 8400:6b1d39a56c2b

Add debugging flag for domains to make domu debugging a run-time option
Signed-off-by: Kip Macy kmacy@fsmware.ckm
author kaf24@firebug.cl.cam.ac.uk
date Thu Dec 15 21:50:12 2005 +0100 (2005-12-15)
parents b5b7a9d9fc56
children 8ebcbcda3d37
files tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c tools/libxc/xc_ptrace.c xen/Rules.mk xen/common/dom0_ops.c xen/include/asm-x86/debugger.h xen/include/public/dom0_ops.h xen/include/xen/sched.h
line diff
     1.1 --- a/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c	Thu Dec 15 21:02:21 2005 +0100
     1.2 +++ b/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c	Thu Dec 15 21:50:12 2005 +0100
     1.3 @@ -231,11 +231,6 @@ linux_wait (char *status)
     1.4    if (myxcwait(xc_handle, current_domid, &w, 0))
     1.5        return -1;
     1.6    
     1.7 -  if (w & (DOMFLAGS_SHUTDOWN|DOMFLAGS_DYING)) {
     1.8 -      *status = 'W';
     1.9 -      return 0;
    1.10 -  }
    1.11 -
    1.12    linux_set_inferior();
    1.13  
    1.14    *status = 'T';
     2.1 --- a/tools/libxc/xc_ptrace.c	Thu Dec 15 21:02:21 2005 +0100
     2.2 +++ b/tools/libxc/xc_ptrace.c	Thu Dec 15 21:50:12 2005 +0100
     2.3 @@ -345,8 +345,6 @@ xc_ptrace(
     2.4      void           *addr = (char *)eaddr;
     2.5      void           *data = (char *)edata;
     2.6  
     2.7 -    op.interface_version = DOM0_INTERFACE_VERSION;
     2.8 -
     2.9      cpu = (request != PTRACE_ATTACH) ? domid_tid : 0;
    2.10      
    2.11      switch ( request )
    2.12 @@ -434,6 +432,13 @@ xc_ptrace(
    2.13                  }
    2.14              }
    2.15          }
    2.16 +        if ( request == PTRACE_DETACH )
    2.17 +        {
    2.18 +            op.cmd = DOM0_SETDEBUGGING;
    2.19 +            op.u.setdebugging.domain = current_domid;
    2.20 +            op.u.setdebugging.enable = 0;
    2.21 +            retval = do_dom0_op(xc_handle, &op);
    2.22 +        }
    2.23          regs_valid = 0;
    2.24          xc_domain_unpause(xc_handle, current_domid > 0 ? current_domid : -current_domid);
    2.25          break;
    2.26 @@ -453,10 +458,15 @@ xc_ptrace(
    2.27              printf("domain currently paused\n");
    2.28          } else
    2.29              retval = xc_domain_pause(xc_handle, current_domid);
    2.30 -    if (get_online_cpumap(xc_handle, &op.u.getdomaininfo, &cpumap))
    2.31 -        printf("get_online_cpumap failed\n");
    2.32 -    if (online_cpumap != cpumap)
    2.33 -        online_vcpus_changed(cpumap);
    2.34 +        op.cmd = DOM0_SETDEBUGGING;
    2.35 +        op.u.setdebugging.domain = current_domid;
    2.36 +        op.u.setdebugging.enable = 1;
    2.37 +        retval = do_dom0_op(xc_handle, &op);
    2.38 +
    2.39 +        if (get_online_cpumap(xc_handle, &op.u.getdomaininfo, &cpumap))
    2.40 +            printf("get_online_cpumap failed\n");
    2.41 +        if (online_cpumap != cpumap)
    2.42 +            online_vcpus_changed(cpumap);
    2.43          break;
    2.44  
    2.45      case PTRACE_SETFPREGS:
     3.1 --- a/xen/Rules.mk	Thu Dec 15 21:02:21 2005 +0100
     3.2 +++ b/xen/Rules.mk	Thu Dec 15 21:50:12 2005 +0100
     3.3 @@ -6,7 +6,6 @@ verbose     ?= n
     3.4  debug       ?= n
     3.5  perfc       ?= n
     3.6  perfc_arrays?= n
     3.7 -domu_debug  ?= n
     3.8  crash_debug ?= n
     3.9  
    3.10  XEN_ROOT=$(BASEDIR)/..
    3.11 @@ -54,10 +53,6 @@ else
    3.12  CFLAGS += -g -DVERBOSE
    3.13  endif
    3.14  
    3.15 -ifeq ($(domu_debug),y)
    3.16 -CFLAGS += -DDOMU_DEBUG
    3.17 -endif
    3.18 -
    3.19  ifeq ($(crash_debug),y)
    3.20  CFLAGS += -g -DCRASH_DEBUG
    3.21  endif
     4.1 --- a/xen/common/dom0_ops.c	Thu Dec 15 21:02:21 2005 +0100
     4.2 +++ b/xen/common/dom0_ops.c	Thu Dec 15 21:50:12 2005 +0100
     4.3 @@ -577,6 +577,22 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     4.4          }
     4.5      }
     4.6      break;
     4.7 +    case DOM0_SETDEBUGGING:
     4.8 +    {
     4.9 +        struct domain *d; 
    4.10 +        ret = -ESRCH;
    4.11 +        d = find_domain_by_id(op->u.setdebugging.domain);
    4.12 +        if ( d != NULL )
    4.13 +        {
    4.14 +            if ( op->u.setdebugging.enable )
    4.15 +                set_bit(_DOMF_debugging, &d->domain_flags);
    4.16 +            else
    4.17 +                clear_bit(_DOMF_debugging, &d->domain_flags);
    4.18 +            put_domain(d);
    4.19 +            ret = 0;
    4.20 +        }
    4.21 +    }
    4.22 +    break;
    4.23  
    4.24  #ifdef PERF_COUNTERS
    4.25      case DOM0_PERFCCONTROL:
     5.1 --- a/xen/include/asm-x86/debugger.h	Thu Dec 15 21:02:21 2005 +0100
     5.2 +++ b/xen/include/asm-x86/debugger.h	Thu Dec 15 21:50:12 2005 +0100
     5.3 @@ -30,6 +30,8 @@
     5.4  #ifndef __X86_DEBUGGER_H__
     5.5  #define __X86_DEBUGGER_H__
     5.6  
     5.7 +#include <xen/sched.h>
     5.8 +#include <asm/regs.h>
     5.9  #include <asm/processor.h>
    5.10  
    5.11  /* The main trap handlers use these helper macros which include early bail. */
    5.12 @@ -41,9 +43,10 @@
    5.13  #if defined(CRASH_DEBUG)
    5.14  
    5.15  extern int __trap_to_cdb(struct cpu_user_regs *r);
    5.16 -#define debugger_trap_entry(_v, _r) (0)
    5.17  
    5.18 -static inline int debugger_trap_fatal(
    5.19 +#define __debugger_trap_entry(_v, _r) (0)
    5.20 +
    5.21 +static inline int __debugger_trap_fatal(
    5.22      unsigned int vector, struct cpu_user_regs *regs)
    5.23  {
    5.24      (void)__trap_to_cdb(regs);
    5.25 @@ -51,60 +54,52 @@ static inline int debugger_trap_fatal(
    5.26  }
    5.27  
    5.28  /* Int3 is a trivial way to gather cpu_user_regs context. */
    5.29 -#define debugger_trap_immediate() __asm__ __volatile__ ( "int3" );
    5.30 +#define __debugger_trap_immediate() __asm__ __volatile__ ( "int3" );
    5.31  
    5.32 -#elif defined(DOMU_DEBUG)
    5.33 +#elif 0
    5.34  
    5.35 -#include <xen/sched.h>
    5.36 -#include <asm/regs.h>
    5.37 +extern int kdb_trap(int, int, struct cpu_user_regs *);
    5.38 +
    5.39 +static inline int __debugger_trap_entry(
    5.40 +    unsigned int vector, struct cpu_user_regs *regs)
    5.41 +{
    5.42 +    return 0;
    5.43 +}
    5.44 +
    5.45 +static inline int __debugger_trap_fatal(
    5.46 +    unsigned int vector, struct cpu_user_regs *regs)
    5.47 +{
    5.48 +    return kdb_trap(vector, 0, regs);
    5.49 +}
    5.50 +
    5.51 +/* Int3 is a trivial way to gather cpu_user_regs context. */
    5.52 +#define __debugger_trap_immediate() __asm__ __volatile__ ( "int3" )
    5.53 +
    5.54 +#else
    5.55 +
    5.56 +#define __debugger_trap_entry(_v, _r) (0)
    5.57 +#define __debugger_trap_fatal(_v, _r) (0)
    5.58 +#define __debugger_trap_immediate()   ((void)0)
    5.59 +
    5.60 +#endif
    5.61  
    5.62  static inline int debugger_trap_entry(
    5.63      unsigned int vector, struct cpu_user_regs *regs)
    5.64  {
    5.65      struct vcpu *v = current;
    5.66  
    5.67 -    if ( !KERNEL_MODE(v, regs) || (v->domain->domain_id == 0) )
    5.68 -        return 0;
    5.69 -    
    5.70 -    switch ( vector )
    5.71 +    if ( KERNEL_MODE(v, regs) &&
    5.72 +         test_bit(_DOMF_debugging, &v->domain->domain_flags) &&
    5.73 +         ((vector == TRAP_int3) || (vector == TRAP_debug)) )
    5.74      {
    5.75 -    case TRAP_int3:
    5.76 -    case TRAP_debug:
    5.77          domain_pause_for_debugger();
    5.78          return 1;
    5.79      }
    5.80  
    5.81 -    return 0;
    5.82 -}
    5.83 -
    5.84 -#define debugger_trap_fatal(_v, _r) (0)
    5.85 -#define debugger_trap_immediate()
    5.86 -
    5.87 -#elif 0
    5.88 -
    5.89 -extern int kdb_trap(int, int, struct cpu_user_regs *);
    5.90 -
    5.91 -static inline int debugger_trap_entry(
    5.92 -    unsigned int vector, struct cpu_user_regs *regs)
    5.93 -{
    5.94 -    return 0;
    5.95 +    return __debugger_trap_entry(vector, regs);
    5.96  }
    5.97  
    5.98 -static inline int debugger_trap_fatal(
    5.99 -    unsigned int vector, struct cpu_user_regs *regs)
   5.100 -{
   5.101 -    return kdb_trap(vector, 0, regs);
   5.102 -}
   5.103 -
   5.104 -/* Int3 is a trivial way to gather cpu_user_regs context. */
   5.105 -#define debugger_trap_immediate() __asm__ __volatile__ ( "int3" );
   5.106 -
   5.107 -#else
   5.108 -
   5.109 -#define debugger_trap_entry(_v, _r) (0)
   5.110 -#define debugger_trap_fatal(_v, _r) (0)
   5.111 -#define debugger_trap_immediate()
   5.112 -
   5.113 -#endif
   5.114 +#define debugger_trap_fatal(v, r) (__debugger_trap_fatal(v, r))
   5.115 +#define debugger_trap_immediate() (__debugger_trap_immediate())
   5.116  
   5.117  #endif /* __X86_DEBUGGER_H__ */
     6.1 --- a/xen/include/public/dom0_ops.h	Thu Dec 15 21:02:21 2005 +0100
     6.2 +++ b/xen/include/public/dom0_ops.h	Thu Dec 15 21:50:12 2005 +0100
     6.3 @@ -404,6 +404,12 @@ typedef struct {
     6.4      xen_domain_handle_t handle;
     6.5  } dom0_setdomainhandle_t;
     6.6  
     6.7 +#define DOM0_SETDEBUGGING 45
     6.8 +typedef struct {
     6.9 +    domid_t domain;
    6.10 +    uint8_t enable;
    6.11 +} dom0_setdebugging_t;
    6.12 +
    6.13  typedef struct {
    6.14      uint32_t cmd;
    6.15      uint32_t interface_version; /* DOM0_INTERFACE_VERSION */
    6.16 @@ -440,7 +446,8 @@ typedef struct {
    6.17          dom0_platform_quirk_t    platform_quirk;
    6.18          dom0_physical_memory_map_t physical_memory_map;
    6.19          dom0_max_vcpus_t         max_vcpus;
    6.20 -        dom0_setdomainhandle_t   setdomainhandle;
    6.21 +        dom0_setdomainhandle_t   setdomainhandle;        
    6.22 +        dom0_setdebugging_t      setdebugging;
    6.23          uint8_t                  pad[128];
    6.24      } u;
    6.25  } dom0_op_t;
     7.1 --- a/xen/include/xen/sched.h	Thu Dec 15 21:02:21 2005 +0100
     7.2 +++ b/xen/include/xen/sched.h	Thu Dec 15 21:50:12 2005 +0100
     7.3 @@ -393,6 +393,10 @@ extern struct domain *domain_list;
     7.4   /* Domain is paused by controller software. */
     7.5  #define _DOMF_ctrl_pause       6
     7.6  #define DOMF_ctrl_pause        (1UL<<_DOMF_ctrl_pause)
     7.7 + /* Domain is being debugged by controller software. */
     7.8 +#define _DOMF_debugging        7
     7.9 +#define DOMF_debugging         (1UL<<_DOMF_debugging)
    7.10 +
    7.11  
    7.12  static inline int domain_runnable(struct vcpu *v)
    7.13  {