https://bugs.kde.org/show_bug.cgi?id=476125

            Bug ID: 476125
           Summary: Valgrind cannot read binaries containing debug symbols
                    in DWARF 64 format
    Classification: Developer tools
           Product: valgrind
           Version: 3.21.0
          Platform: unspecified
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: jsew...@acm.org
          Reporter: borys.sme...@gmail.com
  Target Milestone: ---

Created attachment 162580
  --> https://bugs.kde.org/attachment.cgi?id=162580&action=edit
output of running: valgrind -v ./main

Summary:
Valgrind can read and parse DWARF 32 debug symbols, but it fails when dealing
with DWARF 64.

I have compiled a simple program called main.cpp, whose content is pasted later
in the description. The code allocates few bytes on the heap using operator
new, but it does not free it using delete[] operator. The program is compiled
using gcc 12.2 with -gdwarf64 flag that should turn on DWARF 64 debug symbols.
When trying to run the program with "valgrind ./main", valgrind prints
information that it cannot read debug information. Exact content of the message
from valgrind is in the attachment.
When I run valgrind ./main on the binary compiled without -gdwarf64 flag,
valgrind finds the memory leaks as expected.

Using llvm-dwarfdump I have made sure that the binary does contain debug
symbols in DWARF 64 format.
The output from running: llvm-dwarfdump ./main | grep -i "dwarf"
Compile Unit: length = 0x00000000000000f8, format = DWARF64, version = 0x0005,
unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 (next unit at
0x00000104)

Based on the information provided by GCC:
https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html
the default debug symbol format is DWARF 32 and indeed when I check using
llvm-dwarfdump the content of the ./main binary it indeed contains DWARF 32
information.

main.cpp:

#include <new>

int main()
{
    char* array = new char[10];
}

CMakeLists.txt
cmake_minimum_required(VERSION 3.18)

project(ValgrindTest)

set(CMAKE_BUILD_TYPE DEBUG)
add_compile_options(-g -gdwarf64 -std=c++20)

add_executable(main main.cpp)

Reproduction steps:
1) Create main.cpp and CMakeLists.txt
2) Next to them create build directory
3) cd build && cmake ../
4) make
5) valgrind ./main

Tools used:
Gcc 12.2
CMake 3.18.4
Valgrind 3.21, I have also tried to run it on Valgrind's current master branch,
but valgrind still could not read debug information.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to