MCPcopy Create free account
hub / github.com/SpartanJ/eepp / prepareAndRun

Method prepareAndRun

src/tools/ecode/plugins/debugger/debuggerplugin.cpp:1974–2036  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1972}
1973
1974void DebuggerPlugin::prepareAndRun( DapTool debugger, DapConfig config,
1975 std::unordered_map<std::string, std::string> solvedInputs ) {
1976 int randomPort = Math::randi( 44000, 45000 );
1977 ProtocolSettings protocolSettings;
1978 protocolSettings.launchRequestType = config.request;
1979 protocolSettings.runTarget = config.runTarget;
1980 auto args = config.args;
1981 replaceKeysInJson( args, randomPort, solvedInputs );
1982 protocolSettings.launchArgs = std::move( args );
1983 protocolSettings.redirectStdout = debugger.redirectStdout;
1984 protocolSettings.redirectStderr = debugger.redirectStderr;
1985 protocolSettings.supportsSourceRequest = debugger.supportsSourceRequest;
1986 bool forceUseProgram = false;
1987 bool usesPorts = false;
1988
1989 for ( auto& arg : debugger.run.args ) {
1990 auto ret( replaceKeyInString( arg, randomPort, solvedInputs ) );
1991
1992 // No success? Abort
1993 if ( !ret.first )
1994 return;
1995
1996 auto res( ret.second );
1997 if ( res.size() == 1 && res[0] != arg ) {
1998 if ( String::contains( arg, KEY_RANDPORT ) )
1999 usesPorts = true;
2000 arg = res[0];
2001 }
2002 }
2003
2004 for ( const std::string& cmdArg : config.cmdArgs ) {
2005 if ( cmdArg == KEY_FILE || cmdArg == KEY_ARGS || cmdArg == CMD_PICK_PROCESS ||
2006 cmdArg == CMD_PROMPT_STRING )
2007 forceUseProgram = true;
2008 auto ret = replaceKeyInString( cmdArg, randomPort, solvedInputs );
2009
2010 // No success? Abort
2011 if ( !ret.first )
2012 return;
2013
2014 auto args = ret.second;
2015 for ( const auto& arg : args )
2016 debugger.run.args.emplace_back( arg );
2017 }
2018
2019 if ( getDebugServer( protocolSettings.launchArgs ) )
2020 usesPorts = true;
2021
2022 mThreadPool->run(
2023 [this, protocolSettings = std::move( protocolSettings ), randomPort,
2024 debugger = std::move( debugger ), forceUseProgram, usesPorts]() mutable {
2025 run( debugger.name, std::move( protocolSettings ), std::move( debugger.run ),
2026 randomPort, forceUseProgram, usesPorts, debugger.unstableFrameId );
2027 },
2028 [this]( const Uint64& ) {
2029 if ( !mDebugger || !mDebugger->started() ) {
2030 exitDebugger();
2031

Callers

nothing calls this directly

Calls 9

randiFunction · 0.85
getDebugServerFunction · 0.85
startedMethod · 0.80
addNotificationMethod · 0.80
getNotificationCenterMethod · 0.80
containsFunction · 0.50
sizeMethod · 0.45
runMethod · 0.45
getPluginContextMethod · 0.45

Tested by

no test coverage detected