Skip to content

Conversation

ashgti
Copy link
Contributor

@ashgti ashgti commented Oct 16, 2025

When we restart a process, send an updated 'process' event describing the newly launched process.

I also updated the isLocalProcess value based on if we're on the 'host' platform or not.

When we restart a process, send an updated 'process' event describing the newly launched process.
@ashgti ashgti requested a review from JDevlieghere as a code owner October 16, 2025 17:52
@ashgti ashgti requested review from da-viper and removed request for JDevlieghere October 16, 2025 17:52
@ashgti ashgti requested a review from JDevlieghere October 16, 2025 17:53
@llvmbot
Copy link
Member

llvmbot commented Oct 16, 2025

@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)

Changes

When we restart a process, send an updated 'process' event describing the newly launched process.

I also updated the isLocalProcess value based on if we're on the 'host' platform or not.


Full diff: https://github.com/llvm/llvm-project/pull/163833.diff

2 Files Affected:

  • (modified) lldb/tools/lldb-dap/EventHelper.cpp (+4-1)
  • (modified) lldb/tools/lldb-dap/Handler/RestartRequestHandler.cpp (+2)
diff --git a/lldb/tools/lldb-dap/EventHelper.cpp b/lldb/tools/lldb-dap/EventHelper.cpp
index 2b9ed229405a8..ebddb4ec1f502 100644
--- a/lldb/tools/lldb-dap/EventHelper.cpp
+++ b/lldb/tools/lldb-dap/EventHelper.cpp
@@ -15,6 +15,7 @@
 #include "Protocol/ProtocolRequests.h"
 #include "Protocol/ProtocolTypes.h"
 #include "lldb/API/SBFileSpec.h"
+#include "lldb/API/SBPlatform.h"
 #include "llvm/Support/Error.h"
 #include <utility>
 
@@ -136,7 +137,9 @@ void SendProcessEvent(DAP &dap, LaunchMethod launch_method) {
   EmplaceSafeString(body, "name", exe_path);
   const auto pid = dap.target.GetProcess().GetProcessID();
   body.try_emplace("systemProcessId", (int64_t)pid);
-  body.try_emplace("isLocalProcess", true);
+  body.try_emplace("isLocalProcess",
+                   dap.target.GetPlatform().GetName() ==
+                       lldb::SBPlatform::GetHostPlatform().GetName());
   const char *startMethod = nullptr;
   switch (launch_method) {
   case Launch:
diff --git a/lldb/tools/lldb-dap/Handler/RestartRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/RestartRequestHandler.cpp
index 45dd7ddce0428..706e66fd643a3 100644
--- a/lldb/tools/lldb-dap/Handler/RestartRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/RestartRequestHandler.cpp
@@ -124,6 +124,8 @@ void RestartRequestHandler::operator()(
     return;
   }
 
+  SendProcessEvent(dap, Attach);
+
   // This is normally done after receiving a "configuration done" request.
   // Because we're restarting, configuration has already happened so we can
   // continue the process right away.

@da-viper
Copy link
Contributor

we could also add the pointerSize to the process event.

Comment on lines 140 to 142
body.try_emplace("isLocalProcess",
dap.target.GetPlatform().GetName() ==
lldb::SBPlatform::GetHostPlatform().GetName());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we expose Platform::IsHost through the SB API?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we could make SBPlatform comparable?

Copy link
Collaborator

@jimingham jimingham Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Knowing whether the process you are debugging is running locally seems a generally useful piece of information, that should be simple to ask.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added bool SBPlatform::IsHost() const to the lldb API.

@ashgti
Copy link
Contributor Author

ashgti commented Oct 17, 2025

we could also add the pointerSize to the process event.

Sure, that should be simple to add

@ashgti ashgti requested a review from JDevlieghere October 20, 2025 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants