/[dynamips]/trunk/hv_vm_debug.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/hv_vm_debug.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

upstream/dynamips-0.2.6-RC5/hv_vm_debug.c revision 6 by dpavlin, Sat Oct 6 16:09:07 2007 UTC upstream/dynamips-0.2.7-RC1/hv_vm_debug.c revision 7 by dpavlin, Sat Oct 6 16:23:47 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   * Cisco 7200 (Predator) simulation platform.   * Cisco router simulation platform.
3   * Copyright (c) 2006 Christophe Fillot (cf@utc.fr)   * Copyright (c) 2006 Christophe Fillot (cf@utc.fr)
4   *   *
5   * Hypervisor routines for VM debugging.   * Hypervisor routines for VM debugging.
# Line 23  Line 23 
23  #include <arpa/inet.h>  #include <arpa/inet.h>
24  #include <pthread.h>  #include <pthread.h>
25    
26  #include "mips64.h"  #include "cpu.h"
27  #include "cp0.h"  #include "vm.h"
28  #include "dynamips.h"  #include "dynamips.h"
29  #include "device.h"  #include "device.h"
30  #include "dev_c7200.h"  #include "dev_c7200.h"
# Line 37  Line 37 
37  static int cmd_show_cpu_regs(hypervisor_conn_t *conn,int argc,char *argv[])  static int cmd_show_cpu_regs(hypervisor_conn_t *conn,int argc,char *argv[])
38  {  {
39     vm_instance_t *vm;     vm_instance_t *vm;
40     cpu_mips_t *cpu;     cpu_gen_t *cpu;
41    
42     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
43        return(-1);        return(-1);
44    
45     if ((cpu = cpu_group_find_id(vm->cpu_group,atoi(argv[1]))) != NULL)     if ((cpu = cpu_group_find_id(vm->cpu_group,atoi(argv[1]))) != NULL)
46        mips64_dump_regs(cpu);        cpu->reg_dump(cpu);
47    
48     vm_release(vm);     vm_release(vm);
49     hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");     hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
50     return(0);     return(0);
51  }  }
52    
53  /* Show CPU TLB */  /* Show CPU MMU info */
54  static int cmd_show_cpu_tlb(hypervisor_conn_t *conn,int argc,char *argv[])  static int cmd_show_cpu_mmu(hypervisor_conn_t *conn,int argc,char *argv[])
55  {  {
56     vm_instance_t *vm;     vm_instance_t *vm;
57     cpu_mips_t *cpu;     cpu_gen_t *cpu;
58    
59     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
60        return(-1);        return(-1);
61    
62     if ((cpu = cpu_group_find_id(vm->cpu_group,atoi(argv[1]))) != NULL)     if ((cpu = cpu_group_find_id(vm->cpu_group,atoi(argv[1]))) != NULL)
63        tlb_dump(cpu);        cpu->mmu_dump(cpu);
64    
65     vm_release(vm);     vm_release(vm);
66     hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");     hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
67     return(0);     return(0);
68  }  }
69    
70  /* Set a CPU register*/  /* Set a CPU register */
71  static int cmd_set_cpu_reg(hypervisor_conn_t *conn,int argc,char *argv[])  static int cmd_set_cpu_reg(hypervisor_conn_t *conn,int argc,char *argv[])
72  {  {
73     vm_instance_t *vm;     vm_instance_t *vm;
74     cpu_mips_t *cpu;     cpu_gen_t *cpu;
75     int reg_index;     int reg_index;
76    
77     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
78        return(-1);        return(-1);
79    
80     cpu = cpu_group_find_id(vm->cpu_group,atoi(argv[1]));     cpu = cpu_group_find_id(vm->cpu_group,atoi(argv[1]));
81     reg_index = cp0_get_reg_index(argv[2]);     reg_index = atoi(argv[2]);
82                                                        
83     if (!cpu || (reg_index < 1)) {     if (!cpu || (reg_index < 1)) {
84        vm_release(vm);        vm_release(vm);
# Line 87  static int cmd_set_cpu_reg(hypervisor_co Line 87  static int cmd_set_cpu_reg(hypervisor_co
87     }     }
88    
89     /* Set register value */     /* Set register value */
90     cpu->gpr[reg_index] = strtoull(argv[3],NULL,0);     cpu->reg_set(cpu,reg_index,strtoull(argv[3],NULL,0));
91    
92     vm_release(vm);     vm_release(vm);
93     hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");     hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
# Line 99  static int cmd_add_cpu_breakpoint(hyperv Line 99  static int cmd_add_cpu_breakpoint(hyperv
99                                    int argc,char *argv[])                                    int argc,char *argv[])
100  {  {
101     vm_instance_t *vm;     vm_instance_t *vm;
102     cpu_mips_t *cpu;     cpu_gen_t *cpu;
103     m_uint64_t addr;     m_uint64_t addr;
104    
105     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
# Line 112  static int cmd_add_cpu_breakpoint(hyperv Line 112  static int cmd_add_cpu_breakpoint(hyperv
112     }     }
113    
114     addr = strtoull(argv[2],NULL,0);     addr = strtoull(argv[2],NULL,0);
115     mips64_add_breakpoint(cpu,addr);     cpu->add_breakpoint(cpu,addr);
116    
117     vm_release(vm);     vm_release(vm);
118     hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");     hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
# Line 124  static int cmd_remove_cpu_breakpoint(hyp Line 124  static int cmd_remove_cpu_breakpoint(hyp
124                                       int argc,char *argv[])                                       int argc,char *argv[])
125  {  {
126     vm_instance_t *vm;     vm_instance_t *vm;
127     cpu_mips_t *cpu;     cpu_gen_t *cpu;
128     m_uint64_t addr;     m_uint64_t addr;
129    
130     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
# Line 137  static int cmd_remove_cpu_breakpoint(hyp Line 137  static int cmd_remove_cpu_breakpoint(hyp
137     }     }
138    
139     addr = strtoull(argv[2],NULL,0);     addr = strtoull(argv[2],NULL,0);
140     mips64_remove_breakpoint(cpu,addr);     cpu->remove_breakpoint(cpu,addr);
141    
142     vm_release(vm);     vm_release(vm);
143     hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");     hypervisor_send_reply(conn,HSC_INFO_OK,1,"OK");
# Line 148  static int cmd_remove_cpu_breakpoint(hyp Line 148  static int cmd_remove_cpu_breakpoint(hyp
148  static int cmd_pmem_w32(hypervisor_conn_t *conn,int argc,char *argv[])  static int cmd_pmem_w32(hypervisor_conn_t *conn,int argc,char *argv[])
149  {  {
150     vm_instance_t *vm;     vm_instance_t *vm;
    cpu_mips_t *cpu;  
151     m_uint64_t addr;     m_uint64_t addr;
152     m_uint32_t value;     m_uint32_t value;
153    
154     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
155        return(-1);        return(-1);
156    
    cpu = cpu_group_find_id(vm->cpu_group,atoi(argv[1]));  
                             
    if (!cpu) {  
       vm_release(vm);  
       hypervisor_send_reply(conn,HSC_ERR_BAD_OBJ,1,"No CPU found.");  
       return(-1);  
    }  
   
157     /* Write word */     /* Write word */
158     addr  = strtoull(argv[2],NULL,0);     addr  = strtoull(argv[2],NULL,0);
159     value = strtoul(argv[3],NULL,0);     value = strtoul(argv[3],NULL,0);
# Line 177  static int cmd_pmem_w32(hypervisor_conn_ Line 168  static int cmd_pmem_w32(hypervisor_conn_
168  static int cmd_pmem_r32(hypervisor_conn_t *conn,int argc,char *argv[])  static int cmd_pmem_r32(hypervisor_conn_t *conn,int argc,char *argv[])
169  {  {
170     vm_instance_t *vm;     vm_instance_t *vm;
    cpu_mips_t *cpu;  
171     m_uint64_t addr;     m_uint64_t addr;
172     m_uint32_t value;     m_uint32_t value;
173    
174     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
175        return(-1);        return(-1);
176    
    cpu = cpu_group_find_id(vm->cpu_group,atoi(argv[1]));  
                             
    if (!cpu) {  
       vm_release(vm);  
       hypervisor_send_reply(conn,HSC_ERR_BAD_OBJ,1,"No CPU found.");  
       return(-1);  
    }  
   
177     /* Write word */     /* Write word */
178     addr  = strtoull(argv[2],NULL,0);     addr  = strtoull(argv[2],NULL,0);
179     value = physmem_copy_u32_from_vm(vm,addr);     value = physmem_copy_u32_from_vm(vm,addr);
# Line 205  static int cmd_pmem_r32(hypervisor_conn_ Line 187  static int cmd_pmem_r32(hypervisor_conn_
187  static int cmd_pmem_w16(hypervisor_conn_t *conn,int argc,char *argv[])  static int cmd_pmem_w16(hypervisor_conn_t *conn,int argc,char *argv[])
188  {  {
189     vm_instance_t *vm;     vm_instance_t *vm;
    cpu_mips_t *cpu;  
190     m_uint64_t addr;     m_uint64_t addr;
191     m_uint16_t value;     m_uint16_t value;
192    
193     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
194        return(-1);        return(-1);
195    
    cpu = cpu_group_find_id(vm->cpu_group,atoi(argv[1]));  
                             
    if (!cpu) {  
       vm_release(vm);  
       hypervisor_send_reply(conn,HSC_ERR_BAD_OBJ,1,"No CPU found.");  
       return(-1);  
    }  
   
196     /* Write word */     /* Write word */
197     addr  = strtoull(argv[2],NULL,0);     addr  = strtoull(argv[2],NULL,0);
198     value = strtoul(argv[3],NULL,0);     value = strtoul(argv[3],NULL,0);
# Line 234  static int cmd_pmem_w16(hypervisor_conn_ Line 207  static int cmd_pmem_w16(hypervisor_conn_
207  static int cmd_pmem_r16(hypervisor_conn_t *conn,int argc,char *argv[])  static int cmd_pmem_r16(hypervisor_conn_t *conn,int argc,char *argv[])
208  {  {
209     vm_instance_t *vm;     vm_instance_t *vm;
    cpu_mips_t *cpu;  
210     m_uint64_t addr;     m_uint64_t addr;
211     m_uint16_t value;     m_uint16_t value;
212    
213     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))     if (!(vm = hypervisor_find_object(conn,argv[0],OBJ_TYPE_VM)))
214        return(-1);        return(-1);
215    
    cpu = cpu_group_find_id(vm->cpu_group,atoi(argv[1]));  
                             
    if (!cpu) {  
       vm_release(vm);  
       hypervisor_send_reply(conn,HSC_ERR_BAD_OBJ,1,"No CPU found.");  
       return(-1);  
    }  
   
216     /* Write word */     /* Write word */
217     addr  = strtoull(argv[2],NULL,0);     addr  = strtoull(argv[2],NULL,0);
218     value = physmem_copy_u16_from_vm(vm,addr);     value = physmem_copy_u16_from_vm(vm,addr);
# Line 261  static int cmd_pmem_r16(hypervisor_conn_ Line 225  static int cmd_pmem_r16(hypervisor_conn_
225  /* VM debug commands */  /* VM debug commands */
226  static hypervisor_cmd_t vm_cmd_array[] = {  static hypervisor_cmd_t vm_cmd_array[] = {
227     { "show_cpu_regs", 2, 2, cmd_show_cpu_regs, NULL },     { "show_cpu_regs", 2, 2, cmd_show_cpu_regs, NULL },
228     { "show_cpu_tlb", 2, 2, cmd_show_cpu_tlb, NULL },     { "show_cpu_mmu", 2, 2, cmd_show_cpu_mmu, NULL },
229     { "set_cpu_reg", 4, 4, cmd_set_cpu_reg, NULL },     { "set_cpu_reg", 4, 4, cmd_set_cpu_reg, NULL },
230     { "add_cpu_breakpoint", 3, 3, cmd_add_cpu_breakpoint, NULL },     { "add_cpu_breakpoint", 3, 3, cmd_add_cpu_breakpoint, NULL },
231     { "remove_cpu_breakpoint", 3, 3, cmd_remove_cpu_breakpoint, NULL },     { "remove_cpu_breakpoint", 3, 3, cmd_remove_cpu_breakpoint, NULL },

Legend:
Removed from v.6  
changed lines
  Added in v.7

  ViewVC Help
Powered by ViewVC 1.1.26