1
0
Fork 0

Added new debug commands : set register/memory. Fixed a problem with relative jump addresses

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@462
This commit is contained in:
Ulf Wohlers 2002-10-29 14:40:54 +00:00
parent d565b8c526
commit 63210c1d64
2 changed files with 73 additions and 4 deletions

View file

@ -591,6 +591,46 @@ Bit32u GetHexValue(char* str, char*& hex)
return value;
};
bool ChangeRegister(char* str)
{
Bit32u value = 0;
char* hex = str;
while (*hex==' ') hex++;
if (strstr(hex,"AX")==hex) { hex+=2; reg_ax = GetHexValue(hex,hex); } else
if (strstr(hex,"BX")==hex) { hex+=2; reg_bx = GetHexValue(hex,hex); } else
if (strstr(hex,"CX")==hex) { hex+=2; reg_cx = GetHexValue(hex,hex); } else
if (strstr(hex,"DX")==hex) { hex+=2; reg_dx = GetHexValue(hex,hex); } else
if (strstr(hex,"SI")==hex) { hex+=2; reg_si = GetHexValue(hex,hex); } else
if (strstr(hex,"DI")==hex) { hex+=2; reg_di = GetHexValue(hex,hex); } else
if (strstr(hex,"BP")==hex) { hex+=2; reg_bp = GetHexValue(hex,hex); } else
if (strstr(hex,"SP")==hex) { hex+=2; reg_sp = GetHexValue(hex,hex); } else
if (strstr(hex,"IP")==hex) { hex+=2; reg_ip = GetHexValue(hex,hex); } else
if (strstr(hex,"CS")==hex) { hex+=2; SegSet16(cs,GetHexValue(hex,hex)); } else
if (strstr(hex,"DS")==hex) { hex+=2; SegSet16(ds,GetHexValue(hex,hex)); } else
if (strstr(hex,"ES")==hex) { hex+=2; SegSet16(es,GetHexValue(hex,hex)); } else
if (strstr(hex,"FS")==hex) { hex+=2; SegSet16(fs,GetHexValue(hex,hex)); } else
if (strstr(hex,"GS")==hex) { hex+=2; SegSet16(gs,GetHexValue(hex,hex)); } else
if (strstr(hex,"SS")==hex) { hex+=2; SegSet16(ss,GetHexValue(hex,hex)); } else
if (strstr(hex,"EAX")==hex) { hex+=3; reg_eax = GetHexValue(hex,hex); } else
if (strstr(hex,"EBX")==hex) { hex+=3; reg_ebx = GetHexValue(hex,hex); } else
if (strstr(hex,"ECX")==hex) { hex+=3; reg_ecx = GetHexValue(hex,hex); } else
if (strstr(hex,"EDX")==hex) { hex+=3; reg_edx = GetHexValue(hex,hex); } else
if (strstr(hex,"ESI")==hex) { hex+=3; reg_esi = GetHexValue(hex,hex); } else
if (strstr(hex,"EDI")==hex) { hex+=3; reg_edi = GetHexValue(hex,hex); } else
if (strstr(hex,"EBP")==hex) { hex+=3; reg_ebp = GetHexValue(hex,hex); } else
if (strstr(hex,"ESP")==hex) { hex+=3; reg_esp = GetHexValue(hex,hex); } else
if (strstr(hex,"EIP")==hex) { hex+=3; reg_eip = GetHexValue(hex,hex); } else
if (strstr(hex,"AF")==hex) { hex+=2; flags.af = (GetHexValue(hex,hex)!=0); } else
if (strstr(hex,"CF")==hex) { hex+=2; flags.cf = (GetHexValue(hex,hex)!=0); } else
if (strstr(hex,"DF")==hex) { hex+=2; flags.df = (GetHexValue(hex,hex)!=0); } else
if (strstr(hex,"IF")==hex) { hex+=2; flags.intf = (GetHexValue(hex,hex)!=0); } else
if (strstr(hex,"OF")==hex) { hex+=3; flags.of = (GetHexValue(hex,hex)!=0); } else
if (strstr(hex,"PF")==hex) { hex+=3; flags.pf = (GetHexValue(hex,hex)!=0); } else
{ return false; };
return true;
};
bool ParseCommand(char* str)
{
char* found = str;
@ -666,6 +706,30 @@ bool ParseCommand(char* str)
LOG_DEBUG("DEBUG: Logfile LOGCPU.TXT created.");
return true;
}
found = strstr(str,"SR ");
if (found) { // Set register value
found+=2;
if (ChangeRegister(found)) LOG_DEBUG("DEBUG: Set Register success.");
else LOG_DEBUG("DEBUG: Set Register failure.");
return true;
}
found = strstr(str,"SM ");
if (found) { // Set memory with following values
found+=3;
Bit16u seg = GetHexValue(found,found); found++;
Bit32u ofs = GetHexValue(found,found); found++;
Bit16u count = 0;
while (*found) {
while (*found==' ') found++;
if (*found) {
Bit8u value = GetHexValue(found,found); found++;
mem_writeb(PhysMake(seg,ofs+count),value);
count++;
}
};
LOG_DEBUG("DEBUG: Memory changed.");
return true;
}
found = strstr(str,"INTT ");
if (found) { // Create Cpu log file
found+=4;
@ -708,6 +772,8 @@ bool ParseCommand(char* str)
wprintw(dbg.win_out,"C / D [segment]:[offset] - Set code / data view address\n");
wprintw(dbg.win_out,"INT [nr] / INTT [nr] - Execute / Trace into Iinterrupt\n");
wprintw(dbg.win_out,"LOG [num] - Write cpu log file\n");
wprintw(dbg.win_out,"SR [reg] [value] - Set register value\n");
wprintw(dbg.win_out,"SM [seg]:[off] [val] [.]..- Set memory with following values\n");
wprintw(dbg.win_out,"H - Help\n");
wrefresh(dbg.win_out);
return TRUE;

View file

@ -457,7 +457,7 @@ static char *addr_to_hex(UINT32 addr, int splitup) {
}
static PhysPt getbyte_mac;
static PhysPt startPtr;
static UINT8 getbyte(void) {
return mem_readb(getbyte_mac++);
@ -822,6 +822,8 @@ static void floating_point(int e1)
/*------------------------------------------------------------------------*/
/* Main table driver */
#define INSTRUCTION_SIZE (int)getbyte_mac - (int)startPtr
static void percent(char type, char subtype)
{
INT32 vofs = 0;
@ -864,13 +866,13 @@ static void percent(char type, char subtype)
switch (bytes(subtype)) { /* sizeof offset value */
case 1:
vofs = (INT8)getbyte();
name = addr_to_hex(vofs+instruction_offset,0);
name = addr_to_hex(vofs+instruction_offset+INSTRUCTION_SIZE,0);
break;
case 2:
vofs = getbyte();
vofs += getbyte()<<8;
vofs = (INT16)vofs;
name = addr_to_hex(vofs+instruction_offset,0);
name = addr_to_hex(vofs+instruction_offset+INSTRUCTION_SIZE,0);
break;
#if 0
/* i386 */
@ -879,7 +881,7 @@ static void percent(char type, char subtype)
vofs |= (UINT32)getbyte() << 8;
vofs |= (UINT32)getbyte() << 16;
vofs |= (UINT32)getbyte() << 24;
name = addr_to_hex(vofs+instruction_offset,1);
name = addr_to_hex(vofs+instruction_offset+INSTRUCTION_SIZE,1);
break;
#endif
}
@ -1077,6 +1079,7 @@ Bitu DasmI386(char* buffer, PhysPt pc, Bitu cur_ip, bool bit32)
instruction_offset = cur_ip;
/* input buffer */
startPtr = pc;
getbyte_mac = pc;
/* output buffer */