summaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api/debugger
AgeCommit message (Collapse)Author
2025-10-07[lldb] Add support for unique target ids (#160736)Janet Yang
### Summary Add support for unique target ids per Target instance. This is needed for upcoming changes to allow debugger instances to be shared across separate DAP instances for child process debugging. We want the IDE to be able to attach to existing targets in an already runny lldb-dap session, and having a unique ID per target would make that easier. Each Target instance will have its own unique id, and uses a function-local counter in `TargetList::CreateTargetInternal` to assign incremental unique ids. ### Tests Added several unit tests to test basic functionality, uniqueness of targets, and target deletion doesn't affect the uniqueness. ``` bin/lldb-dotest -p TestDebuggerAPI ```
2025-06-27[lldb] Add class property for the version string (#145974)Jonas Devlieghere
Add a class property for the version string. This allows you to use access the version string through `lldb.SBDebugger.version` instead of having to call `lldb.SBDebugger.GetVersionString()`.
2024-10-18Revert "Renormalize line endings whitespace only after dccebddb3b80"Luke Drummond
This reverts commit 9d98acb196a40fee5229afeb08f95fd36d41c10a.
2024-10-17Renormalize line endings whitespace only after dccebddb3b80Luke Drummond
Line ending policies were changed in the parent, dccebddb3b80. To make it easier to resolve downstream merge conflicts after line-ending policies are adjusted this is a separate whitespace-only commit. If you have merge conflicts as a result, you can simply `git add --renormalize -u && git merge --continue` or `git add --renormalize -u && git rebase --continue` - depending on your workflow.
2024-05-30[lldb] Fixed the TestDebuggerAPI test running on a remote target (#93829)Dmitry Vasilyev
Recently we have disabled this test for Windows host and Linux target. Now we faced the same issue #92419 in case of Linux x86_64 host and Linux Aarch64 target.
2024-05-24[lldb] Fixed the TestDebuggerAPI test on x86_64 Windows host (#90580)Dmitry Vasilyev
Disable the TestDebuggerAPI test in case of the remote target and Windows host.
2024-05-20SBDebugger: Add new APIs `AddDestroyCallback` and `RemoveDestroyCallback` ↵royitaqi
(#89868) # Motivation Individual callers of `SBDebugger::SetDestroyCallback()` might think that they have registered their callback and expect it to be called when the debugger is destroyed. In reality, only the last caller survives, and all previous callers are forgotten, which might be a surprise to them. Worse, if this is called in a race condition, which callback survives is less predictable, which may case confusing behavior elsewhere. # This PR Allows multiple destroy callbacks to be registered and all called when the debugger is destroyed. **EDIT**: Adds two new APIs: `AddDestroyCallback()` and `ClearDestroyCallback()`. `SetDestroyCallback()` will first clear then add the given callback. Tests are added for the new APIs. ## Tests ``` bin/llvm-lit -sv ../external/llvm-project/lldb/test/API/python_api/debugger/TestDebuggerAPI.py ``` ## (out-dated, see comments below) Semantic change to `SetDestroyCallback()` ~~Currently, the method overwrites the old callback with the new one. With this PR, it will NOT overwrite. Instead, it will hold on to both. Both callbacks get called during destroy.~~ ~~**Risk**: Although the documentation of `SetDestroyCallback()` (see [C++](https://lldb.llvm.org/cpp_reference/classlldb_1_1SBDebugger.html#afa1649d9453a376b5c95888b5a0cb4ec) and [python](https://lldb.llvm.org/python_api/lldb.SBDebugger.html#lldb.SBDebugger.SetDestroyCallback)) doesn't really specify the behavior, there is a risk: if existing call sites rely on the "overwrite" behavior, they will be surprised because now the old callback will get called. But as the above said, the current behavior of "overwrite" itself might be unintended, so I don't anticipate users to rely on this behavior. In short, this risk might be less of a problem if we correct it sooner rather than later (which is what this PR is trying to do).~~ ## (out-dated, see comments below) Implementation ~~The implementation holds a `std::vector<std::pair<callback, baton>>`. When `SetDestroyCallback()` is called, callbacks and batons are appended to the `std::vector`. When destroy event happen, the `(callback, baton)` pairs are invoked FIFO. Finally, the `std::vector` is cleared.~~ # (out-dated, see comments below) Alternatives considered ~~Instead of changing `SetDestroyCallback()`, a new method `AddDestroyCallback()` can be added, which use the same `std::vector<std::pair<>>` implementation. Together with `ClearDestroyCallback()` (see below), they will replace and deprecate `SetDestroyCallback()`. Meanwhile, in order to be backward compatible, `SetDestroyCallback()` need to be updated to clear the `std::vector` and then add the new callback. Pros: The end state is semantically more correct. Cons: More steps to take; potentially maintaining an "incorrect" behavior (of "overwrite").~~ ~~A new method `ClearDestroyCallback()` can be added. Might be unnecessary at this point, because workflows which need to set then clear callbacks may exist but shouldn't be too common at least for now. Such method can be added later when needed.~~ ~~The `std::vector` may bring slight performance drawback if its implementation doesn't handle small size efficiently. However, even if that's the case, this path should be very cold (only used during init and destroy). Such performance drawback should be negligible.~~ ~~A different implementation was also considered. Instead of using `std::vector`, the current `m_destroy_callback` field can be kept unchanged. When `SetDestroyCallback()` is called, a lambda function can be stored into `m_destroy_callback`. This lambda function will first call the old callback, then the new one. This way, `std::vector` is avoided. However, this implementation is more complex, thus less readable, with not much perf to gain.~~ --------- Co-authored-by: Roy Shi <royshi@meta.com>
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.
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-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
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-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-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] 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-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-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-08Reland "[lldb] Make CommandInterpreter's execution context the same as ↵Tatyana Krasnukha
debugger's one"
2021-02-02Revert "[lldb] Use current execution context in SBDebugger"Raphael Isemann
This reverts commit 754ab803b8dc659e3645d369d1b5d6d2f97be29e. As pointed out in https://reviews.llvm.org/D95761, this patch could lead to having the wrong execution context in some situations (thanks Jim!). D92164 is addressing the same issue and will replace this patch, so I'll revert this one.
2021-02-01[lldb] Use current execution context in SBDebuggerAndy Yankovsky
Use `GetSelectedExecutionContext()` instead of `GetCommandInterpreter().GetExecutionContext()` in `SBDebugger::GetInternalVariableValue/SBDebugger::SetInternalVariable`. The execution context in the command interpreter might be empty, if no commands has been executed yet (it is updated only when handling commands or completions -- e.g. https://github.com/llvm/llvm-project/blob/main/lldb/source/Interpreter/CommandInterpreter.cpp#L1855). Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D95761
2020-12-17Revert "[lldb] Make CommandInterpreter's execution context the same as ↵Pavel Labath
debugger's one." This reverts commit a01b26fb51c710a3a8ef88cc83b0701461f5b9ab, because it breaks the "finish" command in some way -- the command does not terminate after it steps out, but continues running the target. The exact blast radius is not clear, but it at least affects the usage of the "finish" command in TestGuiBasicDebug.py. The error is *not* gui-related, as the same issue can be reproduced by running the same steps outside of the gui. There is some kind of a race going on, as the test fails only 20% of the time on the buildbot.
2020-12-12[lldb] Make CommandInterpreter's execution context the same as debugger's one.Tatyana Krasnukha
Currently, the interpreter's context is not updated until a command is executed. This has resulted in the behavior of SB-interface functions and some commands depends on previous user actions. The interpreter's context can stay uninitialized, point to a currently selected target, or point to one of previously selected targets. This patch removes any usages of CommandInterpreter::UpdateExecutionContext. CommandInterpreter::HandleCommand* functions still may override context temporarily, but now they always restore it before exiting. CommandInterpreter saves overriden contexts to the stack, that makes nesting commands possible. Added test reproduces one of the issues. Without this fix, the last assertion fails because interpreter's execution context is empty until running "target list", so, the value of the global property was updated instead of process's local instance. Differential Revision: https://reviews.llvm.org/D92164
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