[lldb-dev] How to debug a core file with lldb?

Greg Clayton gclayton at apple.com
Thu Nov 1 10:35:42 PDT 2012


On Nov 1, 2012, at 8:30 AM, Sara Burke <Sara.Burke at mathworks.com> wrote:

> Hi lldb-dev,
> 
> I have a question regarding debugging a core file. With gdb, one can specify -c <core_file> to debug a core file. However, I can find no documentation to do this with lldb. Is there such a way? lldb seems to think the core file is an executable, which isn't necessarily what I would like. Any suggestions?
> 

(lldb) apropos core
The following commands may relate to 'core':
target create -- Create a target using the argument as the main executable.
(lldb) help target create
   Create a target using the argument as the main executable.

Syntax: target create <cmd-options> <filename>

Command Options Usage:
  target create [-a <arch>] [-p <platform-name>] [-v <none>] [-b <none>] [-s <filename>] [-c <path>] <filename>

       -a <arch>  ( --arch <arch> )
            Specify the architecture for the target.

       -b  ( --build )
            Specify the initial SDK build number.

       -c <path>  ( --core <path> )
            Fullpath to a core file to use for this target.

       -p <platform-name>  ( --platform <platform-name> )
            Specify name of the platform to use for this target, creating the platform if necessary.

       -s <filename>  ( --sysroot <filename> )
            Specify the SDK root directory that contains a root of all remote system files.

       -v  ( --version )
            Specify the initial SDK version to use prior to connecting.
   
This command takes options and arguments, if your arguments look like option specifiers you must use '--' to terminate the options before starting to give the arguments.



So there is documentation.

(lldb) target create --core /cores/core.1235

You can optionally give us the architecture and/or executable file if you know them:

(lldb) target create --core /cores/core.1235 --arch x86_64 /path/to/executable

After this commend, you can then do a:

(lldb) thread list
(lldb) thread backtrace all

Core files only work for mach-o core files right now. ELF support hasn't been done yet, but there is good sample code to follow in the following directory:

lldb/source/Plugins/Process/mach-core



More information about the lldb-dev mailing list