summaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api/value
AgeCommit message (Collapse)Author
2025-08-18Decent to Descent (#154040)LauraElanorJones
[lldb] Rename RecursiveDecentFormatter to RecursiveDescentFormatter (NFC)
2025-06-02[lldb] Refactor away UB in SBValue::GetLoadAddress (#141799)Pavel Labath
The problem was in calling GetLoadAddress on a value in the error state, where `ValueObject::GetLoadAddress` could end up accessing the uninitialized "address type" by-ref return value from `GetAddressOf`. This probably happened because each function expected the other to initialize it. We can guarantee initialization by turning this into a proper return value. I've added a test, but it only (reliably) crashes if lldb is built with ubsan.
2024-12-09[lldb] Add lookup by name to SBValue through new member property (#118814)Dave Lee
Introduces a `member` property to `SBValue`. This property provides pythonic access to a value's members, by name. The expression `value.member["name"]` will be an alternate form form of writing `value.GetChildMemberWithName("name")`.
2024-11-12[lldb] Support true/false in ValueObject::SetValueFromCString (#115780)Jonas Devlieghere
Support "true" and "false" (and "YES" and "NO" in Objective-C) in ValueObject::SetValueFromCString. Fixes #112597
2024-03-11Make ValueObject::Cast work for casts from smaller to larger structs in the ↵jimingham
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-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-16[lldb] Replace assertEquals with assertEqual (NFC) (#82073)Jonas Devlieghere
assertEquals is a deprecated alias for assertEqual and has been removed in Python 3.12. This wasn't an issue previously because we used a vendored version of the unittest module. Now that we use the built-in version this gets updated together with the Python version used to run the test suite.
2024-02-15[lldb] Fix Python test formatting (NFC)Jonas Devlieghere
2023-09-19[lldb] Correct expected output for variable on 32 bit platformsDavid Spickett
710276a2505514634a7cc805461b1219dcef9337 added settings to control leading zeros but the initial test case assumed a 64 bit target.
2023-09-18[lldb] Fix the TestValueAPI testwalter erquinigo
This test was reported as failing by https://lab.llvm.org/buildbot/#/builders/68/builds/60172. The fix is very simple. We need to invoke the correct setting.
2023-09-18[LLDB] Add a setting for printing ValueObject hex values without leading ↵Walter Erquinigo
zeroes (#66548) As suggested by Greg in https://github.com/llvm/llvm-project/pull/66534, I'm adding a setting at the Target level that controls whether to show leading zeroes in hex ValueObject values. This has the benefit of reducing the amount of characters displayed in certain interfaces, like VSCode.
2023-08-04[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-08-04[lldb] Bump SWIG minimum version to 4Jonas Devlieghere
SWIG 4 was released in 2019 and has been the de-facto standard for a while now. All bots are running SWIG 4.0 or later. This was motivated by #64279 which discovered that 662548c broke the LLDB build with SWIG 3 on Windows. Differential revision: https://reviews.llvm.org/D156804
2023-06-26Don't allow SBValue::Cast to cast from a smaller type to a larger,Jim Ingham
as we don't in general know where the extra data should come from. Differential Revision: https://reviews.llvm.org/D153657
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-03-10Don't produce a dynamic value if there was an error creating it.Jim Ingham
We used to make a dynamic value that "pretended to be its parent" but that's hard for some of the more complex ValueObject types, and it's better in this case just to return no dynamic value. Differential Revision: https://reviews.llvm.org/D145629
2023-01-25[NFC][LLDB] Rename test filePavel Kosov
Commit 92f0e4cca introduced test file with name TestChangeValue.py, which leads to test failure because there already is a test files with the same name In this commit a newly added file is renamed to fix this failure
2023-01-25[LLDB] Fixes summary formatter for libc++ map allowing modification of ↵Pavel Kosov
contained value Reviewed By: clayborg Differential Revision: https://reviews.llvm.org/D140624
2023-01-25[LLDB] Fix for libc++ atomic allowing modification of contained valuePavel Kosov
Reviewed By: clayborg Differential Revision: https://reviews.llvm.org/D140623
2022-11-11[lldb] Rewrite to assertEqual/assertNotEqual (NFC)Dave Lee
Using the more specific assert* methods results in more useful error message.
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-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-06-08[lldb] Add assertState function to the API test suiteJonas Devlieghere
Add a function to make it easier to debug a test failure caused by an unexpected state. Currently, tests are using assertEqual which results in a cryptic error message: "AssertionError: 5 != 10". Even when a test provides a message to make it clear why a particular state is expected, you still have to figure out which of the two was the expected state, and what the other value corresponds to. We have a function in lldbutil that helps you convert the state number into a user readable string. This patch adds a wrapper around assertEqual specifically for comparing states and reporting better error messages. The aforementioned error message now looks like this: "AssertionError: stopped (5) != exited (10)". If the user provided a message, that continues to get printed as well. Differential revision: https://reviews.llvm.org/D127355
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-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
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-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-13[lldb] Replace assertTrue(a == b, "msg") with assertEquals(a, b, "msg") in ↵Raphael Isemann
the test suite Summary: The error message from the construct `assertTrue(a == b, "msg") ` are nearly always completely useless for actually debugging the issue. This patch is just replacing this construct (and similar ones like `assertTrue(a != b, ...)` with the proper call to assertEqual or assertNotEquals. This patch was mostly written by a shell script with some manual verification afterwards: ``` lang=python import sys def sanitize_line(line): if line.strip().startswith("self.assertTrue(") and " == " in line: line = line.replace("self.assertTrue(", "self.assertEquals(") line = line.replace(" == ", ", ", 1) if line.strip().startswith("self.assertTrue(") and " != " in line: line = line.replace("self.assertTrue(", "self.assertNotEqual(") line = line.replace(" != ", ", ", 1) return line for a in sys.argv[1:]: with open(a, "r") as f: lines = f.readlines() with open(a, "w") as f: for line in lines: f.write(sanitize_line(line)) ``` Reviewers: labath, JDevlieghere Reviewed By: labath Subscribers: abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D74475
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