Change INT 21h and file I/O logging so that it is default off, but can be enabled from dosbox.conf

This commit is contained in:
Jonathan Campbell
2020-03-01 11:28:33 -08:00
parent b2be2303ad
commit ab30f16c37
4 changed files with 47 additions and 11 deletions

View File

@@ -1,6 +1,9 @@
0.83.1 0.83.1
- Added INT 21h debug logging for file I/O and general - Added INT 21h debug logging for file I/O and general
INT 21h usage [patch by ognjenmi] INT 21h usage [patch by ognjenmi]. Added enables for
the logging which are off by default since the INT 21h
and file I/O logging are fairly noisy under normal
usage.
0.83.0 0.83.0
- Added mt32.romdir dosbox.conf configuration option - Added mt32.romdir dosbox.conf configuration option

View File

@@ -42,6 +42,9 @@
using namespace std; using namespace std;
bool log_int21 = false;
bool log_fileio = false;
static bool has_LOG_Init = false; static bool has_LOG_Init = false;
static bool has_LOG_EarlyInit = false; static bool has_LOG_EarlyInit = false;
static bool do_LOG_stderr = false; static bool do_LOG_stderr = false;
@@ -826,6 +829,9 @@ void LOG::Init() {
debuglog=0; debuglog=0;
} }
log_int21 = sect->Get_bool("int21");
log_fileio = sect->Get_bool("fileio");
/* end of early init logging */ /* end of early init logging */
do_LOG_stderr = false; do_LOG_stderr = false;
@@ -923,6 +929,14 @@ void LOG::SetupConfigSection(void) {
Pstring = sect->Add_string(buf,Property::Changeable::Always,"false"); Pstring = sect->Add_string(buf,Property::Changeable::Always,"false");
Pstring->Set_values(log_values); Pstring->Set_values(log_values);
Pstring->Set_help("Enable/Disable logging of this type."); Pstring->Set_help("Enable/Disable logging of this type.");
} }
Prop_bool* Pbool;
Pbool = sect->Add_bool("int21",Property::Changeable::Always,false);
Pbool->Set_help("Log all INT 21h calls");
Pbool = sect->Add_bool("fileio",Property::Changeable::Always,false);
Pbool->Set_help("Log file I/O through INT 21h");
} }

View File

@@ -37,6 +37,9 @@
#include "serialport.h" #include "serialport.h"
#include "dos_network.h" #include "dos_network.h"
extern bool log_int21;
extern bool log_fileio;
Bitu INT29_HANDLER(void); Bitu INT29_HANDLER(void);
Bit32u BIOS_get_PC98_INT_STUB(void); Bit32u BIOS_get_PC98_INT_STUB(void);
@@ -415,6 +418,14 @@ void XMS_DOS_LocalA20EnableIfNotEnabled(void);
static Bitu DOS_21Handler(void) { static Bitu DOS_21Handler(void) {
bool unmask_irq0 = false; bool unmask_irq0 = false;
/* NTS to ognjenmi: Your INT 21h logging patch was modified to log ALL INT 21h calls (the original
* placement put it after the ignore case below), and is now conditional on
* whether INT 21h logging is enabled. Also removed unnecessary copying of reg_al
* and reg_ah to auto type variables. */
if (log_int21) {
LOG(LOG_CPU, LOG_DEBUG)("Executing interrupt 21, ah=%x, al=%x", reg_ah, reg_al);
}
/* Real MS-DOS behavior: /* Real MS-DOS behavior:
* If HIMEM.SYS is loaded and CONFIG.SYS says DOS=HIGH, DOS will load itself into the HMA area. * If HIMEM.SYS is loaded and CONFIG.SYS says DOS=HIGH, DOS will load itself into the HMA area.
* To prevent crashes, the INT 21h handler down below will enable the A20 gate before executing * To prevent crashes, the INT 21h handler down below will enable the A20 gate before executing
@@ -433,9 +444,6 @@ static Bitu DOS_21Handler(void) {
char name2[DOSNAMEBUF+2+DOS_NAMELENGTH_ASCII]; char name2[DOSNAMEBUF+2+DOS_NAMELENGTH_ASCII];
static Bitu time_start = 0; //For emulating temporary time changes. static Bitu time_start = 0; //For emulating temporary time changes.
auto ah = reg_ah;
auto al = reg_al;
LOG(LOG_CPU, LOG_DEBUG)("Executing interrupt 21, ah=%x, al=%x", ah, al);
switch (reg_ah) { switch (reg_ah) {
case 0x00: /* Terminate Program */ case 0x00: /* Terminate Program */
/* HACK for demoscene prod parties/1995/wired95/surprisecode/w95spcod.zip/WINNERS/SURP-KLF /* HACK for demoscene prod parties/1995/wired95/surprisecode/w95spcod.zip/WINNERS/SURP-KLF

View File

@@ -40,6 +40,9 @@
#define FCB_ERR_EOF 3 #define FCB_ERR_EOF 3
#define FCB_ERR_WRITE 1 #define FCB_ERR_WRITE 1
extern bool log_int21;
extern bool log_fileio;
Bitu DOS_FILES = 127; Bitu DOS_FILES = 127;
DOS_File ** Files = NULL; DOS_File ** Files = NULL;
DOS_Drive * Drives[DOS_DRIVES] = {NULL}; DOS_Drive * Drives[DOS_DRIVES] = {NULL};
@@ -369,7 +372,9 @@ bool DOS_ReadFile(Bit16u entry,Bit8u * data,Bit16u * amount,bool fcb) {
return false; return false;
} }
LOG(LOG_FILES, LOG_DEBUG)("Reading %d bytes from %s ", *amount, Files[handle]->name); if (log_fileio) {
LOG(LOG_FILES, LOG_DEBUG)("Reading %d bytes from %s ", *amount, Files[handle]->name);
}
/* /*
if ((Files[handle]->flags & 0x0f) == OPEN_WRITE)) { if ((Files[handle]->flags & 0x0f) == OPEN_WRITE)) {
DOS_SetError(DOSERR_INVALID_HANDLE); DOS_SetError(DOSERR_INVALID_HANDLE);
@@ -397,7 +402,9 @@ bool DOS_WriteFile(Bit16u entry,Bit8u * data,Bit16u * amount,bool fcb) {
return false; return false;
} }
LOG(LOG_FILES, LOG_DEBUG)("Writing %d bytes to %s", *amount, Files[handle]->name); if (log_fileio) {
LOG(LOG_FILES, LOG_DEBUG)("Writing %d bytes to %s", *amount, Files[handle]->name);
}
/* /*
if ((Files[handle]->flags & 0x0f) == OPEN_READ)) { if ((Files[handle]->flags & 0x0f) == OPEN_READ)) {
DOS_SetError(DOSERR_INVALID_HANDLE); DOS_SetError(DOSERR_INVALID_HANDLE);
@@ -459,8 +466,10 @@ bool DOS_CloseFile(Bit16u entry, bool fcb) {
return false; return false;
} }
if (Files[handle]->IsOpen()) { if (Files[handle]->IsOpen()) {
LOG(LOG_FILES, LOG_NORMAL)("Closing file %s", Files[handle]->name); if (log_fileio) {
Files[handle]->Close(); LOG(LOG_FILES, LOG_NORMAL)("Closing file %s", Files[handle]->name);
}
Files[handle]->Close();
} }
DOS_PSP psp(dos.psp()); DOS_PSP psp(dos.psp());
@@ -672,8 +681,10 @@ bool DOS_OpenFileExtended(char const * name, Bit16u flags, Bit16u createAttr, Bi
bool DOS_UnlinkFile(char const * const name) { bool DOS_UnlinkFile(char const * const name) {
char fullname[DOS_PATHLENGTH];Bit8u drive; char fullname[DOS_PATHLENGTH];Bit8u drive;
// An existing device returns an access denied error // An existing device returns an access denied error
LOG(LOG_FILES, LOG_NORMAL)("Deleting file %s", name); if (log_fileio) {
LOG(LOG_FILES, LOG_NORMAL)("Deleting file %s", name);
}
if (DOS_FindDevice(name) != DOS_DEVICES) { if (DOS_FindDevice(name) != DOS_DEVICES) {
DOS_SetError(DOSERR_ACCESS_DENIED); DOS_SetError(DOSERR_ACCESS_DENIED);
return false; return false;