Skip to content

Commit 84ea182

Browse files
medismailbenlravenclaw
authored andcommitted
[lldb/docs] Add scripting extensions documentation to the website (llvm#97262)
This patch adds the documentation for a subset of scripting extensions such as scripted process, scripted thread, operating system threads & scritped thread plans to the lldb website. Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent e32fd49 commit 84ea182

File tree

5 files changed

+48
-47
lines changed

5 files changed

+48
-47
lines changed

lldb/docs/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ if (LLDB_ENABLE_PYTHON AND SPHINX_FOUND)
2727
get_target_property(lldb_bindings_dir swig_wrapper_python BINARY_DIR)
2828
add_custom_target(lldb-python-doc-package
2929
COMMAND "${CMAKE_COMMAND}" -E copy "${lldb_bindings_dir}/lldb.py" "${CMAKE_CURRENT_BINARY_DIR}/lldb/__init__.py"
30+
COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins"
31+
COMMAND "${CMAKE_COMMAND}" -E copy "${LLDB_SOURCE_DIR}/examples/python/templates/scripted_process.py" "${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins/"
32+
COMMAND "${CMAKE_COMMAND}" -E copy "${LLDB_SOURCE_DIR}/examples/python/templates/scripted_platform.py" "${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins/"
33+
COMMAND "${CMAKE_COMMAND}" -E copy "${LLDB_SOURCE_DIR}/examples/python/templates/operating_system.py" "${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins/"
3034
COMMENT "Copying lldb.py to pretend its a Python package.")
31-
add_dependencies(lldb-python-doc-package swig_wrapper_python)
35+
36+
add_dependencies(lldb-python-doc-package swig_wrapper_python lldb-python)
3237

3338
# FIXME: Don't treat Sphinx warnings as errors. The files generated by
3439
# automodapi are full of warnings (partly caused by SWIG, our documentation

lldb/docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ interesting areas to contribute to lldb.
141141
use/python
142142
use/python-reference
143143
Python API <python_api>
144+
Python Extensions <python_extensions>
144145

145146

146147
.. toctree::

lldb/examples/python/templates/operating_system.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ class OperatingSystem(ScriptedThread):
1010
"""
1111
Class that provides data for an instance of a LLDB 'OperatingSystemPython' plug-in class.
1212
13-
```
14-
thread_info = {
15-
"tid": tid,
16-
"name": "four",
17-
"queue": "queue4",
18-
"state": "stopped",
19-
"stop_reason": "none",
20-
"core" : 2
21-
}
22-
```
13+
.. code-block:: python
14+
15+
thread_info = {
16+
"tid": tid,
17+
"name": "four",
18+
"queue": "queue4",
19+
"state": "stopped",
20+
"stop_reason": "none",
21+
"core" : 2
22+
}
2323
2424
- tid : thread ID (mandatory)
2525
- name : thread name (optional key/value pair)

lldb/examples/python/templates/scripted_platform.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ class ScriptedPlatform(metaclass=ABCMeta):
1010
1111
Most of the base class methods are `@abstractmethod` that need to be
1212
overwritten by the inheriting class.
13-
14-
DISCLAIMER: THIS INTERFACE IS STILL UNDER DEVELOPMENT AND NOT STABLE.
15-
THE METHODS EXPOSED MIGHT CHANGE IN THE FUTURE.
1613
"""
1714

1815
processes = None
@@ -32,16 +29,18 @@ def __init__(self, exe_ctx, args):
3229
def list_processes(self):
3330
"""Get a list of processes that are running or that can be attached to on the platform.
3431
35-
processes = {
36-
420: {
37-
name: a.out,
38-
arch: aarch64,
39-
pid: 420,
40-
parent_pid: 42 (optional),
41-
uid: 0 (optional),
42-
gid: 0 (optional),
43-
},
44-
}
32+
.. code-block:: python
33+
34+
processes = {
35+
420: {
36+
name: a.out,
37+
arch: aarch64,
38+
pid: 420,
39+
parent_pid: 42 (optional),
40+
uid: 0 (optional),
41+
gid: 0 (optional),
42+
},
43+
}
4544
4645
Returns:
4746
Dict: The processes represented as a dictionary, with at least the

lldb/examples/python/templates/scripted_process.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ class ScriptedProcess(metaclass=ABCMeta):
1111
1212
Most of the base class methods are `@abstractmethod` that need to be
1313
overwritten by the inheriting class.
14-
15-
DISCLAIMER: THIS INTERFACE IS STILL UNDER DEVELOPMENT AND NOT STABLE.
16-
THE METHODS EXPOSED MIGHT CHANGE IN THE FUTURE.
1714
"""
1815

1916
capabilities = None
@@ -106,8 +103,8 @@ def write_memory_at_address(self, addr, data, error):
106103
107104
Args:
108105
addr (int): Address from which we should start reading.
109-
data (lldb.SBData): An `lldb.SBData` buffer to write to the
110-
process memory.
106+
data (lldb.SBData): An `lldb.SBData` buffer to write to the process
107+
memory.
111108
error (lldb.SBError): Error object.
112109
113110
Returns:
@@ -121,13 +118,13 @@ def write_memory_at_address(self, addr, data, error):
121118
def get_loaded_images(self):
122119
"""Get the list of loaded images for the scripted process.
123120
124-
```
125-
scripted_image = {
126-
uuid = "c6ea2b64-f77c-3d27-9528-74f507b9078b",
127-
path = "/usr/lib/dyld"
128-
load_addr = 0xbadc0ffee
129-
}
130-
```
121+
.. code-block:: python
122+
123+
scripted_image = {
124+
uuid = "c6ea2b64-f77c-3d27-9528-74f507b9078b",
125+
path = "/usr/lib/dyld"
126+
load_addr = 0xbadc0ffee
127+
}
131128
132129
Returns:
133130
List[scripted_image]: A list of `scripted_image` dictionaries
@@ -238,9 +235,6 @@ class ScriptedThread(metaclass=ABCMeta):
238235
239236
Most of the base class methods are `@abstractmethod` that need to be
240237
overwritten by the inheriting class.
241-
242-
DISCLAIMER: THIS INTERFACE IS STILL UNDER DEVELOPMENT AND NOT STABLE.
243-
THE METHODS EXPOSED MIGHT CHANGE IN THE FUTURE.
244238
"""
245239

246240
@abstractmethod
@@ -305,10 +299,12 @@ def get_name(self):
305299
def get_state(self):
306300
"""Get the scripted thread state type.
307301
302+
.. code-block:: python
303+
308304
eStateStopped, ///< Process or thread is stopped and can be examined.
309305
eStateRunning, ///< Process or thread is running and can't be examined.
310-
eStateStepping, ///< Process or thread is in the process of stepping and can
311-
/// not be examined.
306+
eStateStepping, ///< Process or thread is in the process of stepping and
307+
/// can not be examined.
312308
eStateCrashed, ///< Process or thread has crashed and can be examined.
313309
314310
Returns:
@@ -340,12 +336,12 @@ def get_stop_reason(self):
340336
def get_stackframes(self):
341337
"""Get the list of stack frames for the scripted thread.
342338
343-
```
344-
scripted_frame = {
345-
idx = 0,
346-
pc = 0xbadc0ffee
347-
}
348-
```
339+
.. code-block:: python
340+
341+
scripted_frame = {
342+
idx = 0,
343+
pc = 0xbadc0ffee
344+
}
349345
350346
Returns:
351347
List[scripted_frame]: A list of `scripted_frame` dictionaries

0 commit comments

Comments
 (0)