├── .gitignore ├── README.md ├── docs └── lldb-qstring-xcode.png └── qstring.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | lib/ 17 | lib64/ 18 | parts/ 19 | sdist/ 20 | var/ 21 | *.egg-info/ 22 | .installed.cfg 23 | *.egg 24 | 25 | # PyInstaller 26 | # Usually these files are written by a python script from a template 27 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 28 | *.manifest 29 | *.spec 30 | 31 | # Installer logs 32 | pip-log.txt 33 | pip-delete-this-directory.txt 34 | 35 | # Unit test / coverage reports 36 | htmlcov/ 37 | .tox/ 38 | .coverage 39 | .cache 40 | nosetests.xml 41 | coverage.xml 42 | 43 | # Translations 44 | *.mo 45 | *.pot 46 | 47 | # Django stuff: 48 | *.log 49 | 50 | # Sphinx documentation 51 | docs/_build/ 52 | 53 | # PyBuilder 54 | target/ 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # lldb-scripts 2 | 3 | Collection of Python script for lldb, simplifying debugging. 4 | 5 | ## QString printer 6 | 7 | Prints readable QStrings for Qt 5.x inspired by http://codelite.org/LiteEditor/DebugWithLLD 8 | 9 | ### How to use 10 | 11 | * Copy qstring.py into ~/.lldb/ 12 | 13 | * Invoke following command in lldb: 14 | 15 | ``` 16 | command script import ~/.lldb/qstring.py 17 | ``` 18 | 19 | * Enjoy readable QStrings in lldb or Xcode 20 | 21 | 22 | ![Xcode and QString](https://github.com/tgebarowski/lldb-scripts/blob/master/docs/lldb-qstring-xcode.png "Xcode and QString") -------------------------------------------------------------------------------- /docs/lldb-qstring-xcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgebarowski/lldb-scripts/ef5ce1939027b8cec6ee16ffe0c29e4a33edbc6c/docs/lldb-qstring-xcode.png -------------------------------------------------------------------------------- /qstring.py: -------------------------------------------------------------------------------- 1 | import lldb 2 | 3 | def utf16string_summary(value, *rest): 4 | d = value.GetChildMemberWithName("d") 5 | length = d.GetChildMemberWithName("size").GetValueAsSigned() 6 | offset = d.GetChildMemberWithName("offset").GetValueAsSigned() 7 | address = d.GetValueAsUnsigned() + offset 8 | 9 | if length == 0: 10 | return '""' 11 | error = lldb.SBError() 12 | # UTF-16, so we multiply length by 2 13 | bytes = value.GetProcess().ReadMemory(address, length * 2, error) 14 | if bytes is None: 15 | return '""' 16 | return '"%s"' % (bytes.decode('utf-16').encode('utf-8')) 17 | 18 | def __lldb_init_module(debugger, *rest): 19 | print "registering QString" 20 | summary = lldb.SBTypeSummary.CreateWithFunctionName("qstring.utf16string_summary") 21 | summary.SetOptions(lldb.eTypeOptionHideChildren) 22 | debugger.GetDefaultCategory().AddTypeSummary( lldb.SBTypeNameSpecifier("QString", False), summary ) 23 | --------------------------------------------------------------------------------