Created attachment 162580 [details] 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.
In theory valgrind should be able to parse DWARF64, see the initial length field reading in readdwarf.c and readdwarf3.c which set an 64bit flag. But it doesn't surprise me that code/path isn't tested and probably fails since by default DWARF32 is used.
(In reply to Mark Wielaard from comment #1) > In theory valgrind should be able to parse DWARF64, see the initial length > field reading in readdwarf.c and readdwarf3.c which set an 64bit flag. But > it doesn't surprise me that code/path isn't tested and probably fails since > by default DWARF32 is used. Valgrind reads properly DWARF 64 in DWARF4 format. If I compile the exemplary project with -gdwarf-4 -gdwarf64. Valgrind correctly parses the binary, runs it and gives detailed information about memory leaks. If I use this command: llvm-dwarfdump main | grep -i "dwarf" I get the following output: Compile Unit: length = 0x0000000000000141, format = DWARF64, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x0000014d) This proves that the binary uses DWARF 4 with DWARF 64. Conclusion: Valgrind correctly parses DWARF 4 with DWARF 64, but it fails in reading DWARF 5 with DWARF 64.