mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
Improve attach to "Run Target". Now it's possible to debug a terminal application by using this attach.
This commit is contained in:
@@ -20,21 +20,6 @@
|
||||
"env": "${env}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Attach to Name",
|
||||
"request": "attach",
|
||||
"arguments": {
|
||||
"program": "${file}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Attach to Name (wait)",
|
||||
"request": "attach",
|
||||
"arguments": {
|
||||
"program": "${file}",
|
||||
"waitFor": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Attach to PID",
|
||||
"request": "attach",
|
||||
@@ -87,15 +72,17 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Attach to Name",
|
||||
"name": "Attach to binary",
|
||||
"request": "attach",
|
||||
"runTarget": true,
|
||||
"arguments": {
|
||||
"program": "${file}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Attach to Name (wait)",
|
||||
"name": "Attach to binary (wait)",
|
||||
"request": "attach",
|
||||
"runTarget": true,
|
||||
"arguments": {
|
||||
"program": "${file}",
|
||||
"waitFor": true
|
||||
@@ -198,7 +185,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Attach",
|
||||
"name": "Attach to PID",
|
||||
"command_arguments": ["--pid", "${command:pickProcess}"],
|
||||
"request": "attach",
|
||||
"arguments": {
|
||||
|
||||
@@ -48,6 +48,7 @@ struct ProtocolSettings {
|
||||
bool redirectStderr{ false };
|
||||
bool redirectStdout{ false };
|
||||
bool supportsSourceRequest{ true };
|
||||
bool runTarget{ false };
|
||||
std::string launchRequestType{ "launch" };
|
||||
json launchArgs;
|
||||
std::string locale{ "en-US" };
|
||||
|
||||
@@ -153,6 +153,13 @@ void DebuggerClientDap::requestLaunchCommand() {
|
||||
setState( State::Failed );
|
||||
}
|
||||
} );
|
||||
|
||||
if ( mProtocol.runTarget && runTargetCb ) {
|
||||
if ( !mProtocol.launchArgs.contains( "waitFor" ) )
|
||||
runTargetCb();
|
||||
else
|
||||
mWaitingToAttach = true;
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerClientDap::requestInitialize() {
|
||||
@@ -353,6 +360,11 @@ void DebuggerClientDap::processEventOutput( const nlohmann::json& body ) {
|
||||
Output output( body );
|
||||
for ( auto listener : mListeners )
|
||||
listener->outputProduced( output );
|
||||
|
||||
if ( mWaitingToAttach && mProtocol.runTarget && runTargetCb ) {
|
||||
runTargetCb();
|
||||
mWaitingToAttach = false;
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerClientDap::processEventProcess( const nlohmann::json& body ) {
|
||||
|
||||
@@ -22,6 +22,8 @@ class DebuggerClientDap : public DebuggerClient {
|
||||
std::function<void( int )> doneFn )>
|
||||
runInTerminalCb;
|
||||
|
||||
std::function<void()> runTargetCb;
|
||||
|
||||
DebuggerClientDap( const ProtocolSettings& protocolSettings, std::unique_ptr<Bus>&& bus );
|
||||
|
||||
virtual ~DebuggerClientDap();
|
||||
|
||||
@@ -129,6 +129,7 @@ class DebuggerClient {
|
||||
State mState{ State::None };
|
||||
bool mLaunched{ false };
|
||||
bool mConfigured{ false };
|
||||
bool mWaitingToAttach{ false };
|
||||
std::vector<Listener*> mListeners;
|
||||
|
||||
void checkRunning();
|
||||
|
||||
@@ -419,6 +419,7 @@ void DebuggerPlugin::loadDAPConfig( const std::string& path, bool updateConfigFi
|
||||
dapConfig.name = config.value( "name", "" );
|
||||
if ( !dapConfig.name.empty() ) {
|
||||
dapConfig.request = config.value( "request", REQUEST_TYPE_LAUNCH );
|
||||
dapConfig.runTarget = config.value( "runTarget", false );
|
||||
dapConfig.args = config["arguments"];
|
||||
}
|
||||
if ( config.contains( "command_arguments" ) ) {
|
||||
@@ -1736,6 +1737,7 @@ void DebuggerPlugin::prepareAndRun( DapTool debugger, DapConfig config,
|
||||
int randomPort = Math::randi( 44000, 45000 );
|
||||
ProtocolSettings protocolSettings;
|
||||
protocolSettings.launchRequestType = config.request;
|
||||
protocolSettings.runTarget = config.runTarget;
|
||||
auto args = config.args;
|
||||
replaceKeysInJson( args, randomPort, solvedInputs );
|
||||
protocolSettings.launchArgs = args;
|
||||
@@ -2027,6 +2029,11 @@ void DebuggerPlugin::run( const std::string& debugger, ProtocolSettings&& protoc
|
||||
} );
|
||||
};
|
||||
|
||||
dap->runTargetCb = [this] {
|
||||
getUISceneNode()->runOnMainThread(
|
||||
[this] { getPluginContext()->runCommand( "project-run-executable" ); } );
|
||||
};
|
||||
|
||||
mDebugger->start();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ struct DapConfig {
|
||||
std::string request;
|
||||
std::vector<std::string> cmdArgs;
|
||||
nlohmann::json args;
|
||||
bool runTarget{ false };
|
||||
};
|
||||
|
||||
struct DapTool {
|
||||
|
||||
Reference in New Issue
Block a user