summaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api/target
AgeCommit message (Collapse)Author
2025-05-27[lldb][NFC] update API tests which skip/expect-fail armJason Molenda
The architectures provided to skipIf / expectedFail are regular expressions (v. _match_decorator_property() in decorators.py so on Darwin systems "arm64" would match the skips for "arm" (32-bit Linux). Update these to "arm$" to prevent this, and also update three tests (TestBuiltinFormats.py, TestCrossDSOTailCalls.py, TestCrossObjectTailCalls.py) that were skipped for arm64 via this behavior, and need to be skipped or they will fail. This was moviated by the new TestDynamicValue.py test which has an expected-fail for arm, but the test was passing on arm64 Darwin resulting in failure for the CIs.
2025-04-13Skip test on DarwinAdrian Prantl
2025-04-11[lldb][test] Adjust TestTargetReadInstructionsFlavor skipIfsDavid Spickett
Original in https://github.com/llvm/llvm-project/pull/134626 was written as if it was "this or this" but it's "this and this". So the test ran on AArch64 Linux, because Linux is not Windows. Split out the Windows check to fix that.
2025-04-11[lldb] Fix SBTarget::ReadInstruction with flavor (#134626)Ebuka Ezike
When you call the `SBTarget::ReadInstructions` with flavor from lldb crashes. This is because the wrong order of the `DisassemblyBytes` constructor this fixes that --------- Signed-off-by: Ebuka Ezike <yerimyah1@gmail.com>
2025-03-31[lldb] Expose the Target API mutex through the SB API (#133295)Jonas Devlieghere
Expose u target API mutex through the SB API. This is motivated by lldb-dap, which is built on top of the SB API and needs a way to execute a series of SB API calls in an atomic manner (see #131242). We can solve this problem by either introducing an additional layer of locking at the DAP level or by exposing the existing locking at the SB API level. This patch implements the second approach. This was discussed in an RFC on Discourse [0]. The original implementation exposed a move-only lock rather than a mutex [1] which doesn't work well with SWIG 4.0 [2]. This implement the alternative solution of exposing the mutex rather than the lock. The SBMutex conforms to the BasicLockable requirement [3] (which is why the methods are called `lock` and `unlock` rather than Lock and Unlock) so it can be used as `std::lock_guard<lldb::SBMutex>` and `std::unique_lock<lldb::SBMutex>`. [0]: https://discourse.llvm.org/t/rfc-exposing-the-target-api-lock-through-the-sb-api/85215/6 [1]: https://github.com/llvm/llvm-project/pull/131404 [2]: https://discourse.llvm.org/t/rfc-bumping-the-minimum-swig-version-to-4-1-0/85377/9 [3]: https://en.cppreference.com/w/cpp/named_req/BasicLockable
2024-09-25[lldb] Fix error reporting in SBTarget::ReadMemory (#109764)Pavel Labath
The function should use the by-ref SBError argument instead of creating a new one. This code has been here since ~forever, and was probably copied from methods which return an SBError result (where one needs to create a local variable).
2024-02-21[lldb][test] Modernize asserts (#82503)Jordan Rupprecht
This uses [teyit](https://pypi.org/project/teyit/) to modernize asserts, as recommended by the [unittest release notes](https://docs.python.org/3.12/whatsnew/3.12.html#id3). For example, `assertTrue(a == b)` is replaced with `assertEqual(a, b)`. This produces better error messages, e.g. `error: unexpectedly found 1 and 2 to be different` instead of `error: False`.
2024-02-06[lldb] Fix a crasher when using the public API. (#80508)Greg Clayton
A user found a crash when they would do code like: ``` (lldb) script >>> target = lldb.SBTarget() >>> lldb.debugger.SetSelectedTarget(target) ``` We were not checking if the target was valid in and it caused a crash..
2023-06-16[lldb] Fix Python test formatting (NFC)Jonas Devlieghere
All Python files in the LLVM repository were reformatted with Black [1]. Files inside the LLDB subproject were reformatted in 2238dcc39358. This patch updates a handful of tests that were added or modified since then and weren't formatted with Black. [1] https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style/68257
2023-05-29Revert "[LLDB] Add/Remove xfail for some API tests on Windows"tcwg
This reverts commit 6ea1a0d4fc3823de143a288df2059b48dc01cf72. It again marks XFAIL LLDB tests failing after c384fcd3ea1dad782eaaea89b32fc33c0c3528b8
2023-05-25[NFC][Py Reformat] Reformat python files in lldbJonas Devlieghere
This is an ongoing series of commits that are reformatting our Python code. Reformatting is done with `black` (23.1.0). If you end up having problems merging this commit because you have made changes to a python file, the best way to handle that is to run `git checkout --ours <yourfile>` and then reformat it with black. RFC: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style Differential revision: https://reviews.llvm.org/D151460
2023-05-03[LLDB] Add/Remove xfail for some API tests on WindowsMuhammad Omair Javaid
This patch add or removes XFAIL decorator from various tests which were marked xfail for windows. since 44363f2 various tests have started passing but introduced a couple of new failures. Weight is in favor of new XPasses and I have removed XFail decorator from them. Also some new tests have started failing for which we need to file separate bugs. I have marked them xfail for now and will add the bug id after investigating the issue. Differential Revision: https://reviews.llvm.org/D149235
2023-01-26[test] Remove unused `unittest2` importJordan Rupprecht
2022-11-18[lldb] Fix that empty target.run-args are not actually used when launching ↵Raphael Isemann
process `GetPropertyAtIndexAsArgs` returns true on success and false on failure. Right now it returns the converted `size_t` returned from `GetArgs` which describes the number of arguments in the argument list. So for empty argument lists (`(size_t)0` -> `(bool)false`) this function always fails. The only observable effect of this seems to be that empty arguments are never propagated to the internal LaunchInfo for a process. This causes that once any argument has been added to `target.run-args`, clearing `target.run-args` doesn't have any effect. Fixes issue #55568 Reviewed By: JDevlieghere, jingham Differential Revision: https://reviews.llvm.org/D126057
2022-09-06Revert "[lldb][bindings] Fix module_access handling of regex"Stella Stamenova
This reverts commit 75f05fccbbdd91393bdc7b6183b9dd2b1e859f8e. This commit broke the windows lldb bot: https://lab.llvm.org/buildbot/#/builders/83/builds/23284
2022-09-03[lldb][bindings] Fix module_access handling of regexDave Lee
Fixes broken support for: `target.module[re.compile("libFoo")]` There were two issues: 1. The type check was expecting `re.SRE_Pattern` 2. The expression to search the module path had a typo In the first case, `re.SRE_Pattern` does not exist in Python 3, and is replaced with `re.Pattern`. While editing this code, I changed the type checks to us `isinstance`, which is the conventional way of type checking. From the docs on `type()`: > The `isinstance()` built-in function is recommended for testing the type of an object, because it takes subclasses into account. Differential Revision: https://reviews.llvm.org/D133130
2022-08-15[LLDB] Remove __future__ imports from testsDavid Spickett
Not needed now that we require python 3. Reviewed By: kastiglione, JDevlieghere Differential Revision: https://reviews.llvm.org/D131761
2022-06-29[lldb] Use assertState in even more tests (NFC)Jonas Devlieghere
Followup to D127355 and D127378, converting more instances of assertEqual to assertState.
2022-06-17[lldb][tests] Automatically call compute_mydir (NFC)Dave Lee
Eliminate boilerplate of having each test manually assign to `mydir` by calling `compute_mydir` in lldbtest.py. Differential Revision: https://reviews.llvm.org/D128077
2022-06-09[lldb] Use assertState in more tests (NFC)Dave Lee
Follow to D127355, converting more `assertEquals` to `assertState`. Differential Revision: https://reviews.llvm.org/D127378
2022-04-08[lldb] Skip a bunch of tests that shouldn't run remotelyJonas Devlieghere
Skip a bunch of tests that don't really make sense to run remotely.
2022-03-14Don't report memory return values on MacOS_arm64 of SysV_arm64 ABI's.Jim Ingham
They don't require that the memory return address be restored prior to function exit, so there's no guarantee the value is correct. It's better to return nothing that something that's not accurate. Differential Revision: https://reviews.llvm.org/D121348
2022-02-14[lldb] Replace asserts on .Success() with assertSuccess()Dave Lee
Replace forms of `assertTrue(err.Success())` with `assertSuccess(err)` (added in D82759). * `assertSuccess` prints out the error's message * `assertSuccess` expresses explicit higher level semantics, both to the reader and for test failure output * `assertSuccess` seems not to be well known, using it where possible will help spread knowledge * `assertSuccess` statements are more succinct Differential Revision: https://reviews.llvm.org/D119616
2021-10-15[NFC] fix a typoShao-Ce SUN
2021-09-30[lldb] Remove support for replaying the test suite from a reproducerJonas Devlieghere
This patch removes the infrastructure to replay the test suite from a reproducer, as well as the modifications made to the individual tests.
2021-02-08[lldb/tests] Removed add_test_categories decorator for python API tests, NFCTatyana Krasnukha
There is a .categories file in the python_api directory that makes all nested tests belong to the category "pyapi". The decorator is unnecessary for these tests.
2021-02-03[lldb] Convert more assertTrue to assertEqual (NFC)Dave Lee
Follow up to D95813, this converts multiline assertTrue to assertEqual. Differential Revision: https://reviews.llvm.org/D95899
2021-02-02[lldb] Convert assertTrue(a == b) to assertEqual(a, b)Dave Lee
Convert `assertTrue(a == b)` to `assertEqual(a, b)` to produce better failure messages. These were mostly done via regex search & replace, with some manual fixes. Differential Revision: https://reviews.llvm.org/D95813
2021-02-01[lldb/test] Skip `SBTarget::IsLoaded` test on windows (NFC)Med Ismail Bennani
This patch skips the test for the SBTarget::IsLoaded method on windows since the logic is different. Differential Revision: https://reviews.llvm.org/D95686 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-02-01[lldb/API] Expose Module::IsLoadedInTarget() to SB API (NFC)Med Ismail Bennani
This patch adds an `SBTarget::IsLoaded(const SBModule&) const` endpoint to lldb's Scripting Bridge API. As the name suggests, it will allow the user to know if the module is loaded in a specific target. rdar://37957625 Differential Review: https://reviews.llvm.org/D95686 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2021-01-26Make SBDebugger::CreateTargetWithFileAndArch work with lldb::LLDB_DEFAULT_ARCHJim Ingham
Second try, handling both a bogus arch string and the "null file & arch" used to create an empty but valid target. Also check in that case before logging (previously the logging would have crashed.)
2021-01-25Revert "Fix SBDebugger::CreateTargetWithFileAndArch to accept ↵Richard Smith
LLDB_ARCH_DEFAULT." Also revert "Follow on to: f05dc40c31d1883b46b8bb60547087db2f4c03e3" After these changes, multiple lldb tests are failing. Calls to CreateTargetWithFileAndArch(None, None) appear to fail after these changes. This reverts commit f05dc40c31d1883b46b8bb60547087db2f4c03e3 and 1fba21778f84f266f7d32153c88e59e1900fbe5b.
2021-01-25Fix SBDebugger::CreateTargetWithFileAndArch to accept LLDB_ARCH_DEFAULT.Jim Ingham
The API docs in SBDebugger.i claim this should work but it doesn't. This should fix it. Differential Revision: https://reviews.llvm.org/D95164
2020-11-11[lldb][test] Remove not_remote_testsuite_ready in favor of skipIfRemote ↵Raphael Isemann
decorator Those two decorators have identical behaviour. This removes `not_remote_testsuite_ready` as `skipIfRemote` seems more consistent with the other decorator names we have Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D89376
2020-10-22[lldb] Fix TestTargetAPI.py on Apple simulatorsRaphael Isemann
This test checks that the output of `SBTarget.GetDescription()` contains the substrings `'a.out', 'Target', 'Module', 'Breakpoint'` in that order. This test is currently failing on Apple simulators as apparently 'Module' can't be found in the output after 'Target". The reason for that is that the actual output of `SBTarget.GetDescription()` looks like this: ``` Target Module /build/path/lldb-test-build.noindex/python_api/target/TestTargetAPI.test_get_description_dwarf/a.out 0x7ff2b6d3f990: ObjectFileMachO64, file = /build/path/lldb-test-build.noindex/python_api/target/TestTargetAPI.test_get_description [...] 0x7ff307150000: BreakpointList with 0 Breakpoints: <LLDB module output repeats for each loaded module> ``` Clearly the string order should be `'Target', 'Module', 'a.out', 'Breakpoint'`. However, LLDB is also a bunch of system shared libraries (libxpc.dylib, libobjc.A.dylib, etc.) when *not* running against a simulator, we end up unintentionally finding the `'Target', 'Module', 'Breakpoint'` substrings in the trailing descriptions of the system modules. When running against a simulator we however don't load shared system libraries. This patch just moves the substrings in the correct order to make this test pass without having any shared library modules in the description output. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D89698
2020-08-17[lldb] Skip test_launch_simple with reproducersJonas Devlieghere
The test checks the inferior's output. During replay the binary doesn't actually run and the output isn't captured by the reproducers.
2020-08-14[lldb] Use SBProcess::Continue instead of 'run' command in TestTargetAPI.pyRaphael Isemann
This test is flaky on Green Dragon as it often fails when the process state is "Invalid" in the assert: self.assertEqual(process.GetState(), lldb.eStateExited) It seems this is related to just doing "run" which apparently invalidates the Target's process in case it's still running and needs to be restarted. Just doing 'continue' on the process (and ignoring the error in case it already finished) prevents that and makes this consistently pass for me. Just pushing this out to get Green Dragon back online.
2020-08-07[lldb] Assert the process has exited before we gets its output.Jonas Devlieghere
2020-08-06[LLDB] Mark test_launch_simple as a no-debug-info testJonas Devlieghere
No need to run this test with the multiple variants.
2020-08-06[LLDB] Skip test_launch_simple from TestTargetAPI.py when remoteJonas Devlieghere
2020-08-06[LLDB] Skip test_launch_simple from TestTargetAPI.py on Arm/AArch64 LinuxMuhammad Omair Javaid
Recently added TestTargetAPI.py test "test_launch_simple" is failing on Arm/AArch64 Linux targets. Putting them to skip until fixed. Differential Revision: https://reviews.llvm.org/D85235
2020-08-05"|" used when "||" was meant in SBTarget::FindFunctionsJim Ingham
2020-08-05[lldb] Skip test_launch_simple on WindowsJonas Devlieghere
Because stdio manipulation unsupported on Windows.
2020-08-05[lldb] Make SBTarget::LaunchSimple start form the target's LaunchInfoJonas Devlieghere
Currently SBTarget::LaunchSimple creates a new LaunchInfo which means it ignores any target properties that have been set. Instead, it should start from the target's LaunchInfo and populated the specified fields. Differential revision: https://reviews.llvm.org/D85235
2020-05-25[lldb/Test] Add a trace method to replace print statements.Jonas Devlieghere
Many tests use (commented out) print statement for debugging the test itself. This patch adds a new trace method to lldbtest to reuse the existing tracing infrastructure and replace these print statements. Differential revision: https://reviews.llvm.org/D80448
2020-05-20[lldb/Reproducers] Fix/skip passive replay failures in python_api subdirJonas Devlieghere
Fixes or skips tests in the python_api subdirectory that were failing with passive replay.
2020-04-07[lldb] NFC: Fix trivial typo in comments, documents, and messagesKazuaki Ishizaki
Differential Revision: https://reviews.llvm.org/D77460
2020-02-20[lldb] Remove license headers from all test source filesRaphael Isemann
Summary: Around a third of our test sources have LLVM license headers. This patch removes those headers from all test sources and also fixes any tests that depended on the length of the license header. The reasons for this are: * A few tests verify line numbers and will start failing if the number of lines in the LLVM license header changes. Once I landed my patch for valid SourceLocations in debug info we will probably have even more tests that verify line numbers. * No other LLVM project is putting license headers in its test files to my knowledge. * They make the test sources much more verbose than they have to be. Several tests have longer license headers than the actual test source. For the record, the following tests had their line numbers changed to pass with the removal of the license header: lldb-api :: functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py lldb-shell :: Reproducer/TestGDBRemoteRepro.test lldb-shell :: Reproducer/TestMultipleTargets.test lldb-shell :: Reproducer/TestReuseDirectory.test lldb-shell :: ExecControl/StopHook/stop-hook-threads.test lldb-shell :: ExecControl/StopHook/stop-hook.test lldb-api :: lang/objc/exceptions/TestObjCExceptions.py Reviewers: #lldb, espindola, JDevlieghere Reviewed By: #lldb, JDevlieghere Subscribers: emaste, aprantl, arphaman, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D74839
2020-02-11[lldb][test] Remove symlink for API tests.Jordan Rupprecht
Summary: Moves lldbsuite tests to lldb/test/API. This is a largely mechanical change, moved with the following steps: ``` rm lldb/test/API/testcases mkdir -p lldb/test/API/{test_runner/test,tools/lldb-{server,vscode}} mv lldb/packages/Python/lldbsuite/test/test_runner/test lldb/test/API/test_runner for d in $(find lldb/packages/Python/lldbsuite/test/* -maxdepth 0 -type d | egrep -v "make|plugins|test_runner|tools"); do mv $d lldb/test/API; done for d in $(find lldb/packages/Python/lldbsuite/test/tools/lldb-vscode -maxdepth 1 -mindepth 1 | grep -v ".py"); do mv $d lldb/test/API/tools/lldb-vscode; done for d in $(find lldb/packages/Python/lldbsuite/test/tools/lldb-server -maxdepth 1 -mindepth 1 | egrep -v "gdbremote_testcase.py|lldbgdbserverutils.py|socket_packet_pump.py"); do mv $d lldb/test/API/tools/lldb-server; done ``` lldb/packages/Python/lldbsuite/__init__.py and lldb/test/API/lit.cfg.py were also updated with the new directory structure. Reviewers: labath, JDevlieghere Tags: #lldb Differential Revision: https://reviews.llvm.org/D71151