Bug 1449588

Summary: Can ltrace be built with backtrace support?
Product: Red Hat Enterprise Linux 7 Reporter: Peter Edwards <thatsafunnyname>
Component: ltraceAssignee: DJ Delorie <dj>
Status: CLOSED ERRATA QA Contact: Edjunior Barbosa Machado <emachado>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.2CC: codonell, emachado, jolsa, law, mbenitez, mcermak, mjw, mnewsome, mrezanin, pbonzini
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: ltrace-0.7.91-15.el7 Doc Type: Enhancement
Doc Text:
Feature: Backtrace support Reason: Backtraces tell the user not just what function was called, but the context from which the call happened. Result: "ltrace -w 4 /bin/prog" (for example) will list the call stack for each traced call it displays, up to a maximum of 4.
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 10:16:43 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1565233    

Description Peter Edwards 2017-05-10 10:24:12 UTC
Description of problem:

When using ltrace-0.7.91-14.el7.x86_64 there is no backtrace option available:

> ltrace -h
...
  -w, --where=NR      print backtrace showing NR stack frames at most.

Version-Release number of selected component (if applicable):

ltrace-0.7.91-14.el7.x86_64

How reproducible:

Very.

Steps to Reproduce:
1. Run "ltrace -h"
2. Examine output for "-w" option

Actual results:

  No backtrace support.

Expected results:

  Backtrace support.

Additional info:

If the ltrace.spec file is built on a host with the libunwind-devel and libunwind packages installed then the RPMs built contain an ltrace executable with backtrace support.

So maybe in ltrace.spec, something like the following needs to be added:

BuildRequires: libunwind-devel
 
Also see:
  https://bugzilla.redhat.com/show_bug.cgi?id=1170296#c2

Thank you.

Comment 9 Mark Wielaard 2017-10-09 15:05:03 UTC
Note that upstream supports -w backtraces using elfutils libdw (I provided a patch for that some years ago):

commit dfefa9f057857735a073ea655f5cb34351032c8e
Author: Mark Wielaard <mjw>
Date:   Tue Jan 7 21:00:44 2014 +0100

    Add support for using elfutils as unwinder.
    
    This adds support for using elfutils as unwinder with -w. Since elfutils
    0.158 elfutils contains a simple unwinder interface that matches nicely
    on the ltrace backtrace support.
    
    The code reuses the libunwind infrastructure already in ltrace where
    possible (by defining HAVE_UNWINDER which is 1 if either libunwind or
    elfutils is used). It also reuses the ltrace proc_add_library callback
    to keep track of the ELF files mapped for the unwinder.
    
    The current implementation matches the output as if libunwind was used.
    But elfutils can also provide some more information since it can lookup
    the DWARF debuginfo. So if the source info of an address can be found
    through elfutils the backtrace will also include this as an additional
    output line per frame.

Comment 10 Carlos O'Donell 2017-10-09 15:10:57 UTC
(In reply to Mark Wielaard from comment #9)
> Note that upstream supports -w backtraces using elfutils libdw (I provided a
> patch for that some years ago):

I assume that means we can get the same functionality with just elfutils then? You don't say, but I assume this is what you mean.

Comment 11 Mark Wielaard 2017-10-09 15:32:29 UTC
(In reply to Carlos O'Donell from comment #10)
> (In reply to Mark Wielaard from comment #9)
> > Note that upstream supports -w backtraces using elfutils libdw (I provided a
> > patch for that some years ago):
> 
> I assume that means we can get the same functionality with just elfutils
> then? You don't say, but I assume this is what you mean.

Yes, that is what I meant for ltrace (on the architectures RHEL cares about).

There are some differences between the libunwind and elfutils libdw unwinder. The elfutils one is only for "out of process" unwinding (core files or other processes through ptrace), libunwind also contains an in-process unwinder. And libunwind supports a couple of architectures that elfutils libdw doesn't. But elfutils does support all main architectures supported by RHEL.

Comment 15 errata-xmlrpc 2018-10-30 10:16:43 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2018:3133