This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Introduce a FreeBSDKernel plugin for vmcores
ClosedPublic

Authored by mgorny on Dec 1 2021, 2:14 PM.

Details

Summary

Introduce a FreeBSDKernel plugin that provides the ability to read
FreeBSD kernel core dumps. The plugin utilizes libfbsdvmcore to provide
support for both "full memory dump" and minidump formats across variety
of architectures supported by FreeBSD. It provides the ability to read
kernel memory, as well as the crashed thread status with registers
on arm64, i386 and x86_64.

Diff Detail

Event Timeline

mgorny created this revision.Dec 1 2021, 2:14 PM
mgorny requested review of this revision.Dec 1 2021, 2:14 PM

@labath, I'm waiting for your feedback. I suspect you're going to hate it for being so incomplete (but then, we don't expect it to be able to do much more than this) but also love it for being so simple :-P.

mgorny updated this revision to Diff 391613.Dec 3 2021, 5:05 AM
mgorny retitled this revision from [lldb] Introduce absolutely minimal FreeBSDKernel plugin to [lldb] Introduce a FreeBSDKernel plugin for vmcores.
mgorny edited the summary of this revision. (Show Details)

Now with thread and register context classes, and hackish support for grabbing x86_64 registers.

@labath, do you think I should add another file in Process/Utility to abstract away structures used by the FreeBSD kernel in the same style that process plugins do?

mgorny updated this revision to Diff 391827.Dec 4 2021, 3:47 AM

Add arm64 support, simplify logic in ThreadFreeBSDKernel, handle unsupported architectures gracefully (instead of crashing).

mgorny updated this revision to Diff 391834.Dec 4 2021, 5:34 AM
mgorny edited the summary of this revision. (Show Details)

Also i386.

mgorny updated this revision to Diff 392003.Dec 6 2021, 2:47 AM

Force DynamicLoaderStatic. This fixes determining load address for symbols.

labath added a comment.Dec 6 2021, 5:37 AM

I don't have a problem with incomplete patches. I (and llvm, in general) actually strongly incremental development.

I'm more interested in the testing story.

lldb/source/Plugins/Process/FreeBSDKernel/CMakeLists.txt
2

external dependencies are dealt with in LLDBConfig.cmake

mgorny updated this revision to Diff 392328.Dec 7 2021, 3:04 AM

Fix segv when there's no executable module. Move dependency check to LLDBConfig and use find_package()-style check. Add initial test files (still WIP).

mgorny updated this revision to Diff 392333.Dec 7 2021, 3:28 AM

Remove a debugging hack, make the test actually test something.

mgorny updated this revision to Diff 392352.Dec 7 2021, 4:38 AM

Finish that one tet.

mgorny updated this revision to Diff 392723.Dec 8 2021, 5:28 AM

Add the tool to create sparse vmcores.

mgorny updated this revision to Diff 393276.Dec 9 2021, 1:36 PM

Add tests for other vmcores. Fix assert in arm64, and turn it into static_assert.

labath accepted this revision.Dec 14 2021, 7:06 AM

Seems reasonable. I mean, there are a lot of things that are less than ideal, but none of this is substantially worse than what we have already, and you've done a pretty good job explaining what you've done.

This revision is now accepted and ready to land.Dec 14 2021, 7:06 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptDec 14 2021, 9:03 AM