Bug 23902 - MIPS varlocs dwarf_cfi_addrframe: unknown error (missing ebl abi_cfi hook)
Summary: MIPS varlocs dwarf_cfi_addrframe: unknown error (missing ebl abi_cfi hook)
Status: UNCONFIRMED
Alias: None
Product: elfutils
Classification: Unclassified
Component: backends (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 24795
  Show dependency treegraph
 
Reported: 2018-11-20 20:26 UTC by Kurt Roeckx
Modified: 2019-07-10 10:44 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kurt Roeckx 2018-11-20 20:26:45 UTC
On at least mips, alpha and hppa, I'm getting something like:
/<<PKGBUILDDIR>>/tests/varlocs: dwarf_cfi_addrframe 0x120002540: unknown error
*** failure in /<<PKGBUILDDIR>>/tests/varlocs -e /<<PKGBUILDDIR>>/src/addr2line

Logs can be found at:
https://buildd.debian.org/status/fetch.php?pkg=elfutils&arch=alpha&ver=0.175-1&stamp=1542672225&raw=0
https://buildd.debian.org/status/fetch.php?pkg=elfutils&arch=mips&ver=0.175-1&stamp=1542667301&raw=0
https://buildd.debian.org/status/fetch.php?pkg=elfutils&arch=hppa&ver=0.175-1&stamp=1542666561&raw=0

The mips and hppa backend are patches that only exist in Debian, but alpha seems to be part of upstream.

Is this some indication of missing functionality? Any suggestion where to look?
Comment 1 Mark Wielaard 2018-11-21 12:24:05 UTC
The common theme might be that these arches don't use standard .eh_frame and/or have some non-standard section name or type for the unwind tables?

alpha does have an upstream backend, but I am not sure when it was last tested.
Comment 2 Kurt Roeckx 2018-11-21 19:16:11 UTC
At least on mips I'm seeing an .eh_frame and .eh_frame_hdr section. It also has some mips specific sections.

But note that various of the other tests say "Unwinding not supported for this architecture". Is this just a test that also should get skipped?

PS: All arches except amd64 have "Unwinding not supported for this architecture" in run-backtrace-data.sh, which I find a bit surprising.
Comment 3 Mark Wielaard 2018-11-23 09:09:19 UTC
(In reply to Kurt Roeckx from comment #2)
> At least on mips I'm seeing an .eh_frame and .eh_frame_hdr section. It also
> has some mips specific sections.

Assuming they have "normal" types then that part should work because it is (mostly, except for register mapping) arch independent.

> But note that various of the other tests say "Unwinding not supported for
> this architecture". Is this just a test that also should get skipped?

If it would return that error maybe. But the varlocs test doesn't rely on unwinding. There is something odd going on because it gives "Unknown Error", which is not explicitly set anywhere in the code, but is generated when __libelf_seterrno () is called with an unknown error code (which itself is a bug). So something doubly odd is going on.

> PS: All arches except amd64 have "Unwinding not supported for this
> architecture" in run-backtrace-data.sh, which I find a bit surprising.

Yes, that is surprising, run-backtrace-data.sh really should just say that it is only supported on x86_64/amd64. Currently it "abuses" the "Unwinding not supported for this architecture" message to get a SKIP on any other arch.
Comment 4 Kurt Roeckx 2018-11-23 17:49:11 UTC
The varlocs test is calling dwarf_errmsg (-1)
Comment 5 Mark Wielaard 2018-11-23 20:38:04 UTC
(In reply to Kurt Roeckx from comment #4)
> The varlocs test is calling dwarf_errmsg (-1)

OK, that will show the last libdw error set on the current thread.
In which case we might actually have a candidate for why it was set.
The only place DWARF_E_UNKNOWN_ERROR is set (returned) is:

libdw/cfi.c (cie_cache_initial_state):

  /* Fetch the ABI's default CFI program.  */
  if (likely (cache->ebl != (void *) -1l)
      && unlikely (ebl_abi_cfi (cache->ebl, &abi_info) < 0))
    return DWARF_E_UNKNOWN_ERROR;

That would explain the issue on alpha at least because that doesn't have a backend hook for abi_cfi. I suspect your mips and hppa backends also don't have that hooked.
Comment 6 Kurt Roeckx 2018-11-23 20:45:39 UTC
Yes, they all 3 seem to be missing that callback.
Comment 7 Mark Wielaard 2018-11-26 10:45:20 UTC
The ebl abi_cfi hook sets up the initial CFI instructions, default data alignment factor and return address register for the architecture. These are normally given in the System V Application Binary Interface Processor Supplement for a specific architecture which also explain the DWARF register mappings.
Comment 8 Mark Wielaard 2018-11-28 13:05:13 UTC
(In reply to Mark Wielaard from comment #3)
> (In reply to Kurt Roeckx from comment #2)
> > PS: All arches except amd64 have "Unwinding not supported for this
> > architecture" in run-backtrace-data.sh, which I find a bit surprising.
> 
> Yes, that is surprising, run-backtrace-data.sh really should just say that
> it is only supported on x86_64/amd64. Currently it "abuses" the "Unwinding
> not supported for this architecture" message to get a SKIP on any other arch.

I pushed the following commit which should hopefully make this skip message more clear:

commit 63160fceaaac2f9bd13da7abf929907a5f723aab
Author: Mark Wielaard <mark@klomp.org>
Date:   Wed Nov 28 13:58:31 2018 +0100

    tests: Improve backtrace-data SKIP message.
    
    The backtrace-data testcase is x86_64 linux only because it uses its
    own set_initial_registers and scans its own /proc/pid/maps file.
    The SKIP message it gave on other platforms was misleading. It said
    "Unwinding not supported for this architecture". Change it to
    "x86_64 linux only test" to be less confusing.
    
    Signed-off-by: Mark Wielaard <mark@klomp.org>
Comment 9 Kurt Roeckx 2018-12-30 19:53:02 UTC
I've fixed the issue on mips* in Debian, so it's now working on all Debian's release architectures. But some others still have this problem.
Comment 10 Kurt Roeckx 2018-12-30 21:53:39 UTC
In the mean time, I know the patch for mips was wrong, but the test suite seems to be happy with the current patch. Mips has many different ABIs, and I've mixed them up. The callee-saved registers aren't the same in all ABIs, there are small differences.