-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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] Added "port" property to vscode "attach" command. #91570
Conversation
Adding a "port" property to the VsCode "attach" command likely extends the functionality of the debugger configuratiuon to allow attaching to a process using PID or PORT number. Currently, the "Attach" configuration lets the user specify a pid. We tell the user to use the attachCommands property to run "gdb-remote <port>". Followed the below conditions for "attach" command with "port" and "pid" We should add a "port" property. If port is specified and pid is not, use that port to attach. If both port and pid are specified, return an error saying that the user can't specify both pid and port. Ex - launch.json { "version": "0.2.0", "configurations": [ { "name": "lldb-dap Debug", "type": "lldb-dap", "request": "attach", "port":1234, "program": "${workspaceFolder}/a.out", "args": [], "stopOnEntry": false, "cwd": "${workspaceFolder}", "env": [], } ] }
Adding a "port" property to the VsCode "attach" command likely extends the functionality of the debugger configuration to allow attaching to a process using PID or PORT number. Currently, the "Attach" configuration lets the user specify a pid. We tell the user to use the attachCommands property to run "gdb-remote ". Followed the below conditions for "attach" command with "port" and "pid" We should add a "port" property. If port is specified and pid is not, use that port to attach. If both port and pid are specified, return an error saying that the user can't specify both pid and port. Ex - launch.json { "version": "0.2.0", "configurations": [ { "name": "lldb-dap Debug", "type": "lldb-dap", "request": "attach", "port":1234, "program": "${workspaceFolder}/a.out", "args": [], "stopOnEntry": false, "cwd": "${workspaceFolder}", "env": [], } ] } In this patch we have resolved code formatting issues and fixed "test_by_name" failure.
✅ With the latest revision this PR passed the Python code formatter. |
lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
Outdated
Show resolved
Hide resolved
I apologize for missing your earlier comment. To clarify. Please let me know if my understating is incorrect. |
Your understanding of the code is correct. What I am suggesting is basically to emulate this command line behavior in vscode. Basically, instead of two host+port settings, you could have one setting with a sufficiently vague name ("connection url", "remote address", ...) to cover the expanded scope. Then, you implementation could take the user-provided string and fill in the blanks:
The advantage of this is that you'd automatically support every connection protocol that lldb understands with almost no effort. If we stick to the current implementation, then if someone later needs to connect through unix sockets (or whatever), he would have to go back and add another setting to support connecting through that. Now, I do see the appeal of having an explicit host/port fields (they're much easier to understand for the average user), which is why I'm not insisting on this approach. Nonetheless, I think this is an option worth considering, and I think we could avoid most of the confusion by carefully crafting the description of this field to guide the user to the most common scenarios. |
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.
The code looks good, a few nits in comments.
@labath: did we resolve the port race condition testing issue? We really don't want this to be a flaky test on overloaded systems. It would be nice to make sure this is solid before getting this in.
const auto gdb_remote_port = | ||
GetUnsigned(arguments, "gdb-remote-port", invalid_port); | ||
llvm::StringRef gdb_remote_hostname = | ||
GetString(arguments, "gdb-remote-hostname", "localhost"); |
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.
I know in the past we have used 127.0.0.1
instead of localhost
. The reason is people can modify their config files in their environment and localhost
can be aliased to something else. Not sure if this is an issue
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.
Using 127.0.0.1 can provide slight advantage in terms of consistency and compatibility in specific scenarios.
Any suggestions from others?
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.
There are environments (Google's (default) test environment is like that) that don't have an IPv4 stack configured (just v6), so localhost
would be an advantage there. That said, this definitely wouldn't be the first instance of `127.0.0.1 in lldb.
FWIW, I'm of the opinion that anyone who configures localhost
to point to something other than their local host deserves whatever is coming their way,
The current version of the code should be fine. We just need to sort out the code placement issue. |
…review comments.
…d review comments.
I have shifted "Pipe" class to common location "lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py"
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.
My concerns have been addressed (*), so I'm removing my request for changes. It looks like the only way to do that is to Approve the PR, but I'd suggest getting another approval from a lldb-dap owner as well.
(*) There is still the question of the single "url" setting (to rule them all), but I don't consider myself an authority there.
const auto gdb_remote_port = | ||
GetUnsigned(arguments, "gdb-remote-port", invalid_port); | ||
llvm::StringRef gdb_remote_hostname = | ||
GetString(arguments, "gdb-remote-hostname", "localhost"); |
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.
There are environments (Google's (default) test environment is like that) that don't have an IPv4 stack configured (just v6), so localhost
would be an advantage there. That said, this definitely wouldn't be the first instance of `127.0.0.1 in lldb.
FWIW, I'm of the opinion that anyone who configures localhost
to point to something other than their local host deserves whatever is coming their way,
I'll review this today or tomorrow. Thanks for all the activity! |
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.
This LGTM
This breaks lldb-api :: tools/lldb-server/commandline/TestGdbRemoteConnection.py on lldb-aarch64-windows bot. |
File "C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\packages\Python\lldbsuite\test\tools\lldb-server\lldbgdbserverutils.py", line 1045, in init Looks like "import random" should have been added to lldbgdbserverutils.py when the pipe class was moved from TestGDBRemoteConnection.py. |
This fixes TestGdbRemoteConnection.py failing after PR #91570 on AArch64 Windows LLDB buildbot. https://lab.llvm.org/buildbot/#/builders/141/builds/376
) Adding a "port" property to the VsCode "attach" command likely extends the functionality of the debugger configuration to allow attaching to a process using PID or PORT number. Currently, the "Attach" configuration lets the user specify a pid. We tell the user to use the attachCommands property to run "gdb-remote ". Followed the below conditions for "attach" command with "port" and "pid" We should add a "port" property. If port is specified and pid is not, use that port to attach. If both port and pid are specified, return an error saying that the user can't specify both pid and port. Ex - launch.json { "version": "0.2.0", "configurations": [ { "name": "lldb-dap Debug", "type": "lldb-dap", "request": "attach", "gdb-remote-port":1234, "program": "${workspaceFolder}/a.out", "args": [], "stopOnEntry": false, "cwd": "${workspaceFolder}", "env": [], } ] } --------- Co-authored-by: Santhosh Kumar Ellendula <sellendu@hu-sellendu-hyd.qualcomm.com> Co-authored-by: Santhosh Kumar Ellendula <sellendu@hu-sellendu-lv.qualcomm.com>
This fixes TestGdbRemoteConnection.py failing after PR llvm#91570 on AArch64 Windows LLDB buildbot. https://lab.llvm.org/buildbot/#/builders/141/builds/376
This fixes TestGdbRemoteConnection.py failing after PR llvm#91570 on AArch64 Windows LLDB buildbot. https://lab.llvm.org/buildbot/#/builders/141/builds/376
Added "gdb-remote-port" and "gdb-remote-hostname" attach properties usage in README.md. This was missed in PR llvm#91570
Added "gdb-remote-port" and "gdb-remote-hostname" attach properties usage in README.md and updated package.json version to 0.2.3 This was missed in PR #91570 --------- Co-authored-by: Santhosh Kumar Ellendula <sellendu@hu-sellendu-hyd.qualcomm.com> Co-authored-by: Santhosh Kumar Ellendula <sellendu@hu-sellendu-lv.qualcomm.com>
…#99926) Added "gdb-remote-port" and "gdb-remote-hostname" attach properties usage in README.md and updated package.json version to 0.2.3 This was missed in PR llvm#91570 --------- Co-authored-by: Santhosh Kumar Ellendula <sellendu@hu-sellendu-hyd.qualcomm.com> Co-authored-by: Santhosh Kumar Ellendula <sellendu@hu-sellendu-lv.qualcomm.com> (cherry picked from commit 7345025)
Adding a "port" property to the VsCode "attach" command likely extends the functionality of the debugger configuration to allow attaching to a process using PID or PORT number.
Currently, the "Attach" configuration lets the user specify a pid. We tell the user to use the attachCommands property to run "gdb-remote ".
Followed the below conditions for "attach" command with "port" and "pid"
We should add a "port" property. If port is specified and pid is not, use that port to attach. If both port and pid are specified, return an error saying that the user can't specify both pid and port.
Ex - launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "lldb-dap Debug",
"type": "lldb-dap",
"request": "attach",
"gdb-remote-port":1234,
"program": "${workspaceFolder}/a.out",
"args": [],
"stopOnEntry": false,
"cwd": "${workspaceFolder}",
"env": [],
]
}