summaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api/process/TestProcessAPI.py
AgeCommit message (Collapse)Author
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`.
2023-05-30Fix SBValue::FindValue for file static variablesJim Ingham
This was just a thinko. The API StackFrame::GetVariableList takes a bool for "get_file_globals" which if true will also find file statics and file globals. But we only were passing that as true if the ValueType was eValueTypeVariableGlobal, which meant that we never find file statics. It's okay if we cast too wide a net when we do GetVariableList as later on we check against the ValueType to filter globals from statics. There was a test that had a whole bunch of globals and tested FindValue on all of them, but had no statics. So I just made one of the globals a file static, which verifies the fix. Differential Revision: https://reviews.llvm.org/D151392
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-03-03[lldb] Extend SWIG SBProcess interface with WriteMemoryAsCString methodMed Ismail Bennani
This patch tries to address an interoperability issue when writing python string into the process memory. Since the python string is not null-terminated, it would still be written to memory however, when trying to read it again with `SBProcess::ReadCStringFromMemory`, the memory read would fail, since the read string doens't contain a null-terminator, and therefore is not a valid C string. To address that, this patch extends the `SBProcess` SWIG interface to expose a new `WriteMemoryAsCString` method that is only exposed to the SWIG target language. That method checks that the buffer to write is null-terminated and otherwise, it appends a null byte at the end of it. Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2023-02-09Remove test case that tries to allocate impossible amountsJason Molenda
The sanitizer bots are failing with this test; they impose a maximum 0x10000000000 size on allocations, and malloc on darwin will let me malloc that much. The alternative to keep this would be to break it out into a seperate test in TestProcessAIP and skip that if it's on the sanitizer, but this is seeming too fragile IMO so I'm punting it entirely.
2023-02-07Only run the weird new try-to-read-too-much test on DarwinJason Molenda
I'm still getting linux CI bot failures for this test. It's not critical, and it depends on a failure mode that is true on Darwin but I was always gambling that it might fail in the same way on other systems.
2023-02-07Fix TestProcessAPI.py to only allocate sys.maxsize bufferJason Molenda
I hardcoded nearly a UINT64_MAX number in this test case, and python is not able to convert it to a long on some platforms. Use sys.maxsize instead; this also would have failed if the testsuite was run on a 32-bit system.
2023-02-07Check if null buffer handed to SBProcess::ReadMemoryJason Molenda
Add a check for a null destination buffer in SBProcess::ReadMemory, and return an error if that happens. If a Python SB API script tries to allocate a huge amount of memory, the malloc done by the intermediate layers will fail and will hand a null pointer to ReadMemory. lldb will eventually crash trying to write in to that buffer. Also add a test that tries to allocate an impossibly large amount of memory, and hopefully should result in a failed malloc and hitting this error codepath. Differential Revision: https://reviews.llvm.org/D143012 rdar://104846609
2023-02-03[lldb] Add a way to get a scripted process implementation from the SBAPIMed Ismail Bennani
This patch introduces a new `GetScriptedImplementation` method to the SBProcess class in the SBAPI. It will allow users of Scripted Processes to fetch the scripted implementation object from to script interpreter to be able to interact with it directly (without having to go through lldb). This allows to user to perform action that are not specified in the scripted process interface, like calling un-specified methods, but also to enrich the implementation, by passing it complex objects. Differential Revision: https://reviews.llvm.org/D143236 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
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-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.
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-07-16[lldb] Add AllocateMemory/DeallocateMemory to the SBProcess APIPeter S. Housel
This change adds AllocateMemory and DeallocateMemory methods to the SBProcess API, so that clients can allocate and deallocate memory blocks within the process being debugged (for storing JIT-compiled code or other uses). (I am developing a debugger + REPL using the API; it will need to store JIT-compiled code within the target.) Reviewed By: clayborg, jingham Differential Revision: https://reviews.llvm.org/D105389
2021-06-05Revert "[LLDB/API] Expose args and env from SBProcessInfo."Bruce Mitchener
This reverts commit 8d33437d030af27fff21dd3fd0e66893b0148217. This broke one of the buildbots.
2021-06-05[LLDB/API] Expose args and env from SBProcessInfo.Bruce Mitchener
This is another step towards implementing the equivalent of `platform process list` and related functionality. `uint32_t` is used for the argument count and index despite the underlying value being `size_t` to be consistent with other index-based access to arguments. Differential Revision: https://reviews.llvm.org/D103675
2021-06-02[lldb/API] Expose triple for SBProcessInfo.Bruce Mitchener
This is present when doing a `platform process list` and is tracked by the underlying code. To do something like the process list via the SB API in the future, this must be exposed. Differential Revision: https://reviews.llvm.org/D103375
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.
2020-08-06[lldb] Use target.GetLaunchInfo() instead of creating an empty one.Jonas Devlieghere
Update tests that were creating an empty LaunchInfo instead of using the one coming from the target. This ensures target properties are honored.
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-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