bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug binutils/22771] New: nm does not display line information for uninl


From: pcarroll at codesourcery dot com
Subject: [Bug binutils/22771] New: nm does not display line information for uninlined copies of functions
Date: Thu, 01 Feb 2018 15:26:01 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=22771

            Bug ID: 22771
           Summary: nm does not display line information for uninlined
                    copies of functions
           Product: binutils
           Version: 2.30
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: binutils
          Assignee: unassigned at sourceware dot org
          Reporter: pcarroll at codesourcery dot com
  Target Milestone: ---

Created attachment 10768
  --> https://sourceware.org/bugzilla/attachment.cgi?id=10768&action=edit
Possible patch to nm for this issue

The nm utility supports -l for using debug information to obtain file and line
information for each symbol.
When a source is compiled with -O2, functions can be inlined.  The compiler
also produces an uninlined copy of the function, normally for use by other
files.
In the case of DWARF2 debug information, the compiler generates debug
information to describe the function.  It then references that debug
information from the inlined and uninlined copies of the routine through the
use of the DW_AT_abstract_origin reference.  
When nm is used on such a file, it is not able to find file and line
information because that information is present at the common debug information
and not at each actual implementation of the function.

What I am proposing is to modify the find_abstract_instance_name() function
(which I renamed to find_abstract_instance() ) to return the name of the
function as well as file and line information.  The routine is already parsing
all of the debug information in the abstract instance, so it is easy to pick up
the file and line information at that time.  

For example, if I have a simple test case:

int foo(int j)
{
        if (j < 15)
                j += j << 2;
        else if (j < 30)
                j += j << 4;
        else
                j += j << 6;
        return j;
}

int main (int argc,char **argv)
{
        int i = argc;
        i += foo(i);
        return i;
}

If that test case is compiled and then 'nm -l' reads that executable, it
currently produces this symbol output (ignoring a lot of library symbols):

8048400 T foo
080482e0 T main /scratch/pcarroll/its254/test/mytest.c:12

If I modify 'nm' to return file and line information for abstract instances, it
produces the following output:

08048400 T foo  /scratch/pcarroll/its254/test/mytest.c:1
080482e0 T main /scratch/pcarroll/its254/test/mytest.c:12

I am attaching my proposed patch.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]