aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces
AgeCommit message (Collapse)AuthorFilesLines
2025-09-04[lldb] Introduce ScriptedFrame affordance (#149622)Med Ismail Bennani7-1/+242
This patch introduces a new scripting affordance in lldb: `ScriptedFrame`. This allows user to produce mock stackframes in scripted threads and scripted processes from a python script. With this change, StackFrame can be synthetized from different sources: - Either from a dictionary containing a load address, and a frame index, which is the legacy way. - Or by creating a ScriptedFrame python object. One particularity of synthezising stackframes from the ScriptedFrame python object, is that these frame have an optional PC, meaning that they don't have a report a valid PC and they can act as shells that just contain static information, like the frame function name, the list of variables or registers, etc. It can also provide a symbol context. rdar://157260006 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma> Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-07-28Switch the ScriptedBreakpointResolver over to the ScriptedInterface form ↵jimingham7-0/+185
(#150720) This is NFC, I'm modernizing the interface before I add to it in a subsequent commit.
2025-06-04[lldb/cmake] Implicitly pass arguments to llvm_add_library (#142583)Pavel Labath1-3/+2
If we're not touching them, we don't need to do anything special to pass them along -- with one important caveat: due to how cmake arguments work, the implicitly passed arguments need to be specified before arguments that we handle. This isn't particularly nice, but the alternative is enumerating all arguments that can be used by llvm_add_library and the macros it calls (it also relies on implicit passing of some arguments to llvm_process_sources).
2025-05-22[lldb] Remove redundant control flow statements (NFC) (#141183)Kazu Hirata1-1/+0
2025-01-16[lldb] Add OS plugin property for reporting all threads (#123145)Felipe de Azevedo Piovezan2-0/+12
Currently, an LLDB target option controls whether plugins report all threads. However, it seems natural for this knowledge could come from the plugin itself. To support this, this commits adds a virtual method to the plugin base class, making the Python OS query the target option to preserve existing behavior.
2024-09-20[lldb/Interpreter] Introduce ScriptedStopHook{,Python}Interface & make use ↵Med Ismail Bennani7-6/+187
of it (#109498) This patch re-lands #105449 and fixes the various test failures. --------- Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-09-20Revert "[lldb] Fix SWIG wrapper compilation error"David Spickett7-187/+6
...and "[lldb/Interpreter] Introduce `ScriptedStopHook{,Python}Interface` & make use of it (#105449)" This reverts commit 76b827bb4d5b4cc4d3229c4c6de2529e8b156810, and commit 1e131ddfa8f1d7b18c85c6e4079458be8b419421 because the first commit caused the test command-stop-hook-output.test to fail.
2024-09-19[lldb/Interpreter] Introduce `ScriptedStopHook{,Python}Interface` & make use ↵Med Ismail Bennani7-6/+187
of it (#105449) This patch introduces new `ScriptedStopHook{,Python}Interface` classes that make use of the Scripted Interface infrastructure and makes use of it in `StopHookScripted`. It also relax the requirement on the number of argument for initializing scripting extension if the size of the interface parameter pack contains 1 less element than the extension maximum number of positional arguments for this initializer. This addresses the cases where the embedded interpreter session dictionary is passed to the extension initializer which is not used most of the time. --------- Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-09-19[lldb/Interpreter] Add requirements to Scripted Interface abstract methods ↵Med Ismail Bennani6-53/+142
(#109063) This patch adds new requirements to the Scripted Interface abstract method checker to check the minimum number of argument for abstract methods. This check is done when creating the interface object so the object is not created if the user implementation doesn't match the abstract method requirement. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-09-05[lldb] Make deep copies of Status explicit (NFC) (#107170)Adrian Prantl2-5/+9
2024-09-05[lldb] Make conversions from llvm::Error explicit with Status::FromEr… ↵Adrian Prantl1-1/+1
(#107163) …ror() [NFC]
2024-08-27[lldb] Turn lldb_private::Status into a value type. (#106163)Adrian Prantl2-12/+14
This patch removes all of the Set.* methods from Status. This cleanup is part of a series of patches that make it harder use the anti-pattern of keeping a long-lives Status object around and updating it while dropping any errors it contains on the floor. This patch is largely NFC, the more interesting next steps this enables is to: 1. remove Status.Clear() 2. assert that Status::operator=() never overwrites an error 3. remove Status::operator=() Note that step (2) will bring 90% of the benefits for users, and step (3) will dramatically clean up the error handling code in various places. In the end my goal is to convert all APIs that are of the form ` ResultTy DoFoo(Status& error) ` to ` llvm::Expected<ResultTy> DoFoo() ` How to read this patch? The interesting changes are in Status.h and Status.cpp, all other changes are mostly ` perl -pi -e 's/\.SetErrorString/ = Status::FromErrorString/g' $(git grep -l SetErrorString lldb/source) ` plus the occasional manual cleanup.
2024-08-20[lldb] Fix windows debug build after 9d07f43 (#104896)Med Ismail Bennani15-94/+100
This patch tries to fix an issue with the windows debug builds where the PDB file for python scripted interfaces cannot be opened since its path length exceed the windows `MAX_PATH` limit: https://github.com/llvm/llvm-project/pull/101672#issuecomment-2289481324 This patch addresses the issue by building all the interfaces as a single library plugin that initiliazes each component as part of its `Initialize` method, instead of building each interface as its own library plugin. This keeps the build artifact path length smaller while respecting the naming convention and without making any exception in the build system. Fixes #104895. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-08-02Reland "[lldb] Reland 2402b3213c2f with `/H` to debug the windows build ↵David Spickett4-12/+67
issue (#101672) This reverts commit 9effefbae8d96006a4dd29bb9ab8532fd408559d. With the include order in ScriptedProcessPythonInterface.cpp fixed (though I cannot explain exactly why it works) and removes the /H flag intended for debugging this issue. I think it is something to do with Process.h pulling in PosixApi.h somewhere along the line, and including Process.h after lldb-python.h means that NO_PID_T is defined to prevent a redefinition of pid_t.
2024-07-31Revert "[lldb] Reland 2402b3213c2f with `/H` to debug the windows build issue"Haowei Wu4-71/+11
This reverts commit e72cdae47b4e263ea97b2bdd75cf44c1510cf3be, which broke LLVM's lldb builder for Windows msvc.
2024-07-30[lldb] Reland 2402b3213c2f with `/H` to debug the windows build issueMed Ismail Bennani4-11/+71
This patch relands 2402b3213c2f to investigate the ambigious typedef issue happening on the windows bots: https://lab.llvm.org/buildbot/#/builders/141/builds/1175/ However this patch adds the `/H` compiler flag when building the ScriptedProcessPythonInterface library to be able to investigate the include order issue. This patch will be revert after 1 failing run on the windows bot. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-07-30Revert "[lldb] Reland 2402b3213c2f with `-H` to debug the windows build issue"Med Ismail Bennani4-67/+11
This reverts commit c35c4c72e4977258fc1da940e0470e8d0671bf07.
2024-07-30[lldb] Reland 2402b3213c2f with `-H` to debug the windows build issueMed Ismail Bennani4-11/+67
This patch relands 2402b3213c2f to investigate the ambigious typedef issue happening on the windows bots: https://lab.llvm.org/buildbot/#/builders/141/builds/1175/ However this patch adds the `-H` compiler flag when building the ScriptedProcessPythonInterface library to be able to investigate the include order issue. This patch will be revert after 1 failing run on the windows bot. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-07-29Revert "[lldb] Reland 2402b3213c2f with `-H -MM` to debug the windows build ↵Med Ismail Bennani4-67/+11
issue" This reverts commit 6bd5fd35063cd14b0a56bc6f7fb1e7b6e1ac56d5.
2024-07-29[lldb] Reland 2402b3213c2f with `-H -MM` to debug the windows build issueMed Ismail Bennani4-11/+67
This patch relands 2402b3213c2f to investigate the ambigious typedef issue happening on the windows bots: https://lab.llvm.org/buildbot/#/builders/141/builds/1175/ However this patch adds the `-H` & `-MM` compiler flags when building the ScriptedProcessPythonInterface library to be able to investigate the include order issue. This patch will be revert after 1 failing run on the windows bot. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-07-27Revert "[lldb] Add ScriptedProcess to `scripting template list`"Med Ismail Bennani4-64/+11
This reverts commit 2402b3213c2f10d5033b31df3a0e59e4ad151fbd since it breaks the windows bot: https://lab.llvm.org/buildbot/#/builders/141/builds/1175/
2024-07-27[lldb] Add ScriptedProcess to `scripting template list`Med Ismail Bennani4-11/+64
This patch is a follow-up to bccff3baeff8 which adds the `ScriptedProcess` extension to the `scripting template list` command as well as its description. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-07-27[lldb] Add OperatingSystem to `scripting template list`Med Ismail Bennani4-7/+56
This patch is a follow-up to bccff3baeff8 which adds the `OperatingSystem` extension to the `scripting template list` command as well as its description. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-07-27[lldb] Add ScriptedPlatform to `scripting template list`Med Ismail Bennani4-9/+50
This patch is a follow-up to bccff3baeff8 which adds the `ScriptedPlatform` extension to the `scripting template list` command as well as its description. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-07-27[lldb/Commands] Add `scripting template list` command with auto discoveryMed Ismail Bennani4-7/+55
This patch introduces a new `template` multiword sub-command to the `scripting` top-level command. As the name suggests, this sub-command operates on scripting templates, and currently has the ability to automatically discover the various scripting extensions that lldb supports. This was previously reviewed in #97273. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-07-25[lldb] Revert scripting template list patches (#100673)Med Ismail Bennani17-302/+45
Reverts https://github.com/llvm/llvm-project/pull/97273 since it broke the windows bot: https://lab.llvm.org/buildbot/#/builders/141/builds/1025/steps/4/logs/stdio
2024-07-25[lldb/Plugins] Fix build failure on windows following 2914a4b88837Med Ismail Bennani7-16/+43
This patch tries to fix the following build failure on windows: https://lab.llvm.org/buildbot/#/builders/141/builds/1083 This started happening following 2914a4b88837, and it seems to be caused by some special `#include` ordering for the lldb-python header on Windows. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-07-25[lldb/Plugins] Fix build failure on windows following 2914a4b88837Med Ismail Bennani2-0/+15
This patch tries to fix the following build failure on windows: https://lab.llvm.org/buildbot/#/builders/141/builds/1083 This started happening following 2914a4b88837, and it seems to be caused by some special `#include` ordering for the lldb-python header on Windows. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-07-25Revert "[lldb] Fix incorrect logical operator in 'if' condition check (NFC)" ↵David Spickett1-9/+8
(#100561) Reverts llvm/llvm-project#94779 Due to bot failures: https://lab.llvm.org/buildbot/#/builders/18/builds/1371
2024-07-25[lldb] Fix incorrect uses of logical operator in 'if' condition check (NFC) ↵Shivam Gupta1-8/+9
(#94779) The condition checking for missing class name, interpreter dictionary, and script object incorrectly used logical AND (&&), which could never be true to enter the 'if' block. This commit uses separate if conditions for each class name, interpreter dictionary, and script object. Cought by cppcheck - lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h:89:11: warning: Identical inner 'if' condition is always true. [identicalInnerCondition] lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h:91:16: warning: Identical inner 'if' condition is always true. [identicalInnerCondition] Fix #89195 --------- Co-authored-by: Shivam Gupta <shivma98.tkg@gmail.com>
2024-07-25[lldb/Plugins] Fix build failure on windows following 2914a4b88837Med Ismail Bennani4-10/+34
This patch tries to fix the following build failure on windows: https://lab.llvm.org/buildbot/#/builders/141/builds/1083 This started happening following 2914a4b88837, and it seems to be caused by some special `#include` ordering for the lldb-python header on Windows. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-07-25[lldb/Commands] Add `scripting template list` command with auto discoveryMed Ismail Bennani13-34/+225
This patch introduces a new `template` multiword sub-command to the `scripting` top-level command. As the name suggests, this sub-command operates on scripting templates, and currently has the ability to automatically discover the various scripting extensions that lldb supports. This was previously reviewed in #97273. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-07-23Revert "[lldb/Commands] Add `scripting template list` command with auto ↵Med Ismail Bennani13-220/+34
discovery" (#100273) Reverts llvm/llvm-project#97273 since it broke the windows bot: https://lab.llvm.org/buildbot/#/builders/141/builds/1025/steps/4/logs/stdio
2024-07-23[lldb/Commands] Add `scripting template list` command with auto discovery ↵Med Ismail Bennani13-34/+220
(#97273) This patch introduces a new `template` multiword sub-command to the `scripting` top-level command. As the name suggests, this sub-command operates on scripting templates, and currently has the ability to automatically discover the various scripting extensions that lldb supports. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-06-28Reland "[lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription ↵Med Ismail Bennani4-18/+11
return value (#96985)" (#97092) This reverts commit a2e3af5d581547d3ea53e5383d6f7f1cab45120a and solves the build error in https://lab.llvm.org/buildbot/#/builders/141/builds/369. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-06-28Revert "[lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription ↵Nico Weber4-11/+18
return value (#96985)" This reverts commit 1130e923e2d7fe046101bf639bc5ebcde194c005. Very likely causes build problems on Windows and with LLVM_NO_DEAD_STRIP=ON, see https://github.com/llvm/llvm-project/pull/96985#pullrequestreview-2147599208
2024-06-28[lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription return ↵Med Ismail Bennani4-18/+11
value (#96985) This patch changes `ScriptedThreadPlan::GetStopDescription` behavior by discarding its return value since it is optional in the first place (the user doesn't need to provide a return value in their implementation). This patch also addresses the test failures in TestStepScripted following 9a9ec22 and re-enables the tests that were XFAIL'd previously. The issue here was that the `Stream*` that's passed to `ThreadPlanPython::GetDescription` wasn't being passed by reference to the python method so it was never updated to reflect how the python method interacted with it. This patch solves this issue by making a temporary `StreamSP` that will be passed to the python method by reference, after what we will copy its content to the caller `Stream` pointer argument. --------- Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-06-27[lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan ↵Med Ismail Bennani8-23/+251
(#70392) (#96868) This patch makes ScriptedThreadPlan conforming to the ScriptedInterface & ScriptedPythonInterface facilities by introducing 2 ScriptedThreadPlanInterface & ScriptedThreadPlanPythonInterface classes. This allows us to get rid of every ScriptedThreadPlan-specific SWIG method and re-use the same affordances as other scripting offordances, like Scripted{Process,Thread,Platform} & OperatingSystem. To do so, this adds new transformer methods for `ThreadPlan`, `Stream` & `Event`, to allow the bijection between C++ objects and their python counterparts. This just re-lands #70392 after fixing test failures. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-05-23Revert "[lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan ↵Med Ismail Bennani8-251/+23
(Reland #70392)" (#93153) Reverts llvm/llvm-project#93149 since it breaks https://lab.llvm.org/buildbot/#/builders/68/builds/74799
2024-05-23[lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan (Reland ↵Med Ismail Bennani8-23/+251
#70392) (#93149) This patch makes ScriptedThreadPlan conforming to the ScriptedInterface & ScriptedPythonInterface facilities by introducing 2 ScriptedThreadPlanInterface & ScriptedThreadPlanPythonInterface classes. This allows us to get rid of every ScriptedThreadPlan-specific SWIG method and re-use the same affordances as other scripting offordances, like Scripted{Process,Thread,Platform} & OperatingSystem. To do so, this adds new transformer methods for `ThreadPlan`, `Stream` & `Event`, to allow the bijection between C++ objects and their python counterparts. This just re-lands #70392 after fixing test failures. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2024-01-29Revert "[lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan ↵Jason Molenda8-251/+23
(#70392)" Temporarily revert to unblock the CI bots, this is breaking the -DLLVM_ENABLE_MODULES=On modules style build. I've notified Ismail. This reverts commit 888501bc631c4f6d373b4081ff6c504a1ce4a682.
2024-01-29[lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan (#70392)Med Ismail Bennani8-23/+251
This patch makes ScriptedThreadPlan conforming to the ScriptedInterface & ScriptedPythonInterface facilities by introducing 2 ScriptedThreadPlanInterface & ScriptedThreadPlanPythonInterface classes. This allows us to get rid of every ScriptedThreadPlan-specific SWIG method and re-use the same affordances as other scripting offordances, like Scripted{Process,Thread,Platform} & OperatingSystem. To do so, this adds new transformer methods for `ThreadPlan`, `Stream` & `Event`, to allow the bijection between C++ objects and their python counterparts. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-11-07[lldb] Check for abstract methods implementation in Scripted Plugin Objects ↵Med Ismail Bennani5-29/+147
(#71260) This patch enforces that every scripted object implements all the necessary abstract methods. Every scripted affordance language interface can implement a list of abstract methods name that checked when the object is instanciated. Since some scripting affordances implementations can be derived from template base classes, we can't check the object dictionary since it will contain the definition of the base class, so instead, this checks the scripting class dictionary. Previously, for the various python interfaces, we used `ABC.abstractmethod` decorators but this is too language specific and doesn't work for scripting affordances that are not derived from template base classes (i.e OperatingSystem, ScriptedThreadPlan, ...), so this patch provides generic/language-agnostic checks for every scripted affordance. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-11-07Revert "[lldb] Check for abstract methods implementation in Scripted Plugin ↵Med Ismail Bennani5-150/+29
Objects (#71260)" This reverts commit cc9ad72713405ef8f2468c7a714a137b4a3343ba since it breaks some tests upstream: https://lab.llvm.org/buildbot/#/builders/68/builds/63112 ******************** Failed Tests (4): lldb-api :: functionalities/gdb_remote_client/TestThreadSelectionBug.py lldb-api :: functionalities/plugins/python_os_plugin/TestPythonOSPlugin.py lldb-api :: functionalities/plugins/python_os_plugin/stepping_plugin_threads/TestOSPluginStepping.py lldb-api :: functionalities/postmortem/mach-core/TestMachCore.py
2023-11-07[lldb] Check for abstract methods implementation in Scripted Plugin Objects ↵Med Ismail Bennani5-29/+150
(#71260) This patch enforces that every scripted object implements all the necessary abstract methods. Every scripted affordance language interface can implement a list of abstract methods name that checked when the object is instanciated. Since some scripting affordances implementations can be derived from template base classes, we can't check the object dictionary since it will contain the definition of the base class, so instead, this checks the scripting class dictionary. Previously, for the various python interfaces, we used `ABC.abstractmethod` decorators but this is too language specific and doesn't work for scripting affordances that are not derived from template base classes (i.e OperatingSystem, ScriptedThreadPlan, ...), so this patch provides generic/language-agnostic checks for every scripted affordance. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-10-30Revert "[lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan ↵Med Ismail Bennani7-192/+2
(#70392)" This reverts commit 4b3cd379cce3f455bf3c8677ca7a5be6e708a4ce since it introduces some test failures: https://lab.llvm.org/buildbot/#/builders/68/builds/62556
2023-10-30Revert "[lldb] Fix build failure introduced in 484038416d06 (NFC)"Med Ismail Bennani3-44/+22
This reverts commit ed5faa475b401aa91284d19afb52b2927aa59c97 since it introduces test failures: https://lab.llvm.org/buildbot/#/builders/68/builds/62556
2023-10-30[lldb] Fix build failure introduced in 484038416d06 (NFC)Med Ismail Bennani3-22/+44
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-10-30[lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan (#70392)Med Ismail Bennani7-2/+192
This patch makes ScriptedThreadPlan conforming to the ScriptedInterface & ScriptedPythonInterface facilities by introducing 2 ScriptedThreadPlanInterface & ScriptedThreadPlanPythonInterface classes. This allows us to get rid of every ScriptedThreadPlan-specific SWIG method and re-use the same affordances as other scripting offordances, like Scripted{Process,Thread,Platform} & OperatingSystem. To do so, this adds new transformer methods for `ThreadPlan`, `Stream` & `Event`, to allow the bijection between C++ objects and their python counterparts. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-10-26[lldb] Introduce OperatingSystem{,Python}Interface and make use itMed Ismail Bennani4-0/+131
This patch aims to consolidate the OperatingSystem scripting affordance by introducing a stable interface that conforms to the Scripted{,Python}Interface. This unify the way we call into python methods from lldb while also improving its capabilities by allowing us to pass lldb_private objects are arguments. Differential Revision: https://reviews.llvm.org/D159314 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>