Skip to content

Conversation

mentlerd
Copy link
Contributor

Dear ImGui already contains much appreciated support for debuggers to visualize it's custom types at misc/debuggers.

This PR introduces the same capability for LLDB, the choice of debugger of Xcode and macOS. Here is a quick sample of a before/after:

ImVec2 vec2(1, 2);
ImVec4 vec4(1, 2, 3, 4);
ImRect rect(1, 2, 3, 4);

ImVector<int> vec;
vec.push_back(1);
vec.push_back(2);
vec.push_back(3);
vec.push_back(4);

ImSpan<int> span(vec.begin()+1, vec.begin()+3);

printf("Breakpoint here!");
Before After
image image

Admittedly the amount of code to achieve this might be scary. LLDB's scripting integration was built with more complex data structures in mind, thus doing simple things unfortunately takes quite a bit of legwork.

Regardless I thought this might be useful for people who use either LLDB or Xcode to work with Dear ImGui.

@ocornut ocornut added the tools label Sep 20, 2025
@ocornut
Copy link
Owner

ocornut commented Sep 20, 2025

Hello,
Thanks for your PR. Do any OSX user want to review this too?

Feedback
(A) file should probably be called imgui_lldb.py or something else than just imgui.py

(B) this is not safe:

child = 1 if flags & 0x01000000 else 0
popup = 1 if flags & 0x04000000 else 0

As we don't provide binary compatibility. If you can't access the C++ names then best to remove those.

@mentlerd
Copy link
Contributor Author

Done and done! I took the formatting and flag values from the already available .natvis file in the same folder.

@ocornut
Copy link
Owner

ocornut commented Sep 22, 2025

Thank you! Merged as 087fbf0 + amends 46e6382.

Would you be able to provide the equivalent patch for ImStrv in the string_view branch?
https://github.com/ocornut/imgui/tree/features/string_view/misc/debuggers

.natvis:

<!-- String view (non zero-terminated begin/end pair) -->
<Type Name="ImStrv">
  <DisplayString>{Begin,[End-Begin]s8} ({End-Begin,d})</DisplayString>
  <StringView>Begin,[End-Begin]s8</StringView>
</Type>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants