- Debuggersever now always builds, but is disabled by default in runtime.

- use com_enableDebuggerServer=1 to enable debugger server.
This commit is contained in:
HarrievG 2021-05-24 22:21:47 +02:00 committed by Daniel Gibson
parent 5ff3b0b9ee
commit 3ce93c7749
11 changed files with 243 additions and 36 deletions

View file

@ -801,6 +801,17 @@ set(src_d3xp
add_globbed_headers(src_d3xp "d3xp")
set(src_debuggerServer
tools/debugger/DebuggerBreakpoint.h
tools/debugger/DebuggerBreakpoint.cpp
tools/debugger/DebuggerServer.h
tools/debugger/DebuggerServer.cpp
tools/debugger/DebuggerScript.h
tools/debugger/DebuggerScript.cpp
tools/debugger/DebuggerMessages.h
tools/debugger/debugger.cpp
)
set(src_core
${src_renderer}
${src_framework}
@ -863,8 +874,22 @@ if (TOOLS AND MFC_FOUND AND MSVC)
file(GLOB src_script_editor "tools/script/*.cpp")
add_globbed_headers(src_script_editor "tools/script")
# Script Debugger
file(GLOB src_script_debugger "tools/debugger/*.cpp")
add_globbed_headers(src_script_debugger "tools/debugger")
set(src_debuggerClient
tools/debugger/DebuggerClient.h
tools/debugger/DebuggerClient.cpp
tools/debugger/DebuggerApp.h
tools/debugger/DebuggerApp.cpp
tools/debugger/DebuggerQuickWatchDlg.h
tools/debugger/DebuggerQuickWatchDlg.cpp
tools/debugger/DebuggerWindow.h
tools/debugger/DebuggerWindow.cpp
tools/debugger/DebuggerFindDlg.h
tools/debugger/DebuggerFindDlg.cpp
)
set(src_script_debugger
${src_debuggerServer}
${src_debuggerClient}
)
# sound editor?
file(GLOB src_sound_editor "tools/sound/*.cpp")
add_globbed_headers(src_sound_editor "tools/sound")
@ -891,7 +916,10 @@ if (TOOLS AND MFC_FOUND AND MSVC)
SET(CMAKE_MFC_FLAG 2)
set(TOOLS_DEFINES "ID_ALLOW_TOOLS;_AFXDLL")
else()
set(src_editor_tools "tools/edit_stub.cpp" "tools/edit_public.h")
set(src_editor_tools "tools/edit_stub.cpp" "tools/edit_public.h" "tools/debugger/debugger_common.h")
list(APPEND src_editor_tools
${src_debuggerServer}
)
endif()
@ -1056,9 +1084,10 @@ if(DEDICATED)
${src_stub_openal}
${src_stub_gl}
${src_sys_base}
${src_debuggerServer}
)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX neo FILES ${src_core} ${src_sys_base} ${src_stub_openal} ${src_stub_gl})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX neo FILES ${src_core} ${src_sys_base} ${src_stub_openal} ${src_stub_gl} ${src_debuggerServer})
set_target_properties(${DHEWM3BINARY}ded PROPERTIES COMPILE_DEFINITIONS "ID_DEDICATED;__DOOM_DLL__")
set_target_properties(${DHEWM3BINARY}ded PROPERTIES LINK_FLAGS "${ldflags}")

View file

@ -1155,7 +1155,7 @@ void idGameEdit::MapEntityTranslate( const char *name, const idVec3 &v ) const {
***********************************************************************/
bool idGameEdit::IsLineCode( const char *filename, int linenumber ) const {
static idStr fileStr = idStr( MAX_PATH );
idStr fileStr;
idProgram *program = &gameLocal.program;
for ( int i = 0; i < program->NumStatements( ); i++ ) {
fileStr = program->GetFilename( program->GetStatement( i ).file );

View file

@ -98,6 +98,8 @@ idCVar com_timescale( "timescale", "1", CVAR_SYSTEM | CVAR_FLOAT, "scales the ti
idCVar com_makingBuild( "com_makingBuild", "0", CVAR_BOOL | CVAR_SYSTEM, "1 when making a build" );
idCVar com_updateLoadSize( "com_updateLoadSize", "0", CVAR_BOOL | CVAR_SYSTEM | CVAR_NOCHEAT, "update the load size after loading a map" );
idCVar com_enableDebuggerServer( "com_enableDebuggerServer", "0", CVAR_BOOL | CVAR_SYSTEM, "set to 1 on startup to enable debugging with the DHEWM3 debugger" );
idCVar com_product_lang_ext( "com_product_lang_ext", "1", CVAR_INTEGER | CVAR_SYSTEM | CVAR_ARCHIVE, "Extension to use when creating language files." );
// com_speeds times
@ -383,17 +385,15 @@ void idCommonLocal::VPrintf( const char *fmt, va_list args ) {
// remove any color codes
idStr::RemoveColors( msg );
#ifdef ID_ALLOW_TOOLS
// print to script debugger server
if (com_editors & EDITOR_DEBUGGER)
DebuggerServerPrint(msg);
else
#endif
if ( com_enableDebuggerServer.GetBool( ) ) {
// print to script debugger server
if ( com_editors & EDITOR_DEBUGGER )
DebuggerServerPrint( msg );
} else {
// only echo to dedicated console and early console when debugger is not running so no
// deadlocks occur if engine functions called from the debuggerthread trace stuff..
Sys_Printf("%s", msg);
Sys_Printf( "%s", msg );
}
#if 0 // !@#
#if defined(_DEBUG) && defined(WIN32)
if ( strlen( msg ) < 512 ) {
@ -3170,10 +3170,9 @@ void idCommonLocal::InitGame( void ) {
// initialize the user interfaces
uiManager->Init();
#if defined(ID_ALLOW_TOOLS)
// startup the script debugger
DebuggerServerInit();
#endif;
if ( com_enableDebuggerServer.GetBool( ) )
DebuggerServerInit();
PrintLoadingMessage( common->GetLanguageDict()->GetString( "#str_04350" ) );
@ -3210,10 +3209,9 @@ void idCommonLocal::ShutdownGame( bool reloading ) {
sw->StopAllSounds();
}
#if defined(ID_ALLOW_TOOLS)
// shutdown the script debugger
DebuggerServerShutdown();
#endif
if ( com_enableDebuggerServer.GetBool( ) )
DebuggerServerShutdown();
idAsyncNetwork::client.Shutdown();
@ -3310,9 +3308,8 @@ bool idCommonLocal::GetAdditionalFunction(idCommon::FunctionType ft, idCommon::F
void idCommonLocal::DebuggerCheckBreakpoint(idInterpreter* interpreter, idProgram* program, int instructionPointer)
{
#ifdef ID_ALLOW_TOOLS
DebuggerServerCheckBreakpoint(interpreter, program, instructionPointer);
#endif
if ( com_enableDebuggerServer.GetBool( ) )
DebuggerServerCheckBreakpoint(interpreter, program, instructionPointer);
}
idGameCallbacks gameCallbacks;

View file

@ -73,6 +73,7 @@ extern idCVar com_showAsyncStats;
extern idCVar com_showSoundDecoders;
extern idCVar com_makingBuild;
extern idCVar com_updateLoadSize;
extern idCVar com_enableDebuggerServer;
extern int time_gameFrame; // game logic time
extern int time_gameDraw; // game present time

View file

@ -1155,7 +1155,7 @@ void idGameEdit::MapEntityTranslate( const char *name, const idVec3 &v ) const {
bool idGameEdit::IsLineCode(const char* filename, int linenumber) const
{
static idStr fileStr = idStr(MAX_PATH);
idStr fileStr;
idProgram* program = &gameLocal.program;
for (int i = 0; i < program->NumStatements(); i++)
{

View file

@ -25,11 +25,13 @@ If you have questions concerning this license or the applicable additional terms
===========================================================================
*/
#if defined( ID_ALLOW_TOOLS )
#include "tools/edit_gui_common.h"
#include "DebuggerApp.h"
#else
#include "debugger_common.h"
#endif
#include "DebuggerBreakpoint.h"
int rvDebuggerBreakpoint::mNextID = 1;

View file

@ -26,10 +26,13 @@ If you have questions concerning this license or the applicable additional terms
===========================================================================
*/
#if defined( ID_ALLOW_TOOLS )
#include "tools/edit_gui_common.h"
#include "DebuggerApp.h"
#else
#include "debugger_common.h"
#endif
#include "DebuggerScript.h"
#include "../../ui/Window.h"
#include "../../ui/UserInterfaceLocal.h"

View file

@ -26,9 +26,16 @@ If you have questions concerning this license or the applicable additional terms
===========================================================================
*/
#if defined( ID_ALLOW_TOOLS )
#include "tools/edit_gui_common.h"
#include "DebuggerApp.h"
#else
#include "debugger_common.h"
// we need a lot to be able to list all threads in mars_city1
const int MAX_MSGLEN = 8600;
#endif
#include "DebuggerServer.h"
/*
@ -628,11 +635,14 @@ void rvDebuggerServer::Break ( idInterpreter* interpreter, idProgram* program, i
// would just flash
Sleep ( 150 );
//this should be platform specific
#if defined( ID_ALLOW_TOOLS )
// Bring the window back to the foreground
SetForegroundWindow ( win32.hWnd );
SetActiveWindow ( win32.hWnd );
UpdateWindow ( win32.hWnd );
SetFocus ( win32.hWnd );
#endif
// Give the mouse cursor back to the game
// HVG_Note : there be dragons here. somewhere.

View file

@ -26,17 +26,22 @@ If you have questions concerning this license or the applicable additional terms
===========================================================================
*/
#if defined( ID_ALLOW_TOOLS )
#include "tools/edit_gui_common.h"
#include "../../sys/win32/rc/debugger_resource.h"
#include "DebuggerApp.h"
#else
#include "debugger_common.h"
#endif
#include "DebuggerServer.h"
DWORD CALLBACK DebuggerThread ( LPVOID param );
#if defined( ID_ALLOW_TOOLS )
rvDebuggerApp gDebuggerApp;
HWND gDebuggerWindow = NULL;
#endif
bool gDebuggerSuspend = false;
bool gDebuggerConnnected = false;
HANDLE gDebuggerGameThread = NULL;
@ -46,6 +51,7 @@ HANDLE gDebuggerServerThread = NULL;
DWORD gDebuggerServerThreadID = 0;
bool gDebuggerServerQuit = false;
#if defined( ID_ALLOW_TOOLS )
/*
================
DebuggerMain
@ -113,6 +119,7 @@ void DebuggerClientLaunch ( void )
CloseHandle ( process.hThread );
CloseHandle ( process.hProcess );
}
#endif // #if defined( ID_ALLOW_TOOLS )
/*
================

View file

@ -0,0 +1,162 @@
// header that includes all the other needed headers, replacement for precompiled.h (only used by debugger)
// this could be cleaned up more.
#ifndef DEBUGGER_COMMON_H
#define DEBUGGER_COMMON_H
#include "framework/Game.h"
// non-portable system services
#include "sys/platform.h"
#include "sys/sys_public.h"
// id lib
#include "idlib/Lib.h"
// memory management and arrays
#include "idlib/Heap.h"
#include "idlib/containers/List.h"
// math
#include "idlib/math/Simd.h"
#include "idlib/math/Math.h"
#include "idlib/math/Random.h"
#include "idlib/math/Complex.h"
#include "idlib/math/Vector.h"
#include "idlib/math/Matrix.h"
#include "idlib/math/Angles.h"
#include "idlib/math/Quat.h"
#include "idlib/math/Rotation.h"
#include "idlib/math/Plane.h"
#include "idlib/math/Pluecker.h"
#include "idlib/math/Polynomial.h"
#include "idlib/math/Extrapolate.h"
#include "idlib/math/Interpolate.h"
#include "idlib/math/Curve.h"
#include "idlib/math/Ode.h"
#include "idlib/math/Lcp.h"
// bounding volumes
#include "idlib/bv/Sphere.h"
#include "idlib/bv/Bounds.h"
#include "idlib/bv/Box.h"
#include "idlib/bv/Frustum.h"
// geometry
#include "idlib/geometry/DrawVert.h"
#include "idlib/geometry/JointTransform.h"
#include "idlib/geometry/Winding.h"
#include "idlib/geometry/Winding2D.h"
#include "idlib/geometry/Surface.h"
#include "idlib/geometry/Surface_Patch.h"
#include "idlib/geometry/Surface_Polytope.h"
#include "idlib/geometry/Surface_SweptSpline.h"
#include "idlib/geometry/TraceModel.h"
// text manipulation
#include "idlib/Str.h"
#include "idlib/Token.h"
#include "idlib/Lexer.h"
#include "idlib/Parser.h"
#include "idlib/Base64.h"
#include "idlib/CmdArgs.h"
// containers
#include "idlib/containers/BTree.h"
#include "idlib/containers/BinSearch.h"
#include "idlib/containers/HashIndex.h"
#include "idlib/containers/HashTable.h"
#include "idlib/containers/StaticList.h"
#include "idlib/containers/LinkList.h"
#include "idlib/containers/Hierarchy.h"
#include "idlib/containers/Queue.h"
#include "idlib/containers/Stack.h"
#include "idlib/containers/StrList.h"
#include "idlib/containers/StrPool.h"
#include "idlib/containers/VectorSet.h"
#include "idlib/containers/PlaneSet.h"
// hashing
#include "idlib/hashing/CRC32.h"
#include "idlib/hashing/MD4.h"
#include "idlib/hashing/MD5.h"
// misc
#include "idlib/Dict.h"
#include "idlib/LangDict.h"
#include "idlib/BitMsg.h"
#include "idlib/MapFile.h"
#include "idlib/Timer.h"
// framework
#include "framework/BuildVersion.h"
#include "framework/Licensee.h"
#include "framework/CmdSystem.h"
#include "framework/CVarSystem.h"
#include "framework/Common.h"
#include "framework/File.h"
#include "framework/FileSystem.h"
#include "framework/UsercmdGen.h"
// decls
#include "framework/DeclManager.h"
#include "framework/DeclTable.h"
#include "framework/DeclSkin.h"
#include "framework/DeclEntityDef.h"
#include "framework/DeclFX.h"
#include "framework/DeclParticle.h"
#include "framework/DeclAF.h"
#include "framework/DeclPDA.h"
// We have expression parsing and evaluation code in multiple places:
// materials, sound shaders, and guis. We should unify them.
// renderer
#include "renderer/qgl.h"
#include "renderer/Cinematic.h"
#include "renderer/Material.h"
#include "renderer/Model.h"
#include "renderer/ModelManager.h"
#include "renderer/RenderSystem.h"
#include "renderer/RenderWorld.h"
// sound engine
#include "sound/sound.h"
// asynchronous networking
#include "framework/async/NetworkSystem.h"
// user interfaces
#include "ui/ListGUI.h"
#include "ui/UserInterface.h"
// collision detection system
#include "cm/CollisionModel.h"
// AAS files and manager
#include "tools/compilers/aas/AASFile.h"
#include "tools/compilers/aas/AASFileManager.h"
// game interface
#include "framework/Game.h"
//-----------------------------------------------------
#include "framework/DemoChecksum.h"
// framework
#include "framework/Compressor.h"
#include "framework/EventLoop.h"
#include "framework/KeyInput.h"
#include "framework/EditField.h"
#include "framework/Console.h"
#include "framework/DemoFile.h"
#include "framework/Session.h"
// asynchronous networking
#include "framework/async/AsyncNetwork.h"
// Compilers for map, model, video etc. processing.
#include "tools/compilers/compiler_public.h"
#endif // DEBUGGER_COMMON_H

View file

@ -67,10 +67,6 @@ bool GUIEditorHandleMessage( void *msg ) { return false; }
void DebuggerClientLaunch( void ) {}
void DebuggerClientInit( const char *cmdline ) { common->Printf( "The Script Debugger Client only runs on Win32\n" ); }
bool DebuggerServerInit( void ) { return false; }
void DebuggerServerShutdown( void ) {}
void DebuggerServerPrint( const char *text ) {}
void DebuggerServerCheckBreakpoint( idInterpreter *interpreter, idProgram *program, int instructionPointer ) {}
void PDAEditorInit( const idDict *spawnArgs ) { common->Printf( "The PDA editor only runs on Win32\n" ); }