ia64/xen-unstable

changeset 9549:e08dcff87bb2

Enable the setting and trapping of breakpoints for hvm guest.
Catch Ctrl-C for gdbserver and let gdb break from continue command.

Signed-Off-By: Nitin A Kamble <nitin.a.kamble@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Mar 31 10:07:55 2006 +0100 (2006-03-31)
parents 4943372c14f6
children 4860a15edc1c
files tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/server.c tools/libxc/xc_ptrace.c xen/arch/x86/hvm/vmx/vmx.c xen/include/asm-x86/hvm/support.h
line diff
     1.1 --- a/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/server.c	Fri Mar 31 10:06:20 2006 +0100
     1.2 +++ b/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/server.c	Fri Mar 31 10:07:55 2006 +0100
     1.3 @@ -287,6 +287,21 @@ handle_v_requests (char *own_buf, char *
     1.4  }
     1.5  
     1.6  void
     1.7 +handle_breakpoint_requests (char *own_buf, char *status, unsigned char *signal)
     1.8 +{
     1.9 +  /*  Currently we only support software breakpoints */
    1.10 +    switch (own_buf[1]) {
    1.11 +        case '0': /* software breakpoint, int3 based */
    1.12 +	      own_buf[0] = '\0';
    1.13 +            break;
    1.14 +        case '1': /* hardware breakpoint */
    1.15 +        default:
    1.16 +		  write_enn (own_buf);
    1.17 +            break;
    1.18 +    }
    1.19 +}
    1.20 +
    1.21 +void
    1.22  myresume (int step, int sig)
    1.23  {
    1.24    struct thread_resume resume_info[2];
    1.25 @@ -322,6 +337,18 @@ gdbserver_usage (void)
    1.26  	 "HOST:PORT to listen for a TCP connection.\n");
    1.27  }
    1.28  
    1.29 +extern control_c_pressed_flag;
    1.30 +#include <signal.h>
    1.31 +
    1.32 +void ctrl_c_handler(int signo)
    1.33 +{
    1.34 +    printf("Ctrl-C pressed: Quit from the attached gdb first\n");
    1.35 +    control_c_pressed_flag = 1;
    1.36 +}
    1.37 +
    1.38 +struct sigaction ctrl_c_sigaction = { .sa_handler = ctrl_c_handler };
    1.39 +struct sigaction old_sigaction;
    1.40 +
    1.41  int
    1.42  main (int argc, char *argv[])
    1.43  {
    1.44 @@ -396,9 +423,11 @@ main (int argc, char *argv[])
    1.45  	}
    1.46      }
    1.47  
    1.48 +
    1.49    while (1)
    1.50      {
    1.51        remote_open (argv[1]);
    1.52 +      sigaction(SIGINT, &ctrl_c_sigaction, &old_sigaction);
    1.53  
    1.54      restart:
    1.55        setjmp (toplevel);
    1.56 @@ -587,6 +616,9 @@ main (int argc, char *argv[])
    1.57  	      /* Extended (long) request.  */
    1.58  	      handle_v_requests (own_buf, &status, &signal);
    1.59  	      break;
    1.60 +	    case 'Z':
    1.61 +	      handle_breakpoint_requests (own_buf, &status, &signal);
    1.62 +	      break;
    1.63  	    default:
    1.64  	      /* It is a request we don't understand.  Respond with an
    1.65  	         empty packet so that gdb knows that we don't support this
    1.66 @@ -643,5 +675,6 @@ main (int argc, char *argv[])
    1.67  			   "GDBserver will reopen the connection.\n");
    1.68  	  remote_close ();
    1.69  	}
    1.70 +    sigaction(SIGINT, &old_sigaction, NULL);
    1.71      }
    1.72  }
     2.1 --- a/tools/libxc/xc_ptrace.c	Fri Mar 31 10:06:20 2006 +0100
     2.2 +++ b/tools/libxc/xc_ptrace.c	Fri Mar 31 10:07:55 2006 +0100
     2.3 @@ -401,6 +401,8 @@ map_domain_va(
     2.4      return map_domain_va_32(xc_handle, cpu, guest_va, perm);
     2.5  }
     2.6  
     2.7 +int control_c_pressed_flag = 0;
     2.8 +
     2.9  static int 
    2.10  __xc_waitdomain(
    2.11      int xc_handle,
    2.12 @@ -419,7 +421,6 @@ static int
    2.13      op.cmd = DOM0_GETDOMAININFO;
    2.14      op.u.getdomaininfo.domain = domain;
    2.15      
    2.16 -    
    2.17   retry:
    2.18      retval = do_dom0_op(xc_handle, &op);
    2.19      if ( retval || (op.u.getdomaininfo.domain != domain) )
    2.20 @@ -432,12 +433,17 @@ static int
    2.21      if ( options & WNOHANG )
    2.22          goto done;
    2.23  
    2.24 +    if (control_c_pressed_flag) {
    2.25 +        xc_domain_pause(xc_handle, domain);
    2.26 +        control_c_pressed_flag = 0;
    2.27 +        goto done;
    2.28 +    }
    2.29 +
    2.30      if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) )
    2.31      {
    2.32          nanosleep(&ts,NULL);
    2.33          goto retry;
    2.34      }
    2.35 -    /* XXX check for ^C here */
    2.36   done:
    2.37      if (get_online_cpumap(xc_handle, &op.u.getdomaininfo, &cpumap))
    2.38          printf("get_online_cpumap failed\n");
     3.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Fri Mar 31 10:06:20 2006 +0100
     3.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Fri Mar 31 10:07:55 2006 +0100
     3.3 @@ -2130,6 +2130,14 @@ asmlinkage void vmx_vmexit_handler(struc
     3.4  
     3.5              break;
     3.6          }
     3.7 +        case TRAP_int3:
     3.8 +        {
     3.9 +            if ( test_bit(_DOMF_debugging, &v->domain->domain_flags) )
    3.10 +                domain_pause_for_debugger();
    3.11 +            else 
    3.12 +                vmx_inject_exception(v, TRAP_int3, VMX_DELIVER_NO_ERROR_CODE);
    3.13 +            break;
    3.14 +        }
    3.15  #endif
    3.16          case TRAP_no_device:
    3.17          {
     4.1 --- a/xen/include/asm-x86/hvm/support.h	Fri Mar 31 10:06:20 2006 +0100
     4.2 +++ b/xen/include/asm-x86/hvm/support.h	Fri Mar 31 10:07:55 2006 +0100
     4.3 @@ -94,6 +94,7 @@ enum hval_bitmaps {
     4.4  #else
     4.5  #define MONITOR_DEFAULT_EXCEPTION_BITMAP        \
     4.6      ( EXCEPTION_BITMAP_PG |                     \
     4.7 +      EXCEPTION_BITMAP_BP |                     \
     4.8        EXCEPTION_BITMAP_GP )
     4.9  #endif
    4.10