derive_kernel_dir

Function derive_kernel_dir 

Source
pub fn derive_kernel_dir(image: &Path) -> Option<PathBuf>
Expand description

Derive the kernel directory (holding vmlinux and related build artifacts) from a kernel image path.

Recognizes two layouts:

  • Build tree: <root>/arch/x86/boot/bzImage (or arch/arm64/boot/Image) → <root>. Suffix match on the canonical path.
  • Cache entry: <cache_dir>/bzImage (or Image) with a sibling vmlinux<cache_dir>. Lets probe source-location resolution walk a cached kernel’s stripped ELF.

Returns None when neither layout matches or the input path doesn’t canonicalize.

Cache entries carry stripped vmlinux (no DWARF) — strip_vmlinux_debug drops .debug_* on every cache entry regardless of source type. file:line resolution works only for build-tree paths where the unstripped vmlinux is still present, or when the caller layers cache::prefer_source_tree_for_dwarf on top to re-route cache::KernelSource::Local entries at their original source tree.