Skip to content
Permalink
Browse files

Make DEBUGBOX an internal shell command, so that it can trigger debug…

…ging an executable without changing how the executable is loaded
  • Loading branch information...
joncampbell123 committed Apr 4, 2018
1 parent 59d2796 commit ed0fe3598eee9cf27c76eb6642e9e4aca8f35d97
Showing with 37 additions and 4 deletions.
  1. +3 −0 include/shell.h
  2. +19 −4 src/debug/debug.cpp
  3. +15 −0 src/shell/shell_cmds.cpp
@@ -123,6 +123,9 @@ class DOS_Shell : public Program {
void CMD_MORE(char * args);
void CMD_CTTY(char * args);
void CMD_FOR(char * args);
#if C_DEBUG
void CMD_DEBUGBOX(char * args);
#endif
/* The shell's variables */
Bit16u input_handle;
BatchFile * bf;
@@ -111,7 +111,7 @@ class DebugPageHandler : public PageHandler {

class DEBUG;

DEBUG* pDebugcom = 0;
//DEBUG* pDebugcom = 0;
bool exitLoop = false;


@@ -2781,6 +2781,7 @@ static void LogInstruction(Bit16u segValue, Bit32u eipValue, ofstream& out) {
};
#endif

#if 0
// DEBUG.COM stuff

class DEBUG : public Program {
@@ -2838,14 +2839,28 @@ class DEBUG : public Program {
private:
bool active;
};
#endif

#if C_DEBUG
extern bool debugger_break_on_exec;
#endif

void DEBUG_CheckExecuteBreakpoint(Bit16u seg, Bit32u off)
{
#if C_DEBUG
if (debugger_break_on_exec) {
CBreakpoint::AddBreakpoint(seg,off,true);
CBreakpoint::ActivateBreakpoints(SegPhys(cs)+reg_eip,true);
debugger_break_on_exec = false;
}
#endif
#if 0
if (pDebugcom && pDebugcom->IsActive()) {
CBreakpoint::AddBreakpoint(seg,off,true);
CBreakpoint::ActivateBreakpoints(SegPhys(cs)+reg_eip,true);
pDebugcom = 0;
};
#endif
};

Bitu DEBUG_EnableDebugger(void)
@@ -2857,7 +2872,7 @@ Bitu DEBUG_EnableDebugger(void)
};

static void DEBUG_ProgramStart(Program * * make) {
*make=new DEBUG;
// *make=new DEBUG;
}

// INIT
@@ -2925,8 +2940,8 @@ void DEBUG_ShutDown(Section * /*sec*/) {
Bitu debugCallback;

void DEBUG_DOSStartUp(Section *x) {
/* setup debug.com */
PROGRAMS_MakeFile("DEBUGBOX.COM",DEBUG_ProgramStart);
// /* setup debug.com */
// PROGRAMS_MakeFile("DEBUGBOX.COM",DEBUG_ProgramStart);
}

void DEBUG_Init() {
@@ -82,6 +82,9 @@ static SHELL_Cmd cmd_list[]={
{ "FOR", 1, &DOS_Shell::CMD_FOR, "SHELL_CMD_FOR_HELP"},
{ "INT2FDBG", 1, &DOS_Shell::CMD_INT2FDBG, "Hook INT 2Fh for debugging purposes"},
{ "CTTY", 1, &DOS_Shell::CMD_CTTY, "Change TTY device"},
#if C_DEBUG
{ "DEBUGBOX", 0, &DOS_Shell::CMD_DEBUGBOX, "Run program, break into debugger at entry point"},
#endif
{0,0,0,0}
};

@@ -1959,6 +1962,18 @@ void DOS_Shell::CMD_ADDKEY(char * args){
}
}

#if C_DEBUG
bool debugger_break_on_exec = false;

void DOS_Shell::CMD_DEBUGBOX(char * args) {
/* TODO: The command as originally taken from DOSBox SVN supported a /NOMOUSE option to remove the INT 33h vector */
debugger_break_on_exec = true;
while (*args == ' ') args++;
DoCommand(args);
debugger_break_on_exec = false;
}
#endif

void DOS_Shell::CMD_FOR(char *args){
}

0 comments on commit ed0fe35

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.