ia64/xen-unstable

changeset 1326:7178b507e88b

bitkeeper revision 1.879.1.3 (408fbad0T3LWY4pCllkDFuZcXfqMOQ)

properly modify process memory
author ach61@labyrinth.cl.cam.ac.uk
date Wed Apr 28 14:08:16 2004 +0000 (2004-04-28)
parents 47b57e3d20f1
children fcf60f047642 1adc57be9bfa
files xen/arch/i386/pdb-stub.c xen/common/debug-linux.c
line diff
     1.1 --- a/xen/arch/i386/pdb-stub.c	Wed Apr 28 11:47:51 2004 +0000
     1.2 +++ b/xen/arch/i386/pdb-stub.c	Wed Apr 28 14:08:16 2004 +0000
     1.3 @@ -51,6 +51,8 @@ static unsigned char  pdb_xmit_checksum;
     1.4  unsigned long pdb_linux_pid_ptbr (unsigned long cr3, int pid);
     1.5  void pdb_linux_get_values(char *buffer, int length, unsigned long address,
     1.6  			  int pid, unsigned long cr3);
     1.7 +void pdb_linux_set_values(char *buffer, int length, unsigned long address,
     1.8 +			  int pid, unsigned long cr3);
     1.9  
    1.10  struct pdb_context
    1.11  {
    1.12 @@ -571,6 +573,12 @@ pdb_process_command (char *ptr, struct p
    1.13  			{
    1.14  			    hex2mem (ptr, (char *)addr, length);
    1.15  			}
    1.16 +			else if (pdb_ctx.process != -1)
    1.17 +			{
    1.18 +			    pdb_linux_set_values(ptr, length, addr,
    1.19 +						 pdb_ctx.process, 
    1.20 +						 pdb_ctx.ptbr);
    1.21 +			}
    1.22  			else
    1.23  			{
    1.24  			    pdb_set_values (ptr, length,
     2.1 --- a/xen/common/debug-linux.c	Wed Apr 28 11:47:51 2004 +0000
     2.2 +++ b/xen/common/debug-linux.c	Wed Apr 28 14:08:16 2004 +0000
     2.3 @@ -171,6 +171,44 @@ void pdb_linux_get_values(char *buffer, 
     2.4      }
     2.5  }
     2.6  
     2.7 + 
     2.8 +void pdb_linux_set_value(int pid, unsigned long cr3, unsigned long addr,
     2.9 +			 u_char *value)
    2.10 +{
    2.11 +    unsigned long pgd;
    2.12 +    unsigned long l2tab, page;
    2.13 + 
    2.14 +    /* get the process' pgd */
    2.15 +    pgd = pdb_linux_pid_ptbr(cr3, pid);
    2.16 + 
    2.17 +    /* get the l2 table entry */
    2.18 +    pdb_get_values((u_char *) &l2tab, sizeof(l2tab),
    2.19 +		   cr3, pgd + (addr >> PGDIR_SHIFT) * 4);
    2.20 +    l2tab = (unsigned long)__va(machine_to_phys(cr3, l2tab) & PAGE_MASK);
    2.21 + 
    2.22 +    /* get the page table entry */
    2.23 +    pdb_get_values((u_char *) &page, sizeof(page),
    2.24 +		   cr3, l2tab + ((addr & L1_PAGE_BITS) >> PAGE_SHIFT) * 4);
    2.25 +    page = (unsigned long)__va(machine_to_phys(cr3, page) & PAGE_MASK);
    2.26 + 
    2.27 +    /* set the byte */
    2.28 +    pdb_set_values(value, sizeof(u_char), cr3, page + (addr & ~PAGE_MASK));
    2.29 +}
    2.30 + 
    2.31 +void pdb_linux_set_values(char *buffer, int length, unsigned long address,
    2.32 +			  int pid, unsigned long cr3)
    2.33 +{
    2.34 +    int loop;
    2.35 + 
    2.36 +    /* it's difficult to imagine a more inefficient algorithm */
    2.37 +    for (loop = 0; loop < length; loop++)
    2.38 +    {
    2.39 +        pdb_linux_set_value(pid, cr3, address + loop, &buffer[loop * 2]);
    2.40 +    }
    2.41 +}
    2.42 +
    2.43 +/**********************************************************************/
    2.44 +
    2.45  /*
    2.46   * return 1 if is the virtual address is in the operating system's
    2.47   * address space, else 0