[lldb-dev] Various questions about lldbinit and python scripts.
jyavenard at gmail.com
Fri Oct 4 19:40:37 PDT 2013
Being forced to move from gdb to lldb thanks to XCode 5 dropping
support for gdb, I find myself having to re-implement several commands
I had up and running within gdb.
I use the Qt framework, and in gdb, I had various macros to print the
content of Qt objects such as QString, QMap, QList etc...
I tried to follow the tutorials found there:
In the python reference documentation:
there's a link to a template example:
which according to the documentation should be invoked from lldb with:
command script import /path/to/cmdtemplate.py
When doing so, the module gets properly imported and you see in the
The "framestats" command has been installed, type "help framestats" or
"framestats --help" for detailed help.
However trying to use the command
(lldb) framestats --help
error: unable to execute script function
I'm just putting this as an example... I've been unable to load *any*
python script within lldb:
it always yield the same error "unable to execute script function"..
I tried setting the PYTHONPATH variable to:
which is where it's located, to no available...
So I'm looking at some pointers on how to use python scripts within lldb.
Ultimately, what I'm trying to achieve is printing the content of a QString.
A QString object has a private member QString::Data* d; where d->size
contains the number of UTF-16 characters
and d->data is an array of ushort (the UTF-16) characters.
In gdb I would "simply" have:
set $d = ('QString::Data'*) $arg0
set $i = 0
# abort after a '-1' character, to avoid going on forever when
printing a garbage string
while $i < $d->size && ($i == 0 || (char)$d->data[$i-1] != -1)
printf "%c", (char)($d->data[$i++] & 0xff)
to print the content of the QString, I would call printqstringdata variable.d
doing such loop would be easy in python; provided I managed to get the
script to load and provide and retrieve the QString variable argument.
Any pointers or link to some tutorials will be welcome...
Googling lldb python scripting hasn't provided much help at this stage
unfortunately... It seems no one has bothered writing much python
scripts for lldb yet.... probably too new or not popular enough.
More information about the lldb-dev