Page MenuHomeFreeBSD

Use -fdebug-prefix-map in the kernel build.
ClosedPublic

Authored by markj on Mar 19 2019, 2:16 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 21, 6:21 PM
Unknown Object (File)
Feb 3 2024, 8:31 PM
Unknown Object (File)
Jan 30 2024, 8:56 PM
Unknown Object (File)
Jan 7 2024, 5:04 AM
Unknown Object (File)
Jan 6 2024, 10:37 AM
Unknown Object (File)
Dec 23 2023, 3:57 AM
Unknown Object (File)
Nov 22 2023, 7:35 PM
Unknown Object (File)
Nov 22 2023, 7:35 PM
Subscribers

Details

Summary

Our debug info currently contains a few magic paths that are
relative to the object directory. This confuses consumers of kernel
debug info, in particular, syzkaller's code coverage report generation.
In the past I used to frequently see kgdb complain about not being to
find headers under machine/.

clang and modern gcc support -fdebug-map-prefix=src=dst, which tells the
compiler to substitute dst for src in debug info when compiling files
whose path is prefixed by src. This helps with a couple of things:

  • The machine, x86 and MACHINE_CPUARCH symlinks. We can just map those to their canonical paths in the src tree, so e.g., machine/frame.h is translated to sys/amd64/include/frame.h.
  • Autogenerated headers, like vnode_if.h. We include them via a relative path (just "./") now, so substituting the object directory path gives a better chance of finding them.

TODO: add guards for gcc 4.2.

Test Plan

I verified that this works with in-tree clang and the amd64-gcc compiler from ports.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj edited the summary of this revision. (Show Details)
markj edited the test plan for this revision. (Show Details)
markj added a subscriber: tuexen.

Ed pointed out that we may not want absolute paths in general. That's probably true, but I'll note that this change just makes things consistent for now. I think mapping the symlink paths is a no-brainer, at least.

Yes, as long as the main paths are absolute I think it's no worse to make these changes.

I'm not a huge fan of the OBJDIR one, but I don't see a better alternative. Definitely a fan of the symlink changes. Shame the code is duplicated in two places. It might make sense to have some kind of sys/conf/kern.common.mk or something that has shared logic between kmod.mk and kern.*.mk if that is feasible.

This revision is now accepted and ready to land.Mar 19 2019, 5:01 PM
  • Add compiler version guards.
This revision now requires review to proceed.Mar 20 2019, 1:03 AM
This revision is now accepted and ready to land.Mar 20 2019, 1:26 AM
This revision was automatically updated to reflect the committed changes.