- Timestamp:
- Jan 14, 2024 11:49:46 PM (13 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllDbg.cpp
r102867 r102868 52 52 # undef LOG_GROUP 53 53 # define LOG_GROUP LOG_GROUP_IEM_SYSCALL 54 55 DECLINLINE(char *) iemLogSyscallFormatChr(char pszBuf[4], char ch) 56 { 57 if (RT_C_IS_PRINT(ch)) 58 { 59 pszBuf[0] = '\''; 60 pszBuf[1] = ch; 61 pszBuf[2] = '\''; 62 } 63 else if (ch == '\\n' || ch == '\\r') 64 { 65 pszBuf[0] = '\''; 66 pszBuf[1] = ch == '\\n' ? 'n' : 'r'; 67 pszBuf[2] = ' '; 68 } 69 else 70 { 71 pszBuf[0] = ' '; 72 pszBuf[1] = '?'; 73 pszBuf[2] = ' '; 74 } 75 pszBuf[3] = '\0'; 76 return pszBuf; 77 } 78 79 80 /** 81 * The output buffer must be 4x + 8 the size of the input. 82 */ 83 static char *iemLogSyscallFormatStr(char *pszDst, const char *pszSrc, size_t cchSrc) 84 { 85 char * const pszRet = pszDst; 86 *pszDst++ = '\"'; 87 for (unsigned off = 0; off < cchSrc; off++) 88 { 89 char const ch = pszSrc[off]; 90 if (RT_C_IS_PRINT(ch)) 91 *pszDst++ = ch; 92 else 93 { 94 *pszDst++ = '\\'; 95 if (ch == '\n') 96 *pszDst++ = 'n'; 97 else if (ch == '\r') 98 *pszDst++ = 'r'; 99 else if (ch == '\t') 100 *pszDst++ = 't'; 101 else if (ch == '\0') 102 *pszDst++ = '0'; 103 else 104 { 105 static char const s_szHexChars[17] = "0123456789abcdef"; 106 *pszDst++ = 'x'; 107 *pszDst++ = s_szHexChars[(uint8_t)ch >> 4]; 108 *pszDst++ = s_szHexChars[(uint8_t)ch & 0xf]; 109 } 110 } 111 } 112 *pszDst++ = '\"'; 113 *pszDst++ = '\0'; 114 return pszRet; 115 } 116 54 117 55 118 /** … … 87 150 case 0x0d: pszSimple = "read graphics pixel"; break; 88 151 case 0x0e: 89 if (RT_C_IS_PRINT(pVCpu->cpum.GstCtx.al)) 90 Log(("VGABIOS INT 10h: AH=0eh: teletype output: AL=%#04x '%c' BH=%#x (pg) BL=%#x\n", 91 pVCpu->cpum.GstCtx.al, pVCpu->cpum.GstCtx.al, pVCpu->cpum.GstCtx.bh, pVCpu->cpum.GstCtx.bl)); 92 else 93 Log(("VGABIOS INT 10h: AH=0eh: teletype output: AL=%#04x %s BH=%#x (pg) BL=%#x\n", pVCpu->cpum.GstCtx.al, 94 pVCpu->cpum.GstCtx.al == '\n' ? "\\n " 95 : pVCpu->cpum.GstCtx.al == '\r' ? "\\r " 96 : pVCpu->cpum.GstCtx.al == '\t' ? "\\t " : " ? ", 97 pVCpu->cpum.GstCtx.bh, pVCpu->cpum.GstCtx.bl)); 152 { 153 char szChar[4]; 154 Log(("VGABIOS INT 10h: AH=0eh: teletype output: AL=%#04x %s BH=%#x (pg) BL=%#x\n", 155 pVCpu->cpum.GstCtx.al, iemLogSyscallFormatChr(szChar, pVCpu->cpum.GstCtx.al), pVCpu->cpum.GstCtx.bh, 156 pVCpu->cpum.GstCtx.bl)); 98 157 return; 158 } 99 159 case 0x13: 100 160 { … … 112 172 { 113 173 for (unsigned i = 0; i < cbToRead; i += 2) 114 szChars[i] 174 szChars[i] = RT_C_IS_PRINT(szRaw[i]) ? szRaw[i] : '.'; 115 175 szChars[cbToRead] = '\0'; 116 176 } … … 152 212 pVCpu->cpum.GstCtx.ah, pszSimple, pVCpu->cpum.GstCtx.al, 153 213 pVCpu->cpum.GstCtx.bx, pVCpu->cpum.GstCtx.cx, pVCpu->cpum.GstCtx.dx)); 214 } 215 216 217 /** 218 * DOS INT 21h. 219 */ 220 static void iemLogSyscallDosInt21h(PVMCPUCC pVCpu) 221 { 222 const char *pszSimple; 223 switch (pVCpu->cpum.GstCtx.ah) 224 { 225 case 0x00: pszSimple = "terminate program"; break; 226 case 0x01: pszSimple = "read stdin char w/ echo"; break; 227 case 0x02: 228 { 229 char szChar[4]; 230 Log(("DOS INT 21h: AH=02h: write char to stdout - DL=%#04x %s (AL=%#x BX=%#x CX=%#x DX=%#x BP=%#x SI=%#x DI=%#x)\n", 231 pVCpu->cpum.GstCtx.dl, iemLogSyscallFormatChr(szChar, pVCpu->cpum.GstCtx.dl), pVCpu->cpum.GstCtx.al, 232 pVCpu->cpum.GstCtx.bx, pVCpu->cpum.GstCtx.cx, pVCpu->cpum.GstCtx.dx, pVCpu->cpum.GstCtx.bp, 233 pVCpu->cpum.GstCtx.si, pVCpu->cpum.GstCtx.di)); 234 return; 235 } 236 case 0x03: pszSimple = "read char from stdaux"; break; 237 case 0x04: pszSimple = "write char to stdaux"; break; 238 case 0x05: pszSimple = "write char to printer"; break; 239 case 0x06: pszSimple = pVCpu->cpum.GstCtx.dl == 0xff ? "direct console input" : "direct console output"; break; 240 case 0x07: pszSimple = "direct character input w/o echo"; break; 241 case 0x08: pszSimple = "character input w/o echo"; break; 242 case 0x09: 243 { 244 char achRaw[128] = {0}; 245 unsigned const cbToRead = RT_MIN(RT_ELEMENTS(achRaw), 0x10000U - pVCpu->cpum.GstCtx.dx); 246 PGMPhysSimpleReadGCPtr(pVCpu, achRaw, pVCpu->cpum.GstCtx.ds.u64Base + pVCpu->cpum.GstCtx.dx, cbToRead); 247 unsigned cchRaw = 0; 248 while (cchRaw < cbToRead) 249 if (achRaw[cchRaw++] == '$') 250 break; 251 252 char szFmt[sizeof(achRaw) * 4 + 16]; 253 Log(("DOS INT 21h: AH=09h: write string to stdout - DS:DX=%04x:%04x %s\n", 254 pVCpu->cpum.GstCtx.ds.Sel, pVCpu->cpum.GstCtx.dx, iemLogSyscallFormatStr(szFmt, achRaw, cchRaw))); 255 return; 256 } 257 case 0x0a: pszSimple = "buffered input"; break; 258 case 0x0b: pszSimple = "get stdin status"; break; 259 case 0x0c: pszSimple = "flush buf & read stdin"; break; 260 case 0x0d: pszSimple = "disk reset"; break; 261 case 0x0e: pszSimple = "select default drive"; break; 262 case 0x0f: pszSimple = "open file (fcb)"; break; 263 case 0x10: pszSimple = "close file (fcb)"; break; 264 case 0x11: pszSimple = "find first (fcb)"; break; 265 case 0x12: pszSimple = "find next (fcb)"; break; 266 case 0x13: pszSimple = "delete file (fcb)"; break; 267 case 0x14: pszSimple = "seq read (fcb)"; break; 268 case 0x15: pszSimple = "seq write (fcb)"; break; 269 case 0x16: pszSimple = "create/truncate file (fcb)"; break; 270 case 0x17: pszSimple = "rename (fcb)"; break; 271 default: 272 return; 273 } 274 Log(("DOS INT 21h: AH=%02xh: %s - AL=%#x BX=%#x CX=%#x DX=%#x BP=%#x SI=%#x DI=%#x\n", 275 pVCpu->cpum.GstCtx.ah, pszSimple, pVCpu->cpum.GstCtx.al, pVCpu->cpum.GstCtx.bx, pVCpu->cpum.GstCtx.cx, 276 pVCpu->cpum.GstCtx.dx, pVCpu->cpum.GstCtx.bp, pVCpu->cpum.GstCtx.si, pVCpu->cpum.GstCtx.di)); 154 277 } 155 278 … … 1189 1312 iemLogSyscallBiosInt16h(pVCpu); 1190 1313 break; 1314 case 0x21: 1315 iemLogSyscallDosInt21h(pVCpu); 1316 break; 1191 1317 } 1192 1318 } … … 1209 1335 iemLogSyscallBiosInt16h(pVCpu); 1210 1336 break; 1337 case 0x21: 1338 iemLogSyscallDosInt21h(pVCpu); 1339 break; 1211 1340 } 1212 1341 }
Note:
See TracChangeset
for help on using the changeset viewer.