Getting started with clang debuginfo

Paul Floyd pjfloyd at wanadoo.fr
Mon Jul 27 19:37:40 UTC 2020



> On 27 Jul 2020, at 17:39, Konstantin Belousov <kostikbel at gmail.com> wrote:
> 
> On Mon, Jul 27, 2020 at 10:37:53AM -0400, Mark Johnston wrote:
>> On Mon, Jul 27, 2020 at 11:27:40AM +0200, Paul FLOYD wrote:
>>> Hi
>>>  
>>> I'm investigating some of the remaining issues with Valgrind on FreeBSD. One of the two remaining major issues that I'm aware of is with Valgrind reading dwarf  debuginfo from clang compiled binaries. The problem isn't too bad with clang 8 on FreeBSD 12.1. On 13-CURRENT with clang 10 things are noticeably worse. For GCC built binaries I'm not aware of any issues.
>>>  
>>> I'm not familiar (yet) with the debuginfo code in Valgrind.
>>>  
>>> To get me going, does anyone have any pointers to
>>> - documentation on clang debuginfo
> Clang generates DWARF which is documented by the DWARF standard(s),
> available at http://dwarfstd.org/


The site seems to be down ATM.

From what I’ve read, DWARF is somewhat flexible and allows for vendor extensions. For instance I’ve already seen DW_AT_GNU_all_call_sites and DW_GNU_all_tail_call_sites.

> 
>>> - any info on differences wrt GCC (I have seen that GCC does have some debuginfo extensions)
> Gcc also generates DWARF.  It is up to the compiler to interpret the standard
> and provide compliant metadata according to it.
> 
> But I would expect that the practical difference or troubles in parsing
> the compiler' output is due to different versions of the used standard.
> Both gcc and clang allow to specify which level of standard should be
> used, see the description of the -gdwarf-<version> switch.
> 
> Different versions of the same compiler might default to different 
> version of DWARF as well.
> 

No, I don’t think that is the problem. Valgrind can read DWARF up to version 4 (not 5). If it encounters a version it does not know about it says so directly

==1602== Command: ./leak_dwarf5
==1602== 
--1602-- WARNING: Serious error when reading debug info
--1602-- When reading debug info from /usr/home/paulf/scratch/vg_examples/leak_dwarf5:
--1602-- Ignoring non-Dwarf2/3/4 block in .debug_info
--1602-- WARNING: Serious error when reading debug info
--1602-- When reading debug info from /usr/home/paulf/scratch/vg_examples/leak_dwarf5:
--1602-- parse_CU_Header: is neither DWARF2 nor DWARF3 nor DWARF4
==1602== 

So I suspect that this is a question of dialect rather than version.

A+
Paul



More information about the freebsd-toolchain mailing list