summaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api
AgeCommit message (Collapse)Author
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-21[test] Remove named function arguments from TestSBEnvironmentJordan Rupprecht
This is not available in all versions of swig 3.
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-11-12[lldb] Revert SBFileSpec.fullpath path separator fixDave Lee
Primarily reverts 5223366416fb.
2022-11-11[lldb] Rewrite to assertEqual/assertNotEqual (NFC)Dave Lee
Using the more specific assert* methods results in more useful error message.
2022-11-11[lldb] Fix SBFileSpec.fullpath for WindowsDave Lee
Fix `fullpath` to not assume a `/` path separator. This was discovered when D133130 failed on Windows. Use `os.path.join()` to fix the issue. Reviewed By: mib Differential Revision: https://reviews.llvm.org/D133366
2022-10-27[lldb][test] Remove empty setUp/tearDown methods (NFC)Dave Lee
2022-10-20Revert "[lldb] Fix member access in GetExpressionPath"Jonas Devlieghere
This reverts commit 0205aa4a02570dfeda5807f66756ebdbb102744b because it breaks TestArray.py: a->c = <parent failed to evaluate: parent is NULL> I decided to revert instead of disable the test because it looks like a legitimate issue with the patch.
2022-10-12[lldb] Fix member access in GetExpressionPathTonko Sabolčec
This change fixes two issues in ValueObject::GetExpressionPath method: 1. Accessing members of struct references used to produce expression paths such as "str.&str.member" (instead of the expected "str.member"). This is fixed by assigning the flag tha the child value is a dereference when calling Dereference() on references and adjusting logic in expression path creation. 2. If the parent of member access is dereference, the produced expression path was "*(ptr).member". This is incorrect, since it dereferences the member instead of the pointer. This is fixed by wrapping dereference expression into parenthesis, resulting with "(*ptr).member". Reviewed By: werat, clayborg Differential Revision: https://reviews.llvm.org/D132734
2022-09-30Revert "[lldb] Fix member access in GetExpressionPath"Andy Yankovsky
This reverts commit 14642dc74 Broke the tests on macOS -- https://reviews.llvm.org/D132734#3827245
2022-09-30[lldb] Fix member access in GetExpressionPathTonko Sabolčec
This change fixes two issues in ValueObject::GetExpressionPath method: 1. Accessing members of struct references used to produce expression paths such as "str.&str.member" (instead of the expected "str.member"). This is fixed by assigning the flag tha the child value is a dereference when calling Dereference() on references and adjusting logic in expression path creation. 2. If the parent of member access is dereference, the produced expression path was "*(ptr).member". This is incorrect, since it dereferences the member instead of the pointer. This is fixed by wrapping dereference expression into parenthesis, resulting with "(*(ptr)).member". Reviewed By: werat, clayborg Differential Revision: https://reviews.llvm.org/D132734
2022-09-27[lldb][test] Disable TestSBValueUnsignedEnumBitField.py for old DWARF versionsMichael Buch
With older DWARF versions we don't encode the enum's underlying type in DWARF. In those cases LLDB sign-extends the bitfield as a signed integer. Without the actual enum type being present in DWARF there's not much we can do. Differential Revision: https://reviews.llvm.org/D134734
2022-09-23[lldb][TypeSystemClang] Deduce lldb::eEncodingUint for unsigned enum typesMichael Buch
The motivating issue was the following: ``` $ cat main.cpp enum class EnumVals : uint16_t { VAL1 = 0 }; struct Foo { EnumVals b1 : 4; }; int main() { // Assign value out-of-range if // bit-field were signed Foo f{.b1 = (EnumVals)8}; return 0; // Break here } (lldb) script >>> lldb.frame.FindVariable("f").GetChildMemberWithName("b1").GetValueAsUnsigned() 4294967288 ``` In the above example we observe a unsigned integer wrap-around because we sign-extended the bit-fields underlying Scalar value before casting it to an unsigned. The sign extension occurs because we don't mark APSInt::IsUnsigned == true correctly when extracting the value from memory (in Value::ResolveValue). The reason why sign extension causes the wraparound is that the value we're assigning to the bit-field is out-of-range (if it were a signed bit-field), which causes `Scalar::sext` to left-fill the Scalar with 1s. This patch corrects GetEncoding to account for unsigned enum types. With this change the Scalar would be zero-extended instead. This is mainly a convenience fix which well-formed code wouldn't encounter. rdar://99785324 Differential Revision: https://reviews.llvm.org/D134493
2022-09-12Reland "[lldb] Use just-built libcxx for tests when available"Felipe de Azevedo Piovezan
This commit improves upon cc0b5ebf7fc8, which added support for specifying which libcxx to use when testing LLDB. That patch honored requests by tests that had `USE_LIBCPP=1` defined in their makefiles. Now, we also use a non-default libcxx if all conditions below are true: 1. The test is not explicitly requesting the use of libstdcpp (USE_LIBSTDCPP=1). 2. The test is not explicitly requesting the use of the system's library (USE_SYSTEM_STDLIB=1). 3. A path to libcxx was either provided by the user through CMake flags or libcxx was built together with LLDB. Condition (2) is new and introduced in this patch in order to support tests that are either: * Cross-platform (such as API/macosx/macCatalyst and API/tools/lldb-server). The just-built libcxx is usually not built for platforms other than the host's. * Cross-language (such as API/lang/objc/exceptions). In this case, the Objective C runtime throws an exceptions that always goes through the system's libcxx, instead of the just built libcxx. Fixing this would require either changing the install-name of the just built libcxx in Mac systems, or tuning the DYLD_LIBRARY_PATH variable at runtime. Some other tests exposes limitations of LLDB when running with a debug standard library. TestDbgInfoContentForwardLists had an assertion removed, as it was checking for buggy LLDB behavior (which now crashes). TestFixIts had a variable renamed, as the old name clashes with a standard library name when debug info is present. This is a known issue: https://github.com/llvm/llvm-project/issues/34391. For `TestSBModule`, the way the "main" module is found was changed to look for the "a.out" module, instead of relying on the index being 0. In some systems, the index 0 is dyld when a custom standard library is used. Differential Revision: https://reviews.llvm.org/D132940
2022-09-08Revert "[lldb] Use just-built libcxx for tests when available"Felipe de Azevedo Piovezan
This reverts commit c38eeecbc7d929c9601f2189214a7a90d3982a47.
2022-09-08[lldb] Use just-built libcxx for tests when availableFelipe de Azevedo Piovezan
This commit improves upon cc0b5ebf7fc8, which added support for specifying which libcxx to use when testing LLDB. That patch honored requests by tests that had `USE_LIBCPP=1` defined in their makefiles. Now, we also use a non-default libcxx if all conditions below are true: 1. The test is not explicitly requesting the use of libstdcpp (USE_LIBSTDCPP=1). 2. The test is not explicitly requesting the use of the system's library (USE_SYSTEM_STDLIB=1). 3. A path to libcxx was either provided by the user through CMake flags or libcxx was built together with LLDB. Condition (2) is new and introduced in this patch in order to support tests that are either: * Cross-platform (such as API/macosx/macCatalyst and API/tools/lldb-server). The just-built libcxx is usually not built for platforms other than the host's. * Cross-language (such as API/lang/objc/exceptions). In this case, the Objective C runtime throws an exceptions that always goes through the system's libcxx, instead of the just built libcxx. Fixing this would require either changing the install-name of the just built libcxx in Mac systems, or tuning the DYLD_LIBRARY_PATH variable at runtime. Some other tests exposes limitations of LLDB when running with a debug standard library. TestDbgInfoContentForwardLists had an assertion removed, as it was checking for buggy LLDB behavior (which now crashes). TestFixIts had a variable renamed, as the old name clashes with a standard library name when debug info is present. This is a known issue: https://github.com/llvm/llvm-project/issues/34391. For `TestSBModule`, the way the "main" module is found was changed to look for the "a.out" module, instead of relying on the index being 0. In some systems, the index 0 is dyld when a custom standard library is used. Differential Revision: https://reviews.llvm.org/D132940
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-22Don't create sections for SHN_ABS symbols in ELF files.Greg Clayton
Symbols that have the section index of SHN_ABS were previously creating extra top level sections that contained the value of the symbol as if the symbol's value was an address. As far as I can tell, these symbol's values are not addresses, even if they do have a size. To make matters worse, adding these extra sections can stop address lookups from succeeding if the symbol's value + size overlaps with an existing section as these sections get mapped into memory when the image is loaded by the dynamic loader. This can cause stack frames to appear empty as the address lookup fails completely. This patch: - doesn't create a section for any SHN_ABS symbols - makes symbols that are absolute have values that are not addresses - add accessors to SBSymbol to get the value and size of a symbol as raw integers. Prevoiusly there was no way to access a symbol's value from a SBSymbol because the only accessors were: SBAddress SBSymbol::GetStartAddress(); SBAddress SBSymbol::GetEndAddress(); and these accessors would return an invalid SBAddress if the symbol's value wasn't an address - Adds a test to ensure no ".absolute.<symbol-name>" sections are created - Adds a test to test the new SBSymbol APIs Differential Revision: https://reviews.llvm.org/D131705
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-08-11[lldb] Remove unused "import unittest2" statementsDave Lee
2022-08-11[lldb] Remove uses of six module (NFC)Dave Lee
With lldb (& llvm) requiring Python 3.6+, use of the `six` module can be removed. Differential Revision: https://reviews.llvm.org/D131304
2022-08-03[lldb] Add assertStopReason helper functionJonas Devlieghere
Add a function to make it easier to debug a test failure caused by an unexpected stop reason. This is similar to the assertState helper that was added in ce825e46743b. Before: self.assertEqual(stop_reason, lldb.eStopReasonInstrumentation) AssertionError: 5 != 10 After: self.assertStopReason(stop_reason, lldb.eStopReasonInstrumentation) AssertionError: signal (5) != instrumentation (10) Differential revision: https://reviews.llvm.org/D131083
2022-08-02[LLDB] Add SBInstruction::GetControlFlowKind()Jakob Johnson
D128477 adds the control flow kind for `Instruction` and displays this in the `thread trace dump instruction -k` command. This diff exposes the control flow kind via the new `SBInstruction::GetControlFlowKind` method. I've expanded `TestDisassembleRawData` to test this method, but please let me know if there are any other unittests that should also be updated. Test Plan: `./bin/lldb-dotest -p TestDisassembleRawData` Differential Revision: https://reviews.llvm.org/D131005
2022-07-13[LLDB] Fix TestThreadAPI.py for AArch64/WindowsMuhammad Omair Javaid
This patch fixes TestThreadAPI for AArch64 windows by switching over to PDB debug info instead of DWARF. This is needed to step over library functions like printf as there is debug info mismatch between DWARF and PDB. PDB DWARF interworking is not fully supported by LLDB at the moment.
2022-07-12[lldb] add SBSection.alignment to python bindingsDavid M. Lary
This commit adds SBSection.GetAlignment(), and SBSection.alignment as a python property to lldb. Reviewed By: clayborg, JDevlieghere, labath Differential Revision: https://reviews.llvm.org/D128069
2022-07-12Revert "[lldb] add SBSection.alignment to python bindings"Pavel Labath
The patch didn't get proper attribution. Will recommit. This reverts commit 4135abca897d1b945193f767cbf42a200b55bbdc.
2022-07-12[lldb] add SBSection.alignment to python bindingsPavel Labath
This commit adds SBSection.GetAlignment(), and SBSection.alignment as a python property to lldb. Reviewed By: clayborg, JDevlieghere, labath Differential Revision: https://reviews.llvm.org/D128069
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-17[lldb] [test] Update baseline test status for FreeBSDMichał Górny
Fixes #19721 Fixes #18440 Partially fixes bug #47660 Fixes #47761 Fixes #47763 Sponsored by: The FreeBSD Foundation
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-05-25Skip testing of watchpoint hit-count/ignore-count on multithreadedJason Molenda
Skip all watchpoint hit-count/ignore-count tests for multithreaded API tests for now on arm64 Darwin. On AArch64, insns that trigger a WP are rolled back and we are notified. lldb needs to disable the WP, insn step, re-enable it, then report it to the user. lldb only does this full step action for the "selected thread", and so when a program stops with multiple threads hitting a stop reason, some of them watchpoints, any non-selected-thread will not be completed in this way. But all threads with the initial watchpoint exception will have their hit-count/ignore-counts updated. When we resume execution, the other threads sitting at the instruction will again execute & trigger the WP exceptoin again, repeating until we've gone through all of the threads. This bug is being tracked in llvm.org/pr49433 and inside apple in rdar://93863107
2022-05-13[lldb/API] Turn SBCompileUnit::GetIndexForLineEntry into FindLineEntryIndex ↵Med Ismail Bennani
(NFC) This patch renames the `SBCompileUnit::GetIndexForLineEntry` api to be an overload of `SBCompileUnit::FindLineEntryIndex` Differential Revision: https://reviews.llvm.org/D125594 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-05-12[lldb/API] Add SBCompileUnit::GetIndexForLineEntry method to SB APIMed Ismail Bennani
This patch adds a new `GetIndexForLineEntry` method to the `SBCompileUnit` class. As the name suggests, given an `SBLineEntry` object, this will return the line entry index within a specific compile unit. This method can take a `exact` boolean that will make sure that the provided line entry matches perfectly another line entry in the compile unit. rdar://47450887 Differention Revision: https://reviews.llvm.org/D125437 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-04-27Remove Python 2 checks from the test suiteJonas Devlieghere
We dropped downstream support for Python 2 in the previous release. Now that we have branched for the next release the window where this kind of change could introduce conflicts is closing too. Remove Python 2 checks from the test suite. Differential revision: https://reviews.llvm.org/D124429
2022-04-13[lldb] Fixup af921006d3792f for non-linux platformsPavel Labath
2022-04-13[lldb] Remove the global platform listPavel Labath
This patch moves the platform creation and selection logic into the per-debugger platform lists. I've tried to keep functional changes to a minimum -- the main (only) observable difference in this change is that APIs, which select a platform by name (e.g., Debugger::SetCurrentPlatform) will not automatically pick up a platform associated with another debugger (or no debugger at all). I've also added several tests for this functionality -- one of the pleasant consequences of the debugger isolation is that it is now possible to test the platform selection and creation logic. This is a product of the discussion at <https://discourse.llvm.org/t/multiple-platforms-with-the-same-name/59594>. Differential Revision: https://reviews.llvm.org/D120810
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-03-09Revert "[lldb] Remove the global platform list"Pavel Labath
It makes module dependencies loopier. This reverts commits 49cffe3c7fab74252d4b6a073303c803dc1659f0 and ffb9429b6f3c29ab4687b96fd85374924c98ad16.
2022-03-09[lldb] Add SBType::IsAggregateTypeDave Lee
Add `IsAggregateType` to the SB API. I'd like to use this from tests, and there are numerous other `Is<X>Type` predicates on `SBType`. Differential Revision: https://reviews.llvm.org/D121252
2022-03-09[lldb] Fix TestDebuggerAPI on windows (broken by D120810)Pavel Labath
2022-03-09[lldb] Remove the global platform listPavel Labath
This patch moves the platform creation and selection logic into the per-debugger platform lists. I've tried to keep functional changes to a minimum -- the main (only) observable difference in this change is that APIs, which select a platform by name (e.g., Debugger::SetCurrentPlatform) will not automatically pick up a platform associated with another debugger (or no debugger at all). I've also added several tests for this functionality -- one of the pleasant consequences of the debugger isolation is that it is now possible to test the platform selection and creation logic. This is a product of the discussion at <https://discourse.llvm.org/t/multiple-platforms-with-the-same-name/59594>. Differential Revision: https://reviews.llvm.org/D120810
2022-03-04[lldb/test] Re-enable TestEvents.py on Darwin and fix crashesMed Ismail Bennani
This patch re-enables TestEvents.py on Darwin and fixes some crashes that were happening due to an undefined method. I ran it 100 times locally with the following command and it passed every the time: ``` for i in {1..100}; do print $i/100; ./bin/lldb-dotest -p TestEvents.py 2>&1 | rg PASSED; if [ "$?" -eq "1" ]; then break; fi; done ``` Let's see if it still fails non-deterministically on the bots and eventually also re-enable it on linux. rdar://37037235 Differential Revision: https://reviews.llvm.org/D120607 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
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
2022-01-27[lldb/test] Skip TestSBModule unless darwinMed Ismail Bennani
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-01-27Revert "[lldb/test] Try to fix TestSBModule failure"Med Ismail Bennani
This reverts commit 326516448c839d8f9cc515b20a34d0f3a6ee2374.