Commit Graph

7204 Commits

Author SHA1 Message Date
Chelsea Cassanova
9f6d08f256 Revert "[lldb][sbdebugger] Move SBDebugger Broadcast bit enum into lldb-enumerations.h" (#88324)
Reverts llvm/llvm-project#87409 due a missed update to the broadcast bit
causing a build failure on the x86_64 Debian buildbot.
2024-04-10 14:54:30 -07:00
Chelsea Cassanova
af7c196fb8 [lldb][sbdebugger] Move SBDebugger Broadcast bit enum into lldb-enumerations.h (#87409)
When the `eBroadcastBitProgressCategory` bit was originally added to
Debugger.h and SBDebugger.h, each corresponding bit was added in order
of the other bits that were previously there. Since `Debugger.h` has an
enum bit that `SBDebugger.h` does not, this meant that their offsets did
not match.

Instead of trying to keep the bit offsets in sync between the two, it's
preferable to just move SBDebugger's enum into the main enumerations
header and use the bits from there. This also requires that API tests using the bits from SBDebugger update their usage.
2024-04-10 14:45:49 -07:00
Shubham Rastogi
ca55ee8826 Revert "Debuginfod Testing & fixes: 3rd times the charm? (#87676)"
This reverts commit d6713ad80d.

This changed was reverted because of greendragon failures such
as

Unresolved Tests (2):
  lldb-api :: debuginfod/Normal/TestDebuginfod.py
  lldb-api :: debuginfod/SplitDWARF/TestDebuginfodDWP.py
2024-04-04 15:37:07 -07:00
Kevin Frei
d6713ad80d Debuginfod Testing & fixes: 3rd times the charm? (#87676)
I believe I've got the tests properly configured to only run on Linux
x86(_64), as I don't have a Linux AArch64/Arm device to diagnose what's
going wrong with the tests (I suspect there's some issue with generating
`.note.gnu.build-id` sections...)

The actual code fixes have now been reviewed 3 times:
https://github.com/llvm/llvm-project/pull/79181 (moved shell tests to
API tests), https://github.com/llvm/llvm-project/pull/85693 (Changed
some of the testing infra), and
https://github.com/llvm/llvm-project/pull/86812 (didn't get the tests
configured quite right). The Debuginfod integration for symbol
acquisition in LLDB now works with the `executable` and `debuginfo`
Debuginfod network requests working properly for normal, `objcopy
--only-keep-debug` stripped, split-dwarf, and `objcopy
--only-keep-debug` stripped *plus* split-dwarf symbols/binaries.

The reasons for the multiple attempts have been tests on platforms I
don't have access to (Linux AArch64/Arm + MacOS x86_64). I believe I've
got the tests properly disabled for everything except for Linux x86(_64)
now. I've built & tested on MacOS AArch64 and Linux x86_64.

---------

Co-authored-by: Kevin Frei <freik@meta.com>
2024-04-04 11:43:55 -07:00
Chelsea Cassanova
20433e9b24 Revert "DebugInfoD issues, take 2" (#87583)
Reverts llvm/llvm-project#86812. 

This commit caused a regression on the x86_64 MacOS buildbot:
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake/784/
2024-04-03 16:34:03 -07:00
Kevin Frei
a8425d2fa2 DebugInfoD issues, take 2 (#86812)
The previous diff (and it's subsequent fix) were reverted as the tests
didn't work properly on the AArch64 & ARM LLDB buildbots. I made a
couple more minor changes to tests (from @clayborg's feedback) and
disabled them for non Linux-x86(_64) builds, as I don't have the ability
do anything about an ARM64 Linux failure. If I had to guess, I'd say the
toolchain on the buildbots isn't respecting the `-Wl,--build-id` flag.
Maybe, one day, when I have a Linux AArch64 system I'll dig in to it.

From the reverted PR:

I've migrated the tests in my
https://github.com/llvm/llvm-project/pull/79181 from shell to API (at
@JDevlieghere's suggestion) and addressed a couple issues that were
exposed during testing.

The tests first test the "normal" situation (no DebugInfoD involvement,
just normal debug files sitting around), then the "no debug info"
situation (to make sure the test is seeing failure properly), then it
tests to validate that when DebugInfoD returns the symbols, things work
properly. This is duplicated for DWP/split-dwarf scenarios.

---------

Co-authored-by: Kevin Frei <freik@meta.com>
2024-04-03 12:15:41 -07:00
Jordan Rupprecht
a6caceed8d [lldb] Don't crash when attempting to parse breakpoint id N. as N.* (#87263)
We check if the next character after `N.` is `*` before we check its
length. Using `split` on the string is cleaner and less error prone than
using indices with `find` and `substr`.

Note: this does not make `N.` mean anything, it just prevents assertion
failures. `N.` is treated the same as an unrecognized breakpoint name:

```
(lldb) breakpoint enable 1
1 breakpoints enabled.
(lldb) breakpoint enable 1.*
1 breakpoints enabled.
(lldb) breakpoint enable 1.
0 breakpoints enabled.
(lldb) breakpoint enable xyz
0 breakpoints enabled.
```

Found via LLDB fuzzers.
2024-04-01 16:02:12 -05:00
Pablo Busse
154cea4673 [lldb] Fix type lookup in DWARF .o files via debug map (#87177)
An inverted condition causes `SymbolFileDWARFDebugMap::FindTypes` to
bail out after inspecting the first .o file in each module.

The same kind of bug is found in
`SymbolFileDWARFDebugMap::ParseDeclsForContext`.

Correct both early exit conditions and add a regression test for lookup
of up a type defined in a secondary compilation unit.

Fixes #87176
2024-03-31 17:17:32 +01:00
Jordan Rupprecht
a8340767de [lldb] Remove cmake check for pexpect with LLDB_TEST_USE_VENDOR_PACKAGES (#86962)
The commit 8bed754c2f was intended to
support the use case where users want to run all the LLDB tests in an
environment where pexpect is not installed. Those users can build with
`-DLLDB_TEST_USER_ARGS=--skip-category=pexpect` to skip pexpect tests,
*but* because we still fail in cmake configuration, they must use
`-DLLDB_TEST_USE_VENDOR_PACKAGES=ON` to avoid failing due to pexpect not
being available.

I would like to remove `LLDB_TEST_USE_VENDOR_PACKAGES` now, but first
I'd like to make sure users w/o pexpect can pass CI with
`-DLLDB_TEST_USE_VENDOR_PACKAGES=OFF
-DLLDB_TEST_USER_ARGS=--skip-category=pexpect`. Once that is done, I am
not aware of any other issues caused by the previous commits, so the
third party tree should be safe to remove.
2024-03-28 15:57:09 -05:00
Jason Molenda
6a0ec8e25c [lldb] Revive shell test after updating UnwindTable (#86770)
In
     commit 2f63718f85
     Author: Jason Molenda <jmolenda@apple.com>
     Date:   Tue Mar 26 09:07:15 2024 -0700

[lldb] Don't clear a Module's UnwindTable when adding a SymbolFile
(#86603)

I stopped clearing a Module's UnwindTable when we add a SymbolFile to
avoid the memory management problems with adding a symbol file
asynchronously while the UnwindTable is being accessed on another
thread. This broke the target-symbols-add-unwind.test shell test on
Linux which removes the DWARF debub_frame section from a binary, loads
it, then loads the unstripped binary with the DWARF debug_frame section
and checks that the UnwindPlans for a function include debug_frame.

I originally decided that I was willing to sacrifice the possiblity of
additional unwind sources from a symbol file because we rely on assembly
emulation so heavily, they're rarely critical. But there are targets
where we we don't have emluation and rely on things like DWARF
debug_frame a lot more, so this probably wasn't a good choice.

This patch adds a new UnwindTable::Update method which looks for any new
sources of unwind information and adds it to the UnwindTable, and calls
that after a new SymbolFile has been added to a Module.
2024-03-27 09:25:46 -07:00
Jason Molenda
29318abe1d [lldb] Remove test for add-symbol-file adds unwind source
In

commit 2f63718f85
Author: Jason Molenda <jmolenda@apple.com>
Date:   Tue Mar 26 09:07:15 2024 -0700

    [lldb] Don't clear a Module's UnwindTable when adding a SymbolFile (#86603)

I changed lldb to not clear a Module's UnwindTable when we add a
SymbolFile to a binary, because the added benefit is marginal, and
handling this reconstruction correctly is difficult.  This test was
written to explicitly create a test without unwind info in the
binary, then add a symbol file with the unwind info, and check that
it is present.  I've intentionally broken this, so I'm removing the
test.
2024-03-26 10:54:26 -07:00
jimingham
2c76e88e9e Add register lookup as another fallback computation for address-expressions (#85492)
The idea behind the address-expression is that it handles all the common
expressions that produce addresses. It handles actual valid expressions
that return a scalar, and it handles useful cases that the various
source languages don't support. At present, the fallback handles:

<symbol_name>{+-}<offset>

which isn't valid C but is very handy.

This patch adds handling of:

$<reg_name>

and

$<reg_name>{+-}<offset>

That's kind of pointless in C because the C expression parser handles
that expression already. But some languages don't have a straightforward
way to represent register values like this (swift) so having this
fallback is quite a quality of life improvement.

I added a test which tests that I didn't mess up either of these
fallbacks, though it doesn't test the actually handling of registers
that I added, since the expression parser for C succeeds in that case
and returns before this code gets run.

I will add a test on the swift fork for that checks that this works the
same way for a swift frame after this check.
2024-03-25 15:17:23 -07:00
Muhammad Omair Javaid
7fc2fbb3f1 Revert "DebugInfoD tests + fixing issues exposed by tests (#85693)"
This reverts commit 6d939a6ec6.

This broke following LLDB bots:
https://lab.llvm.org/buildbot/#/builders/96/builds/54867
https://lab.llvm.org/buildbot/#/builders/17/builds/50824
2024-03-23 03:31:56 +05:00
Kevin Frei
6d939a6ec6 DebugInfoD tests + fixing issues exposed by tests (#85693)
Finally getting back to Debuginfod tests:
I've migrated the tests in my [earlier
PR](https://github.com/llvm/llvm-project/pull/79181) from shell to API
(at @JDevlieghere's suggestion) and addressed a couple issues that came
about during testing.

The tests first test the "normal" situation (no DebugInfoD involvement,
just normal debug files sitting around), then the "no debug info"
situation (to make sure the test is seeing failure properly), then it
tests to validate that when Debuginfod returns the symbols, things work
properly. This is duplicated for DWP/split-dwarf scenarios.

---------

Co-authored-by: Kevin Frei <freik@meta.com>
2024-03-21 13:09:04 -07:00
Alex Langford
66a2ed50cc [lldb] Remove process restart prompt from TestSourceManager (#85861)
In TestSourceManager, test_artificial_source_location will give the
process restart prompt if you run the test individually. The reason is
that we run the process twice: first using a convenience function to run
to a specific breakpoint and then again to check for a specific message
emitted when you hit the breakpoint. Instead of running twice and making
the test difficult to run individually, we can just check for the
specific messages using other commands.
2024-03-20 10:43:40 -07:00
Felipe de Azevedo Piovezan
12329648e2 [lldb] Omit --show-globals in help target var (#85855)
This option doesn't exist. It is currently displayed by `help target
var` due to a bug introduced by 41ae8e7445 in 2018.

Some code for `target var` and `frame var` is shared, and some hard-code
constants are used in order to filter out options that belong only to
`frame var`. However, the aforementioned commit failed to update these
constants properly. This patch addresses the issue by having a _single_
place where the filtering of options needs to be done.
2024-03-20 07:03:24 -07:00
Mark de Wever
56d45b09dc [lldb][libc++] Adds slice_array data formatters. (#85544)
Co-authored-by: Michael Buch <michaelbuch12@gmail.com>
2024-03-17 14:56:35 +01:00
Dave Lee
4da2b542b1 [lldb] Fix dwim-print to not delete non-result persistent variables (#85152)
`EvaluateExpression` does not always create a new persistent result. If the expression 
is a bare persistent variable, then a new persistent result is not created. This means 
the caller can't assume a new persistent result is created for each evaluation. 
However, `dwim-print` was doing exactly that: assuming a new persistent result for each 
evaluation. This resulted in a bug:

```
(lldb) p int $j = 23
(lldb) p $j
(lldb) p $j
```

The first `p $j` would not create a persistent result, and so `dwim-print` would 
inadvertently delete `$j`. The second `p $j` would fail.

The fix is to try `expr` as a persistent variable, after trying `expr` as a frame 
variable. For persistent variables, this avoids calling `EvaluateExpression`.

Resolves https://github.com/llvm/llvm-project/issues/84806

rdar://124688427
2024-03-15 16:09:24 -07:00
Jason Molenda
52557bce73 [lldb] [Mach-O] ProcessMachCore needs to strip TBI data from addrs (#84998)
Darwin AArch64 application processors are run with Top Byte Ignore mode
enabled so metadata may be stored in the top byte, it needs to be
ignored when reading/writing memory. David Spickett handled this already
in the base class Process::ReadMemory but ProcessMachCore overrides that
method (to avoid the memory cache) and did not pick up the same change.
I add a test case that creates a pointer with metadata in the top byte
and dereferences it with a live process and with a corefile.

rdar://123784501
2024-03-14 08:58:27 -07:00
bvlgah
ece2c25ab9 [LLDB][Test] Fix the test case of listing verbose break info on Windows (#85200)
I noticed a failure of [running LLDB test suites on Windows
AArch64](https://lab.llvm.org/buildbot/#/builders/219/builds/9849). The
failed test case is about
checking output of command `breakpoint list -v -L c++`, and an mismatch
on the demangled
name of a function occurred. The test case expects `ns::func(void)`, but
on Windows it is `int ns::func(void)`.
It results from the different mangling scheme used by MSVC, and the
comparison is as follows:

| Scheme | Mangled | Demangled (fully) | Note |
| --- | --- | --- | --- |
| MSVC | `?func@ns@@YAHXZ` | `int __cdecl ns::func(void)` |
[Godbolt](https://godbolt.org/z/5ns8c7xW3) (I have no available Windows
device) |
| Itanium | `_ZN2ns4funcEv` | `ns::func()` | |

According to the current use of MSVC demangling,


8f68022f8e/lldb/source/Core/Mangled.cpp (L128-L143)

the `__cdecl` specifier is not part of the name. However, the function's
parameter types should be present
as ` llvm::MSDF_NoVariableType` [does not affect a symbol for
functions](8f68022f8e/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp (L417-L453)).

Therefore, it is inappropriate to assume the demangled name are the same
on all platforms. Instead of tweaking the
existing code of demangling to get the same (demangled) name, I think it
is more reasonable to modify the test case.
2024-03-14 09:11:37 +00:00
Dave Lee
b49d741c0c [lldb] Skip TestIndirectSymbols (#85133)
Correction to e2b8cc11b3
2024-03-13 14:15:41 -07:00
Dave Lee
e2b8cc11b3 [lldb] XFAIL TestIndirectSymbols on darwin (#85127)
```
AssertionError: 'main' != 'call_through_indirect_hidden'
```
2024-03-13 13:34:01 -07:00
Jordan Rupprecht
8bed754c2f [lldb][test] Add pexpect category for tests that import pexpect (#84860)
Instead of directly annotating pexpect-based tests with
`@skipIfWindows`, we can tag them with a new `pexpect` category. We
still automatically skip windows behavior by adding `pexpect` to the
skip category list if the platform is windows, but also allow
non-Windows users to skip them by configuring cmake with
`-DLLDB_TEST_USER_ARGS=--skip-category=pexpect`

As a prerequisite, remove the restriction that `@add_test_categories`
can only apply to test cases, and we make the test runner look for
categories on both the class and the test method.
2024-03-13 15:16:15 -05:00
David Spickett
4e49ee55c5 [lldb][Test] Disable ConcurrentVFork tests on Arm/AArch64 Linux
They are either flaky, or not cleaning up after themselves.
See https://github.com/llvm/llvm-project/issues/85084.
2024-03-13 14:30:40 +00:00
David Spickett
eb21ee49cf [lldb][test] Disable other runlocker test on AArch64 Linux
Flaky on the bot: https://lab.llvm.org/buildbot/#/builders/96/builds/54435
2024-03-13 14:15:30 +00:00
Michael Buch
88bf64097e [lldb][test] TestExprCompletion.py: add tests for completion of reserved identifiers (#84890) 2024-03-12 22:19:27 +00:00
Danial Klimkin
ce1fd92817 Update test past bdbad0d07b (#84889) 2024-03-12 11:19:48 +01:00
jimingham
3707c540d2 Make ValueObject::Cast work for casts from smaller to larger structs in the cases where this currently can work. (#84588)
The ValueObjectConstResult classes that back expression result variables
play a complicated game with where the data for their values is stored.
They try to make it appear as though they are still tied to the memory
in the target into which their value was written when the expression is
run, but they also keep a copy in the Host which they use after the
value is made (expression results are "history values" so that's how we
make sure they have "the value at the time of the expression".)

However, that means that if you ask them to cast themselves to a value
bigger than their original size, they don't have a way to get more
memory for that purpose. The same thing is true of ValueObjects backed
by DataExtractors, the data extractors don't know how to get more data
than they were made with in general.

The only place where we actually ask ValueObjects to sample outside
their captured bounds is when you do ValueObject::Cast from one
structure type to a bigger structure type. In
https://reviews.llvm.org/D153657 I handled this by just disallowing
casts from one structure value to a larger one. My reasoning at the time
was that the use case for this was to support discriminator based C
inheritance schemes, and you can't directly cast values in C, only
pointers, so this was not a natural way to handle those types. It seemed
logical that since you would have had to start with pointers in the
implementation, that's how you would write your lldb introspection code
as well.

Famous last words...

Turns out there are some heavy users of the SB API's who were relying on
this working, and this is a behavior change, so this patch makes this
work in the cases where it used to work before, while still disallowing
the cases we don't know how to support.

Note that if you had done this Cast operation before with either
expression results or value objects from data extractors, lldb would not
have returned the correct results, so the cases this patch outlaws are
ones that actually produce invalid results. So nobody should be using
Cast in these cases, or if they were, this patch will point out the bug
they hadn't yet noticed.
2024-03-11 14:13:37 -07:00
Adrian Prantl
6462eadbd3 Report back errors in GetNumChildren() (#84265)
This is a proof-of-concept patch that illustrates how to use the
Expected return values to surface rich error messages all the way up
to the ValueObjectPrinter.

This is the final patch in the series that includes
https://github.com/llvm/llvm-project/pull/83501 and
https://github.com/llvm/llvm-project/pull/84219
2024-03-11 13:04:56 -07:00
Alex Langford
d93a126090 [lldb] Add ability to detect darwin host linker version to xfail tests (#83941)
When Apple released its new linker, it had a subtle bug that caused
LLDB's TLS tests to fail. Unfortunately this means that TLS tests are
not going to work on machines that have affected versions of the linker,
so we should annotate the tests so that they only work when we are
confident the linker has the required fix.

I'm not completely satisfied with this implementation. That being said,
I believe that adding suport for linker versions in general is a
non-trivial change that would require far more thought. There are a few
challenges involved:
- LLDB's testing infra takes an argument to change the compiler, but
there's no way to switch out the linker.
- There's no standard way to ask a compiler what linker it will use.
- There's no standard way to ask a linker what its version is. Many
platforms have the same name for their linker (ld).
- Some platforms automatically switch out the linker underneath you. We
do this for Windows tests (where we use LLD no matter what).

Given that this is affecting the tests on our CI, I think this is an
acceptable solution in the interim.
2024-03-07 18:04:42 -05:00
Dave Lee
ecf7db8b52 [lldb] Disable shell tests affected by ld_new bug (#84246)
Equivalent to the changes made in https://github.com/llvm/llvm-project/pull/83941, 
except to support shell tests.
2024-03-07 12:55:13 -08:00
jeffreytan81
36f866c6ec Fix vfork test strcmp buildbot failure (#84224)
The buildbot seems to complain about `strcmp` function not available in
the vfork patch (https://github.com/llvm/llvm-project/pull/81564):

https://lab.llvm.org/buildbot/#/builders/68/builds/70093/steps/6/logs/stdio

Unfortunately, I can't reproduce the failure on my linux machine so this
is a guessing fix. If anyone has a way to reproduce and very this fix,
please feel free to merge this change.

Co-authored-by: jeffreytan81 <jeffreytan@fb.com>
2024-03-07 09:37:27 -08:00
David Spickett
03588a2726 [lldb][test][FreeBSD] xfail TestPlatformConnect on AArch64
Details in the linked issue. Might fail on other architectures
but I can't confirm, they can add to this if it does.
2024-03-07 14:54:30 +00:00
Jordan Rupprecht
3239b4dcfe [lldb][test] Enforce pexpect system availability by default (#84270)
This switches the default of `LLDB_TEST_USE_VENDOR_PACKAGES` from `ON`
to `OFF` in preparation for eventually deleting it. All known LLDB
buildbots have this package installed, so flipping the default will
uncover any other users.

If this breaks anything, the preferred fix is to install `pexpect` on
the host system. The second fix is to build with cmake option
`-DLLDB_TEST_USE_VENDOR_PACKAGES=ON` as a temporary measure until
`pexpect` can be installed. If neither of those work, reverting this
patch is OK.
2024-03-07 08:53:18 -06:00
Jordan Rupprecht
ec72909b62 [lldb][test] iwyu for vfork test 2024-03-06 18:41:18 -08:00
Felipe de Azevedo Piovezan
0497c77e9e [lldb] Print mangled names with verbose break list (#84071)
When debugging LLDB itself, it can often be useful to know the mangled
name of the function where a breakpoint is set. Since the `--verbose`
setting of `break --list` is aimed at debugging LLDB, this patch makes
it so that the mangled name is also printed in that mode.

Note about testing: since mangling is not the same on Windows and Linux,
the test refrains from hardcoding mangled names.
2024-03-06 16:25:22 -08:00
Greg Clayton
f0eb0c5689 Don't require a UUID in a .dwp file. (#83935)
DWP files don't usually have a GNU build ID built into them. When
searching for a .dwp file, don't require a UUID to be in the .dwp file.
The debug info search information was checking for a UUID in the .dwp
file when debug info search paths were being used. This is now fixed by
not specifying the UUID in the ModuleSpec being used for the .dwp file
search.
2024-03-06 13:49:26 -08:00
Jason Molenda
04bbbba271 Skip TestAddressMasks API tests on 32-bit arm
TestAddressMasks failed on the lldb-arm-buntu bot with the
Code address mask test,

        mask = process.GetAddressMask(lldb.eAddressMaskTypeAny)
        process.SetAddressMask(lldb.eAddressMaskTypeCode, mask | 0x3)
        self.assertEqual(
            0x000002950001F694,
            process.FixAddress(0x00265E950001F697, lldb.eAddressMaskTypeCode),
        )

The API returned 0x000002950001f694 instead of the expected
0x00265e950001f696.  The low bits differ because ABISysV_arm hardcodes
the Code address mask to clear the 0th bit, it doesn't use the
Process code mask.  I didn't debug why some of the high bytes were
dropped.  The address mask APIs are only important on 64-bit targets,
where many of the bits are not used for addressing and are used for
metadata instead, so I'm going to skip these tests on 32-bit arm
instead of debugging.
2024-03-06 10:58:03 -08:00
jeffreytan81
8bdddcf0bb Fix lldb crash while handling concurrent vfork() (#81564)
We got user reporting lldb crash while the debuggee is calling vfork()
concurrently from multiple threads.
The crash happens because the current implementation can only handle
single vfork, vforkdone protocol transaction.

This diff fixes the crash by lldb-server storing forked debuggee's <pid,
tid> pair in jstopinfo which will be decoded by lldb client to create
StopInfoVFork for follow parent/child policy. Each StopInfoVFork will
later have a corresponding vforkdone packet. So the patch also changes
the `m_vfork_in_progress` to be reference counting based.

Two new test cases are added which crash/assert without the changes in
this patch.

---------

Co-authored-by: jeffreytan81 <jeffreytan@fb.com>
2024-03-06 10:50:32 -08:00
Jason Molenda
aeaa11aeac [lldb] Address mask sbprocess apis and new mask invalid const (#83663)
[lldb] Add SBProcess methods for get/set/use address masks (#83095)

I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905
which was approved but I wasn't thrilled with all the API I was adding
to SBProcess for all of the address mask types / memory regions. In this
update, I added enums to control type address mask type (code, data,
any) and address space specifiers (low, high, all) with defaulted
arguments for the most common case.  I originally landed this via
https://github.com/llvm/llvm-project/pull/83095 but it failed on CIs
outside of arm64 Darwin so I had to debug it on more environments
and update the patch.

This patch is also fixing a bug in the "addressable bits to address
mask" calculation I added in AddressableBits::SetProcessMasks. If lldb
were told that 64 bits are valid for addressing, this method would
overflow the calculation and set an invalid mask. Added tests to check
this specific bug while I was adding these APIs.

This patch changes the value of "no mask set" from 0 to
LLDB_INVALID_ADDRESS_MASK, which is UINT64_MAX. A mask of all 1's
means "no bits are used for addressing" which is an impossible mask,
whereas a mask of 0 means "all bits are used for addressing" which
is possible.

I added a base class implementation of ABI::FixCodeAddress and
ABI::FixDataAddress that will apply the Process mask values if they
are set to a value other than LLDB_INVALID_ADDRESS_MASK.

I updated all the callers/users of the Mask methods which were
handling a value of 0 to mean invalid mask to use
LLDB_INVALID_ADDRESS_MASK.

I added code to the all AArch64 ABI Fix* methods to apply the
Highmem masks if they have been set.  These will not be set on a
Linux environment, but in TestAddressMasks.py I test the highmem
masks feature for any AArch64 target, so all AArch64 ABI  plugins 
must handle it.

rdar://123530562
2024-03-06 10:06:56 -08:00
Felipe de Azevedo Piovezan
488ac3d5ef [lldb] Enable a test that was never enabled (#83925)
According to the git log (d9442afba1), this test has never been
enabled/disabled, it was checked in without being called anywhere. But
it passes and it is useful, so this commit enables it.
2024-03-04 15:45:43 -08:00
Med Ismail Bennani
5000e4c252 [lldb/crashlog] Fix breaking changes in textual report format (#83861)
This patch should address some register parsing issue in the legacy
report format.

rdar://107210149

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-03-04 15:44:44 -08:00
Jordan Rupprecht
503075e4d4 [lldb][test][NFC] Narrow scope of import pexpect
We do not run `pexpect` based tests on Windows, but there are still cases where those tests run `import pexpect` outside of the scope where the test is skipped. By moving the import statement to a different scope, those tests can run even when `pexpect` truly isn't installed.

Tangentially related: TestSTTYBeforeAndAfter.py is using a manual `@expectedFailureAll` for windows instead of the common `@skipIfWindows`. If `pexepect` is generally expected to not be available, we should not bother running the test at all.
2024-03-04 11:21:47 -08:00
Jonas Devlieghere
1da5db97cb [lldb] Use sort-ordering for indexes when sorting by size (#83889)
Use sort-ordering for indexes when sorting by size. This addresses
Jason's post commit review feedback.
2024-03-04 10:44:17 -08:00
Michael Buch
252f3c98db [lldb][test] Add test for chained PCH debugging (#83582)
Adds a test-case for debugging a program with a
pch chain, that is, the main executable depends
on a pch that itself included another pch.

Currently clang doesn't emit the sekeleton CUs
required for LLDB to track all types on the pch chain. Thus this test is
XFAILed for now.
2024-03-04 17:17:13 +00:00
Jonas Devlieghere
af009451ec [lldb] Fix thread backtrace --count (#83602)
The help output for `thread backtrace` specifies that you can pass -1 to
`--count` to display all the frames.

```
-c <count> ( --count <count> )
            How many frames to display (-1 for all)
```

However, that doesn't work:

```
(lldb) thread backtrace --count -1
error: invalid integer value for option 'c'
```

The problem is that we store the option value as an unsigned and the
code to parse the string correctly rejects it. There's two ways to fix
this:

1. Make `m_count` a signed value so that it accepts negative values and
appease the parser. The function that prints the frames takes an
unsigned so a negative value will just become a really large positive
value, which is what the current implementation relies on.
2. Keep `m_count` unsigned and instead use 0 the magic value to show all
frames. I don't really see a point in not showing any frames at all,
plus that's already broken (`error: error displaying backtrace for
thread: "0x0001"`).

This patch implements (2) and at the same time improve the error
reporting so that we print the invalid value when we cannot parse it.

rdar://123881767
2024-03-01 11:06:58 -08:00
Jonas Devlieghere
8fa33013de [lldb] Add support for sorting by size to target module dump symtab (#83527)
This patch adds support to sort the symbol table by size. The command
already supports sorting and it already reports sizes. Sorting by size
helps diagnosing size issues.

rdar://123788375
2024-03-01 08:34:36 -08:00
David Spickett
ec8df55570 [lldb][test][Windows] Don't check for pexpect with LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS
See https://github.com/llvm/llvm-project/issues/22648 for why we don't use it on
Windows. Any pexpect tests are skipped there.
2024-03-01 09:47:17 +00:00
Alexander M
5b6e58c565 Revert "XFAIL TestLocalVariables.py on Windows" (#83454)
This reverts commit 3434472ed7.

Closes #43097.
2024-02-29 18:23:12 -08:00
Jason Molenda
e8ce864a36 Revert "[lldb] Add SBProcess methods for get/set/use address masks (#83095)"
This reverts commit 9a12b0a600.

TestAddressMasks fails its first test on lldb-x86_64-debian,
lldb-arm-ubuntu, lldb-aarch64-ubuntu bots.  Reverting while
investigating.
2024-02-29 17:29:24 -08:00