mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-03-21 18:21:08 +00:00
Debugger: Support OnceOnly-Breakpoints ("Run To Cursor")
This commit is contained in:
parent
d7eff865af
commit
4172b006cc
5 changed files with 53 additions and 5 deletions
|
@ -36,11 +36,12 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
int rvDebuggerBreakpoint::mNextID = 1;
|
||||
|
||||
rvDebuggerBreakpoint::rvDebuggerBreakpoint ( const char* filename, int linenumber, int id )
|
||||
rvDebuggerBreakpoint::rvDebuggerBreakpoint ( const char* filename, int linenumber, int id, bool onceOnly )
|
||||
{
|
||||
mFilename = filename;
|
||||
mLineNumber = linenumber;
|
||||
mEnabled = true;
|
||||
mOnceOnly = onceOnly;
|
||||
|
||||
if ( id == -1 )
|
||||
{
|
||||
|
|
|
@ -34,17 +34,19 @@ class rvDebuggerBreakpoint
|
|||
{
|
||||
public:
|
||||
|
||||
rvDebuggerBreakpoint ( const char* filename, int linenumber, int id = -1 );
|
||||
rvDebuggerBreakpoint ( const char* filename, int linenumber, int id = -1, bool onceOnly = false );
|
||||
rvDebuggerBreakpoint ( rvDebuggerBreakpoint& bp );
|
||||
~rvDebuggerBreakpoint ( void );
|
||||
|
||||
const char* GetFilename ( void );
|
||||
int GetLineNumber ( void );
|
||||
int GetID ( void );
|
||||
bool GetOnceOnly ( void );
|
||||
|
||||
protected:
|
||||
|
||||
bool mEnabled;
|
||||
bool mOnceOnly;
|
||||
int mID;
|
||||
int mLineNumber;
|
||||
idStr mFilename;
|
||||
|
@ -68,4 +70,9 @@ ID_INLINE int rvDebuggerBreakpoint::GetID ( void )
|
|||
return mID;
|
||||
}
|
||||
|
||||
ID_INLINE bool rvDebuggerBreakpoint::GetOnceOnly( void )
|
||||
{
|
||||
return mOnceOnly;
|
||||
}
|
||||
|
||||
#endif // DEBUGGERBREAKPOINT_H_
|
||||
|
|
|
@ -495,9 +495,9 @@ rvDebuggerClient::AddBreakpoint
|
|||
Adds a breakpoint to the client and server with the give nfilename and linenumber
|
||||
================
|
||||
*/
|
||||
int rvDebuggerClient::AddBreakpoint ( const char* filename, int lineNumber )
|
||||
int rvDebuggerClient::AddBreakpoint ( const char* filename, int lineNumber, bool onceOnly )
|
||||
{
|
||||
int index = mBreakpoints.Append ( new rvDebuggerBreakpoint ( filename, lineNumber ) );
|
||||
int index = mBreakpoints.Append ( new rvDebuggerBreakpoint ( filename, lineNumber, -1, onceOnly ) );
|
||||
|
||||
SendAddBreakpoint ( *mBreakpoints[index] );
|
||||
|
||||
|
@ -591,6 +591,7 @@ void rvDebuggerClient::SendAddBreakpoint ( rvDebuggerBreakpoint& bp )
|
|||
msg.Init( buffer, sizeof( buffer ) );
|
||||
msg.BeginWriting();
|
||||
msg.WriteShort ( (short)DBMSG_ADDBREAKPOINT );
|
||||
msg.WriteBits ( bp.GetOnceOnly() ? 1 : 0, 1 );
|
||||
msg.WriteInt ( (unsigned long) bp.GetLineNumber ( ) );
|
||||
msg.WriteInt ( bp.GetID ( ) );
|
||||
msg.WriteString ( bp.GetFilename() ); // FIXME: this implies make7bit ?!
|
||||
|
|
|
@ -321,7 +321,7 @@ void rvDebuggerServer::HandleAddBreakpoint ( idBitMsg* msg )
|
|||
|
||||
|
||||
SDL_LockMutex( mCriticalSection );
|
||||
mBreakpoints.Append ( new rvDebuggerBreakpoint ( filename, lineNumber, id ) );
|
||||
mBreakpoints.Append ( new rvDebuggerBreakpoint ( filename, lineNumber, id, onceOnly ) );
|
||||
SDL_UnlockMutex( mCriticalSection );
|
||||
}
|
||||
|
||||
|
@ -599,6 +599,25 @@ void rvDebuggerServer::CheckBreakpoints ( idInterpreter* interpreter, idProgram*
|
|||
continue;
|
||||
}
|
||||
|
||||
// DG: onceOnly support
|
||||
if ( bp->GetOnceOnly() ) {
|
||||
// we'll do the one Break() a few lines below; remove it here while mBreakpoints is unmodified
|
||||
// (it can be modifed from the client while in Break() below)
|
||||
mBreakpoints.RemoveIndex( i );
|
||||
delete bp;
|
||||
|
||||
// also tell client to remove the breakpoint
|
||||
idBitMsg msgOut;
|
||||
byte buffer[MAX_MSGLEN];
|
||||
msgOut.Init( buffer, sizeof( buffer ) );
|
||||
msgOut.BeginWriting();
|
||||
msgOut.WriteShort( (short)DBMSG_REMOVEBREAKPOINT );
|
||||
msgOut.WriteInt( linenumber );
|
||||
msgOut.WriteString( qpath.c_str() );
|
||||
SendPacket( msgOut.GetData(), msgOut.GetSize() );
|
||||
}
|
||||
// DG end
|
||||
|
||||
// Pop out of the critical section so we dont get stuck
|
||||
SDL_UnlockMutex( mCriticalSection );
|
||||
|
||||
|
|
|
@ -1202,6 +1202,7 @@ int rvDebuggerWindow::HandleCommand ( WPARAM wparam, LPARAM lparam )
|
|||
break;
|
||||
}
|
||||
|
||||
case 111: // DG: Debugger.rc has 'MENUITEM "Toggle &Breakpoint\tF9", 111' for the context menu no idea why 111 but this works
|
||||
case ID_DBG_DEBUG_TOGGLEBREAKPOINT:
|
||||
ToggleBreakpoint ( );
|
||||
break;
|
||||
|
@ -1277,6 +1278,23 @@ int rvDebuggerWindow::HandleCommand ( WPARAM wparam, LPARAM lparam )
|
|||
UpdateScript ( );
|
||||
break;
|
||||
}
|
||||
|
||||
// DG: support "Run To Cursor" from context menu
|
||||
case ID_DBG_DEBUG_RUNTOCURSOR:
|
||||
{
|
||||
// Find the currently selected line
|
||||
DWORD sel;
|
||||
SendMessage( mWndScript, EM_GETSEL, (WPARAM)&sel, 0 );
|
||||
int lineNumber = SendMessage( mWndScript, EM_LINEFROMCHAR, sel, 0 ) + 1;
|
||||
|
||||
const char* filename = mScripts[mActiveScript]->GetFilename();
|
||||
mClient->AddBreakpoint( filename, lineNumber, true );
|
||||
mClient->Resume();
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: case ID_DBG_DEBUG_SHOWNEXTSTATEMENT:
|
||||
// whatever this is supposed to do (also from context menu)
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -2102,6 +2120,8 @@ void rvDebuggerWindow::CreateToolbar ( void )
|
|||
SendMessage( mWndToolbar, TB_ADDBITMAP, (WPARAM)4, (LPARAM) &tbab );
|
||||
|
||||
// Add the buttons to the toolbar
|
||||
// FIXME: warning C4838: conversion from 'int' to 'BYTE' requires a narrowing conversion
|
||||
// most probably because TBBUTTON has 4 more bytes in bReserved for alignment on _WIN64
|
||||
TBBUTTON tbb[] = { { 0, 0, TBSTATE_ENABLED, BTNS_SEP, 0, 0, -1 },
|
||||
{ 8, ID_DBG_FILE_OPEN, TBSTATE_ENABLED, BTNS_BUTTON, 0, 0, -1 },
|
||||
{ 0, 0, TBSTATE_ENABLED, BTNS_SEP, 0, 0, -1 },
|
||||
|
|
Loading…
Reference in a new issue