Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 938958 - sys-kernel/gentoo-kernel: improving debugging support aside from BTF
Summary: sys-kernel/gentoo-kernel: improving debugging support aside from BTF
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Distribution Kernel Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-09-03 07:05 UTC by Sam James
Modified: 2024-09-04 15:41 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-09-03 07:05:53 UTC
We're hoping to enable BTF by default as systemd[bpf] needs it, as does DTrace, and other profiling and tracing tools.

One quirk is the complex interaction with USE=debug and USE=strip. Maybe we should always do BTF and have USE=debug control full debugging information (like DWARF), but by default, we'd strip and only keep '.BTF'.

---

Split out from bug 938957:

(In reply to Sam James from comment #1)
> Aside: I _think_ we do the right thing for modules right now, but I'll note
> that when we set INSTALL_MOD_STRIP, we clobber the default '--strip-debug'
> with our '--strip-unneeded'
> (https://docs.kernel.org/kbuild/kbuild.html#install-mod-strip). But maybe
> that's OK.


(In reply to Sam James from comment #2)
> (In reply to Sam James from comment #1)
> > Aside: I _think_ we do the right thing for modules right now, but I'll note
> > that when we set INSTALL_MOD_STRIP, we clobber the default '--strip-debug'
> > with our '--strip-unneeded'
> > (https://docs.kernel.org/kbuild/kbuild.html#install-mod-strip). But maybe
> > that's OK.
> 
> actually, maybe it's bad, because with USE="strip debug", we kill any debug
> info (although I think we end up keeping BTF) in /lib/modules, i.e. we don't
> cater for USE=debug there either. Or maybe we shouldn't worry about that.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-09-03 07:07:18 UTC
Maybe we should live with the ugliness first and keep it as-is, then if +debug goes okay and nothing explodes for a bit, we can start to rework it and make things smaller as a bonus (with that change in bug 938957).
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-09-03 07:11:09 UTC
I should note that we do need to keep *some* mechanism of not-stripping vmlinux at all because systemtap and some other tools still need DWARF.
Comment 3 Nowa Ammerlaan gentoo-dev 2024-09-03 07:30:41 UTC
(In reply to Sam James from comment #0)
> (In reply to Sam James from comment #2)
> > (In reply to Sam James from comment #1)
> > > Aside: I _think_ we do the right thing for modules right now, but I'll note
> > > that when we set INSTALL_MOD_STRIP, we clobber the default '--strip-debug'
> > > with our '--strip-unneeded'
> > > (https://docs.kernel.org/kbuild/kbuild.html#install-mod-strip). But maybe
> > > that's OK.
> > 
> > actually, maybe it's bad, because with USE="strip debug", we kill any debug
> > info (although I think we end up keeping BTF) in /lib/modules, i.e. we don't
> > cater for USE=debug there either. Or maybe we shouldn't worry about that.

For context, the original reason to use '--strip-unneeded' here was because that is the same option that linux-mod-r1.eclass uses:

_modules_process_strip() {
	# letting the package manager handle this complicates scenarios
	# where we want to either compress the pre-stripped module, or
	# sign the module without its signature becoming invalid on merge
	dostrip -x "${@#"${ED}"}"

	if use strip; then
		einfo "Stripping modules ..."
		edob "${KERNEL_STRIP}" --strip-unneeded -- "${@}"
	fi
}

I think we should try to keep the symmetry between in-tree and out-of-tree modules in this regard. So if we want to change this here, we should also make some adjustments to linux-mod-r1.eclass (maybe introduce USE=debug there too?).
Comment 4 Ionen Wolkens gentoo-dev 2024-09-03 07:55:22 UTC
ftr only reason linux-mod-r1 does unneeded was to mimic what portage was already doing to modules before we restricted stripping (aka for parity), so whatever seems better for modules can replace it.

Haven't dug into these issues much, but at a glance I don't quite see what USE=debug in linux-mod-r1 would do though? Note modules will just build using the same settings as the kernel by default.
Comment 5 Ionen Wolkens gentoo-dev 2024-09-03 08:07:19 UTC
(In reply to Ionen Wolkens from comment #4)
> Haven't dug into these issues much, but at a glance I don't quite see what
> USE=debug in linux-mod-r1 would do though? Note modules will just build
> using the same settings as the kernel by default.
...or is this about making this controllable independently from the kernel? Not sure if this would be useful given a lot of debug information would be missing without kernel's -- not that I know much about kernel/modules debugging.
Comment 6 Nowa Ammerlaan gentoo-dev 2024-09-03 08:39:00 UTC
> ...or is this about making this controllable independently from the kernel? 

That was what I was thinking of yes, similar to how USE=modules-sign and USE=modules-compress settings for out-of-tree modules are more or less independent from the kernels USE configuration.