| 2167 | } |
| 2168 | |
| 2169 | void DebuggerPlugin::run( const std::string& debugger, ProtocolSettings&& protocolSettings, |
| 2170 | DapRunConfig&& runConfig, int randPort, bool forceUseProgram, |
| 2171 | bool usesPorts, bool unstableFrameId ) { |
| 2172 | std::optional<Command> cmdOpt = debuggerBinaryExists( debugger, runConfig ); |
| 2173 | |
| 2174 | if ( !cmdOpt && ( protocolSettings.launchRequestType == REQUEST_TYPE_LAUNCH || |
| 2175 | ( protocolSettings.launchRequestType == REQUEST_TYPE_ATTACH && |
| 2176 | protocolSettings.launchArgs.value( "mode", "" ) == "local" && |
| 2177 | protocolSettings.launchArgs.contains( "program" ) ) ) ) { |
| 2178 | auto msg = |
| 2179 | String::format( i18n( "debugger_binary_not_found", |
| 2180 | "Debugger binary not found. Binary \"%s\" must be installed." ) |
| 2181 | .toUtf8(), |
| 2182 | runConfig.command ); |
| 2183 | |
| 2184 | mManager->getPluginContext()->getNotificationCenter()->addNotification( msg ); |
| 2185 | return; |
| 2186 | } |
| 2187 | |
| 2188 | Command cmd = std::move( *cmdOpt ); |
| 2189 | bool isRemote = false; |
| 2190 | bool runsDapServer = false; |
| 2191 | |
| 2192 | for ( auto& arg : cmd.arguments ) |
| 2193 | replaceExecutableArgs( arg ); |
| 2194 | |
| 2195 | Connection con; |
| 2196 | con.host = protocolSettings.launchArgs.value( "host", "localhost" ); |
| 2197 | con.port = randPort; |
| 2198 | |
| 2199 | auto debugServer = getDebugServer( protocolSettings.launchArgs ); |
| 2200 | if ( debugServer ) { |
| 2201 | runsDapServer = true; |
| 2202 | con.host = debugServer->host; |
| 2203 | con.port = debugServer->port; |
| 2204 | } else if ( protocolSettings.launchArgs.contains( "port" ) && |
| 2205 | protocolSettings.launchArgs["port"].is_number_integer() ) { |
| 2206 | con.port = protocolSettings.launchArgs.value( "port", randPort ); |
| 2207 | } |
| 2208 | |
| 2209 | std::string localRoot = mProjectPath; |
| 2210 | std::string remoteRoot; |
| 2211 | |
| 2212 | if ( protocolSettings.launchRequestType == REQUEST_TYPE_LAUNCH ) { |
| 2213 | if ( usesPorts ) { |
| 2214 | auto bus = std::make_unique<BusSocketProcess>( cmd, con ); |
| 2215 | mDebugger = std::make_unique<DebuggerClientDap>( protocolSettings, std::move( bus ) ); |
| 2216 | } else { |
| 2217 | auto bus = std::make_unique<BusProcess>( cmd ); |
| 2218 | mDebugger = std::make_unique<DebuggerClientDap>( protocolSettings, std::move( bus ) ); |
| 2219 | } |
| 2220 | } else if ( protocolSettings.launchRequestType == REQUEST_TYPE_ATTACH ) { |
| 2221 | auto mode = protocolSettings.launchArgs.value( "mode", "" ); |
| 2222 | if ( mode.empty() ) |
| 2223 | mode = "local"; |
| 2224 | |
| 2225 | bool useSocket = !con.host.empty() && con.port != 0; |
| 2226 | if ( ( protocolSettings.launchArgs.contains( "host" ) || |
no test coverage detected