This is an archive of the discontinued LLVM Phabricator instance.

[libunwind] Support cfi_undefined and cfi_register for float registers.
ClosedPublic

Authored by danielkiss on Sep 21 2021, 3:07 AM.

Details

Summary

During a backtrace the .cfi_undefined for a float register causes an assert in libunwind.

Diff Detail

Event Timeline

danielkiss requested review of this revision.Sep 21 2021, 3:07 AM
danielkiss created this revision.

The test fails with g++ on an aarch64-linux-gnu machine.

libunwind/test/floatregister.pass.cpp
11

Does target={{aarch64-.+}} work?

There is no RUN line.

The test fails with g++ on an aarch64-linux-gnu machine.

this works for me:

>uname -m -o
aarch64 GNU/Linux
>g++ --vesion
g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
>g++ libunwind/test/floatregister.pass.cpp -Wl,--export-dynamic -Wl,-ldl
libunwind/test/floatregister.pass.cpp
11

Does target={{aarch64-.+}} work?

It could. Maybe Windows won't work due to dladdr IIRC.

There is no RUN line.

As none of the test here needs one.

MaskRay accepted this revision as: MaskRay.Sep 22 2021, 1:08 PM

This tests needs -Wl,--export-dynamic to work. I missed the fact.

--export-dynamic is specified by if triple is not None and 'linux' in triple: self.cxx.link_flags += ['-Wl,--export-dynamic'] in test/libunwind/test/config.py.
Ideally the test itself should specify such a flag, but the change LGTM.

libunwind/test/floatregister.pass.cpp
41

The comment can be improved by saying what the 4 directives do.

This revision is now accepted and ready to land.Sep 22 2021, 1:08 PM
MaskRay added inline comments.Sep 22 2021, 1:11 PM
libunwind/test/floatregister.pass.cpp
17

assert and signal are not used

Other clean-ups?

30

depend

34

avoid braces around one-line simple statements.

danielkiss marked 4 inline comments as done.

Thanks so much for the quick review.

MaskRay added inline comments.Sep 24 2021, 8:56 AM
libunwind/test/floatregister.pass.cpp
40
danielkiss marked an inline comment as done.Sep 27 2021, 3:01 AM
This revision was landed with ongoing or failed builds.Sep 27 2021, 3:04 AM
This revision was automatically updated to reflect the committed changes.
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptSep 27 2021, 3:04 AM
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald Transcript

This broke building for armv7-mingw. The Register_arm version of getFloatRegister() is not const, contrary to the other getFloatRegister() implementations for other architectures. It's not a plain oversight, as Registers_arm::getFloatRegister has a bunch of logic for fetching the relevant register banks (VFP 0-15, VFP 16-31 or WMMX) if not yet fetched, so it can't be made const easily. And I don't think it's a place where it's necessarily right to make the member variables mutable either...

The one tweak that does seem to work though, is to make DwarfInstructions<A, R>::getSavedFloatRegister take a non-const R argument.

Ping @danielkiss This broke building for dwarf configurations on arm, see comments above.

@mstorsjo sorry for that, other tweak would be just the exclude the RegisterInRegister case for arm. I feel better with this than chaining the interface.

#ifndef _LIBUNWIND_TARGET_ARM
    return registers.getFloatRegister((int)savedReg.value);
#endif
danielkiss added a comment.EditedSep 29 2021, 10:07 AM

Both fixes are simple, I prefer the first one but I really interested in what others think.
D110731
D110732