- Added Console input / command exec to debugger

This commit is contained in:
HarrievG 2021-06-21 14:59:28 +02:00
parent a0007f5f12
commit 7e367a0e62
9 changed files with 108 additions and 20 deletions

View file

@ -126,21 +126,21 @@ IDI_DBG_EMPTY ICON "res\\dbg_empty.ico"
IDR_DBG_ACCELERATORS ACCELERATORS
BEGIN
VK_F9, ID_DBG_DEBUG_QUICKWATCH, VIRTKEY, SHIFT, NOINVERT
VK_F5, ID_DBG_DEBUG_RUN, VIRTKEY, NOINVERT
VK_F11, ID_DBG_DEBUG_STEPINTO, VIRTKEY, NOINVERT
VK_F10, ID_DBG_DEBUG_STEPOVER, VIRTKEY, NOINVERT
VK_F9, ID_DBG_DEBUG_TOGGLEBREAKPOINT, VIRTKEY, NOINVERT
VK_F3, ID_DBG_EDIT_FINDNEXT, VIRTKEY, NOINVERT
VK_F3, ID_DBG_EDIT_FINDPREV, VIRTKEY, SHIFT, NOINVERT
VK_F3, ID_DBG_EDIT_FINDSELECTED, VIRTKEY, CONTROL, NOINVERT
VK_F3, ID_DBG_EDIT_FINDSELECTED, VIRTKEY, CONTROL, NOINVERT
VK_F3, ID_DBG_EDIT_FINDSELECTEDPREV, VIRTKEY, SHIFT, CONTROL,
NOINVERT
VK_F4, ID_DBG_FILE_CLOSE, VIRTKEY, CONTROL, NOINVERT
VK_TAB, ID_DBG_FILE_NEXT, VIRTKEY, CONTROL, NOINVERT
"O", ID_DBG_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT
"F", ID_DBG_EDIT_FIND, VIRTKEY, CONTROL, NOINVERT
VK_F9, ID_DBG_DEBUG_QUICKWATCH, VIRTKEY, SHIFT, NOINVERT
VK_F5, ID_DBG_DEBUG_RUN, VIRTKEY, NOINVERT
VK_F11, ID_DBG_DEBUG_STEPINTO, VIRTKEY, NOINVERT
VK_F10, ID_DBG_DEBUG_STEPOVER, VIRTKEY, NOINVERT
VK_F9, ID_DBG_DEBUG_TOGGLEBREAKPOINT, VIRTKEY, NOINVERT
VK_F3, ID_DBG_EDIT_FINDNEXT, VIRTKEY, NOINVERT
VK_F3, ID_DBG_EDIT_FINDPREV, VIRTKEY, SHIFT, NOINVERT
VK_F3, ID_DBG_EDIT_FINDSELECTED, VIRTKEY, CONTROL, NOINVERT
VK_F3, ID_DBG_EDIT_FINDSELECTEDPREV, VIRTKEY, SHIFT, CONTROL,NOINVERT
VK_F4, ID_DBG_FILE_CLOSE, VIRTKEY, CONTROL, NOINVERT
VK_TAB, ID_DBG_FILE_NEXT, VIRTKEY, CONTROL, NOINVERT
VK_RETURN, ID_DBG_SEND_COMMAND, VIRTKEY, NOINVERT
"O", ID_DBG_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT
"F", ID_DBG_EDIT_FIND, VIRTKEY, CONTROL, NOINVERT
END

View file

@ -76,6 +76,7 @@ If you have questions concerning this license or the applicable additional terms
#define ID_DBG_EDIT_FINDPREV 22022
#define ID_DBG_EDIT_FINDSELECTEDPREV 22023
#define ID_DBG_HELP_ABOUT 22024
#define ID_DBG_SEND_COMMAND 22025
// Next default values for new objects
//

View file

@ -661,3 +661,25 @@ void rvDebuggerClient::ClearThreads ( void )
mThreads.Clear ( );
}
/*
================
rvDebuggerClient::SendCommand
================
*/
void rvDebuggerClient::SendCommand( const char *cmdStr )
{
idBitMsg msg;
byte buffer[MAX_MSGLEN];
if ( !mConnected ) {
return;
}
msg.Init( buffer, sizeof( buffer ) );
msg.BeginWriting( );
msg.WriteShort( ( short ) DBMSG_EXECCOMMAND );
msg.WriteString( cmdStr ); // FIXME: this implies make7bit ?!
SendPacket( msg.GetData( ), msg.GetSize( ) );
}

View file

@ -88,6 +88,8 @@ public:
void StepInto ( void );
void StepOver ( void );
void SendCommand ( const char* cmdStr );
// Breakpoints
int AddBreakpoint ( const char* filename, int lineNumber, bool onceOnly = false );
bool RemoveBreakpoint ( int bpID );

View file

@ -46,7 +46,8 @@ enum EDebuggerMessage
DBMSG_INSPECTTHREADS,
DBMSG_STEPOVER,
DBMSG_STEPINTO,
DBMSG_INSPECTSCRIPTS
DBMSG_INSPECTSCRIPTS,
DBMSG_EXECCOMMAND
};
#endif // DEBUGGER_MESSAGES_H_

View file

@ -251,6 +251,10 @@ bool rvDebuggerServer::ProcessMessages ( void )
case DBMSG_INSPECTSCRIPTS:
HandleInspectScripts( &msg );
break;
case DBMSG_EXECCOMMAND:
HandleExecCommand( &msg );
break;
}
}
@ -424,6 +428,22 @@ void rvDebuggerServer::HandleInspectThreads ( idBitMsg* msg )
SendPacket (msgOut.GetData(), msgOut.GetSize() );
}
/*
================
rvDebuggerServer::HandleExecCommand
Send the list of the current loaded scripts in the interpreter back to the debugger client
================
*/
void rvDebuggerServer::HandleExecCommand( idBitMsg *msg ) {
char cmdStr[2048]; // HvG: randomly chose this size
msg->ReadString( cmdStr, sizeof( cmdStr ) );
cmdSystem->BufferCommandText( CMD_EXEC_APPEND, cmdStr ); // valid command
cmdSystem->BufferCommandText( CMD_EXEC_APPEND, "\n" );
}
/*
================
rvDebuggerServer::HandleInspectScripts

View file

@ -78,6 +78,7 @@ private:
void HandleInspectCallstack ( idBitMsg *msg );
void HandleInspectThreads ( idBitMsg *msg );
void HandleInspectScripts ( idBitMsg *msg );
void HandleExecCommand ( idBitMsg *msg );
////
bool mConnected;

View file

@ -50,6 +50,7 @@ If you have questions concerning this license or the applicable additional terms
#define IDC_DBG_THREADS 31008
#define IDC_DBG_TOOLBAR 31009
#define IDC_DBG_SCRIPTLIST 31010
#define IDC_DBG_CONSOLEINPUT 31011
#define ID_DBG_FILE_MRU1 10000
@ -765,7 +766,7 @@ int rvDebuggerWindow::HandleInitMenu ( WPARAM wParam, LPARAM lParam )
case ID_DBG_DEBUG_STEPOVER:
case ID_DBG_DEBUG_STEPINTO:
case ID_DBG_DEBUG_SHOWNEXTSTATEMENT:
// case ID_DBG_DEBUG_QUICKWATCH:
case ID_DBG_DEBUG_QUICKWATCH:
if ( !mClient->IsConnected() || !mClient->IsStopped() )
{
EnableMenuItem ( hmenu, nPos, MF_GRAYED|MF_BYPOSITION );
@ -868,6 +869,12 @@ int rvDebuggerWindow::HandleCreate ( WPARAM wparam, LPARAM lparam )
SendMessage ( mWndConsole, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN, MAKELONG(18,10) );
SendMessage ( mWndConsole, EM_SETBKGNDCOLOR, 0, GetSysColor ( COLOR_3DFACE ) );
mWndConsoleInput = CreateWindow( "RichEdit20A", "", WS_CHILD | ES_WANTRETURN | ES_AUTOVSCROLL | WS_VSCROLL | WS_BORDER, 0, 0, 100, 18, mWnd, ( HMENU ) IDC_DBG_CONSOLEINPUT, mInstance, 0 );
lf.lfHeight = -MulDiv( 8, GetDeviceCaps( dc, LOGPIXELSY ), 72 );
strcpy( lf.lfFaceName, "Arial" );
SendMessage( mWndConsoleInput, WM_SETFONT, ( WPARAM ) CreateFontIndirect( &lf ), 0 );
SendMessage( mWndConsoleInput, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG( 18, 10 ) );
mWndMargin = CreateWindow ( "STATIC", "", WS_VISIBLE|WS_CHILD, 0, 0, 0, 0, mWndScript, (HMENU)IDC_DBG_SPLITTER, mInstance, NULL );
SetWindowLongPtr ( mWndMargin, GWLP_USERDATA, (LONG_PTR)this );
SetWindowLongPtr ( mWndMargin, GWLP_WNDPROC, (LONG_PTR)MarginWndProc );
@ -1058,6 +1065,36 @@ int rvDebuggerWindow::HandleCommand ( WPARAM wparam, LPARAM lparam )
switch ( id )
{
case ID_DBG_SEND_COMMAND:
{
if ( mClient->IsConnected( ) && GetFocus( ) == mWndConsoleInput ) {
GETTEXTLENGTHEX textLen;
int chars;
textLen.flags = GTL_DEFAULT | GTL_USECRLF;
textLen.codepage = CP_ACP;
chars = SendMessage( mWndConsoleInput, EM_GETTEXTLENGTHEX, ( WPARAM ) &textLen, 0 );
char *text = new char[chars + 1];
GETTEXTEX getText;
getText.cb = chars + 1;
getText.codepage = CP_ACP;
getText.flags = GT_DEFAULT | GT_USECRLF;
getText.lpDefaultChar = NULL;
getText.lpUsedDefChar = NULL;
SendMessage( mWndConsoleInput, EM_GETTEXTEX, ( WPARAM ) &getText, ( LPARAM ) text );
idStr parse = text;
delete[] text;
mClient->SendCommand( parse.c_str() );
SendMessage( mWndConsoleInput, EM_SETSEL, 0, -1 );
SendMessage( mWndConsoleInput, EM_REPLACESEL, FALSE, ( LPARAM ) "" );
UpdateWindow( mWndConsoleInput );
}
break;
}
case ID_DBG_EDIT_FINDSELECTED:
{
idStr text;
@ -1325,7 +1362,8 @@ LRESULT CALLBACK rvDebuggerWindow::WndProc ( HWND wnd, UINT msg, WPARAM wparam,
MoveWindow ( window->mWndBorder, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE );
InflateRect ( &rect, -1, -1 );
MoveWindow ( window->mWndOutput, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE );
MoveWindow ( window->mWndConsole, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE );
MoveWindow ( window->mWndConsole, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top - s18, TRUE );
MoveWindow ( window->mWndConsoleInput, rect.left, rect.bottom-s18, rect.right - rect.left, s18, TRUE );
MoveWindow ( window->mWndCallstack, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE );
MoveWindow ( window->mWndWatch, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE );
MoveWindow ( window->mWndThreads, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE );
@ -1335,6 +1373,7 @@ LRESULT CALLBACK rvDebuggerWindow::WndProc ( HWND wnd, UINT msg, WPARAM wparam,
SendMessage(window->mWndCallstack, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(s18, s10));
SendMessage(window->mWndOutput, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(s18, s10));
SendMessage(window->mWndConsole, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(s18, s10));
SendMessage( window->mWndConsoleInput, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG( s18, s10 ) );
break;
}
@ -1562,7 +1601,6 @@ LRESULT CALLBACK rvDebuggerWindow::WndProc ( HWND wnd, UINT msg, WPARAM wparam,
}
}
break;
case IDC_DBG_CALLSTACK:
if ( hdr->code == NM_DBLCLK )
{
@ -1607,6 +1645,7 @@ LRESULT CALLBACK rvDebuggerWindow::WndProc ( HWND wnd, UINT msg, WPARAM wparam,
{
ShowWindow ( window->mWndOutput, SW_HIDE );
ShowWindow ( window->mWndConsole, SW_HIDE );
ShowWindow ( window->mWndConsoleInput, SW_HIDE );
ShowWindow ( window->mWndCallstack, SW_HIDE );
ShowWindow ( window->mWndWatch, SW_HIDE );
ShowWindow ( window->mWndThreads, SW_HIDE );
@ -1619,6 +1658,7 @@ LRESULT CALLBACK rvDebuggerWindow::WndProc ( HWND wnd, UINT msg, WPARAM wparam,
case 1:
ShowWindow ( window->mWndConsole, SW_SHOW );
ShowWindow( window->mWndConsoleInput, SW_SHOW );
break;
case 2:
@ -1645,7 +1685,7 @@ LRESULT CALLBACK rvDebuggerWindow::WndProc ( HWND wnd, UINT msg, WPARAM wparam,
case WM_CLOSE:
if ( window->mClient->IsConnected ( ) )
{
if ( IDNO == MessageBox ( wnd, "The debugger is currently connected to a running version of the game. Are you sure you want to close now?", "Quake 4 Script Debugger", MB_YESNO|MB_ICONQUESTION ) )
if ( IDNO == MessageBox ( wnd, "The debugger is currently connected to a running version of the game. Are you sure you want to close now?", "Dhewm3 Script Debugger", MB_YESNO|MB_ICONQUESTION ) )
{
return 0;
}

View file

@ -110,6 +110,7 @@ private:
HWND mWndTabs;
HWND mWndBorder;
HWND mWndConsole;
HWND mWndConsoleInput;
HWND mWndCallstack;
HWND mWndScriptList;
HWND mWndWatch;