summaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api
AgeCommit message (Collapse)Author
2023-09-21Revert "[lldb] Add 'modify' type watchpoints, make it default (#66308)"David Spickett
This reverts commit 933ad5c897ee366759a54869b35b2d7285a92137. This caused 1 test failure and an unexpected pass on AArch64 Linux: https://lab.llvm.org/buildbot/#/builders/96/builds/45765 Wasn't reported because the bot was already red at the time.
2023-09-20[lldb] Add 'modify' type watchpoints, make it default (#66308)Jason Molenda
Watchpoints in lldb can be either 'read', 'write', or 'read/write'. This is exposing the actual behavior of hardware watchpoints. gdb has a different behavior: a "write" type watchpoint only stops when the watched memory region *changes*. A user is using a watchpoint for one of three reasons: 1. Want to find what is changing/corrupting this memory. 2. Want to find what is writing to this memory. 3. Want to find what is reading from this memory. I believe (1) is the most common use case for watchpoints, and it currently can't be done in lldb -- the user needs to continue every time the same value is written to the watched-memory manually. I think gdb's behavior is the correct one. There are some use cases where a developer wants to find every function that writes/reads to/from a memory region, regardless of value, I want to still allow that functionality. This is also a bit of groundwork for my large watchpoint support proposal https://discourse.llvm.org/t/rfc-large-watchpoint-support-in-lldb/72116 where I will be adding support for AArch64 MASK watchpoints which watch power-of-2 memory regions. A user might ask to watch 24 bytes, and a MASK watchpoint stub can do this with a 32-byte MASK watchpoint if it is properly aligned. And we need to ignore writes to the final 8 bytes of that watched region, and not show those hits to the user. This patch adds a new 'modify' watchpoint type and it is the default. Re-landing this patch after addressing testsuite failures found in CI on Linux, Intel machines, and windows. rdar://108234227
2023-09-20[lldb][API] Remove debug print in TestRunLocker.pyDavid Spickett
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-18Revert "[lldb] Add 'modify' type watchpoints, make it default (#66308)"Jason Molenda
TestStepOverWatchpoint.py and TestUnalignedWatchpoint.py are failing on the ubuntu and debian bots https://lab.llvm.org/buildbot/#/builders/68/builds/60204 https://lab.llvm.org/buildbot/#/builders/96/builds/45623 and the newly added test TestModifyWatchpoint.py does not work on windows bot https://lab.llvm.org/buildbot/#/builders/219/builds/5708 I will debug tomorrow morning and reland. This reverts commit 3692267ca8f9c51cb55e4387283762d921fe2ae2.
2023-09-18[lldb] Add 'modify' type watchpoints, make it default (#66308)Jason Molenda
Watchpoints in lldb can be either 'read', 'write', or 'read/write'. This is exposing the actual behavior of hardware watchpoints. gdb has a different behavior: a "write" type watchpoint only stops when the watched memory region *changes*. A user is using a watchpoint for one of three reasons: 1. Want to find what is changing/corrupting this memory. 2. Want to find what is writing to this memory. 3. Want to find what is reading from this memory. I believe (1) is the most common use case for watchpoints, and it currently can't be done in lldb -- the user needs to continue every time the same value is written to the watched-memory manually. I think gdb's behavior is the correct one. There are some use cases where a developer wants to find every function that writes/reads to/from a memory region, regardless of value, I want to still allow that functionality. This is also a bit of groundwork for my large watchpoint support proposal https://discourse.llvm.org/t/rfc-large-watchpoint-support-in-lldb/72116 where I will be adding support for AArch64 MASK watchpoints which watch power-of-2 memory regions. A user might ask to watch 24 bytes, and a MASK watchpoint stub can do this with a 32-byte MASK watchpoint if it is properly aligned. And we need to ignore writes to the final 8 bytes of that watched region, and not show those hits to the user. This patch adds a new 'modify' watchpoint type and it is the default. rdar://108234227
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-09-11[lldb][Tests] Reformat API tests with blackDavid Spickett
These are all recent additions I think, including a few of mine for AArch64. Going forward the CI checks should help us fix these earlier.
2023-09-01[lldb] Add syntax color highlighting for disassemblyJonas Devlieghere
Add support for syntax color highlighting disassembly in LLDB. This patch relies on 77d1032516e7, which introduces support for syntax highlighting in MC. Currently only AArch64 and X86 have color support, but other interested backends can adopt WithColor in their respective MCInstPrinter. Differential revision: https://reviews.llvm.org/D159164
2023-08-16Test follow-up to 2e7aa2ee34eb53347396731dc8a3b2dbc6a3df45Jim Ingham
The TestEvents.py test I added for ShadowListeners fails on Windows. Since there's no reason to believe the ShadowListeners feature has different behavior from the other event-based tests here, I copied the skips & expected_flakey's from the other tests in that file to this one.
2023-08-16Replace the singleton "ShadowListener" with a primary and N secondary ListenersJim Ingham
Before the addition of the process "Shadow Listener" you could only have one Listener observing the Process Broadcaster. That was necessary because fetching the Process event is what switches the public process state, and for the execution control logic to be manageable you needed to keep other listeners from causing this to happen before the main process control engine was ready. Ismail added the notion of a "ShadowListener" - which allowed you ONE extra process listener. This patch inverts that setup by designating the first listener as primary - and giving it priority in fetching events. Differential Revision: https://reviews.llvm.org/D157556
2023-08-11[lldb] SBTarget::AddModule do all searches by UUID, set Target archJason Molenda
Make SBTarget::AddModule possibly call out to an external program to find the binary by UUID if it can't be found more easily, the same way `target modules add -u ...` works from the commandline. If the Target does not have an architecture set yet, use the Module's Arch to initialize it. Allows an API writer to create a target with no arch, and inherit it from the first binary they load with AddModules. Differential Revision: https://reviews.llvm.org/D157659 rdar://113657555
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-07-21[lldb] Convert script native types to StructuredData counterpartMed Ismail Bennani
This patch adds the ability to pass native types from the script interpreter to methods that use a {SB,}StructuredData argument. To do so, this patch changes the `ScriptedObject` struture that holds the pointer to the script object as well as the originating script interpreter language. It also exposes that to the SB API via a new class called `SBScriptObject`. This structure allows the debugger to parse the script object and convert it to a StructuredData object. If the type is not compatible with the StructuredData types, we will store its pointer in a `StructuredData::Generic` object. This patch also adds some SWIG typemaps that checks the input argument to ensure it's either an SBStructuredData object, in which case it just passes it throught, or a python object that is NOT another SB type, to provide some guardrails for the user. rdar://111467140 Differential Revision: https://reviews.llvm.org/D155161 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-07-14[lldb][Windows] Fix TestLocateModuleCallbackKazuki Sakamoto
D153735 added the tests but it is failing due to POSIX path vs Windows path. https://lab.llvm.org/buildbot/#/builders/219/builds/4084 Fix it. - MODULE_PLATFORM_PATH is POSIX path. - Normalize self.input_dir, FileSpec and SymbolFileSpec fullpath. Differential Revision: https://reviews.llvm.org/D155124
2023-07-12[lldb][LocateModuleCallback] Implement API, Python interfaceKazuki Sakamoto
RFC https://discourse.llvm.org/t/rfc-python-callback-for-target-get-module/71580 Use SWIG for the locate module callback the same as other Python callbacks. TestLocateModuleCallback.py verifies the functionalities. Differential Revision: https://reviews.llvm.org/D153735
2023-07-12[lldb][LocateModuleCallback] Update SBFileSpec/SBModuleSpecKazuki Sakamoto
RFC https://discourse.llvm.org/t/rfc-python-callback-for-target-get-module/71580 SBFileSpec and SBModuleSpec will be used for locate module callback as Python function arguments. This diff allows these things. - Can be instantiated from SBPlatform. - Can be passed to/from Python. - Can be accessed for object offset and size. Differential Revision: https://reviews.llvm.org/D153733
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-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-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-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-22[lldb] Add support for negative integer to {SB,}StructuredDataMed Ismail Bennani
This patch refactors the `StructuredData::Integer` class to make it templated, makes it private and adds 2 public specialization for both `int64_t` & `uint64_t` with a public type aliases, respectively `SignedInteger` & `UnsignedInteger`. It adds new getter for signed and unsigned interger values to the `StructuredData::Object` base class and changes the implementation of `StructuredData::Array::GetItemAtIndexAsInteger` and `StructuredData::Dictionary::GetValueForKeyAsInteger` to support signed and unsigned integers. This patch also adds 2 new `Get{Signed,Unsigned}IntegerValue` to the `SBStructuredData` class and marks `GetIntegerValue` as deprecated. Finally, this patch audits all the caller of `StructuredData::Integer` or `StructuredData::GetIntegerValue` to use the proper type as well the various tests that uses `SBStructuredData.GetIntegerValue`. rdar://105575764 Differential Revision: https://reviews.llvm.org/D150485 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-05-04Add AArch64 MASK watchpoint support in debugserverJason Molenda
Add suport for MASK style watchpoints on AArch64 in debugserver on Darwin systems, for watching power-of-2 sized memory ranges. More work needed in lldb before this can be exposed to the user (because they will often try watching memory ranges that are not exactly power-of-2 in size/alignment) but this is the first part of adding that capability. Differential Revision: https://reviews.llvm.org/D149792 rdar://108233371
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-22[lldb] Update some uses of Python2 API in typemaps.Jorge Gorbe Moya
Python 3 doesn't have a distinction between PyInt and PyLong, it's all PyLong now. This also fixes a bug in SetNumberFromObject. This used to crash LLDB: ``` lldb -o "script data=lldb.SBData(); data.SetDataFromUInt64Array([2**63])" ``` The problem happened in the PyInt path: ``` if (PyInt_Check(obj)) number = static_cast<T>(PyInt_AsLong(obj)); ``` when obj doesn't fit in a signed long, `PyInt_AsLong` would fail with "OverflowError: Python int too large to convert to C long". The existing long path does the right thing, as it will call `PyLong_AsUnsignedLongLong` for uint64_t. Differential Revision: https://reviews.llvm.org/D146590
2023-03-15Add a Debugger interruption mechanism in conjunction with theJim Ingham
Command Interpreter mechanism. Differential Revision: https://reviews.llvm.org/D145136
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-03-07Add a new SBDebugger::SetDestroyCallback() APIJeffrey Tan
Adding a new SBDebugger::SetDestroyCallback() API. This API can be used by any client to query for statistics/metrics before exiting debug sessions. Differential Revision: https://reviews.llvm.org/D143520
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-03-02[LLDB] XFAIL TestRunLocker.py for windowsMuhammad Omair Javaid
TestRunLocker.py is failing on windows x64 and AArch64 buildbots. Buildbot log suggests that test needs some minor modification for windows which I will do later. https://lab.llvm.org/buildbot/#/builders/83/builds/29680 https://lab.llvm.org/buildbot/#/builders/219/builds/942
2023-03-02Revert "[LLDB] XFAIL TestRunLocker.py on Windows"Muhammad Omair Javaid
This reverts commit 9d28e00e741cb19684111656803434aceef4c2a0.
2023-03-02[LLDB] XFAIL TestRunLocker.py on WindowsMuhammad Omair Javaid
2023-03-01[LLDB] Expose several methods in SBWatchpointDan Liew
This patch adds the following methods: * `GetType()` * `GetWatchValueKind()` * `GetWatchSpec()` * `IsWatchingReads()` * `IsWatchingWrites()` These mostly expose methods that `lldb_private::Watchpoint` already had. Tests are included that exercise these new methods. The motivation for exposing these are as follows: * `GetType()` - With this information and the address from a watchpoint it is now possible to construct an SBValue from an SBWatchpoint. Previously this wasn't possible. The included test case illustrates doing this. * `GetWatchValueKind()` - This allows the caller to determine whether the watchpoint is a variable watchpoint or an expression watchpoint. A new enum (`WatchpointValueKind`) has been introduced to represent the return values. Unfortunately the name `WatchpointKind` was already taken. * `GetWatchSpec()` - This allows (at least for variable watchpoints) to use a sensible name for SBValues created from an SBWatchpoint. * `IsWatchingReads()` - This allow checking if a watchpoint is monitoring read accesses. * `IsWatchingWRites()` - This allow checking if a watchpoint is monitoring write accesses. rdar://105606978 Reviewers: jingham, mib, bulbazord, jasonmolenda, JDevlieghere Differential Revision: https://reviews.llvm.org/D144937
2023-02-28Fix the run locker setting for async launches that don't stop at theJim Ingham
initial stop. The code was using PrivateResume when it should have used Resume. This was allowing expression evaluation while the target was running, and though that was caught a litle later on, we should never have gotten that far. To make sure that this is caught immediately I made an error SBValue when this happens, and test that we get this error. Differential Revision: https://reviews.llvm.org/D144665
2023-02-17[lldb] StructuredData should not truncate uint64_t valuesAlex Langford
In json::Value, getAsInteger returns an optional<int64_t> and getAsNumber returns an optional<double>. If a value is larger than what an int64_t can hold but smaller than what a uint64_t can hold, the getAsInteger function will fail but the getAsNumber will succeed. However, the value shouldn't be interpreted as a double. rdar://105556974 Differential Revision: https://reviews.llvm.org/D144238
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-08[lldb] Accept negative indexes in __getitem__Dave Lee
To the Python bindings, add support for Python-like negative indexes. While was using `script`, I tried to access a thread's bottom frame with `thread.frame[-1]`, but that failed. This change updates the `__getitem__` implementations to support negative indexes as one would expect in Python. Differential Revision: https://reviews.llvm.org/D143282
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>
2023-01-30Revert "Revert "[lldb] Make SBSection::GetSectionData call ↵Muhammad Omair Javaid
Section::GetSectionData."" This reverts commit e1bbe50f5a48e9b5407de9e5f4ab8197dedc85c5. Differential Revision: https://reviews.llvm.org/D142672
2023-01-30Revert "[lldb] Make SBSection::GetSectionData call Section::GetSectionData."Muhammad Omair Javaid
This reverts commit 805600c7d573cf88cf035d01a2ea9389fc24d435. LLDB windows buildbots were broken by the TestSectionAPI.py test. I dont have full context of the commit to fix it. Reverting it temporarily. https://lab.llvm.org/buildbot/#/builders/83/builds/28617 https://lab.llvm.org/buildbot/#/builders/219/builds/180 Differential Revision: https://reviews.llvm.org/D142672
2023-01-27[lldb] Make SBSection::GetSectionData call Section::GetSectionData.Jorge Gorbe Moya
`SBSection::GetSectionData` and `Section::GetSectionData` are implemented differently, and the `SBSection` method doesn't handle compressed sections correctly. Differential Revision: https://reviews.llvm.org/D142672
2023-01-26[test] Remove unused `unittest2` importJordan Rupprecht
2023-01-25[lldb][test] Replace use of p with expression (NFC)Dave Lee
In API tests, replace use of the `p` alias with the `expression` command. To avoid conflating tests of the alias with tests of the expression command, this patch canonicalizes to the use `expression`. Differential Revision: https://reviews.llvm.org/D141539
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