Bug 31169 - [display text] Source code locations can not be found in a C++ application
Summary: [display text] Source code locations can not be found in a C++ application
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gprofng (show other bugs)
Version: 2.41
: P2 normal
Target Milestone: ---
Assignee: Vladimir Mezentsev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-14 22:52 UTC by Ruud van der Pas
Modified: 2023-12-20 22:12 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 Ruud van der Pas 2023-12-14 22:52:44 UTC
This is a C++ application developed at the University of Bristol. The developers run into the problem that "gprofng display text" cannot locate the source file(s), while the application and library objects have been compiled with -g.


This problem seems to be related to interpreting the DWARF output. If -gdwarf-2 is added on the g++ compile lines, the source files can be located and source line level information is printed.

If however, -gdwarf-3 is used, the locations of the source files cannot be found and consequently, no source line level information is printed.

A test case exhibiting this problem has been made available. The program needs to be compiled with g++ 8.5 and that has been used in the tests.
Comment 1 Sourceware Commits 2023-12-20 22:10:46 UTC
The master branch has been updated by Vladimir Mezentsev <vmezents@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0b3ad397ef2dc54602d7966af53515061312733c

commit 0b3ad397ef2dc54602d7966af53515061312733c
Author: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
Date:   Mon Dec 18 21:04:57 2023 -0800

    gprofng: 31169 Source code locations can not be found in a C++ application
    
    gprofng incorrectly reads the form of the DW_FORM_ref_addr attribute for DWARF
    Version 3 or later.
    From DWARF specification:
      References that use the attribute form DW_FORM_ref_addr are specified to
      be four bytes in the DWARF 32-bit format and eight bytes in the DWARF
      64-bit format, while DWARF Version 2 specifies that such references have
      the same size as an address on the target system.
    
    2023-12-18  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>
    
            PR gprofng/31169
            * src/DwarfLib.cc: Fix the reader for DW_FORM_ref_addr.
Comment 2 Vladimir Mezentsev 2023-12-20 22:12:52 UTC
Update status as resolved/fixed.