Page MenuHomeFreeBSD

stand: Add libbacktrace to toolbox of boot loader
Needs ReviewPublic

Authored by imp on Jan 5 2023, 12:36 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, May 18, 9:59 AM
Unknown Object (File)
Fri, May 17, 10:43 PM
Unknown Object (File)
Fri, May 17, 10:22 AM
Unknown Object (File)
Tue, May 14, 6:56 AM
Unknown Object (File)
Tue, May 14, 6:56 AM
Unknown Object (File)
Tue, May 14, 6:55 AM
Unknown Object (File)
Tue, May 14, 6:55 AM
Unknown Object (File)
Tue, May 14, 5:46 AM

Details

Reviewers
manu
jrtc27
kevans
Summary

libbacktrace is a combination of libunwind and libexecinfo from
userland, configured for the boot loader. At the present time, the
symbol translation has been disabled from libexecinfo. This will produce
numeric backtraces, which can be helpful in producing automatic
backtraces for exceptional events (like null pointer dereference).

Doesn't work on powerpc, so not enabled on powerpc*. It wasn't obvious
why the same thing that worked elsewhere failed here, so punt until
someone with more powerpc fu can figure it out.

Sponsored by: Netflix

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 48969
Build 45858: arc lint + arc unit

Event Timeline

imp requested review of this revision.Jan 5 2023, 12:36 AM
imp removed rG FreeBSD src repository as the repository for this revision.

use alloca instead of heap alloc
Fix typos

share/mk/src.opts.mk
135

likely need to add the docs to this too...

stand/libbacktrace/unwind-hacks.h
37

I know this is evil.

fprintf / flush were functions in early versions of this code, but switched to
defines since it was easier. Remove the no longer needed begin/end decls.

stand/libbacktrace/Makefile
67

That's not true, they get passed in different registers in some ABIs (amd64 uses XMM registers, aarch64 uses D registers). Though like the in-kernel printf floating-point formats aren't even supported in the implementation so whatever register it uses doesn't actually matter, it'll just stop processing formats and print the rest of the string verbatim. So it doesn't hit UB, but it also doesn't work as intended.

Oh, and we don't need the assembler guard anymore since we're not declaring
C functions.

share/mk/src.opts.mk
322

How come? The userspace versions work just fine...

stand/libbacktrace/Makefile
72

This seems odd, why condition it?

Improve comments in the crazy hack we do to get libunwind compliling.

fix comment about libexecinfo. we don't use hack-unwind.h for libexecinfo.

arichardson added inline comments.
stand/libbacktrace/unwind-hacks.h
39

This sounds like something that should be fixed in libunwind with something like _LIBUNWIND_HAS_NO_FLOAT or inferred from soft float compiler flags. But I guess it's okay as an ugly workaround.