ia64/xen-unstable

changeset 1092:53b906cc1cba

bitkeeper revision 1.726 (402d38a5ev6IHCrkovur_GS1Iinquw)

allow gdb to change registers
author ach61@labyrinth.cl.cam.ac.uk
date Fri Feb 13 20:50:45 2004 +0000 (2004-02-13)
parents 38210918dfa7
children d5fe78785e26 8a531b79be75
files docs/pdb.txt xen/arch/i386/pdb-stub.c xenolinux-2.4.24-sparse/arch/xeno/drivers/block/xl_block.c
line diff
     1.1 --- a/docs/pdb.txt	Fri Feb 13 13:58:10 2004 +0000
     1.2 +++ b/docs/pdb.txt	Fri Feb 13 20:50:45 2004 +0000
     1.3 @@ -1,7 +1,7 @@
     1.4  Pervasive Debugging 
     1.5  ===================
     1.6  
     1.7 -040205 Alex Ho (alex.ho@cl.cam.ac.uk)
     1.8 +040205 Alex Ho (alex.ho at cl.cam.ac.uk)
     1.9  
    1.10  Introduction
    1.11  ------------
     2.1 --- a/xen/arch/i386/pdb-stub.c	Fri Feb 13 13:58:10 2004 +0000
     2.2 +++ b/xen/arch/i386/pdb-stub.c	Fri Feb 13 20:50:45 2004 +0000
     2.3 @@ -118,6 +118,81 @@ pdb_process_query (char *ptr)
     2.4      }
     2.5  }
     2.6  
     2.7 +void
     2.8 +pdb_x86_to_gdb_regs (char *buffer, struct pt_regs *regs)
     2.9 +{
    2.10 +    int idx = 0;
    2.11 +
    2.12 +    mem2hex ((char *)&regs->eax, &buffer[idx], sizeof(regs->eax));
    2.13 +    idx += sizeof(regs->eax) * 2;
    2.14 +    mem2hex ((char *)&regs->ecx, &buffer[idx], sizeof(regs->ecx));
    2.15 +    idx += sizeof(regs->ecx) * 2;
    2.16 +    mem2hex ((char *)&regs->edx, &buffer[idx], sizeof(regs->edx));
    2.17 +    idx += sizeof(regs->edx) * 2;
    2.18 +    mem2hex ((char *)&regs->ebx, &buffer[idx], sizeof(regs->ebx));
    2.19 +    idx += sizeof(regs->ebx) * 2;
    2.20 +    mem2hex ((char *)&regs->esp, &buffer[idx], sizeof(regs->esp));
    2.21 +    idx += sizeof(regs->esp) * 2;
    2.22 +    mem2hex ((char *)&regs->ebp, &buffer[idx], sizeof(regs->ebp));
    2.23 +    idx += sizeof(regs->ebp) * 2;
    2.24 +    mem2hex ((char *)&regs->esi, &buffer[idx], sizeof(regs->esi));
    2.25 +    idx += sizeof(regs->esi) * 2;
    2.26 +    mem2hex ((char *)&regs->edi, &buffer[idx], sizeof(regs->edi));
    2.27 +    idx += sizeof(regs->edi) * 2;
    2.28 +    mem2hex ((char *)&regs->eip, &buffer[idx], sizeof(regs->eip));
    2.29 +    idx += sizeof(regs->eip) * 2;
    2.30 +    mem2hex ((char *)&regs->eflags, &buffer[idx], sizeof(regs->eflags));
    2.31 +    idx += sizeof(regs->eflags) * 2;
    2.32 +    mem2hex ((char *)&regs->xcs, &buffer[idx], sizeof(regs->xcs));
    2.33 +    idx += sizeof(regs->xcs) * 2;
    2.34 +    mem2hex ((char *)&regs->xss, &buffer[idx], sizeof(regs->xss));
    2.35 +    idx += sizeof(regs->xss) * 2;
    2.36 +    mem2hex ((char *)&regs->xds, &buffer[idx], sizeof(regs->xds));
    2.37 +    idx += sizeof(regs->xds) * 2;
    2.38 +    mem2hex ((char *)&regs->xes, &buffer[idx], sizeof(regs->xes));
    2.39 +    idx += sizeof(regs->xes) * 2;
    2.40 +    mem2hex ((char *)&regs->xfs, &buffer[idx], sizeof(regs->xfs));
    2.41 +    idx += sizeof(regs->xfs) * 2;
    2.42 +    mem2hex ((char *)&regs->xgs, &buffer[idx], sizeof(regs->xgs));
    2.43 +}
    2.44 +
    2.45 +/* at this point we allow any register to be changed, caveat emptor */
    2.46 +void
    2.47 +pdb_gdb_to_x86_regs (struct pt_regs *regs, char *buffer)
    2.48 +{
    2.49 +    hex2mem(buffer, (char *)&regs->eax, sizeof(regs->eax));
    2.50 +    buffer += sizeof(regs->eax) * 2;
    2.51 +    hex2mem(buffer, (char *)&regs->ecx, sizeof(regs->ecx));
    2.52 +    buffer += sizeof(regs->ecx) * 2;
    2.53 +    hex2mem(buffer, (char *)&regs->edx, sizeof(regs->edx));
    2.54 +    buffer += sizeof(regs->edx) * 2;
    2.55 +    hex2mem(buffer, (char *)&regs->ebx, sizeof(regs->ebx));
    2.56 +    buffer += sizeof(regs->ebx) * 2;
    2.57 +    hex2mem(buffer, (char *)&regs->esp, sizeof(regs->esp));
    2.58 +    buffer += sizeof(regs->esp) * 2;
    2.59 +    hex2mem(buffer, (char *)&regs->ebp, sizeof(regs->ebp));
    2.60 +    buffer += sizeof(regs->ebp) * 2;
    2.61 +    hex2mem(buffer, (char *)&regs->esi, sizeof(regs->esi));
    2.62 +    buffer += sizeof(regs->esi) * 2;
    2.63 +    hex2mem(buffer, (char *)&regs->edi, sizeof(regs->edi));
    2.64 +    buffer += sizeof(regs->edi) * 2;
    2.65 +    hex2mem(buffer, (char *)&regs->eip, sizeof(regs->eip));
    2.66 +    buffer += sizeof(regs->eip) * 2;
    2.67 +    hex2mem(buffer, (char *)&regs->eflags, sizeof(regs->eflags));
    2.68 +    buffer += sizeof(regs->eflags) * 2;
    2.69 +    hex2mem(buffer, (char *)&regs->xcs, sizeof(regs->xcs));
    2.70 +    buffer += sizeof(regs->xcs) * 2;
    2.71 +    hex2mem(buffer, (char *)&regs->xss, sizeof(regs->xss));
    2.72 +    buffer += sizeof(regs->xss) * 2;
    2.73 +    hex2mem(buffer, (char *)&regs->xds, sizeof(regs->xds));
    2.74 +    buffer += sizeof(regs->xds) * 2;
    2.75 +    hex2mem(buffer, (char *)&regs->xes, sizeof(regs->xes));
    2.76 +    buffer += sizeof(regs->xes) * 2;
    2.77 +    hex2mem(buffer, (char *)&regs->xfs, sizeof(regs->xfs));
    2.78 +    buffer += sizeof(regs->xfs) * 2;
    2.79 +    hex2mem(buffer, (char *)&regs->xgs, sizeof(regs->xgs));
    2.80 +}
    2.81 +
    2.82  int
    2.83  pdb_process_command (char *ptr, struct pt_regs *regs)
    2.84  {
    2.85 @@ -139,84 +214,77 @@ pdb_process_command (char *ptr, struct p
    2.86          pdb_out_buffer[2] = hexchars[sigval % 16];
    2.87          pdb_out_buffer[3] = 0;
    2.88          break;
    2.89 -    case 'S':                                        /* step with signal */
    2.90 -    case 's':                                                    /* step */
    2.91 +    case 'S':                                            /* step with signal */
    2.92 +    case 's':                                                        /* step */
    2.93          regs->eflags |= 0x100;
    2.94          pdb_stepping = 1;
    2.95          return 1;                                        
    2.96          /* not reached */
    2.97 -    case 'C':                                    /* continue with signal */
    2.98 -    case 'c':                                                /* continue */
    2.99 +    case 'C':                                        /* continue with signal */
   2.100 +    case 'c':                                                    /* continue */
   2.101          regs->eflags &= ~0x100;
   2.102          /* jump out before replying to gdb */
   2.103          return 1;
   2.104          /* not reached */
   2.105      case 'd':
   2.106 -        remote_debug = !(remote_debug);               /* toggle debug flag */
   2.107 +        remote_debug = !(remote_debug);                 /* toggle debug flag */
   2.108          break;
   2.109 -    case 'D':                                                  /* detach */
   2.110 +    case 'D':                                                      /* detach */
   2.111          return go;
   2.112          /* not reached */
   2.113 -    case 'g':                   /* return the value of the CPU registers */
   2.114 +    case 'g':                       /* return the value of the CPU registers */
   2.115      {
   2.116 -        int idx = 0;
   2.117 -        mem2hex ((char *)&regs->eax, &pdb_out_buffer[idx], sizeof(regs->eax));
   2.118 -        idx += sizeof(regs->eax) * 2;
   2.119 -        mem2hex ((char *)&regs->ecx, &pdb_out_buffer[idx], sizeof(regs->ecx));
   2.120 -        idx += sizeof(regs->ecx) * 2;
   2.121 -        mem2hex ((char *)&regs->edx, &pdb_out_buffer[idx], sizeof(regs->edx));
   2.122 -        idx += sizeof(regs->edx) * 2;
   2.123 -        mem2hex ((char *)&regs->ebx, &pdb_out_buffer[idx], sizeof(regs->ebx));
   2.124 -        idx += sizeof(regs->ebx) * 2;
   2.125 -        mem2hex ((char *)&regs->esp, &pdb_out_buffer[idx], sizeof(regs->esp));
   2.126 -        idx += sizeof(regs->esp) * 2;
   2.127 -        mem2hex ((char *)&regs->ebp, &pdb_out_buffer[idx], sizeof(regs->ebp));
   2.128 -        idx += sizeof(regs->ebp) * 2;
   2.129 -        mem2hex ((char *)&regs->esi, &pdb_out_buffer[idx], sizeof(regs->esi));
   2.130 -        idx += sizeof(regs->esi) * 2;
   2.131 -        mem2hex ((char *)&regs->edi, &pdb_out_buffer[idx], sizeof(regs->edi));
   2.132 -        idx += sizeof(regs->edi) * 2;
   2.133 -        mem2hex ((char *)&regs->eip, &pdb_out_buffer[idx], sizeof(regs->eip));
   2.134 -        idx += sizeof(regs->eip) * 2;
   2.135 -        mem2hex ((char *)&regs->eflags, &pdb_out_buffer[idx], sizeof(regs->eflags));
   2.136 -        idx += sizeof(regs->eflags) * 2;
   2.137 -        mem2hex ((char *)&regs->xcs, &pdb_out_buffer[idx], sizeof(regs->xcs));
   2.138 -        idx += sizeof(regs->xcs) * 2;
   2.139 -        mem2hex ((char *)&regs->xss, &pdb_out_buffer[idx], sizeof(regs->xss));
   2.140 -        idx += sizeof(regs->xss) * 2;
   2.141 -        mem2hex ((char *)&regs->xds, &pdb_out_buffer[idx], sizeof(regs->xds));
   2.142 -        idx += sizeof(regs->xds) * 2;
   2.143 -        mem2hex ((char *)&regs->xes, &pdb_out_buffer[idx], sizeof(regs->xes));
   2.144 -        idx += sizeof(regs->xes) * 2;
   2.145 -        mem2hex ((char *)&regs->xfs, &pdb_out_buffer[idx], sizeof(regs->xfs));
   2.146 -        idx += sizeof(regs->xfs) * 2;
   2.147 -        mem2hex ((char *)&regs->xgs, &pdb_out_buffer[idx], sizeof(regs->xgs));
   2.148 +        pdb_x86_to_gdb_regs (pdb_out_buffer, regs);
   2.149  
   2.150 -        /*
   2.151 -          TRC(printk ("  reg: %s \n", pdb_out_buffer));
   2.152 -          TRC(printk ("  ebx: 0x%08lx\n", regs->ebx));
   2.153 -          TRC(printk ("  ecx: 0x%08lx\n", regs->ecx));
   2.154 -          TRC(printk ("  edx: 0x%08lx\n", regs->edx));
   2.155 -          TRC(printk ("  esi: 0x%08lx\n", regs->esi));
   2.156 -          TRC(printk ("  edi: 0x%08lx\n", regs->edi));
   2.157 -          TRC(printk ("  ebp: 0x%08lx\n", regs->ebp));
   2.158 -          TRC(printk ("  eax: 0x%08lx\n", regs->eax));
   2.159 -          TRC(printk ("  xds: 0x%08x\n", regs->xds));
   2.160 -          TRC(printk ("  xes: 0x%08x\n", regs->xes));
   2.161 -          TRC(printk ("  xfs: 0x%08x\n", regs->xfs));
   2.162 -          TRC(printk ("  xgs: 0x%08x\n", regs->xgs));
   2.163 -          TRC(printk ("  eip: 0x%08lx\n", regs->eip));
   2.164 -          TRC(printk ("  xcs: 0x%08x\n", regs->xcs));
   2.165 -          TRC(printk ("  efl: 0x%08lx\n", regs->eflags));
   2.166 -          TRC(printk ("  esp: 0x%08lx\n", regs->esp));
   2.167 -          TRC(printk ("  xss: 0x%08x\n", regs->xss));
   2.168 -        */
   2.169 +	/*
   2.170 +	printk ("  reg: %s",   pdb_out_buffer);
   2.171 +	printk ("\n");
   2.172 +	printk ("  eax: 0x%08lx\n", regs->eax);
   2.173 +	printk ("  ecx: 0x%08lx\n", regs->ecx);
   2.174 +	printk ("  edx: 0x%08lx\n", regs->edx);
   2.175 +	printk ("  ebx: 0x%08lx\n", regs->ebx);
   2.176 +	printk ("  esp: 0x%08lx\n", regs->esp);
   2.177 +	printk ("  ebp: 0x%08lx\n", regs->ebp);
   2.178 +	printk ("  esi: 0x%08lx\n", regs->esi);
   2.179 +	printk ("  edi: 0x%08lx\n", regs->edi);
   2.180 +	printk ("  eip: 0x%08lx\n", regs->eip);
   2.181 +	printk ("  efl: 0x%08lx\n", regs->eflags);
   2.182 +	printk ("  xcs: 0x%08x\n",  regs->xcs);
   2.183 +	printk ("  xss: 0x%08x\n",  regs->xss);
   2.184 +	printk ("  xds: 0x%08x\n",  regs->xds);
   2.185 +	printk ("  xes: 0x%08x\n",  regs->xes);
   2.186 +	printk ("  xfs: 0x%08x\n",  regs->xfs);
   2.187 +	printk ("  xgs: 0x%08x\n",  regs->xgs);
   2.188 +	*/
   2.189  
   2.190          break;
   2.191      }
   2.192 -    case 'G':          /* set the value of the CPU registers - return OK */
   2.193 +    case 'G':              /* set the value of the CPU registers - return OK */
   2.194 +    {
   2.195 +        pdb_gdb_to_x86_regs (regs, ptr);
   2.196 +
   2.197 +	/*
   2.198 +	printk ("  ptr: %s \n\n",   ptr);
   2.199 +	printk ("  eax: 0x%08lx\n", regs->eax);
   2.200 +	printk ("  ecx: 0x%08lx\n", regs->ecx);
   2.201 +	printk ("  edx: 0x%08lx\n", regs->edx);
   2.202 +	printk ("  ebx: 0x%08lx\n", regs->ebx);
   2.203 +	printk ("  esp: 0x%08lx\n", regs->esp);
   2.204 +	printk ("  ebp: 0x%08lx\n", regs->ebp);
   2.205 +	printk ("  esi: 0x%08lx\n", regs->esi);
   2.206 +	printk ("  edi: 0x%08lx\n", regs->edi);
   2.207 +	printk ("  eip: 0x%08lx\n", regs->eip);
   2.208 +	printk ("  efl: 0x%08lx\n", regs->eflags);
   2.209 +	printk ("  xcs: 0x%08x\n",  regs->xcs);
   2.210 +	printk ("  xss: 0x%08x\n",  regs->xss);
   2.211 +	printk ("  xds: 0x%08x\n",  regs->xds);
   2.212 +	printk ("  xes: 0x%08x\n",  regs->xes);
   2.213 +	printk ("  xfs: 0x%08x\n",  regs->xfs);
   2.214 +	printk ("  xgs: 0x%08x\n",  regs->xgs);
   2.215 +	*/
   2.216 +
   2.217          break;
   2.218 -
   2.219 +    }
   2.220      case 'H':
   2.221      {
   2.222          int thread;
   2.223 @@ -244,9 +312,9 @@ pdb_process_command (char *ptr, struct p
   2.224          strcpy (pdb_out_buffer, "OK");
   2.225          break;
   2.226      }
   2.227 -    case 'k':                                            /* kill request */
   2.228 +    case 'k':                                                /* kill request */
   2.229      {
   2.230 -        strcpy (pdb_out_buffer, "OK");                    /* ack for fun */
   2.231 +        strcpy (pdb_out_buffer, "OK");                        /* ack for fun */
   2.232          printk ("don't kill bill...\n");
   2.233          ack = 0;
   2.234          break;
   2.235 @@ -325,9 +393,9 @@ pdb_process_command (char *ptr, struct p
   2.236          int thread;
   2.237          if (hexToInt (&ptr, &thread))
   2.238          {
   2.239 -            struct task_struct *p;
   2.240 +	    struct task_struct *p;
   2.241              thread -= PDB_DOMAIN_OFFSET;
   2.242 -            if ( (p = find_domain_by_id(thread)) == NULL )
   2.243 +            if ( (p = find_domain_by_id(thread)) == NULL)
   2.244                  strcpy (pdb_out_buffer, "E00");
   2.245              else
   2.246                  strcpy (pdb_out_buffer, "OK");
   2.247 @@ -746,7 +814,7 @@ int pdb_handle_exception(int exceptionVe
   2.248  
   2.249  void pdb_key_pressed(u_char key, void *dev_id, struct pt_regs *regs) 
   2.250  {
   2.251 -    pdb_handle_exception(136, regs);
   2.252 +    pdb_handle_exception(KEYPRESS_EXCEPTION, regs);
   2.253      return;
   2.254  }
   2.255  
     3.1 --- a/xenolinux-2.4.24-sparse/arch/xeno/drivers/block/xl_block.c	Fri Feb 13 13:58:10 2004 +0000
     3.2 +++ b/xenolinux-2.4.24-sparse/arch/xeno/drivers/block/xl_block.c	Fri Feb 13 20:50:45 2004 +0000
     3.3 @@ -12,6 +12,7 @@
     3.4  #include <linux/cdrom.h>
     3.5  #include <linux/tqueue.h>
     3.6  #include <linux/sched.h>
     3.7 +#include <scsi/scsi.h>
     3.8  
     3.9  #include <linux/interrupt.h>
    3.10  
    3.11 @@ -212,6 +213,10 @@ int xenolinux_block_ioctl(struct inode *
    3.12              if ( put_user(0, (byte *)(argument + i)) ) return -EFAULT;
    3.13          return 0;
    3.14  
    3.15 +    case SCSI_IOCTL_GET_BUS_NUMBER:
    3.16 +        DPRINTK("FIXME: SCSI_IOCTL_GET_BUS_NUMBER ioctl in xl_block");
    3.17 +        return -ENOSYS;
    3.18 +
    3.19      default:
    3.20          printk(KERN_ALERT "ioctl %08x not supported by xl_block\n", command);
    3.21          return -ENOSYS;