Search code examples
lldb

Is there an equivalent of dds on lldb


I am trying to debug an issue on OSX and lldb is getting in my way. I think my program has a corrupted stack, and I would like to be able to manually walk the stack.

In WinDBG, there is a command called dds that I can use to dump all the pointers on the stack (basically, walking from rsp, walking towards higher addresses) and resolve all pointers to symbols (and print nothing if it does not correspond to code), I am looking for a similar command on lldb. I know I could memory read --format x manually one by one and then look them up using image lookup, but that would be too time consuming.


Solution

  • There isn't a built-in command to do the walk itself, so you will have to page through the memory up from rsp by hand.

    But you might find the "A" format helpful for this task. That will print the memory as a list of address-sized words, and for any values that point into TEXT or DATA it will print the symbol's name. Like:

    (lldb) mem read -fA `$rsp - 16 * 8` `$rsp` -fA 
    0x7ffeefbff660: 0x0000000000000000
    0x7ffeefbff668: 0x00007ffeefbff660
    0x7ffeefbff670: 0x0000003002000000
    0x7ffeefbff678: 0x00007fff6e2ee568 libsystem_platform.dylib`__platform_sigaction + 103
    0x7ffeefbff680: 0x0000000000000000
    0x7ffeefbff688: 0x0000000000000000
    0x7ffeefbff690: 0x0000000000013dc9
    0x7ffeefbff698: 0x0000000000000000
    0x7ffeefbff6a0: 0x00007fff6e238fe2 libsystem_kernel.dylib`__sigaction + 10
    0x7ffeefbff6a8: 0x0000000000000000
    0x7ffeefbff6b0: 0x000000000000001e
    0x7ffeefbff6b8: 0x0000000000013dc9
    0x7ffeefbff6c0: 0x00007ffeefbff700
    0x7ffeefbff6c8: 0x0000000100002020 _dyld_private
    0x7ffeefbff6d0: 0x000000000000000e
    0x7ffeefbff6d8: 0x0000000100000f45 signals`main + 53 at signals.c:13:3