[Lldb-commits] [lldb] 841e1e1 - [lldb-dap] Send a 'process' event on restart. (#163833)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 21 14:47:17 PDT 2025
Author: John Harrison
Date: 2025-10-21T14:47:12-07:00
New Revision: 841e1e1e17c3bd83e9eaa9e10a057b8217eb8de3
URL: https://github.com/llvm/llvm-project/commit/841e1e1e17c3bd83e9eaa9e10a057b8217eb8de3
DIFF: https://github.com/llvm/llvm-project/commit/841e1e1e17c3bd83e9eaa9e10a057b8217eb8de3.diff
LOG: [lldb-dap] Send a 'process' event on restart. (#163833)
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.
Added:
lldb/bindings/interface/SBPlatformExtensions.i
Modified:
lldb/bindings/interfaces.swig
lldb/include/lldb/API/SBPlatform.h
lldb/source/API/SBPlatform.cpp
lldb/tools/lldb-dap/EventHelper.cpp
lldb/tools/lldb-dap/Handler/RestartRequestHandler.cpp
Removed:
################################################################################
diff --git a/lldb/bindings/interface/SBPlatformExtensions.i b/lldb/bindings/interface/SBPlatformExtensions.i
new file mode 100644
index 0000000000000..86759bda50630
--- /dev/null
+++ b/lldb/bindings/interface/SBPlatformExtensions.i
@@ -0,0 +1,7 @@
+%extend lldb::SBPlatform {
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ is_host = property(IsHost, None, doc='''A read only property that returns a boolean value that indiciates if this platform is the host platform.''')
+ %}
+#endif
+}
diff --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
index e71ed136f20e6..b3d44979c916c 100644
--- a/lldb/bindings/interfaces.swig
+++ b/lldb/bindings/interfaces.swig
@@ -53,6 +53,7 @@
%include "./interface/SBModuleSpecDocstrings.i"
%include "./interface/SBMutexExtensions.i"
%include "./interface/SBPlatformDocstrings.i"
+%include "./interface/SBPlatformExtensions.i"
%include "./interface/SBProcessDocstrings.i"
%include "./interface/SBProcessInfoDocstrings.i"
%include "./interface/SBProgressDocstrings.i"
diff --git a/lldb/include/lldb/API/SBPlatform.h b/lldb/include/lldb/API/SBPlatform.h
index d63d2ed1eaba6..7cb19b3f7ec46 100644
--- a/lldb/include/lldb/API/SBPlatform.h
+++ b/lldb/include/lldb/API/SBPlatform.h
@@ -112,6 +112,9 @@ class LLDB_API SBPlatform {
bool IsValid() const;
+ /// Returns true if this platform is the host platform, otherwise false.
+ bool IsHost() const;
+
void Clear();
const char *GetWorkingDirectory();
diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp
index ec59e27a08b30..9a0b47ce80336 100644
--- a/lldb/source/API/SBPlatform.cpp
+++ b/lldb/source/API/SBPlatform.cpp
@@ -331,6 +331,11 @@ SBPlatform::operator bool() const {
return m_opaque_sp.get() != nullptr;
}
+bool SBPlatform::IsHost() const {
+ LLDB_INSTRUMENT_VA(this);
+ return m_opaque_sp.get() != nullptr && m_opaque_sp->IsHost();
+}
+
void SBPlatform::Clear() {
LLDB_INSTRUMENT_VA(this);
diff --git a/lldb/tools/lldb-dap/EventHelper.cpp b/lldb/tools/lldb-dap/EventHelper.cpp
index 3042d3293b482..c5d5f2bb59b42 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>
@@ -78,11 +79,9 @@ void SendExtraCapabilities(DAP &dap) {
// { "$ref": "#/definitions/Event" },
// {
// "type": "object",
-// "description": "Event message for 'process' event type. The event
-// indicates that the debugger has begun debugging a
-// new process. Either one that it has launched, or one
-// that it has attached to.",
-// "properties": {
+// "description": "The event indicates that the debugger has begun
+// debugging a new process. Either one that it has launched, or one that
+// it has attached to.", "properties": {
// "event": {
// "type": "string",
// "enum": [ "process" ]
@@ -93,31 +92,37 @@ void SendExtraCapabilities(DAP &dap) {
// "name": {
// "type": "string",
// "description": "The logical name of the process. This is
-// usually the full path to process's executable
-// file. Example: /home/myproj/program.js."
+// usually the full path to process's executable file. Example:
+// /home/example/myproj/program.js."
// },
// "systemProcessId": {
// "type": "integer",
-// "description": "The system process id of the debugged process.
-// This property will be missing for non-system
-// processes."
+// "description": "The process ID of the debugged process, as
+// assigned by the operating system. This property should be
+// omitted for logical processes that do not map to operating
+// system processes on the machine."
// },
// "isLocalProcess": {
// "type": "boolean",
// "description": "If true, the process is running on the same
-// computer as the debug adapter."
+// computer as the debug adapter."
// },
// "startMethod": {
// "type": "string",
// "enum": [ "launch", "attach", "attachForSuspendedLaunch" ],
// "description": "Describes how the debug engine started
-// debugging this process.",
-// "enumDescriptions": [
+// debugging this process.", "enumDescriptions": [
// "Process was launched under the debugger.",
// "Debugger attached to an existing process.",
-// "A project launcher component has launched a new process in
-// a suspended state and then asked the debugger to attach."
+// "A project launcher component has launched a new process in a
+// suspended state and then asked the debugger to attach."
// ]
+// },
+// "pointerSize": {
+// "type": "integer",
+// "description": "The size of a pointer or address for this
+// process, in bits. This value may be used by clients when
+// formatting addresses for display."
// }
// },
// "required": [ "name" ]
@@ -126,7 +131,7 @@ void SendExtraCapabilities(DAP &dap) {
// "required": [ "event", "body" ]
// }
// ]
-// }
+// },
void SendProcessEvent(DAP &dap, LaunchMethod launch_method) {
lldb::SBFileSpec exe_fspec = dap.target.GetExecutable();
char exe_path[PATH_MAX];
@@ -136,7 +141,8 @@ 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().IsHost());
+ body.try_emplace("pointerSize", dap.target.GetAddressByteSize() * 8);
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..100173bfc3082 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, Launch);
+
// 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.
More information about the lldb-commits
mailing list