-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[lldb-dap] Specify the executable path in the attach info #138557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb-dap] Specify the executable path in the attach info #138557
Conversation
Currently, we are only using the executable name when attaching. The AttachRequestHandler isn't setting the path in the attach info, which means that we rely on the target when attaching by name. When wo go down this path, we only look at the executable's filename, not its full path. Since we know the full path from the attach arguments, we should specify it in the attach info. Fixes llvm#138197
@llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) ChangesCurrently, we are only using the executable name when attaching. The AttachRequestHandler isn't setting the path in the attach info, which means that we rely on the target when attaching by name. When wo go down this path, we only look at the executable's filename, not its full path. Since we know the full path from the attach arguments, we should specify it in the attach info. Fixes #138197 Full diff: https://github.com/llvm/llvm-project/pull/138557.diff 1 Files Affected:
diff --git a/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
index 7084d30f2625b..a509aa09a385c 100644
--- a/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
@@ -49,7 +49,6 @@ void AttachRequestHandler::operator()(const llvm::json::Object &request) const {
llvm::json::Object response;
lldb::SBError error;
FillResponse(request, response);
- lldb::SBAttachInfo attach_info;
const int invalid_port = 0;
const auto *arguments = request.getObject("arguments");
const lldb::pid_t pid =
@@ -58,10 +57,7 @@ void AttachRequestHandler::operator()(const llvm::json::Object &request) const {
GetInteger<uint64_t>(arguments, "gdb-remote-port").value_or(invalid_port);
const auto gdb_remote_hostname =
GetString(arguments, "gdb-remote-hostname").value_or("localhost");
- if (pid != LLDB_INVALID_PROCESS_ID)
- attach_info.SetProcessID(pid);
const auto wait_for = GetBoolean(arguments, "waitFor").value_or(false);
- attach_info.SetWaitForLaunch(wait_for, false /*async*/);
dap.configuration.initCommands = GetStrings(arguments, "initCommands");
dap.configuration.preRunCommands = GetStrings(arguments, "preRunCommands");
dap.configuration.postRunCommands = GetStrings(arguments, "postRunCommands");
@@ -161,7 +157,13 @@ void AttachRequestHandler::operator()(const llvm::json::Object &request) const {
dap.target.ConnectRemote(listener, connect_url.c_str(), "gdb-remote",
error);
} else {
- // Attach by process name or id.
+ // Attach by pid or process name.
+ lldb::SBAttachInfo attach_info;
+ if (pid != LLDB_INVALID_PROCESS_ID)
+ attach_info.SetProcessID(pid);
+ if (dap.configuration.program.has_value())
+ attach_info.SetExecutable(dap.configuration.program->data());
+ attach_info.SetWaitForLaunch(wait_for, false /*async*/);
dap.target.Attach(attach_info, error);
}
} else {
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Currently, we are only using the executable name when attaching. The AttachRequestHandler isn't setting the path in the attach info, which means that we rely on the target when attaching by name. When wo go down this path, we only look at the executable's filename, not its full path. Since we know the full path from the attach arguments, we should specify it in the attach info. Fixes llvm#138197
Currently, we are only using the executable name when attaching. The AttachRequestHandler isn't setting the path in the attach info, which means that we rely on the target when attaching by name. When wo go down this path, we only look at the executable's filename, not its full path. Since we know the full path from the attach arguments, we should specify it in the attach info.
Fixes #138197