public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: sergiodj+buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] Allow the find_abstract_instance_name() function in the BFD library to also return file and line number information.
Date: Tue, 06 Feb 2018 16:04:00 -0000	[thread overview]
Message-ID: <422f3d3d6d5713bf9235b7b7696818a70b3b578d@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT 422f3d3d6d5713bf9235b7b7696818a70b3b578d ***

Author: Paul Carroll <pcarroll@codesourcery.com>
Branch: master
Commit: 422f3d3d6d5713bf9235b7b7696818a70b3b578d

Allow the find_abstract_instance_name() function in the BFD library to also return file and line number information.

The nm utility supports -l for using debug information to obtain file and line information for each symbol, if available.
We have a tool that consumes this information and displays it.
This identified a problem with the 'nm' utility.

When a source is compiled with -O2, functions can be inlined.  The compiler also produces an uninlined copy of the function, normally for linking to other object files.
In the case of DWARF2 debug information, the compiler generates debug information to describe a function.  If that function is inlined, the compiler 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 in the common debug information and not at each actual implementation of the function.
The 'nm' utility only retrieves the name of the function from the abstract origin debug information and no more.

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 any 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. If, for some reason, the file and line information is not present, the routine behaves as before.

For example, if I have a simple test case:

int foo(int j)
{
        if (j < 15)
                j += j << 2;
        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 with -O2 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
--------------------------------------------------------------------------
bfd	* bfd/dwarf2.c (find_abstract_name): Modified to return file and
	line information in addition to name, if they can be found.


             reply	other threads:[~2018-02-06 16:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-06 16:04 sergiodj+buildbot [this message]
2018-02-06 16:04 ` Failures on Debian-s390x-m64, branch master sergiodj+buildbot
2018-02-06 16:05 ` Failures on Fedora-i686, " sergiodj+buildbot
2018-02-06 16:08 ` Failures on Fedora-x86_64-native-gdbserver-m32, " sergiodj+buildbot
2018-02-06 16:19 ` Failures on Debian-s390x-native-extended-gdbserver-m64, " sergiodj+buildbot
2018-02-06 16:25 ` Failures on Ubuntu-AArch32-native-extended-gdbserver-m32, " sergiodj+buildbot
2018-02-06 16:25 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " sergiodj+buildbot
2018-02-06 16:28 ` Failures on Fedora-x86_64-cc-with-index, " sergiodj+buildbot
2018-02-06 16:33 ` Failures on Debian-s390x-native-gdbserver-m64, " sergiodj+buildbot
2018-02-06 16:41 ` Failures on Fedora-x86_64-m32, " sergiodj+buildbot
2018-02-06 16:46 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " sergiodj+buildbot
2018-02-06 16:49 ` Failures on Fedora-s390x-m64, " sergiodj+buildbot
2018-02-06 16:49 ` Failures on Fedora-x86_64-native-gdbserver-m64, " sergiodj+buildbot
2018-02-06 17:14 ` Failures on Ubuntu-AArch32-native-gdbserver-m32, " sergiodj+buildbot
2018-02-06 17:32 ` Failures on Ubuntu-AArch64-m64, " sergiodj+buildbot
2018-02-06 18:37 ` Failures on Ubuntu-AArch32-m32, " sergiodj+buildbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=422f3d3d6d5713bf9235b7b7696818a70b3b578d@gdb-build \
    --to=sergiodj+buildbot@sergiodj.net \
    --cc=gdb-testers@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).