Commit Graph

8638 Commits

Author SHA1 Message Date
David Spickett
78c5d9100f [lldb][test] Disable TestLldbGdbServer.py on Linux temporarily (#161868)
While #161510 is dealt with.
2025-10-03 16:54:18 +01:00
Julian Lettner
f4784fd13f [debugserver] Support for qMemTags packet (#160952)
Support for `qMemTags` packet in debugserver which allows usage of
LLDB's `memory tag read` on Darwin.
2025-10-02 13:57:40 -07:00
Alex Langford
dbffd0aeaf [lldb] Add lld requirement to NativePDB test (#161731)
The cpp file fails to build without `lld-link`.
2025-10-02 13:50:11 -07:00
Michael Buch
faf070f062 [lldb][test] TestExprDefinitionInDylib.py adjust test to account for older compiler versions
Skip tests that require `-gstructor-decl-linkage-names` on Clang versions that don't support it.

 Don't pass `-gno-structor-decl-linkage-names` on Clang versions where it the flag didn't exist but it was the default behaviour of the compiler anyway.

Drive-by:
- We used to run `self.expect("Bar()")` which would always fail. So the `error=True` would be true even if we didn't pass the `-gno-structor-linkage-names`. So it wasn't testing the behaviour properly. This patch changes these to `self.expect("expr Bar()")`.
2025-10-02 14:08:40 +01:00
Michael Buch
82b3057a5e [lldb][test] TestAbiTagStructors.py adjust test to account for older compiler versions
Skip tests that require `-gstructor-decl-linkage-names` on Clang
versions that don't support it.

Don't pass `-gno-structor-decl-linkage-names` on Clang versions where it
the flag didn't exist but it was the default behaviour of the compiler
anyway.
2025-10-02 13:48:46 +01:00
Michael Buch
7e6d277d3b [lldb][test] TestStructuredBinding.py: adjust assertion to check for compatible compiler version
Requires a compiler with the changes in https://github.com/llvm/llvm-project/pull/122265
2025-10-02 13:33:21 +01:00
Michael Buch
86ba1986a2 [lldb][test] Un-XFAIL TestDataFormatterStdUnorderedMap.py for older Clang versions
Fixed in https://github.com/llvm/llvm-project/pull/156033
2025-10-02 13:30:43 +01:00
Michael Buch
6382bb5dda [lldb][test] XFAIL TestGlobalSymbolObjCConflict.c on Windows
Failing with:
```
error: command failed with exit status: 1
executed command: 'c:\buildbot\as-builder-10\lldb-x86-64\build\bin\filecheck.exe' 'C:\buildbot\as-builder-10\lldb-x86-64\llvm-project\lldb\test\Shell\Expr\TestGlobalSymbolObjCConflict.c'
.---command stderr------------
| C:\buildbot\as-builder-10\lldb-x86-64\llvm-project\lldb\test\Shell\Expr\TestGlobalSymbolObjCConflict.c:30:11: error: CHECK: expected string not found in input
| // CHECK: (lldb) p OglobalVar
|           ^
| <stdin>:1:1: note: scanning from here
| (lldb) command source -s 0 'C:/buildbot/as-builder-10/lldb-x86-64/build/tools/lldb\test\Shell\lit-lldb-init-quiet'
| ^
| <stdin>:4:1: note: possible intended match here
| (lldb) target create "C:\\buildbot\\as-builder-10\\lldb-x86-64\\build\\tools\\lldb\\test\\Shell\\Expr\\Output\\TestGlobalSymbolObjCConflict.c.tmp.out"
| ^
|
| Input file: <stdin>
| Check file: C:\buildbot\as-builder-10\lldb-x86-64\llvm-project\lldb\test\Shell\Expr\TestGlobalSymbolObjCConflict.c
|
| -dump-input=help explains the following input dump.
|
| Input was:
| <<<<<<
|             1: (lldb) command source -s 0 'C:/buildbot/as-builder-10/lldb-x86-64/build/tools/lldb\test\Shell\lit-lldb-init-quiet'
| check:30'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
|             2: Executing commands in 'C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\test\Shell\lit-lldb-init-quiet'.
| check:30'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|             3: (lldb) command source -C --silent-run true lit-lldb-init
| check:30'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|             4: (lldb) target create "C:\\buildbot\\as-builder-10\\lldb-x86-64\\build\\tools\\lldb\\test\\Shell\\Expr\\Output\\TestGlobalSymbolObjCConflict.c.tmp.out"
| check:30'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| check:30'1     ?                                                                                                                                                       possible intended match
|             5: Current executable set to 'C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\test\Shell\Expr\Output\TestGlobalSymbolObjCConflict.c.tmp.out' (x86_64).
| check:30'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|             6: (lldb) b 27
| check:30'0     ~~~~~~~~~~~~
| >>>>>>
`-----------------------------
error: command failed with exit status: 1
```

We probably need to use LLD here or something. But I don't have a Windows machine to test this on. So XFAILing for now.
2025-10-02 11:59:26 +01:00
Georgiy Samoylov
b181c22c54 [lldb][RISCV] Fixed TestSymbolFileJSON for RISC-V (#161497)
This test failed during testing on the RISC-V target because we couldn't
strip the main label from the binary. main is dynamically linked when
the -fPIC flag is enabled. The RISC-V ABI requires that executables
support loading at arbitrary addresses to enable shared libraries and
secure loading (ASLR). In PIC mode, function addresses cannot be
hardcoded in the code. Instead, code is generated to load addresses from
the GOT/PLT tables, which are initialized by the dynamic loader. The
reference to main thus ends up in .dynsym and is dynamically bound. We
cannot strip main or any other dynamically linked functions because
these functions are referenced indirectly via dynamic linking tables
(.plt and .got). Removing these symbols would break the dynamic linking
mechanism needed to resolve function addresses at runtime, causing the
executable to fail to correctly call them.
2025-10-01 15:40:42 -07:00
Jacob Lalonde
b66dfa7273 [LLDB] Add load core time to target metrics (#161581)
This patch adds a load core time, right now we don't have much insight
into the performance of load core, especially for large coredumps. To
start collecting information on this I've added some minor
instrumentation code to measure the two call sites of `LoadCore`.

I've also added a test to validate the new metric is output in
statistics dump
2025-10-01 21:14:23 +00:00
Michael Buch
9f7e7f7d9c [lldb][MachO] Fix inspection of global variables that start with 'O' (#161521)
On Darwin C-symbols are prefixed with a '_'. The LLDB Macho-O parses
handles Objective-C metadata symbols starting with '_OBJC' specially.
Previously global symbols starting with a '_O' prefix were lost because
of incorrectly scoped if-guards. This patch removes those checks.

There is more cleanup that can be done in this file because there's a
bunch of duplicated checks for these ObjC symbols. I decided to leave
that for an NFC follow-up.

Depends on https://github.com/llvm/llvm-project/pull/161520

rdar://158159242
2025-10-01 16:47:15 +01:00
Michael Buch
7ae3eca657 [lldb][test] Allow '.c' files to be used as shell tests (#161520)
Required for https://github.com/llvm/llvm-project/pull/161521
2025-10-01 16:24:30 +01:00
David Spickett
edb80a8d7f [lldb][test] Fix bf16 test cases on Arm 32-bit (#161528)
Fixes #157674

On ARM, the presence of a specific bf16 type in the AST is gated by: 
```
bool ARMTargetInfo::hasBFloat16Type() const {
  // The __bf16 type is generally available so long as we have any fp registers.
  return HasBFloat16 || (FPU && !SoftFloat);
}
```

And the target we use when evaluating symbols (derived from the program
file, I think, haven't found it yet) does not enable any of this.

This means that we fall back to __fp16.

So for parts of the testing we just need to expect __fp16 instead, and
others we need to skip because now a class looks like it inherits from
itself.

There's a proper fix here somewhere but I don't know what it is yet.
2025-10-01 15:53:10 +01:00
Timur Golubovich
0a0d497993 [lldb][TypeSystemClang] Added unique builtins types for __bf16 and _Float16 (#157674)
During debugging applization with __bf16 and _Float16 float types it was
discovered that lldb creates the same CompilerType for them. This can
cause an infinite recursion error, if one tries to create two struct
specializations with these types and then inherit one specialization
from another.
2025-10-01 11:20:58 +01:00
Michael Buch
332b4deb0d [lldb][IRExecutionUnit] Return error on failure to resolve function address (#161363)
Starting with https://github.com/llvm/llvm-project/pull/148877 we
started encoding the module ID of the function DIE we are currently
parsing into its `AsmLabel` in the AST. When the JIT asks LLDB to
resolve our special mangled name, we would locate the module and resolve
the function/symbol we found in it.

If we are debugging with a `SymbolFileDWARFDebugMap`, the module ID we
encode is that of the `.o` file that is tracked by the debug-map. To
resolve the address of the DIE in that `.o` file, we have to ask
`SymbolFileDWARFDebugMap::LinkOSOAddress` to turn the address of the
`.o` DIE into a real address in the linked executable. This will only
work if the `.o` address was actually tracked by the debug-map. However,
if the function definition appears in multiple `.o` files (which is the
case for functions defined in headers), the linker will most likely
de-deuplicate that definition. So most `.o`'s definition DIEs for that
function won't have a contribution in the debug-map, and thus we fail to
resolve the address.

When debugging Clang on Darwin, e.g., you'd see:
```
(lldb) expr CXXDecl->getName()

error: Couldn't look up symbols:
  $__lldb_func::0x1:0x4000d000002359da:_ZNK5clang9NamedDecl7getNameEv
Hint: The expression tried to call a function that is not present in the target, perhaps because it was optimized out by the compiler.
```
unless you were stopped in the `.o` file whose definition of `getName`
made it into the final executable.

The fix here is to error out if we fail to resolve the address, causing
us to fall back on the old flow which did a lookup by mangled name,
which the `SymbolFileDWARFDebugMap` will handle correctly.

An alternative fix to this would be to encode the
`SymbolFileDWARFDebugMap`'s module-id. And implement
`SymbolFileDWARFDebugMap::ResolveFunctionCallLabel` by doing a mangled
name lookup. The proposed approach doesn't stop us from implementing
that, so we could choose to do it in a follow-up.

rdar://161393045
2025-10-01 08:37:15 +01:00
Michael Buch
eef7a7663d [lldb][DWARFASTParserClang] Simplify obsolete error condition for malformed array member type offsets (#160132)
First time check was introduced in
`fa3ab4599d717feedbb83e08e7f654913942520b` to work around a debug-info
generation bug in Clang. This bug was fixed in Clang-4. The check has
since been adjusted (first in
`808ff186f6a6ba1fd38cc7e00697cd82f4afe540`, and then most recently in
`370db9c62910195e664e82dde6f0adb3e255a4fd`).

This check is getting quite convoluted, and all it does is turn an
`array[1]` into an `array[0]` type when it is deemed correct. At this
point the workaround probably never fires, apart from actually valid
codegen. This patch removes the special conditions and emits the error
specifically in those cases where we know the DWARF is malformed.

Added some shell tests for the error case.
2025-09-29 21:05:37 +01:00
David Spickett
368d59986e [lldb][test] Fix elf-no-shdrs-pt-notes.yaml on Windows (#160827)
Windows paths have different slashes, but I don't think we care about
the exact paths there anyway so I've just checked for the final
filename.

Fixes #160652
2025-09-26 09:15:57 +01:00
Greg Clayton
4193a90b42 Modify ObjectFileELF so it can load notes from PT_NOTE segments. (#160652)
The ObjectFileELF parser was not able to load ELF notes from PT_NOTE
program headers. This patch fixes ObjectFileELF::GetUUID() to check the
program header and parse the notes in any PT_NOTE segments. This will
allow memory ELF files to extract the UUID from an in memory image that
has no section headers. Added a test that creates an ELF file, strips
all section headers, and then makes sure that LLDB can see the UUID
value.
2025-09-25 14:06:48 -07:00
Martin Storsjö
185ae5cdc6 Revert "[LLDB][NativePDB] Create functions with mangled name (#149701)"
This reverts commit e98f34eb08.

This broke demangling of Itanium symbols on i386.
2025-09-25 23:15:04 +03:00
David Spickett
bafcc3e3b3 [lldb][test] Refactor and expand TestMemoryRegionDirtyPages.py (#156035)
This started as me being annoyed that I got loads of this when
inspecting memory regions on Mac:
Modified memory (dirty) page list provided, 0 entries.

So I thought I should test the existing behaviour, which led me to
refactor the existing test to run the same checks on all regions.

In the process I realised that the output is not wrong. There is a
difference between knowing that no pages are dirty and not knowing
anything about dirty pages. We print that there are 0 entries so the
user knows that difference.

The test case now checks "memory region" output as well as API use.
There were also some checks only run on certain regions, like page size,
which now run for all of them.
2025-09-25 10:58:19 +01:00
David Spickett
ed07b3043d [lldb][test] Make hex prefix optional in DWARF union types test
Fixes #159401

On Windows there is no hex prefix, I suspect because somewhere we
print a pointer. I'd prefer to fix that itself but can't get to
a Windows machine at the moment. It's not important to the purpose
of the test anyway.
2025-09-25 09:23:41 +00:00
Greg Clayton
370db9c629 Fix a bug where an error was emitted for GCC union types. (#159401)
GCC doesn't add DW_AT_data_member_location attributes to the
DW_TAG_member children of DW_TAG_union_type types. An error was being
emitted incorrectly for these cases fr om the DWARFASTParserClang. This
fixes that issue and adds a test.
2025-09-24 16:27:43 -07:00
Julian Lettner
5d511b6736 [lldb][test] Unify test infrastructure for checking CPU features (#153914)
This addresses limitations in our testing infrastructure for checking
CPU features. Before this
* `getCPUInfo()` was Linux-only, and the
* `@skipUnlessFeature` decorator was Darwin-only and did not consider
the remote (on device) testing use case.

Introduce `CPUFeature` class as an abstraction to hide the
platform-specific implementations to check for CPU features. Unify local
(on host) and remote (on device) test execution by always going through
`test.run_platform_command()` which uses LLDB's `platform shell <cmd>`
command.

Potential future cleanups: I think `@skipUnlessFeature` decorator could
be used in place of code like this:
```
if not self.isAArch64SME():
    self.skipTest("SME must be present.")
if not self.isAArch64SME2():
    self.skipTest("SME2 must be present.")
```
2025-09-24 13:31:02 -07:00
nerix
e98f34eb08 [LLDB][NativePDB] Create functions with mangled name (#149701)
Before, functions created using the NativePDB plugin would not know
about their mangled name. This showed when printing a stacktrace. There,
only the function name was shown. For
https://github.com/llvm/llvm-project/issues/143149, the mangled function
name is required to separate different parts.

This PR adds that name if available.

The Clang AST nodes also take in a mangled name, which was previously
unset. I don't think this unblocks anything further, because Clang can
mangle the function anyway.
2025-09-24 16:12:54 +02:00
Raul Tambre
c520531cfc [cmake][lldb][test] Respect LIBCXX_LIBDIR_SUBDIR (#159106)
This code in principle needs to match the one in libc++ but hasn't been updated to account for
LIBCXX_LIBDIR_SUBDIR so tests don't work if LLVM is built with it specified.

Fixes: ed155f3f23
2025-09-24 14:42:37 +03:00
nerix
cae73be8a6 [LLDB][PDB] Fix plugin warning message style (#160398)
Makes the warning message conform to the [LLVM error and warning
style](https://llvm.org/docs/CodingStandards.html#error-and-warning-messages)
as mentioned in
https://github.com/llvm/llvm-project/pull/160067#discussion_r2373391186.
2025-09-24 09:15:53 +02:00
David Spickett
70bd610e43 [lldb][test] Fix tpyo in TestDAP_module.py skip
Fixes 1af2ddbbcf
2025-09-23 14:23:49 +00:00
David Spickett
1af2ddbbcf [lldb][test] Disable part of TestDAP_module.py on Linux
This test sometimes times out in CI runs:
/usr/bin/python3 /home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/./lib --env LLVM_INCLUDE_DIR=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/include --env LLVM_TOOLS_DIR=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin --libcxx-include-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/include/c++/v1 --libcxx-include-target-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/include/x86_64-unknown-linux-gnu/c++/v1 --libcxx-library-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./lib/x86_64-unknown-linux-gnu --arch x86_64 --build-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lldb-test-build.noindex --lldb-module-cache-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin/lldb --compiler /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin/clang --dsymutil /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin --lldb-obj-root /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/lldb --lldb-libs-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./lib --cmake-build-type Release /home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/test/API/tools/lldb-dap/module -p TestDAP_module.py
--
Exit Code: -9
Timeout: Reached timeout of 1200 seconds
...

https://github.com/llvm/llvm-project/actions/runs/17940597997/job/51016081497?pr=139293

The logs say that one test passed, but the printed communication logs relate to
that test too. So I can't tell if that one failed or a different part did.

Given that I've had to disable multiple parts of DAP tests before, I'm just going to
skip the whole file. It's not pretty, but it'll save contributors hassle.

See #137660.
2025-09-23 14:19:00 +00:00
nerix
5b3dd43bd2 [LLDB][PDB] Warn if DIA plugin is requested but not available (#160067)
If LLDB was built without the DIA SDK and the DIA reader is explicitly
requested (through `LLDB_USE_NATIVE_PDB_READER=0` or `settings set
plugin.symbol-file.pdb.reader dia`), LLDB should print a warning,
because it will use the native reader in any case
(https://github.com/llvm/llvm-project/pull/159769#discussion_r2367316980).

This PR adds the warning and a test when LLDB is not built with the SDK
on Windows. I don't think any builder runs this configuration, as there
are still five failing tests. I tested this locally with and without the
SDK.
2025-09-23 12:14:59 +02:00
nerix
e08d8e3d16 [LLDB][PDB] Run UDT layout test with native PDB too (#159769)
This test was failing with the native plugin due to two reasons:

1. The static `C::abc` was printed as `(int) ::C::abc = 123`
2. The order of the base classes of [`C`
(`List::Value`)](b7e4edca3d/lldb/test/Shell/SymbolFile/PDB/Inputs/UdtLayoutTest.cpp (L30))
is different between DIA and the native plugin. I don't know how the
order in the DIA plugin is determined - it prints `B<0>`, `B<1>`,
`B<2>`, `B<3>`, `A`. The native plugin follows the order of the bases in
memory and prints `B<2>`, `B<3>`, `A`, `B<0>`, `B<1>` (last three are
the virtual bases).
    <details><summary>Class layout of C</summary>
    
    ```
    class C size(88):
            +---
    0       | +--- (base class B<2>)
    0       | | {vbptr}
    8       | | _a
    9.      | | _b (bitstart=3,nbits=6)
    11      | | _c
            | +---
    15      | +--- (base class B<3>)
    15      | | {vbptr}
    23      | | _a
    24.     | | _b (bitstart=3,nbits=6)
    26      | | _c
            | +---
            | <alignment member> (size=2)
    32      | _x
    36      | _y
    38      | _z
            | <alignment member> (size=1)
            | <alignment member> (size=2)
            +---
            +--- (virtual base A)
    40      | {vfptr}
    48      | U _u
            | <alignment member> (size=4)
            +---
            +--- (virtual base B<0>)
    56      | {vbptr}
    64      | _a
    65.     | _b (bitstart=3,nbits=6)
    67      | _c
            +---
            +--- (virtual base B<1>)
    71      | {vbptr}
    79      | _a
    80.     | _b (bitstart=3,nbits=6)
    82      | _c
            +---
    ```
    </details>

I split the tests for the plugins for better readability.
2025-09-23 11:34:48 +02:00
Michael Buch
012680faf4 [clang][Expr] Teach IgnoreUnlessSpelledInSource about implicit calls to std::get free function (#122265)
When we generate the debug-info for a `VarDecl` we try to determine
whether it was introduced as part of a structure binding (aka a "holding
var"). If it was then we don't mark it as `artificial`.

The heuristic to determine a holding var uses
`IgnoreUnlessSpelledInSource` to unwrap the `VarDecl` initializer until
we hit a `DeclRefExpr` that refers to a `Decomposition`. For "tuple-like
decompositions", Clang will generate a call to a `template<size_t I> Foo
get(Bar)` function that retrieves the `Ith` element from the tuple-like
structure. If that function is a member function, we get an AST that
looks as follows:
```
VarDecl implicit used z1 'std::tuple_element<0, B>::type &&' cinit
`-ExprWithCleanups <col:10> 'int' xvalue
  `-MaterializeTemporaryExpr <col:10> 'int' xvalue extended by Var 0x11d110cf8 'z1' 'std::tuple_element<0, B>::type &&'
    `-CXXMemberCallExpr <col:10> 'int'
      `-MemberExpr <col:10> '<bound member function type>' .get 0x11d104390
        `-ImplicitCastExpr <col:10> 'B' xvalue <NoOp>
          `-DeclRefExpr <col:10> 'B' lvalue Decomposition 0x11d1100a8 '' 'B'
```
`IgnoreUnlessSpelledInSource` happily unwraps this down to the
`DeclRefExpr`. However, when the `get` helper is a free function (which
it is for `std::pair` in libc++ for example), then the AST is:
```
VarDecl col:16 implicit used k 'std::tuple_element<0, const std::tuple<int, int>>::type &' cinit
`-CallExpr <col:16> 'const typename tuple_element<0UL, tuple<int, int>>::type':'const int' lvalue adl
  |-ImplicitCastExpr <col:16> 'const typename tuple_element<0UL, tuple<int, int>>::type &(*)(const tuple<int, int> &) noexcept' <FunctionToPointerDecay>
  | `-DeclRefExpr <col:16> 'const typename tuple_element<0UL, tuple<int, int>>::type &(const tuple<int, int> &) noexcept' lvalue Function 0x1210262d8 'get' 'const typename tuple_element<0UL, tuple<int, int>>::type &(const tuple<int, int> &) noexcept' (FunctionTemplate 0x11d068088 'get')
  `-DeclRefExpr <col:16> 'const std::tuple<int, int>' lvalue Decomposition 0x121021518 '' 'const std::tuple<int, int> &'
```
`IgnoreUnlessSpelledInSource` doesn't unwrap this `CallExpr`, so we
incorrectly mark the binding as `artificial` in debug-info.

This patch adjusts `IgnoreUnlessSpelledInSource` so it unwraps implicit
`CallExpr`s. It's almost identical to how we treat implicit constructor
calls (unfortunately the code can't quite be re-used because a
`CXXConstructExpr` is-not a `CallExpr`, and we check `isElidable`, which
doesn't exist for regular function calls. So I added a new
`IgnoreImplicitCallSingleStep`).

Fixes https://github.com/llvm/llvm-project/issues/122028
2025-09-20 18:30:18 +01:00
David Spickett
b21dd44dbc [lldb][test] Enable non-address bit WritePointerToMemory test on Linux (#157435)
First added in #153585 for Darwin only. All Linux AArch64 systems also
have Top Byte Ignore enabled in userspace so the test "just works"
there.

FreeBSD has very recently gained Top Byte Ignore support:
4c6c27d3fb

However it's so recent, I don't want to assume it'll be available on any
random FreeBSD system out there.

There isn't really a good place to put this test, so I put it in the top
level of API, next to the other non-address bit test that didn't have a
good home either.
2025-09-19 16:00:33 +01:00
David Peixotto
44a1f7e7ca [lldb] Fix unsafe map mutation in ProcessElfCore::FindModuleUUID (#159444)
The `ProcessElfCore::FindModuleUUID` function can be called by multiple
threads at the same time when `target.parallel-module-load` is true. We
were using the `operator[]` to lookup the UUID which will mutate the map
when the key is not present. This is unsafe in a multi-threaded contex
so we now use a read-only `find` operation and explicitly return an
invalid UUID when the key is not present.

The `m_uuids` map can follow a create-then-query pattern. It is
populated in the `DoLoadCore` function which looks like it is only
called in a single-threaded context so we do not need extra locking as
long as we keep the other accesses read-only.

Other fixes I considered

* Use a lock to protect access - We don't need to modify the map after
creation so we can allow concurrent read-only access.
* Store the map in a const pointer container to prevent accidental
mutation in other places.
     - Only accessed in one place currently so just added a comment.
* Store the UUID in the NT_FILE_Entry after building the mapping
correctly in `UpdateBuildIdForNTFileEntries`. - The map lets us avoid a
linear search in `FindModuleUUID`.

This commit also reverts the temporary workaround from #159395 which
disabled parallel module loading to avoid the test failure.

Fixes #159377
2025-09-18 08:20:09 -07:00
David Spickett
1dc6bf3ff9 [lldb][lldb-dap] Disable all lldb-dap tests on Windows on Arm (#159542)
This reverts the following commits:
a0a82ee19d
757bb36a58
83b48b13f3
b45f1fb377
d2e153981e
e2d1bbebbb
71cae12442
7dd879bdc0
f3b542e314

Where I had disabled specific tests due to them being flakey on our
Windows on Arm bot.

Clearly this strategy isn't working because
every day I see a new random test failing.

Until something can be done about this, disable
every lldb-dap test on Windows on Arm. The coverage we get is just not
worth spamming contributors
who have nothing to do with lldb-dap.

See #137660
2025-09-18 11:01:19 +01:00
nerix
4625c8f076 [LLDB][NativePDB] Add modifiers to modified type name (#159296)
When creating LLDB types from `LF_MODIFIER` records, the type name of
the modified type was used. This didn't include the modifiers
(`const`/`volatile`/`__unaligned`). With this PR, they're included.

The DIA plugin had a test for this. That test also assumed that function
types had a name. I removed that check here, because function/procedure
types themselves in PDB don't have a name:

```
  0x1015 | LF_ARGLIST [size = 20, hash = 0xBCB6]
           0x0074 (int): `int`
           0x1013: `int* __restrict`
           0x1014: `int& __restrict`
  0x1016 | LF_PROCEDURE [size = 16, hash = 0x3F611]
           return type = 0x0003 (void), # args = 3, param list = 0x1015
           calling conv = cdecl, options = None
```

I assume DIA gets the name from the function symbol itself. In the
native plugin, that name isn't included and multiple functions with the
same signature will reuse one type, whereas DIA would create a new type
for each function. The
[Shell/SymbolFile/PDB/func-symbols.test](b29c7ded31/lldb/test/Shell/SymbolFile/PDB/func-symbols.test)
also relies on this.
2025-09-18 11:55:15 +02:00
David Spickett
d0bdc5d945 [lldb][test] Disable parallel module loading for TestNetBSDCore.py (#159395)
Since #157170 this test has been flakey on several LLDB buildbots. I
suspect it's to do with mutli-threading, there are more details in
#159377.

Disable parallel loading for now so we are not spamming people making
unrelated changes.
2025-09-17 17:40:36 +01:00
cmtice
9855d546a4 [LLDB] Add boolean literals to DIL. (#157992)
This adds the ability to recognize (and create ValueObjects for) boolean
literals ("true", "false") to DIL. This is a preliminary step to adding
type casting (and also for the ternary op).
2025-09-16 16:04:42 -07:00
Druzhkov Sergei
1819798227 [lldb-dap] Add stdio redirection (#158609)
As far as I understand, lldb-dap does not currently support stdio
redirection. I have added support for this via a new field in the launch
configuration named `stdio`. It was inspired by the same named field in
[CodeLLDB](https://github.com/vadimcn/codelldb/blob/master/MANUAL.md#stdio-redirection).
2025-09-16 11:07:24 -07:00
David Spickett
a0a82ee19d [lldb][lldb-dap] Disable more DAP tests on Windows (#158906)
Flakey on Windows on Arm:
https://lab.llvm.org/buildbot/#/builders/141/builds/11540

See #137660
2025-09-16 10:58:49 +01:00
Michael Buch
f5022bd03e [lldb][test] import-std-module: skip vector tests
This unblocks https://github.com/llvm/llvm-project/pull/158606. The tests are failing because libc++ is now using lambdas in function bodies in the vector header. Ever since https://github.com/llvm/llvm-project/issues/149477 we bail out of importing types when we encounter lambdas. Until we fix ASTImport of `clang::LambdaExpr` nodes properly, this will need to be skipped.
2025-09-16 10:30:49 +01:00
Sirraide
9b95e10d5e [LLDB] [Tests] Downgrade -Wincompatible-pointer-types to a warning in some tests (#158756)
These no longer compile because the warning now defaults to an error
after #157364, so downgrade the error to a warning for now; I’m not
familiar enough with either LLDB or MacOS to fix these warnings properly
(assuming they’re unintended).
2025-09-16 02:02:01 +02:00
Michael Buch
95d5d984db [lldb][TypeSystem] Enable colored AST dump (#86159)
This patch causes the various AST dump commands (`target modules dump
ast`/`target dump typesystem`) to be color-highlighted. I added a `bool
show_color` parameter to `SymbolFile::DumpClangAST` and
`TypeSystem::Dump`. In `TypeSystemClang` I temporarily sets the
`getShowColors` flag on the owned Clang AST (using an RAII helper) for
the duration of the AST dump. We use `Debugger::GetUseColors` to decide
whether to color the AST dump.
2025-09-15 18:03:55 +01:00
Sirraide
b24769855d [Clang] [Sema] Make -Wincompatible-pointer-types an error by default (#157364)
GCC 14 also made this an error by default, so we’re following suit.

Fixes #74605
2025-09-15 16:55:00 +00:00
Ebuka Ezike
5e118eca93 [lldb][test] Fix unordered-map test. (#158286)
The build step is overidden so it uses `libstdc++` instead of `libc++`
on linux
2025-09-15 15:21:56 +01:00
nerix
4de9bee7e5 [LLDB][PDB] Require Windows for for testing PDB plugin-selection again (#158559)
Amends #158284 and fixes the failure on `lldb-remote-linux-win` from
https://github.com/llvm/llvm-project/pull/158284#issuecomment-3290154510.
That builder is configured with the DIA SDK but builds for Linux, so the
debug information will be DWARF, not PDB.
2025-09-15 11:07:42 +02:00
David Spickett
757bb36a58 [lldb][test] Disable a test from TestDAP_cancel.py on Windows
Flakey on our Windows on Arm bot:
https://lab.llvm.org/buildbot/#/builders/141/builds/11516

See https://github.com/llvm/llvm-project/issues/137660
2025-09-15 08:48:04 +00:00
nerix
b31f8cb1c9 [LLDB] Require DIA SDK for testing the PDB plugin-selection setting (#158284)
If LLDB is built without the DIA SDK enabled, then the native plugin is
used regardless of `plugin.symbol-file.pdb.reader` or
`LLDB_USE_NATIVE_PDB_READER`. This made the test fail on Windows when
the DIA SDK was disabled
(https://github.com/llvm/llvm-project/issues/114906#issuecomment-3241796062).

This PR changes the requirement for the test from `target-windows` to
`diasdk` (only used in this test).
2025-09-13 09:15:52 +00:00
Felipe de Azevedo Piovezan
5d088ba304 [lldb] Track CFA pointer metadata in StackID (#157498)
[lldb] Track CFA pointer metadata in StackID

    In this commit:

9c8e716442 [lldb] Make StackID call Fix{Code,Data} pointers (#152796)

We made StackID keep track of the CFA without any pointer metadata in
it. This is necessary when comparing two StackIDs to determine which one
    is "younger".

However, the CFA inside StackIDs is also used in other contexts through
    the method StackID::GetCallFrameAddress. One notable case is
DWARFExpression: the computation of `DW_OP_call_frame_address` is done
    using StackID. This feeds into many other places, e.g. expression
evaluation may require the address of a variable that is computed from
    the CFA; to access the variable without faulting, we may need to
preserve the pointer metadata. As such, StackID must be able to provide
    both versions of the CFA.

    In the spirit of allowing consumers of pointers to decide what to do
with pointer metadata, this patch changes StackID to store both versions
of the cfa pointer. Two getter methods are provided, and all call sites
    except DWARFExpression preserve their existing behavior (stripped
    pointer). Other alternatives were considered:

    * Just store the raw pointer. This would require changing the
comparisong operator `<` to also receive a Process, as the comparison
requires stripped pointers. It wasn't clear if all call-sites had a
non-null process, whereas we know we have a process when creating a
      StackID.

* Store a weak pointer to the process inside the class, and then strip
      metadata as needed. This would require a `weak_ptr::lock` in many
operations of LLDB, and it felt wasteful. It also prevents stripping
      of the pointer if the process has gone away.

This patch also changes RegisterContextUnwind::ReadFrameAddress, which
is the method computing the CFA fed into StackID, to also preserve the
    signature pointers.
2025-09-12 09:17:48 -07:00
David Spickett
83b48b13f3 [lldb][test] Disable more of TestDAP_attach.py on Windows
Flaky on our Windows on Arm bot:
https://lab.llvm.org/buildbot/#/builders/141/builds/11465

See #137660
2025-09-12 10:21:04 +00:00
Dave Lee
580fdeb6ff [lldb] Test global variable support of dwim-print (NFC) (#157908)
DIL has made `frame variable` support global variables, which in turn
means dwim-print inherits support for global variables.
2025-09-11 15:55:11 -07:00