Support for Linux core files

Hello,
I would like to write a simple tool that, given a Linux core dump,
produces a list of variables and their values (for those variables for
which it can be determined). I'm considering writing the tool on top of
LLDB.

If I understand correctly, there is no support for Linux cores in LLDB.
What would it take to implement it? Is it just a matter of implementing
the Process subclass for Linux cores? Or is there any other
Linux-related functionality missing? I see that there is support for
Linux processes but I haven't been successful in compiling LLDB yet, so
I can not try it out myself.

Thanks,
Martin Milata

Hello,
I would like to write a simple tool that, given a Linux core dump,
produces a list of variables and their values (for those variables for
which it can be determined). I'm considering writing the tool on top of
LLDB.

That should be easy.

If I understand correctly, there is no support for Linux cores in LLDB.

Correct, there is no linux core support currently.

What would it take to implement it?

We support mach-o core files, so there is some great example code that should be easy to adapt. The the mach-o core file example plug-in:

lldb/source/Plugins/Process/mach-core

Is it just a matter of implementing
the Process subclass for Linux cores?

Yes, see very simple and quick example in lldb/source/Plugins/Process/mach-core. Basically the linux plug-in will need to recognize linux core files and know how to parse them. I am not sure what the linux core file format is. On MacOSX, our core files are just mach-o files (very similar to executable files). As long as the linux core file is an ELF file, you should be good to go and the port should be easy. If not, you will need to write a "ObjectFile" subclass to parse the core file, or just parse it manually in your ProcessLinuxCore (you might want to name this ProcessELFCore if it is not tied to linux).

Or is there any other Linux-related functionality missing?

There is a lot of work going on for Linux right now, so it should be pretty functional as far as running/attaching.

I see that there is support for
Linux processes but I haven't been successful in compiling LLDB yet, so
I can not try it out myself.

See the other messages on this build list. The message thread right before you e-mail had details on how to successfully build on linux.

> Hello,
> I would like to write a simple tool that, given a Linux core dump,
> produces a list of variables and their values (for those variables for
> which it can be determined). I'm considering writing the tool on top of
> LLDB.

That should be easy.

> If I understand correctly, there is no support for Linux cores in LLDB.

Correct, there is no linux core support currently.

> What would it take to implement it?

We support mach-o core files, so there is some great example code that
should be easy to adapt. The the mach-o core file example plug-in:

lldb/source/Plugins/Process/mach-core

> Is it just a matter of implementing
> the Process subclass for Linux cores?

Yes, see very simple and quick example in
lldb/source/Plugins/Process/mach-core. Basically the linux plug-in
will need to recognize linux core files and know how to parse them. I
am not sure what the linux core file format is. On MacOSX, our core
files are just mach-o files (very similar to executable files). As
long as the linux core file is an ELF file, you should be good to go
and the port should be easy. If not, you will need to write a
"ObjectFile" subclass to parse the core file, or just parse it
manually in your ProcessLinuxCore (you might want to name this
ProcessELFCore if it is not tied to linux).

Yes, linux cores are indeed ELF files.

> Or is there any other Linux-related functionality missing?

There is a lot of work going on for Linux right now, so it should be
pretty functional as far as running/attaching.

> I see that there is support for
> Linux processes but I haven't been successful in compiling LLDB yet, so
> I can not try it out myself.

See the other messages on this build list. The message thread right
before you e-mail had details on how to successfully build on linux.

Thanks for the information, Greg. Even though I really like the LLDB
design and the linux core support seems like a fun little project, I
have for other reasons decided not to use LLDB. So if anyone reading
this would like to have this feature - go ahead, I'm not working on it;)

Martin