This is an archive of the discontinued LLVM Phabricator instance.

[unwind] Handle UNW_X86_64_RIP register
ClosedPublic

Authored by vitalybuka on Aug 11 2021, 10:37 AM.

Details

Reviewers
compnerd
MaskRay
Group Reviewers
Restricted Project
Commits
rG2f1ee56f3cb8: [unwind] Handle UNW_X86_64_RIP register
Summary

In some binaries, built with clang/lld, libunwind crashes
with "unsupported x86_64 register" for regNum == 16:

#1 abort ()
#2  libunwind::DwarfInstructions<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::evaluateExpression(unsigned long, libunwind::LocalAddressSpace&, libunwind::Registers_x86_64 const&, unsigned long) () 
#3 libunwind::DwarfInstructions<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::stepWithDwarf(libunwind::LocalAddressSpace&, unsigned long, unsigned long, libunwind::Registers_x86_64&, bool&) ()
#4 libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::step()
#5  _Unwind_Backtrace ()
#6  UnwindSlow ()

Diff Detail

Event Timeline

vitalybuka created this revision.Aug 11 2021, 10:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2021, 10:37 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
vitalybuka requested review of this revision.Aug 11 2021, 10:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2021, 10:37 AM
vitalybuka edited the summary of this revision. (Show Details)Aug 11 2021, 10:39 AM
vitalybuka added a reviewer: compnerd.

remode debug logging

vitalybuka edited the summary of this revision. (Show Details)Aug 11 2021, 10:45 AM
vitalybuka edited the summary of this revision. (Show Details)
MaskRay added inline comments.
libunwind/src/Registers.hpp
349–350

Add UNW_X86_64_RIP here

453–454

Add UNW_X86_64_RIP here

libunwind/test/libunwind_01.pass.cpp
67

I am thinking of making the function available on all arches:

int num_regs = 0;
#if defined(__x86_64__)
num_regs = 33;
#endif

for (int i = 0; i < num_regs; ++i) {
  ...
}

MaskRay's comments

vitalybuka marked 3 inline comments as done.Aug 11 2021, 10:15 PM
MaskRay accepted this revision.Aug 11 2021, 10:43 PM

Looks great!

libunwind/test/libunwind_01.pass.cpp
66

-2

This revision is now accepted and ready to land.Aug 11 2021, 10:43 PM
vitalybuka added inline comments.Aug 12 2021, 12:18 AM
libunwind/test/libunwind_01.pass.cpp
66

-2+1 does not work on line 79

This revision was automatically updated to reflect the committed changes.