52 Commits

Author SHA1 Message Date
jimingham
4c8e79f815
Switch the ScriptedBreakpointResolver over to the ScriptedInterface form (#150720)
This is NFC, I'm modernizing the interface before I add to it in a
subsequent commit.
2025-07-28 15:11:22 -07:00
Pavel Labath
2c4f67794b
[lldb/cmake] Implicitly pass arguments to llvm_add_library (#142583)
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-06-04 11:33:37 +02:00
Kazu Hirata
6979ab2655
[lldb] Remove redundant control flow statements (NFC) (#141183) 2025-05-22 22:36:26 -07:00
Felipe de Azevedo Piovezan
cb82771c96
[lldb] Add OS plugin property for reporting all threads (#123145)
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.
2025-01-16 15:05:46 -08:00
Med Ismail Bennani
f732157a9d
[lldb/Interpreter] Introduce ScriptedStopHook{,Python}Interface & make use 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-20 16:55:47 -07:00
David Spickett
801046e330 Revert "[lldb] Fix SWIG wrapper compilation error"
...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-20 09:57:07 +00:00
Med Ismail Bennani
1e131ddfa8
[lldb/Interpreter] Introduce ScriptedStopHook{,Python}Interface & make use 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 23:35:34 -07:00
Med Ismail Bennani
21026073e3
[lldb/Interpreter] Add requirements to Scripted Interface abstract methods (#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-19 13:55:41 -07:00
Adrian Prantl
b798f4bd50
[lldb] Make deep copies of Status explicit (NFC) (#107170) 2024-09-05 12:44:13 -07:00
Adrian Prantl
a0dd90eb7d
[lldb] Make conversions from llvm::Error explicit with Status::FromEr… (#107163)
…ror() [NFC]
2024-09-05 12:19:31 -07:00
Adrian Prantl
0642cd768b
[lldb] Turn lldb_private::Status into a value type. (#106163)
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-27 10:59:31 -07:00
Med Ismail Bennani
356533246a
[lldb] Fix windows debug build after 9d07f43 (#104896)
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-20 10:47:06 -07:00
David Spickett
9d07f43676
Reland "[lldb] Reland 2402b3213c2f with /H to debug the windows build 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-08-02 08:55:26 -07:00
Haowei Wu
9effefbae8 Revert "[lldb] Reland 2402b3213c2f with /H to debug the windows build issue"
This reverts commit e72cdae47b4e263ea97b2bdd75cf44c1510cf3be, which broke
LLVM's lldb builder for Windows msvc.
2024-07-31 13:58:30 -07:00
Med Ismail Bennani
e72cdae47b [lldb] Reland 2402b3213c2f with /H to debug the windows build issue
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-30 19:54:11 -07:00
Med Ismail Bennani
f65fa5461d Revert "[lldb] Reland 2402b3213c2f with -H to debug the windows build issue"
This reverts commit c35c4c72e4977258fc1da940e0470e8d0671bf07.
2024-07-30 19:46:19 -07:00
Med Ismail Bennani
c35c4c72e4 [lldb] Reland 2402b3213c2f with -H to debug the windows build issue
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-30 18:26:04 -07:00
Med Ismail Bennani
8425aa24d8 Revert "[lldb] Reland 2402b3213c2f with -H -MM to debug the windows build issue"
This reverts commit 6bd5fd35063cd14b0a56bc6f7fb1e7b6e1ac56d5.
2024-07-29 21:02:06 -07:00
Med Ismail Bennani
6bd5fd3506 [lldb] Reland 2402b3213c2f with -H -MM to debug the windows build issue
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-29 20:51:49 -07:00
Med Ismail Bennani
bbc457a4f4 Revert "[lldb] Add ScriptedProcess to scripting template list"
This reverts commit 2402b3213c2f10d5033b31df3a0e59e4ad151fbd since it
breaks the windows bot:

https://lab.llvm.org/buildbot/#/builders/141/builds/1175/
2024-07-27 18:04:44 -07:00
Med Ismail Bennani
2402b3213c [lldb] Add ScriptedProcess to scripting template list
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 17:30:31 -07:00
Med Ismail Bennani
995f643f5a [lldb] Add OperatingSystem to scripting template list
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 15:30:19 -07:00
Med Ismail Bennani
ecf125eaf0 [lldb] Add ScriptedPlatform to scripting template list
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 14:21:18 -07:00
Med Ismail Bennani
bccff3baef [lldb/Commands] Add scripting template list command with auto discovery
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-27 13:36:30 -07:00
Med Ismail Bennani
e8504cb0c9
[lldb] Revert scripting template list patches (#100673)
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 17:11:36 -07:00
Med Ismail Bennani
0d4f9484bc [lldb/Plugins] Fix build failure on windows following 2914a4b88837
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 16:19:34 -07:00
Med Ismail Bennani
c1d1a752ce [lldb/Plugins] Fix build failure on windows following 2914a4b88837
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 13:32:24 -07:00
David Spickett
a466db2b32
Revert "[lldb] Fix incorrect logical operator in 'if' condition check (NFC)" (#100561)
Reverts llvm/llvm-project#94779

Due to bot failures:
https://lab.llvm.org/buildbot/#/builders/18/builds/1371
2024-07-25 13:18:11 +01:00
Shivam Gupta
2ba3fe7356
[lldb] Fix incorrect uses of logical operator in 'if' condition check (NFC) (#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 16:59:39 +05:30
Med Ismail Bennani
c3a2efceb5 [lldb/Plugins] Fix build failure on windows following 2914a4b88837
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 01:19:23 -07:00
Med Ismail Bennani
2914a4b888 [lldb/Commands] Add scripting template list command with auto discovery
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 00:12:06 -07:00
Med Ismail Bennani
39c23a31d2
Revert "[lldb/Commands] Add scripting template list command with auto 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 16:04:48 -07:00
Med Ismail Bennani
43ca63149d
[lldb/Commands] Add scripting template list command with auto discovery (#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-07-23 10:19:52 -07:00
Med Ismail Bennani
6cb45aea92
Reland "[lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription 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-28 11:53:19 -07:00
Nico Weber
a2e3af5d58 Revert "[lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription 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 13:25:11 +02:00
Med Ismail Bennani
1130e923e2
[lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription return 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-28 01:40:03 -07:00
Med Ismail Bennani
9a9ec228cd
[lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan (#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-06-27 01:45:30 -07:00
Med Ismail Bennani
ae3f68066c
Revert "[lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan (Reland #70392)" (#93153)
Reverts llvm/llvm-project#93149 since it breaks
https://lab.llvm.org/buildbot/#/builders/68/builds/74799
2024-05-23 01:46:29 -07:00
Med Ismail Bennani
4cc6d0f4df
[lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan (Reland #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-05-23 01:25:48 -07:00
Jason Molenda
61384850c5 Revert "[lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan (#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 10:43:33 -08:00
Med Ismail Bennani
888501bc63 [lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan (#70392)
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>
2024-01-29 03:17:33 -08:00
Med Ismail Bennani
0a21144614 [lldb] Check for abstract methods implementation in Scripted Plugin Objects (#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-07 22:01:41 -08:00
Med Ismail Bennani
c2ad9f8b60 Revert "[lldb] Check for abstract methods implementation in Scripted Plugin 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 13:04:01 -08:00
Med Ismail Bennani
cc9ad72713
[lldb] Check for abstract methods implementation in Scripted Plugin Objects (#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-07 12:07:16 -08:00
Med Ismail Bennani
6eafe2cb7a Revert "[lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan (#70392)"
This reverts commit 4b3cd379cce3f455bf3c8677ca7a5be6e708a4ce since it
introduces some test failures:

https://lab.llvm.org/buildbot/#/builders/68/builds/62556
2023-10-30 17:40:11 -07:00
Med Ismail Bennani
2b7ba0155d Revert "[lldb] Fix build failure introduced in 484038416d06 (NFC)"
This reverts commit ed5faa475b401aa91284d19afb52b2927aa59c97 since it
introduces test failures:

https://lab.llvm.org/buildbot/#/builders/68/builds/62556
2023-10-30 17:38:36 -07:00
Med Ismail Bennani
ed5faa475b [lldb] Fix build failure introduced in 484038416d06 (NFC)
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-10-30 17:24:35 -07:00
Med Ismail Bennani
4b3cd379cc
[lldb] Make use of Scripted{Python,}Interface for ScriptedThreadPlan (#70392)
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-30 16:52:17 -07:00
Med Ismail Bennani
7a1e878358 [lldb] Introduce OperatingSystem{,Python}Interface and make use it
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>
2023-10-26 15:12:22 -07:00
Med Ismail Bennani
7b8e686115 [lldb] Fix build failure introduced by f22d82c
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2023-10-25 10:31:43 -07:00