[lldb-dev] Guessing pointed data size

Greg Clayton gclayton at apple.com
Thu Aug 22 17:31:16 PDT 2013

Calling a function is easy:

(lldb) expr (size_t)malloc_size(my_ptr)

Your pointer might have to be the exact allocated address, it can't be just any address in a heap allocated block.

LLDB also has utilities that help you with heap stuff:

(lldb) script import lldb.macosx
(lldb) malloc_info my_ptr

Or if you want to find a pointer value inside memory:

(lldb) ptr_prefs my_ptr

If LLDB can determine the dynamic type of a block of memory, it might be able to print it for you:

(lldb) malloc_info --type my_ptr

IF the block is Objective C, you can PO the address of the containing block:

(lldb) malloc_info --po my_ptr

For all the gory details type "help malloc_info" and "help ptr_refs" for more information.


On Aug 22, 2013, at 5:13 PM, Sebastien Metrot <meeloo at gmail.com> wrote:

> Hello,
> I'm trying to find a way to guess the size of data that was malloc'd in the debugged process. I know there is an unsupported malloc_size function on MacOSX that is equivalent to _msize on Win32 (not found the equivalent on linux yet) and I'm wondering what would be the best way to call these functions in the debugged process+address space in order to display the data that is pointed to as children of the pointer instead of a single value as of now.
> I though there was a way call a debuggee function with the lldb API but I haven't found it so I'm starting to think I have just imagined it.
> S.
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev

More information about the lldb-dev mailing list