Commit Graph

469 Commits

Author SHA1 Message Date
Adrian Vogelsgesang
620738e662 [lldb-dap][test] Fix readMemory test (#109057)
So far, the test case was also testing the offset -1. This test cases
failed if the string is immediately at the beginning of the memory
region, though, and the offset -1 hence belonged to a different memory
region.

The fix is rather straightforward:
Passing an offset of -1 is not used by any actual clients of lldb-dap,
anyway. As such, this commit simply removes the corresponding test case.
2024-09-18 16:16:31 +02:00
David Spickett
ab38ec9ac3 [lldb][lldb-dap] Disable read memory test on Windows
This isn't strictly a Windows issue but for now it's the only bot
that was hit by this failure.

It can happen on Linux too but I expect we'll fix it and remove the
skip soon anyway.

Test was added in #104317.
2024-09-17 12:51:46 +00:00
David Spickett
b39a100ff4 [lldb][lldb-dap] Remove unused includes in memory test
Added in 3acb1eac5e
2024-09-17 09:30:14 +00:00
Adrian Vogelsgesang
0cc2cd7815 [lldb-dap] Provide declarationLocation for variables (#102928)
This commit implements support for the "declaration location" recently
added by microsoft/debug-adapter-protocol#494 to the debug adapter
protocol.

For the `declarationLocationReference` we need a variable ID similar to
the `variablesReference`. I decided to simply reuse the
`variablesReference` here and renamed `Variables::expandable_variables`
and friends accordingly. Given that almost all variables have a
declaration location, we now assign those variable ids to all variables.

While `declarationLocationReference` effectively supersedes
`$__lldb_extensions.declaration`, I did not remove this extension, yet,
since I assume that there are some closed-source extensions which rely
on it.

I tested this against VS-Code Insiders. However, VS-Code Insiders
currently only supports `valueLoctionReference` and not
`declarationLocationReference`, yet. Locally, I hence published the
declaration locations as value locations, and VS Code Insiders navigated
to the expected places. Looking forward to proper VS Code support for
`declarationLocationReference`.
2024-09-17 02:18:52 +02:00
Adrian Vogelsgesang
3acb1eac5e [lldb-dap] Support inspecting memory (#104317)
Add support for the `readMemory` request which allows VS-Code to
inspect memory. Also, add `memoryReference` to variables and `evaluate`
responses, such that the binary view can be opened from the variables
view and from the "watch" pane.
2024-09-16 22:56:20 +02:00
Pavel Labath
e054712a85 [lldb] Deflake TestDAP_attach (#108226)
The test failed in
<https://lab.llvm.org/buildbot/#/builders/162/builds/5785> due to frame
variable not being in stop commands, even though the DAP log shows the
command being present there. I'm pretty sure this is a race in the test
the collection of the test log. I fix that by making sure we wait for
the expected output, and also by increasing the timeout (1s is cutting
it very close).

The arm failure link is no longer functional, but I'm fairly certain
that this was the cause of those flakes as well.
2024-09-13 11:21:50 +02:00
Pavel Labath
069b841c2e [lldb] Make sure TestDAP_subtleFrames actually uses libc++ (#108227)
Without this, the binary would still be built with libstdc++, if that's
the system/compiler default.
2024-09-13 11:18:05 +02:00
Vladislav Dzhidzhoev
44fc987ed1 [lldb][test] Toolchain detection rewrite in Python (#102185)
This fix is based on a problem with cxx_compiler and cxx_linker macros
on Windows.
There was an issue with compiler detection in paths containing "icc". In
such case, Makefile.rules thought it was provided with icc compiler.

To solve that, utilities detection has been rewritten in Python.
The last element of compiler's path is separated, taking into account
the platform path delimiter, and compiler type is extracted, with regard
of possible cross-toolchain prefix.

---------

Co-authored-by: Pavel Labath <pavel@labath.sk>
2024-09-11 16:04:01 +03:00
John Harrison
5b4100cc35 [lldb-dap] Improve stackTrace and exceptionInfo DAP request handlers (#105905)
Refactoring `stackTrace` to perform frame look ups in a more on-demand
fashion to improve overall performance.

Additionally adding additional information to the `exceptionInfo`
request to report exception stacks there instead of merging the
exception stack into the stack trace. The `exceptionInfo` request is
only called if a stop event occurs with `reason='exception'`, which
should mitigate the performance of `SBThread::GetCurrentException`
calls.

Adding unit tests for exception handling and stack trace supporting.
2024-09-10 12:40:20 -07:00
David Spickett
5a658ee933 [lldb][test] Skip some lldb-server tests on Windows
These are known to return errors occasionaly on our Windows on Arm
bot.
2024-09-04 09:43:18 +00:00
Da-Viper
7d7d2d2b54 [lldb-dap][test] Fix: Typo in unresolved test (#107030)
There is a typo in an assertion that causes the instruction break-point
test to be unresolved
2024-09-03 08:37:59 +02:00
David Spickett
f7d6dfa005 [lldb][lldb-dap] Enable more tests on Windows
These few worked without changes.
2024-08-29 13:33:30 +00:00
David Spickett
b2a820faea [lldb][lldb-dap][test] Enable Launch tests
Add Windows include equivalents for includes and shell command.
2024-08-29 11:55:35 +00:00
David Spickett
ae34257e90 [lldb][lldb-dap][test] Skip logpoint test on Windows again
This one snuck into the previous patch. The test program needs
updating if it's ever going to work on Windows.
2024-08-29 08:33:34 +00:00
David Spickett
c954306ef7 [lldb][lldb-dap][test] Enable more tests on Windows
These tests "just work" on our Windows On Arm machine.
2024-08-29 07:37:02 +00:00
David Spickett
af3ee626a3 [lldb][lldb-dap][test] Enable more attach tests on Windows
By adding the equivalent includes.
2024-08-28 16:51:45 +00:00
David Spickett
a3cd8d76de [lldb][lldb-dap][test] Enable variable tests on Windows
At least for our Windows on Arm machine compiling with clang-cl,
it has inverted which variables get a `::` prefix.

Would not surprise me if msvc does the opposite so feel free to
revert if these tests fail for you.
2024-08-28 14:42:06 +00:00
Santhosh Kumar Ellendula
fbef4c2d31 [lldb][lldb-dap] Fix for TestDAP_instruction_breakpoint.py test failure on windows. (#106200)
TestDAP_instruction_breakpoint.py failed on windows, so these tests were
skipped for windows build.

---------

Co-authored-by: Santhosh Kumar Ellendula <sellendu@hu-sellendu-hyd.qualcomm.com>
Co-authored-by: Santhosh Kumar Ellendula <sellendu@hu-sellendu-lv.qualcomm.com>
2024-08-27 10:31:18 +01:00
Santhosh Kumar Ellendula
89c27d6b07 [lldb-dap] Enabling instruction breakpoint support to lldb-dap. (#105278)
Added support for "supportsInstructionBreakpoints" capability and now it
this command is triggered when we set instruction breakpoint.
We need this support as part of enabling disassembly view debugging.
Following features should work as part of this feature enablement:

1. Settings breakpoints in disassembly view: Unsetting the breakpoint is
not happening from the disassembly view. Currently we need to unset
breakpoint manually from the breakpoint List. Multiple breakpoints are
getting set for the same $

2. Step over, step into, continue in the disassembly view

The format for DisassembleRequest and DisassembleResponse at
https://raw.githubusercontent.com/microsoft/vscode/master/src/vs/workbench/contrib/debug/common/debugProtocol.d.ts
.

Ref Images:
Set instruction breakpoint in disassembly view:

![image](https://github.com/user-attachments/assets/833bfb34-86f4-40e2-8c20-14b638a612a2)

After issuing continue:

![image](https://github.com/user-attachments/assets/884572a3-915e-422b-b8dd-d132e5c00de6)

---------

Co-authored-by: Santhosh Kumar Ellendula <sellendu@hu-sellendu-hyd.qualcomm.com>
Co-authored-by: Santhosh Kumar Ellendula <sellendu@hu-sellendu-lv.qualcomm.com>
2024-08-27 00:19:39 +05:30
Adrian Prantl
9e9e8238df Revert "Revert "[lldb-dap] Mark hidden frames as "subtle" (#105457)""
This reverts commit aa70f83e66.
2024-08-23 11:06:01 -07:00
Dmitri Gribenko
aa70f83e66 Revert "[lldb-dap] Mark hidden frames as "subtle" (#105457)"
This reverts commit 6f456024c3, which
depends on https://github.com/llvm/llvm-project/pull/104523, which I'm
reverting.
2024-08-22 13:24:57 +02:00
John Harrison
8e0b9c8592 [lldb-dap] Skip the lldb-dap output test on windows, it seems all the lldb-dap tests are disabled on windows. (#105604)
This should fix https://lab.llvm.org/buildbot/#/builders/141/builds/1747
2024-08-21 18:52:48 -07:00
John Harrison
30ca06c4d0 [lldb-dap] When sending a DAP Output Event break each message into separate lines. (#105456)
Previously, when output like `"hello\nworld\n"` was produced by lldb (or
the process) the message would be sent as a single Output event. By
being a single event this causes VS Code to treat this as a single
message in the console when handling displaying and filtering in the
Debug Console.

Instead, with these changes we send each line as its own event. This
results in VS Code representing each line of output from lldb-dap as an
individual output message.

Resolves #105444
2024-08-21 13:48:29 -07:00
Adrian Vogelsgesang
6257a98b25 [lldb-dap] Implement StepGranularity for "next" and "step-in" (#105464)
VS Code requests the `instruction` stepping granularity if the assembly
view is currently focused. By implementing `StepGranularity`, we can
hence properly single-step through assembly code.
2024-08-21 20:30:10 +02:00
Adrian Vogelsgesang
6f456024c3 [lldb-dap] Mark hidden frames as "subtle" (#105457)
This commit takes advantage of the recently introduced
`SBFrame::IsHidden` to show those hidden frames as "subtle" frames in
the UI. E.g., VS Code hides those stack frames by default, and renders
them as grayed out frames, in case the user decides to show them in the
stack trace
2024-08-21 08:25:57 +02:00
Kendal Harland
2ea4a03c0f Fix test assertions in TestDAP_stepInTargets.py (#96687)
The strings this test is using seem to consistently fail to match
against the expected values when built & run targeting Windows amd64.
This PR updates them to the expected values.

To fix the test and avoid over-specifying for a specific platform, use
`assertIn(<target-substring>,...)` to see if we've got the correct
target label instead of comparing the demangler output for an exact
string match.

---------

Co-authored-by: kendal <kendal@thebrowser.company>
2024-07-16 12:59:08 +02:00
jeffreytan81
db9ac92501 Add lldb version into initialize response lldb-dap (#98703)
Frequently, while troubleshooting user's debugging issues in VScode, we
would like to know lldb version so that we can confirm if certain
patch/feature is in or not.

This PR adds version string into `initialize` response so that telemetry
can track it.

---------

Co-authored-by: jeffreytan81 <jeffreytan@fb.com>
2024-07-15 20:03:50 -04:00
Santhosh Kumar Ellendula
a52be0cc11 [lldb-dap] Added "port" property to vscode "attach" command. (#91570)
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>
2024-06-28 10:20:50 -05:00
Eisuke Kawashima
fd35a92300 [lldb] fix(lldb/**.py): fix comparison to True/False (#94039)
from PEP8
(https://peps.python.org/pep-0008/#programming-recommendations):

> Comparisons to singletons like None should always be done with is or
is not, never the equality operators.

Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
2024-06-26 15:55:15 +01:00
Pavel Labath
c053ec95f7 [lldb] Fix TestDAP_runInTerminal for #96256
change the expected error msg.
2024-06-24 14:16:24 +02:00
Jonas Devlieghere
bf3e3289d6 [lldb] Unify Platform::ResolveExecutable (#96256)
The Platform class currently has two functions to resolve an executable:
`ResolveExecutable` and `ResolveRemoteExecutable`. The former strictly
deals with local files while the latter can handle potentially remote
files. I couldn't figure out why the distinction matters, at the latter
is a super-set of the former.

To make things even more confusion, we had a similar but not identical
implementation in RemoteAwarePlatform where its implementation of
`ResolveExecutable` could handle remote files. To top it all off, we had
copy-pasted implementation, dead code included in
`PlatformAppleSimulator` and `PlatformRemoteDarwinDevice`.

I went ahead and unified all the different implementation on the
original `ResolveRemoteExecutable` implementation. As far as I can tell,
it should work for every other platform, and the test suite (on macOS)
seems to agree with me, except for a small wording change.
2024-06-21 11:29:49 -07:00
Jonas Devlieghere
22ea97d7bf [lldb] Use packaging module instead of pkg_resources (#93712)
Use the packaging [1] module for parsing version numbers, instead of
pkg_resources which is distributed with setuptools. I recently switched
over to using the latter, knowing it was deprecated (in favor of the
packaging module) because it comes with Python out of the box. Newer
versions of setuptools have removed `pkg_resources` so we have to use
packaging.

[1] https://pypi.org/project/packaging/
2024-06-13 16:00:12 -07:00
Jay Foad
d4a0154902 [llvm-project] Fix typo "seperate" (#95373) 2024-06-13 20:20:27 +01:00
Miro Bucko
11a4d43f4a Fix flaky TestDAP_console test. (#94494)
Test Plan:
llvm-lit
llvm-project/lldb/test/API/tools/lldb-dap/console/TestDAP_console.py
2024-06-12 06:21:17 +07:00
Dmitry Vasilyev
a6cc363b27 [lldb] Disable TestPtyServer API test when remote testing (#94587)
The local PTY is not available for the remotely executed lldb-server to
pass the test. Also, in general, we cannot execute the local lldb-server
instance because it could be compiled for the different system/cpu
target.
2024-06-06 10:02:27 +01:00
Jonas Devlieghere
39e12e0ab2 [lldb] Update error message in TestDAP_optimized after #94420
Fixes:
  https://lab.llvm.org/buildbot/#/builders/68/builds/75571
2024-06-05 11:25:17 -07:00
Pavel Labath
d00731cb7f [lldb] s/assertEquals/assertEqual in TestDAP_variables_children 2024-06-03 11:23:51 +02:00
Dmitry Vasilyev
b62ba7f5b1 [lldb] Fixed the TestGdbRemotePlatformFile test running on a remote target (#93832)
Skip checking of few stat fields like st_dev (ID of device containing
file) in case of a remote target.
2024-05-30 19:57:16 +04:00
Dmitry Vasilyev
facb767e5b [lldb] Fixed the TestGdbRemoteLibrariesSvr4Support test running on a remote target (#93825)
The TestGdbRemoteLibrariesSvr4Support test failed in case of Linux
x86_64 host and Linux Aarch64 target. Installing libraries to the remote
target is not enough. This test actively uses self.getBuildDir() and
os.path.realpath() which does not work in case of the remote target. So,
disable this test for remote target now.
2024-05-30 19:56:04 +04:00
Pavel Labath
f38ebec710 [lldb-dap] Don't call GetNumChildren on non-indexed synthetic variables (#93534)
A synthetic child provider might need to do considerable amount of work
to compute the number of children. lldb-dap is currently calling that
for all synthethic variables, but it's only actually using the value for
values which it deems to be "indexed" (which is determined by looking at
the name of the first child). This patch reverses the logic so that
GetNumChildren is only called for variables with a suitable first child.
2024-05-30 09:54:13 +02:00
Pavel Labath
fa6377119c [lldb-dap] Automatically skip lldb-dap tests for remote platforms (#93169)
The don't currently work (and they're also not particularly useful,
since all of the remote stuff happens inside lldb).

This saves us from annotating tests one by one.
2024-05-24 08:52:32 +02:00
Pavel Labath
af8f1554b8 [lldb-dap] Don't send expanded descriptions for "hover" expressions (#92726)
VSCode will automatically ask for the children (in structured form) so
there's no point in sending the textual representation. This can make
displaying hover popups for complex variables with complicated data
formatters much faster. See discussion on #77026 for context.
2024-05-21 10:37:41 +02:00
Jonas Devlieghere
a4ad05284e [lldb-dap] Replace assertEquals with assertEqual (NFC)
Fixes new test that were added or modified after #82073. Also fixes a
formatting issue.
2024-05-17 10:12:51 -07:00
Dmitry Vasilyev
d38ea8c4c8 [lldb] Fixed the test TestGdbRemoteAttachWait running on a remote target (#92413)
Install `_exe_to_attach` to a remote target if necessary.
2024-05-17 20:14:09 +04:00
Pavel Labath
33bf08ec36 [lldb-dap] Correctly detect alias commands with arguments in repl (#92137)
ResolveCommand will not succeed for an alias command with arguments, and
the code wasn't providing any. Replace that with explicit query(ies) for
the existence of a command with the given name.
2024-05-17 11:24:20 +02:00
Dmitry Vasilyev
c7ae8c6639 [lldb] Fixed the DAP tests in case of a remote target (#92416)
These tests are based on dap_server which runs locally. These tests
failed in case of Windows host and Linux target.
2024-05-16 21:30:31 +04:00
Dmitry Vasilyev
d665d51c92 [lldb] Fixed the DAP tests in case of a remote target (#92398)
These tests failed in case of Windows host and Linux target, because
dap_server tried to run ELF file on Windows.
2024-05-16 18:34:58 +04:00
Dmitry Vasilyev
2bc9af9656 [lldb][Windows] Disable the TestGdbRemoteLibrariesSvr4Support test for Windows host (#92341)
Windows does not allow quotes in file names. So it is impossible to
build `libsvr4lib_b".so` on Windows.
2024-05-16 16:49:56 +04:00
Dmitry Vasilyev
34f33babc2 [lldb] Fixed the TestGdbRemoteCompletion test (#92268)
Do not try to run lldb-server on localhost in case of the remote target.
2024-05-15 20:48:16 +04:00
Dmitry Vasilyev
eacefba9aa [lldb][Windows] Fixed tests TestPty and TestPtyServer (#92090)
The tests TestPty and TestPtyServer use the Unix specific python builtin
module termios. They are failed in case of Windows host and Linux
target. Disable them for Windows host too.
2024-05-15 14:44:24 +04:00