Commit Graph

489 Commits

Author SHA1 Message Date
Vladislav Dzhidzhoev
4e80c532c6 [lldb][tests] Fix passing pthread library to a linker for some API tests (#118530)
Specify ENABLE_THREADS := YES within test's Makefile instead of passing
-lpthread explicitly via the compiler's CFLAGS options.

Refactoring fix.

Co-authored-by: Vladimir Vereschaka <vvereschaka@accesssoftek.com>
2024-12-04 16:55:28 +01:00
Michael Buch
ceeb08b9e0 Revert "[lldb-dap] Support column breakpoints (#113787)"
This reverts commit 4f48a81a62.

The newly added test was failing on the public macOS Arm64 bots:
```
======================================================================
FAIL: test_column_breakpoints (TestDAP_breakpointLocations.TestDAP_setBreakpoints)
   Test retrieving the available breakpoint locations.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_breakpointLocations.py", line 77, in test_column_breakpoints
    self.assertEqual(
AssertionError: Lists differ: [{'co[70 chars]e': 41}, {'column': 3, 'line': 42}, {'column': 18, 'line': 42}] != [{'co[70 chars]e': 42}, {'column': 18, 'line': 42}]

First differing element 2:
{'column': 3, 'line': 41}
{'column': 3, 'line': 42}

First list contains 1 additional elements.
First extra element 4:
{'column': 18, 'line': 42}

  [{'column': 39, 'line': 40},
   {'column': 51, 'line': 40},
-  {'column': 3, 'line': 41},
   {'column': 3, 'line': 42},
   {'column': 18, 'line': 42}]
Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang
----------------------------------------------------------------------
Ran 1 test in 1.554s

FAILED (failures=1)
```
2024-11-18 16:15:06 +00:00
Adrian Vogelsgesang
4f48a81a62 [lldb-dap] Support column breakpoints (#113787)
This commit adds support for column breakpoints to lldb-dap.

To do so, support for the `breakpointLocations` request was
added. To find all available breakpoint positions, we iterate over
the line table.

The `setBreakpoints` request already forwarded the column correctly to
`SBTarget::BreakpointCreateByLocation`. However, `SourceBreakpointMap`
did not keep track of multiple breakpoints in the same line. To do so,
the `SourceBreakpointMap` is now indexed by line+column instead of by
line only.

See http://jonasdevlieghere.com/post/lldb-column-breakpoints/ for a
high-level introduction to column breakpoints.
2024-11-16 19:01:12 +01:00
John Harrison
c658d07c4f [lldb-dap] Adjust the evaluate test to use a different lldb command. (#116045)
Previously this used `var` as both an lldb command and variable in the
source to validate the behavior of the 'auto' repl mode. However, `var`
seems to occasionally fail in the CI test when attempting to print some
c++ types. Instead switch the command and variable name to `list` which
should not run the dynamic variable formatting code for c++ objects.

This should fix #116041.
2024-11-13 11:17:07 -08:00
Pavel Labath
6e4cd463e5 [lldb] s/assertEquals/assertEqual TestDAP_sendEvent
New unittest versions don't have the "s" version.
2024-11-08 13:25:23 +01:00
Felipe de Azevedo Piovezan
d6a1501377 [lldb] Skip TestDAP_completions on older versions of libcxx 2024-11-01 08:55:23 -07:00
John Harrison
c5c11f3404 [lldb-dap] Creating an API for sending dap events from a script in lldb-dap. (#112384)
Custom DAP events can be detected using
https://code.visualstudio.com/api/references/vscode-api#debug.onDidReceiveDebugSessionCustomEvent.

This API allows an lldb python script to send events to the DAP
client to allow extensions to handle these custom events.
2024-10-16 17:19:51 -07:00
Stefan Gränitz
3ef630ac33 [lldb] Support tests with nested make invocations on Windows 2/2 (#112360)
Following up from https://github.com/llvm/llvm-project/pull/112342, we
roll out the fix and quote nested `make` invocations in all API tests.
2024-10-16 13:07:02 +02:00
John Harrison
224f62de9e [lldb-dap] Improving the naming consistency of startDebugging reverse request. (#112396)
Adjusting the name from `lldb-dap startDebugging` to `lldb-dap
start-debugging` to improve consistency with other names for commands in
lldb/lldb-dap.
2024-10-15 12:19:21 -07:00
Adrian Vogelsgesang
9f8ae7844d [lldb-dap] Implement value locations for function pointers (#104589)
This commit adds `valueLocationReference` to function pointers and
function references. Thereby, users can navigate directly to the
pointed-to function from within the "variables" pane.

In general, it would be useful to also a add similar location references
also to member function pointers, `std::source_location`,
`std::function`, and many more. Doing so would require extending the
formatters to provide such a source code location.

There were two RFCs about this a while ago:

https://discourse.llvm.org/t/rfc-extending-formatters-with-a-source-code-reference/68375
https://discourse.llvm.org/t/rfc-sbvalue-metadata-provider/68377/26

However, both RFCs ended without a conclusion. As such, this commit now
implements the lowest-hanging fruit, i.e. function pointers. If people
find it useful, I will revive the RFC afterwards.
2024-10-11 03:31:26 +02:00
Vladislav Dzhidzhoev
b773da0c5e [lldb][test] Use $(STRIP) instead of strip in API tests (Darwin-only change) (#111816)
This makes tests more portable.
Make variables for LLVM utils are passed to `make` on Darwin as well.

Co-authored-by: Vladimir Vereschaka <vvereschaka@accesssoftek.com>
2024-10-10 14:21:25 +02:00
David Spickett
b43e003d90 Revert "[lldb][test] Enable TestDAP_runInTerminal on non-x86 architectures" (#111648)
Reverts llvm/llvm-project#111543

https://lab.llvm.org/buildbot/#/builders/18/builds/5140 failed here
again. Clearly there is something different on Arm but I don't know what
it is yet.
2024-10-09 09:55:39 +01:00
David Spickett
de4f2c976f [lldb][test] Enable TestDAP_runInTerminal on non-x86 architectures (#111543)
I don't see an obvious reason it has to be x86 specific and local
testing on Arm and AArch64 is fine.

Originally disabled in 50337fb933 in
response to failures apparently caused by
https://reviews.llvm.org/D93951.

Perhaps those still exist but worth trying this and checking I think.
2024-10-09 09:14:48 +01:00
David Spickett
98c9c1a4d2 [lldb][test] Disable new lldb-dap test on non-x86
Guessing that this is missing because it's failing on Arm 32 bit
and every other test has this requirement.
2024-10-08 14:29:08 +00:00
Da-Viper
d4c1789112 Make env and source map dictionaries #95137 (#106919)
Fixes #95137
2024-10-07 12:38:36 -04:00
Augusto Noronha
47ff13b45b [lldb-dap] Disable TestDAP_optimized under ASAN (#111063)
This test is failing on green dragon and I couldn't figure out why,
disabling it for now under ASAN to get the bot green.

Opened an issue (https://github.com/llvm/llvm-project/issues/111061) to
track the problem.
2024-10-03 13:47:26 -07:00
Adrian Vogelsgesang
a5876bef61 [lldb-dap] Correct auto-completion based on ReplMode and escape char (#110784)
This commit improves the auto-completion in the Debug Console provided
by VS-Code.

So far, we were always suggesting completions for both LLDB commands and
for variables / expressions, even if the heuristic already determined
how the given string will be executed, e.g., because the user explicitly
typed the escape prefix. Furthermore, auto-completion after the escape
character was broken, since the offsets were not adjusted correctly.
With this commit we now correctly take this into account.

Even with this commit, auto-completion does not always work reliably:

* VS Code only requests auto-completion after typing the first
alphabetic character, but not after punctuation characters. This means
that no completions are provided after typing "`"
* LLDB does not provide autocompletions if a string is an exact match.
This means if a user types `l` (which is a valid command), LLDB will not
provide "language" and "log" as potential completions. Even worse, VS
Code caches the completion and does client-side filtering. Hence, even
after typing `la`, no auto-completion for "language" is shown in the UI.

Those issues might be fixed in follow-up commits. Also with those known
issues, the experience is already much better with this commit.

Furthermore, I updated the README since I noticed that it was slightly
inaccurate.
2024-10-03 02:50:46 +02:00
Adrian Vogelsgesang
786dc5a2da [lldb-dap] Simplify readMemory (#109485)
The `readMemory` request used the `MemoryRegionInfo` so it could also
support short reads. Since #106532, this is no longer necessary, as
mentioned by @labath in a comment on #104317.

With this commit, we no longer set the `unreadableBytes` in the result.
But this is optional, anyway, according to the spec, and afaik the
VS Code UI does not make good use of `unreadableBytes`, anyway.

We prefer `SBTarget::ReadMemory` over `SBProcess::ReadMemory`, because
the `memory read` command also reads memory through the target instead
of the process, and because users would expect the UI view and the
results from memory read to be in-sync.
2024-09-25 13:49:42 +02:00
Adrian Vogelsgesang
19ecdedcd2 [lldb-dap] Rename enableDisplayExtendedBacktrace (#109521)
The `enable` prefix is a filler word which adds no additional
information. Rename the setting to `displayExtendedBacktrace`

Given that this setting was only introduced a month ago, and that there
has not been any release since then, I assume that usage is still rather
low. As such, it should be fine to not provide backwards-compatibility
workarounds.
2024-09-22 19:15:16 +02:00
cmtice
2011cbcd84 [lldb-dap] Add feature to remember last non-empty expression. (#107485)
Update lldb-dap so if the user just presses return, which sends an empty
expression, it re-evaluates the most recent non-empty
expression/command. Also udpated test to test this case.
2024-09-20 14:04:44 -07:00
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