Skip to content

Commit 46a010f

Browse files
A new and improved lldb_bson.py (#1238)
* Complete overhaul of lldb_bson.py * Tweak summary strings to resemble those in the Mongo repl * Python 3.8 compat * Update documentation on debugging with LLDB
1 parent e8ce539 commit 46a010f

File tree

3 files changed

+1583
-194
lines changed

3 files changed

+1583
-194
lines changed

lldb.pyi

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
"""
2+
This Python type stubs file is only here to support checking of lldb_bson.py.
3+
The type/member/constant listings in here are incomplete, as only those that
4+
are used in lldb_bson have been transcribed from the LLDB Python API
5+
documentation. Refer: https://lldb.llvm.org/python_api.html
6+
"""
7+
8+
from typing import IO, Any, Sequence, TypeAlias, NoReturn
9+
10+
_Pointer: TypeAlias = int
11+
_Size: TypeAlias = int
12+
_Offset: TypeAlias = int
13+
_InternalDict: TypeAlias = dict[str, Any]
14+
15+
class SBError:
16+
def __init__(self) -> None: ...
17+
@property
18+
def success(self) -> bool: ...
19+
@property
20+
def fail(self) -> bool: ...
21+
@property
22+
def description(self) -> str: ...
23+
24+
class SBDebugger:
25+
def __init__(self, _: NoReturn) -> None: ...
26+
def HandleCommand(self, command: str) -> None: ...
27+
def GetErrorFileHandle(self) -> IO[str]: ...
28+
def GetSelectedTarget(self) -> SBTarget | None: ...
29+
30+
class SBAddress:
31+
def __init__(self) -> None: ...
32+
@property
33+
def offset(self) -> type: ...
34+
@property
35+
def load_addr(self) -> _Pointer: ...
36+
def SetLoadAddress(self, addr: _Pointer, tgt: SBTarget) -> None: ...
37+
38+
class SBData:
39+
def GetSignedInt32(self, err: SBError, off: _Offset) -> int: ...
40+
@staticmethod
41+
def CreateDataFromUInt64Array(endian: ByteOrderType, size: _Size, dat: Sequence[int]) -> SBData: ...
42+
@staticmethod
43+
def CreateDataFromCString(endian: ByteOrderType, size: _Size, s: str) -> SBData: ...
44+
45+
byte_order: ByteOrderType
46+
47+
@property
48+
def uint8(self) -> Sequence[int]: ...
49+
@property
50+
def uint32(self) -> Sequence[int]: ...
51+
@property
52+
def uint64(self) -> Sequence[int]: ...
53+
@property
54+
def size(self) -> int: ...
55+
def ReadRawData(self, err: SBError, off: _Offset, size: _Size) -> bytes: ...
56+
def GetAddress(self, err: SBError, off: _Offset) -> _Pointer: ...
57+
def GetUnsignedInt32(self, err: SBError, off: _Offset) -> int: ...
58+
def GetUnsignedInt64(self, err: SBError, off: _Offset) -> int: ...
59+
60+
class SBValue:
61+
def Dereference(self) -> SBValue: ...
62+
def TypeIsPointerType(self) -> bool: ...
63+
def GetChildMemberWithName(self, name: str) -> SBValue: ...
64+
def GetValueAsUnsigned(self) -> int: ...
65+
def Cast(self, type: SBType) -> SBValue: ...
66+
def GetAddress(self) -> SBAddress: ...
67+
def GetData(self) -> SBData: ...
68+
def GetNonSyntheticValue(self) -> SBValue: ...
69+
def CreateChildAtOffset(self, name: str, offset: _Offset, type: SBType) -> SBValue: ...
70+
def CreateValueFromData(self, name: str, data: SBData, type: SBType) -> SBValue: ...
71+
def CreateValueFromAddress(self, name: str, addr: _Pointer, type: SBType) -> SBValue: ...
72+
def CreateValueFromExpression(self, name: str, expr: str) -> SBValue: ...
73+
def synthetic_child_from_address(self, name: str, addr: _Pointer, type: SBType) -> SBValue: ...
74+
def synthetic_child_from_expression(self, name: str, expr: str) -> SBValue: ...
75+
@property
76+
def addr(self) -> SBAddress: ...
77+
@property
78+
def frame(self) -> SBFrame: ...
79+
@property
80+
def type(self) -> SBType: ...
81+
@property
82+
def name(self) -> str: ...
83+
@property
84+
def target(self) -> SBTarget: ...
85+
@property
86+
def load_addr(self) -> _Pointer: ...
87+
@property
88+
def size(self) -> int: ...
89+
@property
90+
def unsigned(self) -> int: ...
91+
@property
92+
def data(self) -> SBData: ...
93+
@property
94+
def deref(self) -> SBValue: ...
95+
@property
96+
def process(self) -> SBProcess: ...
97+
@property
98+
def error(self) -> SBError: ...
99+
@property
100+
def changed(self) -> bool: ...
101+
@property
102+
def children(self) -> Sequence[SBValue]: ...
103+
104+
value: str
105+
format: ValueFormatType
106+
107+
class SBFrame:
108+
def FindVariable(self, var_name: str) -> SBValue: ...
109+
def EvaluateExpression(self, expr: str) -> SBValue: ...
110+
@property
111+
def locals(self) -> Sequence[SBValue]: ...
112+
@property
113+
def thread(self) -> SBThread: ...
114+
115+
class SBThread:
116+
@property
117+
def frames(self) -> Sequence[SBFrame]: ...
118+
@property
119+
def process(self) -> SBProcess: ...
120+
121+
class SBProcess:
122+
def ReadMemory(self, addr: _Pointer, size: int, err: SBError) -> bytes: ...
123+
def ReadCStringFromMemory(self, addr: _Pointer, max: int, err: SBError) -> bytes: ...
124+
@property
125+
def selected_thread(self) -> SBThread: ...
126+
@property
127+
def id(self) -> int: ...
128+
129+
class SBCommandReturnObject:
130+
def AppendMessage(self, s: str) -> None: ...
131+
132+
class SBTarget:
133+
def FindFirstType(self, type: str) -> SBType: ...
134+
def CreateValueFromData(self, name: str, data: SBData, type: SBType) -> SBValue: ...
135+
def CreateValueFromExpression(self, name: str, expr: str) -> SBValue: ...
136+
def CreateValueFromAddress(self, name: str, addr: SBAddress, type: SBType) -> SBValue: ...
137+
def GetBasicType(self, type: BasicType) -> SBType: ...
138+
@property
139+
def process(self) -> SBProcess: ...
140+
141+
class SBType:
142+
def GetDisplayTypeName(self) -> str: ...
143+
def GetPointerType(self) -> SBType: ...
144+
def GetArrayType(self, size: int) -> SBType: ...
145+
@property
146+
def name(self) -> str: ...
147+
def IsValid(self) -> bool: ...
148+
@property
149+
def fields(self) -> Sequence[SBTypeMember]: ...
150+
@property
151+
def size(self) -> int: ...
152+
153+
class SBTypeMember:
154+
@property
155+
def name(self) -> str: ...
156+
@property
157+
def byte_offset(self) -> int: ...
158+
159+
class SBSyntheticValueProvider:
160+
def __init__(self, valobj: SBValue, internal_dict: _InternalDict) -> None: ...
161+
def num_children(self) -> int: ...
162+
def get_child_at_index(self, pos: int) -> SBValue: ...
163+
def has_children(self) -> bool: ...
164+
def get_value(self) -> SBValue: ...
165+
def update(self) -> bool | None: ...
166+
167+
# Types not present in lldb, but represent the types of top-level constants:
168+
# (These may only be used in unevaluated contexts)
169+
class ByteOrderType: ...
170+
class ValueFormatType: ...
171+
class BasicType: ...
172+
173+
eBasicTypeNullPtr: BasicType
174+
eBasicTypeUnsignedChar: BasicType
175+
eBasicTypeDouble: BasicType
176+
eBasicTypeBool: BasicType
177+
eBasicTypeChar: BasicType
178+
eBasicTypeUnsignedChar: BasicType
179+
eBasicTypeVoid: BasicType
180+
181+
eFormatDefault: ValueFormatType
182+
eFormatHex: ValueFormatType
183+
eFormatBinary: ValueFormatType
184+
eFormatPointer: ValueFormatType
185+
eFormatInvalid: ValueFormatType
186+
187+
debugger: SBDebugger

0 commit comments

Comments
 (0)