Skip to content

Commit 67ee497

Browse files
mentlerdocornut
authored andcommitted
ImStrv: Added ImStrv formatter for LLDB (e.g. Xcode)
1 parent 6307b44 commit 67ee497

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

misc/debuggers/imgui_lldb.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,35 @@ def get_summary(self):
9191

9292
return f"Min=({minX}, {minY}) Max=({maxX}, {maxY}) Size=({maxX - minX}, {maxY - minY})"
9393

94+
class ImStrvSummary(object):
95+
def __init__(self, valobj, internal_dict):
96+
self.valobj = valobj
97+
98+
def update(self):
99+
pass
100+
101+
def get_summary(self):
102+
begin = self.valobj.GetChildMemberWithName("Begin").GetValueAsUnsigned()
103+
end = self.valobj.GetChildMemberWithName("End").GetValueAsUnsigned()
104+
105+
if begin == 0:
106+
return "<null>"
107+
108+
if end < begin:
109+
return "<invalid>"
110+
111+
error = lldb.SBError()
112+
data = self.valobj.GetProcess().ReadMemory(begin, end - begin, error)
113+
114+
if not error.Success():
115+
return "<failed to read memory>"
116+
117+
# Turn the byte sequence into utf-8, escape non-printables
118+
data = data.decode("utf-8", errors="backslashreplace")
119+
data = repr(data)[1:-1]
120+
121+
return f'"{data}"'
122+
94123
def get_active_enum_flags(valobj):
95124
flag_set = set()
96125

@@ -187,3 +216,4 @@ def add_synthetic(typename, impl):
187216
add_summary("^ImVec4$", "x=${var.x} y=${var.y} z=${var.z} w=${var.w}")
188217
add_summary("^ImRect$", ImRectSummary)
189218
add_summary("^ImGuiWindow$", ImGuiWindowSummary)
219+
add_summary("^ImStrv", ImStrvSummary)

0 commit comments

Comments
 (0)