Skip to content

Commit 313cff1

Browse files
committed
[lldb] [NFC] Fix swig docstring annotations (llvm#88073)
Some of the SB API method description docstrings for swing are annotated as `%feature("autodoc")` - but `"autodoc"` annotations are only to substitute a string showing the arguments and return variables - either in a single line, or in multiple lines. SBMemoryRegionInfo used `"autodoc"` correctly describing the parameters and return type, but then it added a description too which is not correct either. Change all of these that are adding a method description to use `%feature("docstring")` instead. There were a half dozen instances where `"autodoc"` was correctly being used and we have overriden the parameter and return types with a more readable version. (cherry picked from commit e35fb3f)
1 parent 6bf0f1d commit 313cff1

File tree

4 files changed

+51
-53
lines changed

4 files changed

+51
-53
lines changed

lldb/bindings/interface/SBMemoryRegionInfoDocstrings.i

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,30 @@
22
"API clients can get information about memory regions in processes."
33
) lldb::SBMemoryRegionInfo;
44

5-
%feature("autodoc", "
6-
GetRegionEnd(SBMemoryRegionInfo self) -> lldb::addr_t
5+
%feature("docstring", "
76
Returns whether this memory region has a list of modified (dirty)
87
pages available or not. When calling GetNumDirtyPages(), you will
98
have 0 returned for both \"dirty page list is not known\" and
109
\"empty dirty page list\" (that is, no modified pages in this
1110
memory region). You must use this method to disambiguate."
1211
) lldb::SBMemoryRegionInfo::HasDirtyMemoryPageList;
1312

14-
%feature("autodoc", "
15-
GetNumDirtyPages(SBMemoryRegionInfo self) -> uint32_t
13+
%feature("docstring", "
1614
Return the number of dirty (modified) memory pages in this
1715
memory region, if available. You must use the
1816
SBMemoryRegionInfo::HasDirtyMemoryPageList() method to
1917
determine if a dirty memory list is available; it will depend
2018
on the target system can provide this information."
2119
) lldb::SBMemoryRegionInfo::GetNumDirtyPages;
2220

23-
%feature("autodoc", "
24-
GetDirtyPageAddressAtIndex(SBMemoryRegionInfo self, uint32_t idx) -> lldb::addr_t
21+
%feature("docstring", "
2522
Return the address of a modified, or dirty, page of memory.
2623
If the provided index is out of range, or this memory region
2724
does not have dirty page information, LLDB_INVALID_ADDRESS
2825
is returned."
2926
) lldb::SBMemoryRegionInfo::GetDirtyPageAddressAtIndex;
3027

31-
%feature("autodoc", "
32-
GetPageSize(SBMemoryRegionInfo self) -> int
28+
%feature("docstring", "
3329
Return the size of pages in this memory region. 0 will be returned
3430
if this information was unavailable."
3531
) lldb::SBMemoryRegionInfo::GetPageSize();

lldb/bindings/interface/SBProcessDocstrings.i

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ SBProcess supports thread iteration. For example (from test/lldbutil.py), ::
2020
"
2121
) lldb::SBProcess;
2222

23-
%feature("autodoc", "
23+
%feature("docstring", "
2424
Writes data into the current process's stdin. API client specifies a Python
2525
string as the only argument."
2626
) lldb::SBProcess::PutSTDIN;
2727

28-
%feature("autodoc", "
28+
%feature("docstring", "
2929
Reads data from the current process's stdout stream. API client specifies
3030
the size of the buffer to read data into. It returns the byte buffer in a
3131
Python string."
3232
) lldb::SBProcess::GetSTDOUT;
3333

34-
%feature("autodoc", "
34+
%feature("docstring", "
3535
Reads data from the current process's stderr stream. API client specifies
3636
the size of the buffer to read data into. It returns the byte buffer in a
3737
Python string."
@@ -47,34 +47,34 @@ SBProcess supports thread iteration. For example (from test/lldbutil.py), ::
4747
"See SBTarget.Launch for argument description and usage."
4848
) lldb::SBProcess::RemoteLaunch;
4949

50-
%feature("autodoc", "
50+
%feature("docstring", "
5151
Returns the INDEX'th thread from the list of current threads. The index
5252
of a thread is only valid for the current stop. For a persistent thread
5353
identifier use either the thread ID or the IndexID. See help on SBThread
5454
for more details."
5555
) lldb::SBProcess::GetThreadAtIndex;
5656

57-
%feature("autodoc", "
57+
%feature("docstring", "
5858
Returns the thread with the given thread ID."
5959
) lldb::SBProcess::GetThreadByID;
6060

61-
%feature("autodoc", "
61+
%feature("docstring", "
6262
Returns the thread with the given thread IndexID."
6363
) lldb::SBProcess::GetThreadByIndexID;
6464

65-
%feature("autodoc", "
65+
%feature("docstring", "
6666
Returns the currently selected thread."
6767
) lldb::SBProcess::GetSelectedThread;
6868

69-
%feature("autodoc", "
69+
%feature("docstring", "
7070
Lazily create a thread on demand through the current OperatingSystem plug-in, if the current OperatingSystem plug-in supports it."
7171
) lldb::SBProcess::CreateOSPluginThread;
7272

73-
%feature("autodoc", "
73+
%feature("docstring", "
7474
Returns the process ID of the process."
7575
) lldb::SBProcess::GetProcessID;
7676

77-
%feature("autodoc", "
77+
%feature("docstring", "
7878
Returns an integer ID that is guaranteed to be unique across all process instances. This is not the process ID, just a unique integer for comparison and caching purposes."
7979
) lldb::SBProcess::GetUniqueID;
8080

@@ -95,7 +95,7 @@ SBProcess supports thread iteration. For example (from test/lldbutil.py), ::
9595
will always increase, but may increase by more than one per stop."
9696
) lldb::SBProcess::GetStopID;
9797

98-
%feature("autodoc", "
98+
%feature("docstring", "
9999
Reads memory from the current process's address space and removes any
100100
traps that may have been inserted into the memory. It returns the byte
101101
buffer in a Python string. Example: ::
@@ -105,7 +105,7 @@ SBProcess supports thread iteration. For example (from test/lldbutil.py), ::
105105
new_bytes = bytearray(content)"
106106
) lldb::SBProcess::ReadMemory;
107107

108-
%feature("autodoc", "
108+
%feature("docstring", "
109109
Writes memory to the current process's address space and maintains any
110110
traps that might be present due to software breakpoints. Example: ::
111111
@@ -116,8 +116,8 @@ SBProcess supports thread iteration. For example (from test/lldbutil.py), ::
116116
print('SBProcess.WriteMemory() failed!')"
117117
) lldb::SBProcess::WriteMemory;
118118

119-
%feature("autodoc", "
120-
Reads a NULL terminated C string from the current process's address space.
119+
%feature("docstring", "
120+
Reads a NUL terminated C string from the current process's address space.
121121
It returns a python string of the exact length, or truncates the string if
122122
the maximum character limit is reached. Example: ::
123123
@@ -131,7 +131,7 @@ SBProcess supports thread iteration. For example (from test/lldbutil.py), ::
131131
) lldb::SBProcess::ReadCStringFromMemory;
132132

133133

134-
%feature("autodoc", "
134+
%feature("docstring", "
135135
Reads an unsigned integer from memory given a byte size and an address.
136136
Returns the unsigned integer that was read. Example: ::
137137
@@ -145,7 +145,7 @@ SBProcess supports thread iteration. For example (from test/lldbutil.py), ::
145145
) lldb::SBProcess::ReadUnsignedFromMemory;
146146

147147

148-
%feature("autodoc", "
148+
%feature("docstring", "
149149
Reads a pointer from memory from an address and returns the value. Example: ::
150150
151151
# Read a pointer from address 0x1000
@@ -158,24 +158,24 @@ SBProcess supports thread iteration. For example (from test/lldbutil.py), ::
158158
) lldb::SBProcess::ReadPointerFromMemory;
159159

160160

161-
%feature("autodoc", "
161+
%feature("docstring", "
162162
Returns the implementation object of the process plugin if available. None
163163
otherwise."
164164
) lldb::SBProcess::GetScriptedImplementation;
165165

166-
%feature("autodoc", "
166+
%feature("docstring", "
167167
Returns the process' extended crash information."
168168
) lldb::SBProcess::GetExtendedCrashInformation;
169169

170-
%feature("autodoc", "
170+
%feature("docstring", "
171171
Load the library whose filename is given by image_spec looking in all the
172172
paths supplied in the paths argument. If successful, return a token that
173173
can be passed to UnloadImage and fill loaded_path with the path that was
174174
successfully loaded. On failure, return
175175
lldb.LLDB_INVALID_IMAGE_TOKEN."
176176
) lldb::SBProcess::LoadImageUsingPaths;
177177

178-
%feature("autodoc", "
178+
%feature("docstring", "
179179
Return the number of different thread-origin extended backtraces
180180
this process can support as a uint32_t.
181181
When the process is stopped and you have an SBThread, lldb may be
@@ -184,12 +184,12 @@ SBProcess supports thread iteration. For example (from test/lldbutil.py), ::
184184
queue)."
185185
) lldb::SBProcess::GetNumExtendedBacktraceTypes;
186186

187-
%feature("autodoc", "
187+
%feature("docstring", "
188188
Takes an index argument, returns the name of one of the thread-origin
189189
extended backtrace methods as a str."
190190
) lldb::SBProcess::GetExtendedBacktraceTypeAtIndex;
191191

192-
%feature("autodoc", "
192+
%feature("docstring", "
193193
Get information about the process.
194194
Valid process info will only be returned when the process is alive,
195195
use IsValid() to check if the info returned is valid. ::
@@ -199,7 +199,7 @@ SBProcess supports thread iteration. For example (from test/lldbutil.py), ::
199199
process_info.GetProcessID()"
200200
) lldb::SBProcess::GetProcessInfo;
201201

202-
%feature("autodoc", "
202+
%feature("docstring", "
203203
Allocates a block of memory within the process, with size and
204204
access permissions specified in the arguments. The permissions
205205
argument is an or-combination of zero or more of
@@ -209,7 +209,11 @@ SBProcess supports thread iteration. For example (from test/lldbutil.py), ::
209209
lldb.LLDB_INVALID_ADDRESS if the allocation failed."
210210
) lldb::SBProcess::AllocateMemory;
211211

212-
%feature("autodoc", "
212+
%feature("docstring", "Get default process broadcaster class name (lldb.process)."
213+
) lldb::SBProcess::GetBroadcasterClass;
214+
215+
216+
%feature("docstring", "
213217
Deallocates the block of memory (previously allocated using
214218
AllocateMemory) given in the argument."
215219
) lldb::SBProcess::DeallocateMemory;

lldb/bindings/interface/SBQueueDocstrings.i

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"Represents a libdispatch queue in the process."
33
) lldb::SBQueue;
44

5-
%feature("autodoc", "
5+
%feature("docstring", "
66
Returns an lldb::queue_id_t type unique identifier number for this
77
queue that will not be used by any other queue during this process'
88
execution. These ID numbers often start at 1 with the first
99
system-created queues and increment from there."
1010
) lldb::SBQueue::GetQueueID;
1111

12-
%feature("autodoc", "
12+
%feature("docstring", "
1313
Returns an lldb::QueueKind enumerated value (e.g. eQueueKindUnknown,
1414
eQueueKindSerial, eQueueKindConcurrent) describing the type of this
1515
queue."

lldb/bindings/interface/SBThreadDocstrings.i

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,24 @@ See also :py:class:`SBFrame` ."
5555
eStopReasonPlanComplete 0"
5656
) lldb::SBThread::GetStopReasonDataAtIndex;
5757

58-
%feature("autodoc", "
58+
%feature("docstring", "
5959
Collects a thread's stop reason extended information dictionary and prints it
6060
into the SBStream in a JSON format. The format of this JSON dictionary depends
6161
on the stop reason and is currently used only for instrumentation plugins."
6262
) lldb::SBThread::GetStopReasonExtendedInfoAsJSON;
6363

64-
%feature("autodoc", "
64+
%feature("docstring", "
6565
Returns a collection of historical stack traces that are significant to the
6666
current stop reason. Used by ThreadSanitizer, where we provide various stack
6767
traces that were involved in a data race or other type of detected issue."
6868
) lldb::SBThread::GetStopReasonExtendedBacktraces;
6969

70-
%feature("autodoc", "
70+
%feature("docstring", "
7171
Pass only an (int)length and expect to get a Python string describing the
7272
stop reason."
7373
) lldb::SBThread::GetStopDescription;
7474

75-
%feature("autodoc", "
75+
%feature("docstring", "
7676
Returns a unique thread identifier (type lldb::tid_t, typically a 64-bit type)
7777
for the current SBThread that will remain constant throughout the thread's
7878
lifetime in this process and will not be reused by another thread during this
@@ -81,7 +81,7 @@ See also :py:class:`SBFrame` ."
8181
to associate data from those tools with lldb. See related GetIndexID."
8282
) lldb::SBThread::GetThreadID;
8383

84-
%feature("autodoc", "
84+
%feature("docstring", "
8585
Return the index number for this SBThread. The index number is the same thing
8686
that a user gives as an argument to 'thread select' in the command line lldb.
8787
These numbers start at 1 (for the first thread lldb sees in a debug session)
@@ -91,12 +91,12 @@ See also :py:class:`SBFrame` ."
9191
This method returns a uint32_t index number, takes no arguments."
9292
) lldb::SBThread::GetIndexID;
9393

94-
%feature("autodoc", "
94+
%feature("docstring", "
9595
Return the queue name associated with this thread, if any, as a str.
9696
For example, with a libdispatch (aka Grand Central Dispatch) queue."
9797
) lldb::SBThread::GetQueueName;
9898

99-
%feature("autodoc", "
99+
%feature("docstring", "
100100
Return the dispatch_queue_id for this thread, if any, as a lldb::queue_id_t.
101101
For example, with a libdispatch (aka Grand Central Dispatch) queue."
102102
) lldb::SBThread::GetQueueID;
@@ -109,7 +109,7 @@ See also :py:class:`SBFrame` ."
109109
anything was printed into the stream (true) or not (false)."
110110
) lldb::SBThread::GetInfoItemByPathAsString;
111111

112-
%feature("autodoc", "
112+
%feature("docstring", "
113113
Return the SBQueue for this thread. If this thread is not currently associated
114114
with a libdispatch queue, the SBQueue object's IsValid() method will return false.
115115
If this SBThread is actually a HistoryThread, we may be able to provide QueueID
@@ -141,14 +141,14 @@ See also :py:class:`SBFrame` ."
141141
"Do an instruction level single step in the currently selected thread."
142142
) lldb::SBThread::StepInstruction;
143143

144-
%feature("autodoc", "
144+
%feature("docstring", "
145145
Force a return from the frame passed in (and any frames younger than it)
146146
without executing any more code in those frames. If return_value contains
147147
a valid SBValue, that will be set as the return value from frame. Note, at
148148
present only scalar return values are supported."
149149
) lldb::SBThread::ReturnFromFrame;
150150

151-
%feature("autodoc", "
151+
%feature("docstring", "
152152
Unwind the stack frames from the innermost expression evaluation.
153153
This API is equivalent to 'thread return -x'."
154154
) lldb::SBThread::UnwindInnermostExpression;
@@ -181,7 +181,7 @@ See also :py:class:`SBFrame` ."
181181
or thread-stop-format (stop_format = true)."
182182
) lldb::SBThread::GetDescription;
183183

184-
%feature("autodoc","
184+
%feature("docstring","
185185
Given an argument of str to specify the type of thread-origin extended
186186
backtrace to retrieve, query whether the origin of this thread is
187187
available. An SBThread is retured; SBThread.IsValid will return true
@@ -192,8 +192,7 @@ See also :py:class:`SBFrame` ."
192192
the returned thread's own thread origin in turn."
193193
) lldb::SBThread::GetExtendedBacktraceThread;
194194

195-
%feature("autodoc","
196-
Takes no arguments, returns a uint32_t.
195+
%feature("docstring","
197196
If this SBThread is an ExtendedBacktrace thread, get the IndexID of the
198197
original thread that this ExtendedBacktrace thread represents, if
199198
available. The thread that was running this backtrace in the past may
@@ -202,29 +201,28 @@ See also :py:class:`SBFrame` ."
202201
In that case, this ExtendedBacktrace thread's IndexID will be returned."
203202
) lldb::SBThread::GetExtendedBacktraceOriginatingIndexID;
204203

205-
%feature("autodoc","
204+
%feature("docstring","
206205
Returns an SBValue object represeting the current exception for the thread,
207206
if there is any. Currently, this works for Obj-C code and returns an SBValue
208207
representing the NSException object at the throw site or that's currently
209208
being processes."
210209
) lldb::SBThread::GetCurrentException;
211210

212-
%feature("autodoc","
211+
%feature("docstring","
213212
Returns a historical (fake) SBThread representing the stack trace of an
214213
exception, if there is one for the thread. Currently, this works for Obj-C
215214
code, and can retrieve the throw-site backtrace of an NSException object
216215
even when the program is no longer at the throw site."
217216
) lldb::SBThread::GetCurrentExceptionBacktrace;
218217

219-
%feature("autodoc","
220-
Takes no arguments, returns a bool.
218+
%feature("docstring","
221219
lldb may be able to detect that function calls should not be executed
222220
on a given thread at a particular point in time. It is recommended that
223221
this is checked before performing an inferior function call on a given
224222
thread."
225223
) lldb::SBThread::SafeToCallFunctions;
226224

227-
%feature("autodoc","
228-
Retruns a SBValue object representing the siginfo for the current signal.
225+
%feature("docstring","
226+
Returns a SBValue object representing the siginfo for the current signal.
229227
"
230228
) lldb::SBThread::GetSiginfo;

0 commit comments

Comments
 (0)