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

Method debuggerBinaryExists

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

Source from the content-addressed store, hash-verified

2109}
2110
2111std::optional<Command>
2112DebuggerPlugin::debuggerBinaryExists( const std::string& debugger,
2113 std::optional<DapRunConfig> optRunConfig ) {
2114 auto debuggerIt = std::find_if( mDaps.begin(), mDaps.end(), [&debugger]( const DapTool& dap ) {
2115 return dap.name == debugger;
2116 } );
2117
2118 if ( debuggerIt == mDaps.end() )
2119 return {};
2120
2121 DapRunConfig runConfig = optRunConfig ? *optRunConfig : debuggerIt->run;
2122 Command cmd;
2123 cmd.command = std::move( runConfig.command );
2124 cmd.arguments = std::move( runConfig.args );
2125
2126 std::string findBinary;
2127 auto findBinaryIt = debuggerIt->findBinary.find( String::toLower( Sys::getPlatform() ) );
2128 if ( findBinaryIt != debuggerIt->findBinary.end() )
2129 findBinary = findBinaryIt->second;
2130
2131 std::string fallbackCommand = debuggerIt->fallbackCommand;
2132
2133 if ( !findBinary.empty() && Sys::which( cmd.command ).empty() ) {
2134 auto foundCmd = findCommand( findBinary, cmd.command );
2135 if ( !foundCmd.empty() ) {
2136 cmd.command = std::move( foundCmd );
2137 } else if ( !fallbackCommand.empty() ) {
2138 foundCmd = findCommand( findBinary, fallbackCommand );
2139 if ( !foundCmd.empty() )
2140 cmd.command = std::move( foundCmd );
2141 }
2142 }
2143
2144 if ( !cmd.command.empty() && !FileSystem::fileExists( cmd.command ) &&
2145 Sys::which( cmd.command ).empty() ) {
2146 auto args = Process::parseArgs( cmd.command );
2147 if ( args.empty() ||
2148 ( !FileSystem::fileExists( args[0] ) && Sys::which( args[0] ).empty() ) ) {
2149 if ( fallbackCommand.empty() || ( !FileSystem::fileExists( fallbackCommand ) &&
2150 Sys::which( fallbackCommand ).empty() ) ) {
2151 return {};
2152 } else {
2153 cmd.command = std::move( fallbackCommand );
2154 }
2155 }
2156 }
2157
2158 return cmd;
2159}
2160
2161void DebuggerPlugin::initStatusDebuggerController() {
2162 auto sdc = getStatusDebuggerController();

Callers 1

getHealthMethod · 0.80

Calls 5

findCommandFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
findMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected