Adding EmitExecEvent() function to interface.
authorKirill Frolov <k.frolov@samsung.com>
Fri, 30 Oct 2020 23:56:38 +0000 (02:56 +0300)
committerAlexander Soldatov/Platform Lab /SRR/Staff Engineer/Samsung Electronics <soldatov.a@samsung.com>
Thu, 19 Nov 2020 14:35:45 +0000 (17:35 +0300)
This commit changes debugger interface and adds new function
EmitExecEvent which notifies VSCode protocol, that new
program is executed by the debugger.

This commit is needed to fix issue #272 (VisualStudio on Mac).

src/debug/netcoredbg/cliprotocol.h
src/debug/netcoredbg/debugger.h
src/debug/netcoredbg/manageddebugger.cpp
src/debug/netcoredbg/miprotocol.h
src/debug/netcoredbg/protocol.h
src/debug/netcoredbg/vscodeprotocol.cpp
src/debug/netcoredbg/vscodeprotocol.h

index 54510fcf1e47c95e5cdc0fcbc9ffafc983d86fdc..82bd0a65589e6fbed477e2cde8d7d476684952c4 100644 (file)
@@ -41,6 +41,7 @@ public:
                                  redOn(""), colorOff("") {}
 #endif                                
     void EmitInitializedEvent() override {}
+    void EmitExecEvent(PID, const std::string& argv) override {}
     void EmitStoppedEvent(StoppedEvent event) override;
     void EmitExitedEvent(ExitedEvent event) override;
     void EmitTerminatedEvent() override {}
index 437d246d7a0ced9f8583ef769d11488d3305ea80..3e6534dc7a6fb47386cf95f89aa0efe0100130eb 100644 (file)
@@ -77,6 +77,7 @@ public:
     void SetDebugger(Debugger *debugger) { m_debugger = debugger; }
 
     virtual void EmitInitializedEvent() = 0;
+    virtual void EmitExecEvent(PID, const std::string& argv0) = 0;
     virtual void EmitStoppedEvent(StoppedEvent event) = 0;
     virtual void EmitExitedEvent(ExitedEvent event) = 0;
     virtual void EmitTerminatedEvent() = 0;
index 779f8e77f582cb74122bad8b6360aa75265c58d5..402a6f080d29c333e4e2a495e30bb38b83ef4440 100644 (file)
@@ -1762,6 +1762,9 @@ HRESULT ManagedDebugger::RunProcess(string fileExec, std::vector<string> execArg
         return E_FAIL;
     }
 
+    if (m_startupResult == S_OK)
+        m_protocol->EmitExecEvent(PID{m_processId}, fileExec);
+
     return m_startupResult;
 }
 
index 5431f2ae8bfe7512dc4a186218a7274f0d994e66..2577d527b145f4e49fdc7b3904fd86116d1d0c21 100644 (file)
@@ -40,6 +40,7 @@ public:
 
     MIProtocol() : IProtocol(), m_varCounter(0) {}
     void EmitInitializedEvent() override {}
+    void EmitExecEvent(PID, const std::string& argv0) override {}
     void EmitStoppedEvent(StoppedEvent event) override;
     void EmitExitedEvent(ExitedEvent event) override;
     void EmitTerminatedEvent() override {}
index 6347d79419076ddb5c808e48233775566782e6e3..c8a132cf7b9b9e10af62f8bb6dd3ec4637649ad4 100644 (file)
 
 // Types commonly used in the debugger:
 
+// Process identifier.
+class PID : public Utility::CustomScalarType<PID>
+{      
+public:
+    typedef DWORD ScalarType;
+
+    explicit PID(ScalarType n) : m_pid{int(n)} {}
+    explicit operator ScalarType() const { return m_pid; }
+
+private:
+    int m_pid;
+};
+
 // Data type deficated to carry thread id.
 class ThreadId : public Utility::CustomScalarType<ThreadId>
 {
index 8259739b5753e2cb2a04b843b0d52d1e87d2380f..319ee2db2f9b2126f711d5efff189f472474f490 100644 (file)
@@ -299,6 +299,18 @@ void VSCodeProtocol::EmitInitializedEvent()
     EmitEvent("initialized", json::object());
 }
 
+void VSCodeProtocol::EmitExecEvent(PID pid, const std::string& argv0)
+{
+    json body;
+
+    body["name"] = argv0;
+    body["systemProcessId"] = unsigned(pid);
+    body["isLocalProcess"] = true;
+    body["startMethod"] = "launch";
+
+    EmitEvent("process", body);
+}
+
 void VSCodeProtocol::EmitCapabilitiesEvent()
 {
     LogFuncEntry();
index 441cd86bee6bf80a7c9b92dff3dc09a22dbd8c32..ea56a6a4115055d9496e5d03067da9e6d23594a4 100644 (file)
@@ -66,6 +66,7 @@ public:
     }
 
     void EmitInitializedEvent() override;
+    void EmitExecEvent(PID, const std::string& argv0) override;
     void EmitStoppedEvent(StoppedEvent event) override;
     void EmitExitedEvent(ExitedEvent event) override;
     void EmitTerminatedEvent() override;