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)
Sun, Nov 3, 8:45 AM
Unknown Object (File)
Oct 9 2024, 2:16 AM
Unknown Object (File)
Oct 4 2024, 12:06 AM
Unknown Object (File)
Oct 2 2024, 1:55 PM
Unknown Object (File)
Sep 24 2024, 5:47 PM
Unknown Object (File)
Sep 24 2024, 4:11 AM
Unknown Object (File)
Sep 23 2024, 7:01 PM
Unknown Object (File)
Sep 23 2024, 1:12 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.