gdb internal fatal error while opening a binary built with gsplit-dwarf

Message ID 20240322170122.20010-1-sungdgdhtryrt@gmail.com
State New
Headers
Series gdb internal fatal error while opening a binary built with gsplit-dwarf |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Hans March 22, 2024, 5:01 p.m. UTC
  Binaries built with '-gsplit-dwarf' and clang-16 using dwp with
dwarf version 5 will crash with a segmentation fault as a result
of a missing section read call in read_dwo_str_index(). Without
the split dwarf option everything works fine. The error occurs
from commit 65067f1c2c842f001017638c4fe53613d6656263 until latest,
previous commits work without problems. Steps to reproduce are in
the bug description.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31497
Reviewed-by: Tom Tromey <tom@tromey.com>
---
 gdb/dwarf2/read.c | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 7442094874c..a45bc512724 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -17501,6 +17501,9 @@  read_dwo_str_index (const struct die_reader_specs *reader, ULONGEST str_index)
   ULONGEST str_offsets_base;
   if (reader->cu->header.version >= 5)
     {
+      struct objfile *objfile = reader->cu->per_objfile->objfile;
+      reader->dwo_file->sections.str_offsets.read (objfile);
+
       /* We have a DWARF5 CU with a reference to a .debug_str_offsets section,
 	 so assume the .debug_str_offsets section is DWARF5 as well, and
 	 parse the header.  FIXME: Parse the header only once.  */