Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 09 Mar 2026 22:32:27 +0000
From:      Minsoo Choo <minsoochoo0122@proton.me>
To:        freebsd-hackers@freebsd.org, freebsd-arch@freebsd.org
Subject:   [Status Report] LLDB improvements on FreeBSD
Message-ID:  <PNs02s7a9UoJNo2Umum1GFyCzF-NyA06GehhUwnLvXjkjWy0AC1BJXAEW30YCqvSV66YvS01fjgZmVXAcxn8hLOio-prCimz7Giyg6l38hE=@proton.me>
In-Reply-To: <8FA29C46-A15F-4B66-BDCA-4FF81EF8879B@proton.me>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
Greetings,

Almost a month has passed since I opened this thread. This time it's my progress report and future roadmap.

The LLDB kernel debugging plugin is almost complete. I only have stack unwinding implementation left which will be reviewed and hopefully accepted by this week. Note that i386 and armv7 won't have this feature due to LLDB's limitation (this is where GDB is superior to LLDB). Otherwise I need to rewrite LLDB's unwinding mechanism but there is time constraint. After that, I'll work on DynamicLoader for kernel objects and test suites.

For backporting this to FreeBSD's in-tree LLDB: LLVM 21 MFV is a blocker right now. dim@ has almost finished MFV patches (not merged yet) and currently working on updating ports [1]. Note that LLVM's internal API changes quite frequently so it might be difficult to backport my changes from LLVM 23-git to LLVM 21. If the backport is too much work, I can wait until LLVM 22 MFV. If that doesn't work, we can only wait for LLVM 23 MFV. But this won't be likely to happen because most of my work started a few weeks after LLVM 22 branching.

Fun fact: LLDB kernel debugging on aarch64 dump was broken for years and no one has reported it. Now when LLDB compiles it will refuse to build if its pcb and trapframe info mismatches FreeBSD's so this won't happen anymore. Details are available at [2].

If I still have time after all those works, I'll work on making kernel debugging platform cross-platform. We have a patch from early 2019 that converts minidump to elf [3]. Replacing kvm-based implementation with an implementation derived from LLDB's elf-core will make cross-platform debugging possible (e.g. debugging FreeBSD crash dump with LLDB on macOS/Linux). This has two problems however:

- Minidump needs to be converted to elf-core which can only be done after savecore(8) happens.
- LLDB needs a special handling for /dev/mem.

However I don't believe they are blockers but just bit time consuming to deal with. I'll bring up this topic again once I finish upstreaming test suite.

[1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292067
[2] https://github.com/llvm/llvm-project/pull/180222
[3] https://reviews.freebsd.org/D19253

--
Minsoo Choo
[-- Attachment #2 --]
<div style="font-family: Arial, sans-serif; font-size: 14px;">Greetings,</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">Almost a month has passed since I opened this thread. This time it's my progress report and future roadmap.</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">The LLDB kernel debugging plugin is almost complete. I only have stack unwinding implementation left which will be reviewed and hopefully accepted by this week. Note that i386 and armv7 won't have this feature due to LLDB's limitation (this is where GDB is superior to LLDB). Otherwise I need to rewrite LLDB's unwinding mechanism but there is time constraint. After that, I'll work on DynamicLoader for kernel objects and test suites.</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">For backporting this to FreeBSD's in-tree LLDB: LLVM 21 MFV is a blocker right now. dim@ has almost finished MFV patches (not merged yet) and currently working on updating ports [1]. Note that LLVM's internal API changes quite frequently so it might be difficult to backport my changes from LLVM 23-git to LLVM 21. If the backport is too much work, I can wait until LLVM 22 MFV. If that doesn't work, we can only wait for LLVM 23 MFV. But this won't be likely to happen because most of my work started a few weeks after LLVM 22 branching.</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">Fun fact: LLDB kernel debugging on aarch64 dump was broken for years and no one has reported it. Now when LLDB compiles it will refuse to build if its pcb and trapframe info mismatches FreeBSD's so this won't happen anymore. Details are available at [2].</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">If I still have time after all those works, I'll work on making kernel debugging platform cross-platform. We have a patch from early 2019 that converts minidump to elf [3]. Replacing kvm-based implementation with an implementation derived from LLDB's elf-core will make cross-platform debugging possible (e.g. debugging FreeBSD crash dump with LLDB on macOS/Linux). This has two problems however:</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><ol data-editing-info="{&quot;orderedStyleType&quot;:1,&quot;unorderedStyleType&quot;:1}" style="margin-top: 0px; margin-bottom: 0px;" data-listchain="__List_Chain_167"><li style="list-style-type: &quot;1. &quot;;">Minidump needs to be converted to elf-core which can only be done after savecore(8) happens.</li><li style="list-style-type: &quot;2. &quot;;">LLDB needs a special handling for /dev/mem.</li></ol><div><br></div><div>However I don't believe they are blockers but just bit time consuming to deal with. I'll bring up this topic again once I finish upstreaming test suite.</div></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><span>[1]&nbsp;<a target="_blank" rel="noreferrer nofollow noopener" href="https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292067">https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292067</a></span><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">[2]&nbsp;<span><a target="_blank" rel="noreferrer nofollow noopener" href="https://github.com/llvm/llvm-project/pull/180222">https://github.com/llvm/llvm-project/pull/180222</a></span></div><div style="font-family: Arial, sans-serif; font-size: 14px;">[3]&nbsp;<span><a target="_blank" rel="noreferrer nofollow noopener" href="https://reviews.freebsd.org/D19253">https://reviews.freebsd.org/D19253</a></span></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div>
<div style="font-family: Arial, sans-serif; font-size: 14px;" class="protonmail_signature_block">
    <div class="protonmail_signature_block-user">
        <div><span style="line-height: normal; font-family: Arial, sans-serif; font-size: 14px; font-weight: 400;">--</span></div><div><span style="line-height: normal; font-family: Arial, sans-serif; font-size: 14px; font-weight: 400;">Minsoo Choo</span></div></div></div>
home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?PNs02s7a9UoJNo2Umum1GFyCzF-NyA06GehhUwnLvXjkjWy0AC1BJXAEW30YCqvSV66YvS01fjgZmVXAcxn8hLOio-prCimz7Giyg6l38hE=>