aboutsummaryrefslogtreecommitdiff
path: root/lldb/packages/Python/lldbsuite/test/lldbtest.py
AgeCommit message (Collapse)AuthorFilesLines
7 days[lldb][test] Unify test infrastructure for checking CPU features (#153914)Julian Lettner1-45/+21
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-04[lldb] Add utility to create Mach-O corefile from YAML desc (#153911)Jason Molenda1-1/+26
I've wanted a utility to create a corefile for test purposes given a bit of memory and regsters, for a while. I've written a few API tests over the years that needed exactly this capability -- we have several one-off Mach-O corefile creator utility in the API testsuite to do this. But it's a lot of boilerplate when you only want to specify some register contents and memory contents, to create an API test. This adds yaml2mach-core, a tool that should build on any system, takes a yaml description of register values for one or more threads, optionally memory values for one or more memory regions, and can take a list of UUIDs that will be added as LC_NOTE "load binary" metadata to the corefile so binaries can be loaded into virtual address space in a test scenario. The format of the yaml file looks like ``` cpu: armv7m # optionally specify the number of bits used for addressing # (this line is from a different, 64-bit, yaml file) addressable-bits: num-bits: 39 # optionally specify one or more binary UUID and slide/virtual address to be added as an LC_NOTE # (this line is from a different, 64-bit, yaml file) binaries: - name: debug-binary.development uuid: 67942352-5857-3D3D-90CB-A3F80BA67B04 virtual-address: 0xfffffff01840c000 threads: - regsets: - flavor: gpr registers: [{name: sp, value: 0x2000fe70}, {name: r7, value: 0x2000fe80}, {name: pc, value: 0x0020392c}, {name: lr, value: 0x0020392d}] memory-regions: # stack memory - addr: 0x2000fe70 UInt32: [ 0x0000002a, 0x20010e58, 0x00203923, 0x00000001, 0x2000fe88, 0x00203911, 0x2000ffdc, 0xfffffff9 ] # instructions of a function - addr: 0x203910 UInt8: [ 0xf8, 0xb5, 0x04, 0xaf, 0x06, 0x4c, 0x07, 0x49, 0x74, 0xf0, 0x2e, 0xf8, 0x01, 0xac, 0x74, 0xf0 ] ``` and that's all that is needed to specify a corefile where four register values are specified (the others will be set to 0), and two memory regions will be emitted. The memory can be specified as an array of UInt8, UInt32, or UInt64, I anticipate that some of these corefiles may have stack values constructed manually and it may be simpler for a human to write them in a particular grouping of values. I needed this utility for an upcoming patch for ARM Cortex-M processors, to create a test for the change. I took the opportunity to remove two of the "trivial mach-o corefile" creator utilities I've written in the past, which also restricted the tests to only run on Darwin systems because I was using the system headers for Mach-O constant values. rdar://110663219
2025-07-30[lldb][test] Fix running TestWithLimitDebugInfo.py on Windows (#150579)Igor Kudrin1-9/+8
When debug info categories were set for a test method with the `@add_test_categories` decorator, they were all added to its "categories" attribute. If some of these categories were not supported, `LLDBTestResult.startTest()` skipped all variants of the test method. For example, the tests in `TestWithLimitDebugInfo.py` use the categories `dwarf` and `dwo`. However, since `dwo` is not supported on Windows, all the tests in this file were skipped, even though the tests for `dwarf` could be run.
2025-07-30Re-land "[lldb] Pick the builder for the target platform (#151262)"Jonas Devlieghere1-1/+1
Pick the builder for the target platform, not the host platform. This is necessary when running the test suite remotely on a different platform. Unlike for Darwin, both Windows and Linux us the default builder, which is why this went unnoticed on the remote-linux bots.
2025-07-28[lldb][AArch64][Linux] Show MTE store only setting in mte_ctrl (#145033)David Spickett1-0/+3
This controls whether tag checking is performed for loads and stores, or stores only. It requires a specific architecture feature which we detect with a HWCAP3 and cpuinfo feature. Live process tests look for this and adjust expectations accordingly, core file tests are using an updated file with this feature enabled. The size of the core file has increased and there's nothing I can do about that. Could be the presence of new architecure features or kernel changes since I last generated them. I can generate a smaller file that has the tag segment, but that segment does not actually contain tag data. So that's no use.
2025-07-15[lldb] Add completions for plugin list/enable/disable (#147775)David Peixotto1-4/+11
This commit adds completion support for the plugin commands. It will try to complete partial namespaces to the full namespace string. If the completion input is already a full namespace string then it will add all the matching plugins in that namespace as completions. This lets the user complete to the namespace first and then tab-complete to the next level if desired. ``` (lldb) plugin list a<tab> Available completions: abi architecture (lldb) plugin list ab<tab> (lldb) plugin list abi<tab> (lldb) plugin list abi.<tab> Available completions: abi.SysV-arm64 abi.ABIMacOSX_arm64 abi.SysV-arm ... ```
2025-04-30[NFC][lldb][test] Fix typo in test setup commands. (#137944)Ebuka Ezike1-1/+1
2025-04-23[lldb] returning command completions up to a maximum (#135565)Ely Ronnen1-2/+2
- Adding `max_return_elements` field to `CompletionRequest`. - adding maximum checks to `SymbolCompleter` and `SourceFileCompleter`. Fixes #135553
2025-04-01[lldb] add --platform-available-ports option to the dotest.py (#112555)dlav-sc1-0/+4
This patch adds --platform-available-ports option to the dotest.py script to avoid hardcoded gdb ports in lldb testsuite. Currently, this option could be helpful in GdbRemoteTestCases (e.g. TestLldbGdbServer, TestNonStop, TestGdbRemoteThreadsInStopReply, TestGdbRemotePlatformFile, TestGdbRemote_vCont)
2025-03-26[lldb] Implement a statusline in LLDB (#121860)Jonas Devlieghere1-0/+3
Add a statusline to command-line LLDB to display information about the current state of the debugger. The statusline is a dedicated area displayed at the bottom of the screen. The information displayed is configurable through a setting consisting of LLDB’s format strings. Enablement ---------- The statusline is enabled by default, but can be disabled with the following setting: ``` (lldb) settings set show-statusline false ``` Configuration ------------- The statusline is configurable through the `statusline-format` setting. The default configuration shows the target name, the current file, the stop reason and any ongoing progress events. ``` (lldb) settings show statusline-format statusline-format (format-string) = "${ansi.bg.blue}${ansi.fg.black}{${target.file.basename}}{ | ${line.file.basename}:${line.number}:${line.column}}{ | ${thread.stop-reason}}{ | {${progress.count} }${progress.message}}" ``` The statusline supersedes the current progress reporting implementation. Consequently, the following settings no longer have any effect (but continue to exist to not break anyone's `.lldbinit`): ``` show-progress -- Whether to show progress or not if the debugger's output is an interactive color-enabled terminal. show-progress-ansi-prefix -- When displaying progress in a color-enabled terminal, use the ANSI terminal code specified in this format immediately before the progress message. show-progress-ansi-suffix -- When displaying progress in a color-enabled terminal, use the ANSI terminal code specified in this format immediately after the progress message. ``` Format Strings -------------- LLDB's format strings are documented in the LLDB documentation and on the website: https://lldb.llvm.org/use/formatting.html#format-strings. The current implementation is relatively limited but various improvements have been discussed in the RFC. One such improvement is being to display a string when a format string is empty. Right now, when launching LLDB without a target, the statusline will be empty, which is expected, but looks rather odd. RFC --- The full RFC can be found on Discourse: https://discourse.llvm.org/t/rfc-lldb-statusline/83948
2025-03-24[lldb] Fix TestGdbRemoteForkNonStop.py test (#131293)Georgiy Samoylov1-1/+1
During lldb testing on remote targets TestGdbRemoteForkNonStop.py freezes because in this test we try to create file on remote machine using absolute file path from local machine. This patch fixes this error
2025-03-17[lldb] Support ordered patterns in lldbtest.expect (#131475)Dave Lee1-10/+12
Change `lldbtest.expect` to require the regexes in `patterns` be found in order – when the `ordered` parameter is true. This matches the behavior of `substrs`. The `ordered` parameter is true by default, so this change also fixes tests by either tweaking the patterns to work in order, or by setting `ordered=False`. I have often wanted to test with `patterns` and also verify the order. This change allows that.
2025-03-17Reapply "[lldb] Implement basic support for reverse-continue (#125242)" ↵Pavel Labath1-0/+2
(again) (#128156) This reverts commit https://github.com/llvm/llvm-project/commit/87b7f63a117c340a6d9ca47959335fd7ef6c7ad2, reapplying https://github.com/llvm/llvm-project/commit/7e66cf74fb4e6a103f923e34700a7b6f20ac2a9b with a small (and probably temporary) change to generate more debug info to help with diagnosing buildbot issues.
2025-03-10[lldb] Add more ARM checks in TestLldbGdbServer.py (#130277)David Spickett1-0/+7
When https://github.com/llvm/llvm-project/pull/130034 enabled RISC-V here I noticed that these should run for ARM as well. ARM only has 4 argument registers, which matches Arm's ABI for it: https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#core-registers The ABI defines a link register LR, and I assume that's what becomes 'ra' in LLDB. Tested on ARM and AArch64 Linux.
2025-03-07[lldb] Adapt llgs tests for RISC-V (#130034)Georgiy Samoylov1-0/+4
Some lldb tests from llgs category fail on RISC-V target due to lack of necessary condition checks. This patch adapts these tests by taking into account the peculiarities of the RISC-V architecture
2025-01-31Revert "Reland "[lldb] Implement basic support for reverse-continue" (#125242)"Adrian Prantl1-2/+0
This reverts commit 7e66cf74fb4e6a103f923e34700a7b6f20ac2a9b. Breaking green dragon: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/19569/testReport/junit/lldb-api/functionalities_reverse-execution/TestReverseContinueWatchpoints_py/
2025-01-31Reland "[lldb] Implement basic support for reverse-continue" (#125242)David Spickett1-0/+2
This reverts commit a774de807e56c1147d4630bfec3110c11d41776e. This is the same changes as last time, plus: * We load the binary into the target object so that on Windows, we can resolve the locations of the functions. * We now assert that each required breakpoint has at least 1 location, to prevent an issue like that in the future. * We are less strict about the unsupported error message, because it prints "error: windows" on Windows instead of "error: gdb-remote".
2025-01-30Revert "Reland "[lldb] Implement basic support for reverse-continue" ↵David Spickett1-2/+0
(#123906)"" (#125091) Reverts llvm/llvm-project#123945 Has failed on the Windows on Arm buildbot: https://lab.llvm.org/buildbot/#/builders/141/builds/5865 ``` ******************** Unresolved Tests (2): lldb-api :: functionalities/reverse-execution/TestReverseContinueBreakpoints.py lldb-api :: functionalities/reverse-execution/TestReverseContinueWatchpoints.py ******************** Failed Tests (1): lldb-api :: functionalities/reverse-execution/TestReverseContinueNotSupported.py ``` Reverting while I reproduce locally.
2025-01-30Reland "[lldb] Implement basic support for reverse-continue" (#123906)" ↵David Spickett1-0/+2
(#123945) This reverts commit 22561cfb443267905d4190f0e2a738e6b412457f and fixes b7b9ccf44988edf49886743ae5c3cf4184db211f (#112079). The problem is that x86_64 and Arm 32-bit have memory regions above the stack that are readable but not writeable. First Arm: ``` (lldb) memory region --all <...> [0x00000000fffcf000-0x00000000ffff0000) rw- [stack] [0x00000000ffff0000-0x00000000ffff1000) r-x [vectors] [0x00000000ffff1000-0xffffffffffffffff) --- ``` Then x86_64: ``` $ cat /proc/self/maps <...> 7ffdcd148000-7ffdcd16a000 rw-p 00000000 00:00 0 [stack] 7ffdcd193000-7ffdcd196000 r--p 00000000 00:00 0 [vvar] 7ffdcd196000-7ffdcd197000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0 [vsyscall] ``` Compare this to AArch64 where the test did pass: ``` $ cat /proc/self/maps <...> ffffb87dc000-ffffb87dd000 r--p 00000000 00:00 0 [vvar] ffffb87dd000-ffffb87de000 r-xp 00000000 00:00 0 [vdso] ffffb87de000-ffffb87e0000 r--p 0002a000 00:3c 76927217 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 ffffb87e0000-ffffb87e2000 rw-p 0002c000 00:3c 76927217 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 fffff4216000-fffff4237000 rw-p 00000000 00:00 0 [stack] ``` To solve this, look up the memory region of the stack pointer (using https://lldb.llvm.org/resources/lldbgdbremote.html#qmemoryregioninfo-addr) and constrain the read to within that region. Since we know the stack is all readable and writeable. I have also added skipIfRemote to the tests, since getting them working in that context is too complex to be worth it. Memory write failures now display the range they tried to write, and register write errors will show the name of the register where possible. The patch also includes a workaround for a an issue where the test code could mistake an `x` response that happens to begin with an `O` for an output packet (stdout). This workaround will not be necessary one we start using the [new implementation](https://discourse.llvm.org/t/rfc-fixing-incompatibilties-of-the-x-packet-w-r-t-gdb/84288) of the `x` packet. --------- Co-authored-by: Pavel Labath <pavel@labath.sk>
2025-01-22Revert "[lldb] Implement basic support for reverse-continue" (#123906)Pavel Labath1-2/+0
Reverts llvm/llvm-project#112079 due to failures on the arm bot.
2025-01-22[lldb] Implement basic support for reverse-continue (#112079)Robert O'Callahan1-0/+2
This commit adds support for a `SBProcess::ContinueInDirection()` API. A user-accessible command for this will follow in a later commit. This feature depends on a gdbserver implementation (e.g. `rr`) providing support for the `bc` and `bs` packets. `lldb-server` does not support those packets, and there is no plan to change that. For testing purposes, this commit adds a Python implementation of *very limited* record-and-reverse-execute functionality, implemented as a proxy between lldb and lldb-server in `lldbreverse.py`. This should not (and in practice cannot) be used for anything except testing. The tests here are quite minimal but we test that simple breakpoints and watchpoints work as expected during reverse execution, and that conditional breakpoints and watchpoints work when the condition calls a function that must be executed in the forward direction.
2025-01-14[lldb][Linux] Mark memory regions used for shadow stacks (#117861)David Spickett1-0/+3
This is intended for use with Arm's Guarded Control Stack extension (GCS). Which reuses some existing shadow stack support in Linux. It should also work with the x86 equivalent. A "ss" flag is added to the "VmFlags" line of shadow stack memory regions in `/proc/<pid>/smaps`. To keep the naming generic I've called it shadow stack instead of guarded control stack. Also the wording is "shadow stack: yes" because the shadow stack region is just where it's stored. It's enabled for the whole process or it isn't. As opposed to memory tagging which can be enabled per region, so "memory tagging: enabled" fits better for that. I've added a test case that is also intended to be the start of a set of tests for GCS. This should help me avoid duplicating the inline assembly needed. Note that no special compiler support is needed for the test. However, for the intial enabling of GCS (assuming the libc isn't doing it) we do need to use an inline assembly version of prctl. This is because as soon as you enable GCS, all returns are checked against the GCS. If the GCS is empty, the program will fault. In other words, you can never return from the function that enabled GCS, unless you push values onto it (which is possible but not needed here). So you cannot use the libc's prctl wrapper for this reason. You can use that wrapper for anything else, as we do to check if GCS is enabled.
2025-01-14[LLDB][LoongArch] Add LSX and LASX register definitions and operationswanglei1-0/+11
With this patch, vector registers can be read and written when debugging a live process. Note: We currently assume that all LoongArch64 processors include the LSX and LASX extensions. To add test cases, the following modifications were also made: lldb/packages/Python/lldbsuite/test/lldbtest.py lldb/packages/Python/lldbsuite/test/make/Makefile.rules Reviewed By: DavidSpickett, SixWeining Pull Request: https://github.com/llvm/llvm-project/pull/120664
2024-12-02[lldb] fix fd leak during lldb testsuite (#118093)dlav-sc1-9/+10
During lldb testing dotest.py opens files to dump testcase results, but doesn't close them. This patch makes necessary changes to fix the file descriptors leak.
2024-10-10Revert "[lldb] Implement basic support for reverse-continue (#99736)"Jason Molenda1-2/+0
Reverting this again; I added a commit which added @skipIfDarwin markers to the TestReverseContinueBreakpoints.py and TestReverseContinueNotSupported.py API tests, which use lldb-server in gdbserver mode which does not work on Darwin. But the aarch64 ubuntu bot reported a failure on TestReverseContinueBreakpoints.py, https://lab.llvm.org/buildbot/#/builders/59/builds/6397 File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py", line 63, in test_reverse_continue_skip_breakpoint self.reverse_continue_skip_breakpoint_internal(async_mode=False) File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py", line 81, in reverse_continue_skip_breakpoint_internal self.expect( File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2372, in expect self.runCmd( File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 1002, in runCmd self.assertTrue(self.res.Succeeded(), msg + output) AssertionError: False is not true : Process should be stopped due to history boundary Error output: error: Process must be launched. This reverts commit 4f297566b3150097de26c6a23a987d2bd5fc19c5.
2024-10-10[lldb] Implement basic support for reverse-continue (#99736)Robert O'Callahan1-0/+2
This commit only adds support for the `SBProcess::ReverseContinue()` API. A user-accessible command for this will follow in a later commit. This feature depends on a gdbserver implementation (e.g. `rr`) providing support for the `bc` and `bs` packets. `lldb-server` does not support those packets, and there is no plan to change that. So, for testing purposes, `lldbreverse.py` wraps `lldb-server` with a Python implementation of *very limited* record-and-replay functionality for use by *tests only*. The majority of this PR is test infrastructure (about 700 of the 950 lines added).
2024-10-10Revert "[lldb] Implement basic support for reverse-continue (#99736)"Augusto Noronha1-2/+0
This reverts commit d5e1de6da96c1ab3b8cae68447e8ed3696a7006e.
2024-10-10[lldb] Implement basic support for reverse-continue (#99736)Robert O'Callahan1-0/+2
This commit only adds support for the `SBProcess::ReverseContinue()` API. A user-accessible command for this will follow in a later commit. This feature depends on a gdbserver implementation (e.g. `rr`) providing support for the `bc` and `bs` packets. `lldb-server` does not support those packets, and there is no plan to change that. So, for testing purposes, `lldbreverse.py` wraps `lldb-server` with a Python implementation of *very limited* record-and-replay functionality for use by *tests only*. The majority of this PR is test infrastructure (about 700 of the 950 lines added).
2024-09-26[lldb] Fix minor runCmd error message formatting (#110150)Dave Lee1-7/+5
This tweaks the construction of the error message when using `expect`/`runCmd`. With this change, the stdout/stderr is placed after the message "Command '<command>' did not return successfully". Before: ``` AssertionError: False is not True : Command 'p whatever Error output: error: <some error message> ' did not return successfully ``` After: ``` AssertionError: False is not True : Command 'p whatever' did not return successfully Error output: error: <some error message> ```
2024-09-25[lldb][AArch64][Linux] Add Floating Point Mode Register (#106695)David Spickett1-0/+3
Otherwise known as FEAT_FPMR. This register controls the behaviour of floating point operations. https://developer.arm.com/documentation/ddi0601/2024-06/AArch64-Registers/FPMR--Floating-point-Mode-Register As the current floating point register contexts are fixed size, this has been placed in a new set. Linux kernel patches have landed already, so you can cross check with those. To simplify testing we're not going to do any floating point operations, just read and write from the program and debugger to make sure each sees the other's values correctly.
2024-09-12[lldb][test] Handle failure to get /proc/cpuinfo from a remote Linux ↵David Spickett1-1/+12
platform (#108183) I've been testing against qemu-aarch64 using the qemu-user platform, which doesn't support get-file: ``` AssertionError: False is not true : Command 'platform get-file "/proc/cpuinfo" <...>/TestAArch64LinuxMTEMemoryRegion.test_mte_regions/cpuinfo Command output: get-file failed: unimplemented ' did not return successfully ``` QEMU itself does support overriding cpuinfo for the emulated process (https://gitlab.com/qemu-project/qemu/-/commit/a55b9e72267085957cadb0af0a8811cfbd7c61a9) however we'd need to be able to read the cpuinfo before the process starts, so I'm not attempting to use this feature. Instead if the get-file fails, assume empty cpuinfo so we can at least carry on testing. I've logged the failure and the reason to the trace so developers can find it. ``` runCmd: platform get-file "/proc/cpuinfo" <...>/TestAArch64LinuxMTEMemoryRegion.test_mte_regions/cpuinfo check of return status not required runCmd failed! Failed to get /proc/cpuinfo from remote: "get-file failed: unimplemented" All cpuinfo feature checks will fail. ``` For now this only helps AArch64 but I suspect that RISC-V, being even more mix and match when it comes to extensions, may need this in future. And I know we have some folks testing against qemu-riscv at the moment.
2024-08-30[NFC] Prefer subprocess.DEVNULL over os.devnull (#106500)Nicolas van Kempen1-2/+1
There is no need to support Python 2.7 anymore, Python 3.3+ has `subprocess.DEVNULL`. This is good practice and also prevents file handles from staying open unnecessarily. Also remove a couple unused or unneeded `__future__` imports.
2024-07-31[lldb][test] Fix TestMultipleDebuggers test on non-x86, other small issues ↵David Spickett1-4/+10
(#101169) This test has been flaky lately (https://github.com/llvm/llvm-project/issues/101162) and I disabled it everywhere initially. I found that it always uses "x86_64" for the program architecture so the test was "passing" elsewhere but I don't think it was meant to. So I have added a define to pass on the host's architecture when compiling. This makes it work on AArch64 as well. While I'm here I've fixed the uint64_t formatting warnings by using the defined formats that'll work everywhere. In addition, I found that the function names include "()" on Linux, so now we check for "foo" or "foo()". The test cpp file has never been, or was only partially formatted so I've not formatted the changes, just kept to the local style. I've removed the Linux skip to see if any of this helps the timeouts, and to verify the build command changes. If the timeouts come back I'll disable it again.
2024-07-26[lldb] Remove python helper getCompilerBinary() (#100660)Kendal Harland1-4/+0
This causes a number of tests be `UNRESOLVED` on Windows if `getCompiler()` has a space in the name, because `getCompilerBinary()` unconditionally splits on whitespace and returns the first result, which might just be`"C:\Program"` if using a compiler such as `clang-cl` `cl` from the absolute path to Visual studio's installation directory. Co-authored-by: kendal <kendal@thebrowser.company>
2024-06-26[lldb] fix(lldb/**.py): fix comparison to None (#94017)Eisuke Kawashima1-3/+3
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[lldb] fix(lldb/**.py): fix comparison to True/False (#94039)Eisuke Kawashima1-1/+1
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-05-16[lldb] Move TestBase.runCmd() to the Base class (#92252)Dmitry Vasilyev1-65/+65
runCmd() is called from Base.getCPUInfo() but implemented only in TestBase(Base). Usually it works if TestBase is used. But call getCPUInfo() from a class based on Base will cause something like ``` File "E:\projects\llvm-nino\lldb\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py", line 1256, in getCPUInfo self.runCmd('platform get-file "/proc/cpuinfo" ' + cpuinfo_path) AttributeError: 'TestGdbRemoteExpeditedRegisters' object has no attribute 'runCmd' ``` BTW, TestBase.setUp() called runCmd() before applying LLDB_MAX_LAUNCH_COUNT and LLDB_TIME_WAIT_NEXT_LAUNCH. This patch fixes the test TestGdbRemoteExpeditedRegisters in case of Windows host and Linux target.
2024-04-30[lldb] Fixed SyntaxWarning invalid escape sequence '\l' in lldbtest.py (#90609)Dmitry Vasilyev1-1/+1
2024-04-29Add a new SBExpressionOptions::SetLanguage() API (NFCI) (#89981)Adrian Prantl1-7/+18
that separates out language and version. To avoid reinventing the wheel and introducing subtle incompatibilities, this API uses the table of languages and versiond defined by the upcoming DWARF 6 standard (https://dwarfstd.org/languages-v6.html). While the DWARF 6 spec is not finialized, the list of languages is broadly considered stable. The primary motivation for this is to allow the Swift language plugin to switch between language dialects between, e.g., Swift 5.9 and 6.0 with out introducing a ton of new language codes. On the main branch this change is considered NFC. Depends on https://github.com/llvm/llvm-project/pull/89980
2024-04-15[libc++][CI] Tests LLDB libc++ data formatters. (#88312)Mark de Wever1-0/+2
This enables testing of the LLDB libc++ specific data formatters. This is enabled in the bootstrap build since building LLDB requires Clang and this is quite expensive. Adding this test changes the build time from 31 to 34 minutes.
2024-02-26[lldb][test][Windows] Don't assert that module cache is emptyDavid Spickett1-1/+3
For whatever reason on Windows, it is not at this point. The copy of unit test we used to use would ignore failures during teardown but Python's does not.
2024-02-16[lldb] Don't overwrite the dynamic loader library path for "driver tests"Jonas Devlieghere1-15/+0
We have a handful of tests that build a driver which links against LLDB. When running those binaries, we overwrite the dynamic loader library path to point to the build directory's libs dir, presumably to make sure we load LLDB from there. This above becomes an issue when you have libc++ enabled and the driver is linked against the system's libc++, but the dynamic loader flag forces it to pick up libc++ from the libs dir. We could try to make the logic for building the driver smarter and have it pick up the just-built libc++ like we do for our test binaries, but I don't think we need to overwrite the library path in the first place. The build logic to build these drivers already takes care to set the correct RPATH in the linker. This patch removes the logic and simplifies the tests.
2024-02-13[lldb][test] Switch LLDB API tests from vendored unittest2 to unittest (#79945)Jordan Rupprecht1-19/+9
This removes the dependency LLDB API tests have on lldb/third_party/Python/module/unittest2, and instead uses the standard one provided by Python. This does not actually remove the vendored dep yet, nor update the docs. I'll do both those once this sticks. Non-trivial changes to call out: - expected failures (i.e. "bugnumber") don't have a reason anymore, so those params were removed - `assertItemsEqual` is now called `assertCountEqual` - When a test is marked xfail, our copy of unittest2 considers failures during teardown to be OK, but modern unittest does not. See TestThreadLocal.py. (Very likely could be a real bug/leak). - Our copy of unittest2 was patched to print all test results, even ones that don't happen, e.g. `(5 passes, 0 failures, 1 errors, 0 skipped, ...)`, but standard unittest prints a terser message that omits test result types that didn't happen, e.g. `OK (skipped=1)`. Our lit integration parses this stderr and needs to be updated w/ that expectation. I tested this w/ `ninja check-lldb-api` on Linux. There's a good chance non-Linux tests have similar quirks, but I'm not able to uncover those.
2024-01-26[lldb] Remove obsolete signBinary helper (#79656)Jonas Devlieghere1-8/+0
On Darwin, the Makefile already (ad-hoc) signs everything it builds. There's also no need to use lldb_codesign for this.
2024-01-19[lldb][test] Apply @expectedFailureAll/@skipIf early for debug_info tests ↵Jordan Rupprecht1-0/+22
(#73067) The @expectedFailureAll and @skipIf decorators will mark the test case as xfail/skip if _all_ conditions passed in match, including debug_info. * If debug_info is not one of the matching conditions, we can immediately evaluate the check and decide if it should be decorated. * If debug_info *is* present as a match condition, we need to defer whether or not to decorate until when the `LLDBTestCaseFactory` metaclass expands the test case into its potential variants. This is still early enough that the standard `unittest` framework will recognize the test as xfail/skip by the time the test actually runs. TestDecorators exhibits the edge cases more thoroughly. With the exception of `@expectedFailureIf` (added by this commit), all those test cases pass prior to this commit. This is a followup to 212a60ec37322f853e91e171b305479b1abff2f2.
2023-11-15[lldb][test] Remove `self` references from decorators (#72416)Jordan Rupprecht1-94/+9
This is partial step toward removing the vendored `unittest2` dep in favor of the `unittest` library in standard python. One of the large differences is when xfail decorators are evaluated. With the `unittest2` vendored dep, this can happen at the moment of calling the test case, and with LLDB's decorator wrappers, we are passed the test class in the decorator arg. With the `unittest` framework, this is determined much earlier; we cannot decide when the test is about to start that we need to xfail. Fortunately, almost none of these checks require any state that can't be determined statically. For this patch, I moved the impl for all the checks to `lldbplatformutil` and pointed the decorators to that, removing as many `self` (i.e. test class object) references as possible. I left wrappers within `TestBase` that forward to `lldbplatformutil` for convenience, but we should probably remove those later. The remaining check that can't be moved statically is the check for the debug info type (e.g. to xfail only for dwarf). Fixing that requires a different approach, so I will postpone that to the next patch.
2023-11-10[lldb][AArch64][Linux] Add field information for the mte_ctrl register (#71808)David Spickett1-0/+11
This is a Linux pseudo register provided by the NT_ARM_TAGGED_ADDR_CTRL register set. It reflects the value passed to prctl PR_SET_TAGGED_ADDR_CTRL. https://docs.kernel.org/arch/arm64/memory-tagging-extension.html The fields are made from the #defines the kernel provides for setting the value. Its contents are constant so no runtime detection is needed (once we've decided we have this register in the first place). The permitted generated tags is technically a bitfield but at this time we don't have a way to mark a field as preferring hex formatting. ``` (lldb) register read mte_ctrl mte_ctrl = 0x000000000007fffb = (TAGS = 65535, TCF_ASYNC = 0, TCF_SYNC = 1, TAGGED_ADDR_ENABLE = 1) ``` (4 bit tags mean 16 possible tags, 16 bit bitfield) Testing has been added to TestMTECtrlRegister.py, which needed a more granular way to check for XML support, so I've added hasXMLSupport that can be used within a test case instead of skipping whole tests if XML isn't supported. Same for the core file tests.
2023-11-01[lldb][AArch64] Add SME2's ZT0 register (#70205)David Spickett1-0/+4
SME2 is documented as part of the main SME supplement: https://developer.arm.com/documentation/ddi0616/latest/ The one change for debug is this new ZT0 register. This register contains data to be used with new table lookup instructions. It's size is always 512 bits (not scalable) and can be interpreted in many different ways depending on the instructions that use it. The kernel has implemented this as a new register set containing this single register. It always returns register data (with no header, unlike ZA which does have a header). https://docs.kernel.org/arch/arm64/sme.html ZT0 is only active when ZA is active (when SVCR.ZA is 1). In the inactive state the kernel returns 0s for its contents. Therefore lldb doesn't need to create 0s like it does for ZA. However, we will skip restoring the value of ZT0 if we know that ZA is inactive. As writing to an inactive ZT0 sets SVCR.ZA to 1, which is not desireable as it would activate ZA also. Whether SVCR.ZA is set will be determined only by the ZA data we restore. Due to this, I've added a new save/restore kind SME2. This is easier than accounting for the variable length ZA in the SME data. We'll only save an SME2 data block if ZA is active. If it's not we can get fresh 0s back from the kernel for ZT0 anyway so there's nothing for us to restore. This new register will only show up if the system has SME2 therefore the SME set presented to the user may change, and I've had to account for that in in a few places. I've referred to it internally as simply "ZT" as the kernel does in NT_ARM_ZT, but the architecture refers to the specific register as "ZT0" so that's what you'll see in lldb. ``` (lldb) register read -s 6 Scalable Matrix Extension Registers: svcr = 0x0000000000000000 svg = 0x0000000000000004 za = {0x00 <...> 0x00} zt0 = {0x00 <...> 0x00} ```
2023-10-25[lldb][AArch64] Simplify AArch64SMEFA64 checkDavid Spickett1-3/+2
So we only have to read cpuinfo once.
2023-10-25[lldb][AArch64] Add isAArch64SMEFA64 check to SME testing (#68094)David Spickett1-0/+8
FEAT_SME_FA64 (smefa64 in Linux cpuinfo) allows the use of the full A64 instruction set while in streaming SVE mode. See https://developer.arm.com/documentation/ddi0616/latest/ for details. This means for example if we want to write to the ffr register during or use floating point registers while in streaming mode, we need this extension. I initially was using QEMU which has it by default, and switched to Arm's FVP which does not. So this change adds a more strict check and converts most of the tests to use that. It would be possible in some cases to avoid the offending instructions but it would be a lot of effort and liable to fail randomly as the C library changes. It is also my assumption that the majority of systems will have smefa64 as QEMU has chosen to have. If I turn out to be wrong, we can make the effort to get the tests working without smefa64. `isAArch64SME` remains for some tests, which are as follows: * `test_aarch64_dynamic_regset_config` merely checks for the presence of a register set, which appears for any SME system not just one with smefa64. * `test_aarch64_dynamic_regset_config_sme_za_disabled` only needs the ZA register and does not enter streaming mode. * `test_sme_not_present` tests for the absence of the SME register set, so must be skipped if any form of SME is present. * Various tests in `TestSVERegisters.py` need to know if SME is present at all to generate an expected SVCR value. Earlier in the callstack something else checked `isAArch64SMEFA64` already. * `TestAArch64LinuxTLSRegisters.py` needs to test the `tpidr2` register if any form of SME is present. msr/mrs instructions are used to do this and are allowed even if smefa64 is not present.