Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lldb/bindings/interface/SBPlatformExtensions.i
Original file line number Diff line number Diff line change
@@ -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
}
1 change: 1 addition & 0 deletions lldb/bindings/interfaces.swig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions lldb/include/lldb/API/SBPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions lldb/source/API/SBPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
40 changes: 23 additions & 17 deletions lldb/tools/lldb-dap/EventHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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" ]
Expand All @@ -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" ]
Expand All @@ -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];
Expand All @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions lldb/tools/lldb-dap/Handler/RestartRequestHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading