How to debug a core file with lldb?

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?

THanks,
Sara

target create -c

(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

Great, thanks Greg. I must not have the most up-to-date lldb version, for I see the following when I do the same commands:

(lldb) version
LLDB-112.2

(lldb) apropos core
No commands found pertaining to ‘core’. Try ‘help’ to see a complete list of debugger commands.

(lldb) help target create
Create a target using the argument as the main executable.

Syntax: target create

Command Options Usage:
target create [-a ] [-p ] [-v ] [-b ] [-s ]

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

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

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

-s ( --sysroot )
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.

(lldb) target create --core /cores/core.1235
lldb: unrecognized option `–core’
error: unknown or ambiguous option

Could you tell me what vernon of lldb the core support is in? Thanks!

Ah, I see, I was using Xcode 4.3.3 but Xcode 4.5.1 does have the lldb version with core support document. Thanks for your help!

Hey Sara,

I installed latest Xcode and switched to latest lldb. Its working for me.

Thanks again!

-Prabhat