Diff for /np2/i386c/ia32/debug.c between versions 1.6 and 1.8

version 1.6, 2004/02/04 13:24:35 version 1.8, 2004/02/20 16:09:04
Line 41  cpu_reg2str(void) Line 41  cpu_reg2str(void)
 {  {
         static char buf[512];          static char buf[512];
   
         sprintf(buf,          snprintf(buf, sizeof(buf),
             "eax=%08x ebx=%08x ecx=%08x edx=%08x\n"              "eax=%08x ebx=%08x ecx=%08x edx=%08x\n"
             "esp=%08x ebp=%08x esi=%08x edi=%08x\n"              "esp=%08x ebp=%08x esi=%08x edi=%08x\n"
             "eip=%08x prev_eip=%08x\n"              "eip=%08x prev_eip=%08x\n"
Line 64  cpu_reg2str(void) Line 64  cpu_reg2str(void)
             (CPU_EFLAG & VM_FLAG) != 0,              (CPU_EFLAG & VM_FLAG) != 0,
             (CPU_EFLAG & RF_FLAG) != 0,              (CPU_EFLAG & RF_FLAG) != 0,
             (CPU_EFLAG & NT_FLAG) != 0,              (CPU_EFLAG & NT_FLAG) != 0,
             (CPU_EFLAG >> 12) & 3,              (int)((CPU_EFLAG >> 12) & 3),
             CPU_OV ? "OV" : "NV",              CPU_OV ? "OV" : "NV",
             CPU_EFLAG & D_FLAG ? "UP" : "DN",              CPU_EFLAG & D_FLAG ? "UP" : "DN",
             CPU_EFLAG & I_FLAG ? "DI" : "EI",              CPU_EFLAG & I_FLAG ? "DI" : "EI",
Line 94  fpu_reg2str(void) Line 94  fpu_reg2str(void)
         strcpy(buf, "st=\n");          strcpy(buf, "st=\n");
         for (no = 0; no < 8; no++) {          for (no = 0; no < 8; no++) {
                 for (i = 9; i >= 0; i--) {                  for (i = 9; i >= 0; i--) {
                         sprintf(tmp, "%02x", FPU_ST[no][i]);                          snprintf(tmp, sizeof(tmp), "%02x", FPU_ST[no][i]);
                         strcat(buf, tmp);                          strcat(buf, tmp);
                 }                  }
                 strcat(buf, "\n");                  strcat(buf, "\n");
         }          }
   
         sprintf(tmp,          snprintf(tmp, sizeof(tmp),
             "ctrl=%04x  status=%04x  tag=%04x\n"              "ctrl=%04x  status=%04x  tag=%04x\n"
             "inst=%08x%04x  data=%08x%04x  op=%03x\n",              "inst=%08x%04x  data=%08x%04x  op=%03x\n",
             FPU_CTRLWORD,              FPU_CTRLWORD,
Line 120  a20str(void) Line 120  a20str(void)
 {  {
         static char buf[32];          static char buf[32];
   
         sprintf(buf, "a20line=%s\n", CPU_STAT_ADRSMASK == 0xffffffff ? "enable" : "disable");          snprintf(buf, sizeof(buf), "a20line=%s\n",
               (CPU_STAT_ADRSMASK == 0xffffffff) ? "enable" : "disable");
         return buf;          return buf;
 }  }
   
Line 155  dbg_printf(const char *str, ...) Line 156  dbg_printf(const char *str, ...)
 }  }
   
 void  void
 memory_dump(int idx, DWORD madr)  memory_dump(int idx, UINT32 madr)
 {  {
         DWORD addr;          UINT32 addr;
         size_t size;          size_t size;
         unsigned char buf[16];  
         size_t s, i;          size_t s, i;
         BYTE p;          UINT8 buf[16];
           UINT8 c;
   
         if (madr < 0x80) {          if (madr < 0x80) {
                 size = madr + 0x80;                  size = madr + 0x80;
Line 177  memory_dump(int idx, DWORD madr) Line 178  memory_dump(int idx, DWORD madr)
                         memset(buf, '.', sizeof(buf));                          memset(buf, '.', sizeof(buf));
                 }                  }
   
                 p = cpu_vmemoryread(idx, addr + s);                  c = cpu_vmemoryread(idx, addr + s);
                 VERBOSE(("%02x ", p));                  VERBOSE(("%02x ", c));
                 if (p >= 0x20 && p <= 0x7e)                  if (c >= 0x20 && c <= 0x7e)
                         buf[s % 16] = p;                          buf[s % 16] = c;
   
                 if ((s % 16) == 15) {                  if ((s % 16) == 15) {
                         VERBOSE(("| "));                          VERBOSE(("| "));
Line 192  memory_dump(int idx, DWORD madr) Line 193  memory_dump(int idx, DWORD madr)
 }  }
   
 void  void
 gdtr_dump(DWORD base, DWORD limit)  gdtr_dump(UINT32 base, UINT limit)
 {  {
         DWORD v[2];          UINT32 v[2];
         DWORD i;          UINT i;
   
         VERBOSE(("GDTR_DUMP: GDTR_BASE = 0x%08x, GDTR_LIMIT = 0x%04x",base,limit));          VERBOSE(("GDTR_DUMP: GDTR_BASE = 0x%08x, GDTR_LIMIT = 0x%04x", base, limit));
   
         for (i = 0; i < limit; i += 8) {          for (i = 0; i < limit; i += 8) {
                 v[0] = cpu_kmemoryread_d(base + i);                  v[0] = cpu_kmemoryread_d(base + i);
Line 207  gdtr_dump(DWORD base, DWORD limit) Line 208  gdtr_dump(DWORD base, DWORD limit)
 }  }
   
 void  void
 ldtr_dump(DWORD base, DWORD limit)  ldtr_dump(UINT32 base, UINT limit)
 {  {
         DWORD v[2];          UINT32 v[2];
         DWORD i;          UINT i;
   
         VERBOSE(("LDTR_DUMP: LDTR_BASE = 0x%08x, LDTR_LIMIT = 0x%04x",base,limit));          VERBOSE(("LDTR_DUMP: LDTR_BASE = 0x%08x, LDTR_LIMIT = 0x%04x", base, limit));
   
         for (i = 0; i < limit; i += 8) {          for (i = 0; i < limit; i += 8) {
                 v[0] = cpu_kmemoryread_d(base + i);                  v[0] = cpu_kmemoryread_d(base + i);
Line 222  ldtr_dump(DWORD base, DWORD limit) Line 223  ldtr_dump(DWORD base, DWORD limit)
 }  }
   
 void  void
 idtr_dump(DWORD base, DWORD limit)  idtr_dump(UINT32 base, UINT limit)
 {  {
         DWORD v[2];          UINT32 v[2];
         DWORD i;          UINT i;
   
         VERBOSE(("IDTR_DUMP: IDTR_BASE = 0x%08x, IDTR_LIMIT = 0x%04x",base,limit));          VERBOSE(("IDTR_DUMP: IDTR_BASE = 0x%08x, IDTR_LIMIT = 0x%04x", base, limit));
   
         for (i = 0; i < limit; i += 8) {          for (i = 0; i < limit; i += 8) {
                 v[0] = cpu_kmemoryread_d(base + i);                  v[0] = cpu_kmemoryread_d(base + i);
Line 237  idtr_dump(DWORD base, DWORD limit) Line 238  idtr_dump(DWORD base, DWORD limit)
 }  }
   
 void  void
 tr_dump(WORD selector, DWORD base, DWORD limit)  tr_dump(UINT16 selector, UINT32 base, UINT limit)
 {  {
         DWORD v;          UINT32 v;
         DWORD i;          UINT i;
   
         VERBOSE(("TR_DUMP: selector = %04x", selector));          VERBOSE(("TR_DUMP: selector = %04x", selector));
   
Line 250  tr_dump(WORD selector, DWORD base, DWORD Line 251  tr_dump(WORD selector, DWORD base, DWORD
         }          }
 }  }
   
 DWORD  UINT32
 pde_dump(DWORD base, int idx)  pde_dump(UINT32 base, int idx)
 {  {
         DWORD paddr;          UINT32 paddr;
         DWORD v;          UINT32 v;
         int i;          int i;
   
         if (idx < 0 && idx > -8192) {          if (idx < 0 && idx > -8192) {
Line 278  pde_dump(DWORD base, int idx) Line 279  pde_dump(DWORD base, int idx)
         return paddr;          return paddr;
 }  }
   
 DWORD  UINT32
 convert_laddr_to_paddr(DWORD laddr)  convert_laddr_to_paddr(UINT32 laddr)
 {  {
         DWORD paddr;    /* physical address */          UINT32 paddr;           /* physical address */
         DWORD pde_addr; /* page directory entry address */          UINT32 pde_addr;        /* page directory entry address */
         DWORD pde;      /* page directory entry */          UINT32 pde;             /* page directory entry */
         DWORD pte_addr; /* page table entry address */          UINT32 pte_addr;        /* page table entry address */
         DWORD pte;      /* page table entry */          UINT32 pte;             /* page table entry */
   
         pde_addr = (CPU_CR3 & CPU_CR3_PD_MASK) | ((laddr >> 20) & 0xffc);          pde_addr = (CPU_CR3 & CPU_CR3_PD_MASK) | ((laddr >> 20) & 0xffc);
         pde = cpu_memoryread_d(pde_addr);          pde = cpu_memoryread_d(pde_addr);
Line 302  convert_laddr_to_paddr(DWORD laddr) Line 303  convert_laddr_to_paddr(DWORD laddr)
         return paddr;          return paddr;
 }  }
   
 DWORD  UINT32
 convert_vaddr_to_paddr(unsigned int idx, DWORD offset)  convert_vaddr_to_paddr(unsigned int idx, UINT32 offset)
 {  {
         descriptor_t *sdp;          descriptor_t *sdp;
         DWORD laddr;          UINT32 laddr;
   
         if (idx < CPU_SEGREG_NUM) {          if (idx < CPU_SEGREG_NUM) {
                 sdp = &CPU_STAT_SREG(idx);                  sdp = &CPU_STAT_SREG(idx);

Removed from v.1.6  
changed lines
  Added in v.1.8


RetroPC.NET-CVS <cvs@retropc.net>