Skip to content

Instantly share code, notes, and snippets.

@memononen
Created May 15, 2026 17:53
Show Gist options
  • Select an option

  • Save memononen/b7409e9a654edccce844033e9d4bee4b to your computer and use it in GitHub Desktop.

Select an option

Save memononen/b7409e9a654edccce844033e9d4bee4b to your computer and use it in GitHub Desktop.
Python summaries for LLDB in CLion on Windows

Python summaries for LLDB in CLion on Windows

  • add /.lldbinit:
settings set target.load-cwd-lldbinit true
  • add /.lldbinit:
command script import <dir/formatter.py> # e.g. formatters/motley_formatter.py
  • CLion: turn on MSVC+lldb (or else default is gdb)
    • Settings > Build,Execution,Deployment > CMake
    • Change toolchain to "Visual Studio"
  • Categories seems broken on CLion, use default category
    • just dont provide category, omit -w or --category
  • Sometimes lldb uses the struct name sometimes typedef
    • if you define your structs like:
		typede struct foo {
			int a;
		} foo_t
  • you will need to add pattern to match both
    • one option is to use regex:
		debugger.HandleCommand('type summary add --regex "^mo_name(_t)?$" --python-function motley_formatter.mo_name_SummaryProvider')
  • The shorthand params sometimes confuse lldb, use the full ones (the real issue is probably some param order thing)
    • --regex instead of -x
    • --python-function not -F
    • etc
  • CLion adds synthetic types for unnamed unions
    • use raw_struct = valobj.GetNonSyntheticValue()
  • valobj.CreateValueFromAddress() does not always work for pointers to heap arrays, but valobj.CreateChildAtOffset() might work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment