Bug 27333

Summary: [dwarf-5] abort on unhandled DW_TAG_type_unit in process_psymtab_comp_unit
Product: gdb Reporter: Tom de Vries <vries>
Component: symtabAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: ahmedsayeed1982, ahmedsayeed1982, brobecker, diheto5497, donipah907, fiteva5725, focixujo, glassmtech, gulsenenginar, mark, marlenesanchez231+jaime, mehmetgelisin, oficaj3, paneki8601, progonsaytu, ribevi6798, tes.vik1986, tesaso8237, ucelsanicin, vries, xecana8007
Priority: P2    
Version: HEAD   
Target Milestone: 10.2   
Host: Target:
Build: Last reconfirmed:

Description Tom de Vries 2021-02-03 11:55:56 UTC
When running test-case gdb.cp/cpexprs-debug-types.exp with target board unix/gdb:debug_flags=-gdwarf-5, I run into:
...
(gdb) file cpexprs-debug-types^M
Reading symbols from cpexprs-debug-types...^M
ERROR: Couldn't load cpexprs-debug-types into GDB (eof).
ERROR: Couldn't send delete breakpoints to GDB.
ERROR: GDB process no longer exists
GDB process exited with wait status 23054 exp9 0 0 CHILDKILLED SIGABRT SIGABRT
...

Reproduced with:
...
$ gdb -q ./outputs/gdb.cp/cpexprs-debug-types/cpexprs-debug-types
Reading symbols from ./outputs/gdb.cp/cpexprs-debug-types/cpexprs-debug-types...
Aborted (core dumped)
...
Comment 1 Tom de Vries 2021-02-03 12:54:07 UTC
we run into this abort:
...
(gdb) down
#2  0x000000000062ecba in process_psymtab_comp_unit (this_cu=0x20c0120, 
    per_objfile=0x20612a0, want_partial_unit=false, pretend_language=language_minimal)
    at src/gdb/dwarf2/read.c:7837
7837          abort ();
...
because we don't handle:
...
(gdb) p reader.comp_unit_die->tag
$1 = DW_TAG_type_unit
...
in the switch:
...
  switch (reader.comp_unit_die->tag)
    {
    case DW_TAG_compile_unit:
      this_cu->unit_type = DW_UT_compile;
      break;
    case DW_TAG_partial_unit:
      this_cu->unit_type = DW_UT_partial;
      break;
    default:
      abort ();
    }
...
Comment 2 Tom de Vries 2021-02-03 13:05:31 UTC
This seems applicate:
...
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 5f894895cdc..47af194c50e 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -7833,6 +7833,9 @@ process_psymtab_comp_unit (dwarf2_per_cu_data *this_cu,
     case DW_TAG_partial_unit:
       this_cu->unit_type = DW_UT_partial;
       break;
+    case DW_TAG_type_unit:
+      this_cu->unit_type = DW_UT_type;
+      break;
     default:
       abort ();
     }
...
and fixes the abort upon load.
Comment 4 Sourceware Commits 2021-02-05 16:47:17 UTC
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

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

commit e77b0004dd114d6ddf3bb92b521b2854341f3f85
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Feb 5 17:47:07 2021 +0100

    [gdb/symtab] Handle DW_TAG_type_unit in process_psymtab_comp_unit
    
    When running test-case gdb.cp/cpexprs-debug-types.exp with target board
    unix/gdb:debug_flags=-gdwarf-5, I run into:
    ...
    (gdb) file cpexprs-debug-types^M
    Reading symbols from cpexprs-debug-types...^M
    ERROR: Couldn't load cpexprs-debug-types into GDB (eof).
    ERROR: Couldn't send delete breakpoints to GDB.
    ERROR: GDB process no longer exists
    GDB process exited with wait status 23054 exp9 0 0 CHILDKILLED SIGABRT SIGABRT
    ...
    
    We're running into this abort in process_psymtab_comp_unit:
    ...
      switch (reader.comp_unit_die->tag)
        {
        case DW_TAG_compile_unit:
          this_cu->unit_type = DW_UT_compile;
          break;
        case DW_TAG_partial_unit:
          this_cu->unit_type = DW_UT_partial;
          break;
        default:
          abort ();
        }
    ...
    because reader.comp_unit_die->tag == DW_TAG_type_unit.
    
    Fix this by adding a DW_TAG_type_unit case.
    
    Tested on x86_64-linux.
    
    gdb/ChangeLog:
    
    2021-02-05  Tom de Vries  <tdevries@suse.de>
    
            PR symtab/27333
            * dwarf2/read.c (process_psymtab_comp_unit): Handle DW_TAG_type_unit.
Comment 5 Tom de Vries 2021-02-05 16:48:32 UTC
Patch committed, marking resolved-fixed.
Comment 6 Sourceware Commits 2021-03-06 06:34:44 UTC
The gdb-10-branch branch has been updated by Joel Brobecker <brobecke@sourceware.org>:

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

commit df3ec334b8ccec482dac01fe2ff12030701da5ee
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Feb 5 17:47:07 2021 +0100

    [gdb/symtab] Handle DW_TAG_type_unit in process_psymtab_comp_unit
    
    When running test-case gdb.cp/cpexprs-debug-types.exp with target board
    unix/gdb:debug_flags=-gdwarf-5, I run into:
    ...
    (gdb) file cpexprs-debug-types^M
    Reading symbols from cpexprs-debug-types...^M
    ERROR: Couldn't load cpexprs-debug-types into GDB (eof).
    ERROR: Couldn't send delete breakpoints to GDB.
    ERROR: GDB process no longer exists
    GDB process exited with wait status 23054 exp9 0 0 CHILDKILLED SIGABRT SIGABRT
    ...
    
    We're running into this abort in process_psymtab_comp_unit:
    ...
      switch (reader.comp_unit_die->tag)
        {
        case DW_TAG_compile_unit:
          this_cu->unit_type = DW_UT_compile;
          break;
        case DW_TAG_partial_unit:
          this_cu->unit_type = DW_UT_partial;
          break;
        default:
          abort ();
        }
    ...
    because reader.comp_unit_die->tag == DW_TAG_type_unit.
    
    Fix this by adding a DW_TAG_type_unit case.
    
    Tested on x86_64-linux.
    
    gdb/ChangeLog:
    
    2021-02-05  Tom de Vries  <tdevries@suse.de>
    
            PR symtab/27333
            * dwarf2/read.c (process_psymtab_comp_unit): Handle DW_TAG_type_unit.
    
    (cherry picked from commit e77b0004dd114d6ddf3bb92b521b2854341f3f85)
Comment 7 Ahmed Sayeed 2021-06-27 17:56:07 UTC Comment hidden (spam)
Comment 8 Ucel Sani 2021-08-19 06:01:52 UTC Comment hidden (spam)
Comment 9 ribevi 2021-08-27 18:01:35 UTC Comment hidden (spam)
Comment 10 james rohan 2021-09-02 11:07:02 UTC Comment hidden (spam)
Comment 11 james robin 2021-09-06 09:09:19 UTC Comment hidden (spam)
Comment 12 Mehmet gelisin 2021-09-10 19:39:28 UTC Comment hidden (spam)
Comment 13 diheto 2021-09-22 10:10:32 UTC Comment hidden (spam)
Comment 14 Kylan 2021-09-26 13:31:45 UTC Comment hidden (spam)
Comment 15 Chris James 2021-09-28 00:48:38 UTC Comment hidden (spam)
Comment 16 Gulsen Engin 2021-10-09 11:00:14 UTC Comment hidden (spam)
Comment 17 oficaj3 2021-10-10 16:10:38 UTC Comment hidden (spam)
Comment 18 Canerkin 2021-10-18 19:58:04 UTC Comment hidden (spam)
Comment 19 progonsaytu 2021-10-19 07:14:13 UTC Comment hidden (spam)
Comment 20 fiteva 2021-10-23 13:47:06 UTC Comment hidden (spam)
Comment 21 glassmtech 2021-10-24 10:02:09 UTC Comment hidden (spam)
Comment 22 paneki 2021-11-06 21:12:47 UTC Comment hidden (spam)
Comment 23 tesaso8237@funboxcn.com 2021-11-13 19:33:10 UTC Comment hidden (spam)
Comment 24 tesaso8237@funboxcn.comxecana8007@funboxcn.com 2021-11-16 19:04:52 UTC Comment hidden (spam)
Comment 25 tesaso8237@funboxcn.comxecana8007@funboxcn.com 2021-11-16 19:08:32 UTC Comment hidden (spam)
Comment 26 tesaso8237@funboxcn.comxecana8007@funboxcn.com 2021-11-16 19:12:37 UTC Comment hidden (spam)
Comment 27 tesaso8237@funboxcn.comxecana8007@funboxcn.com 2021-11-16 19:15:57 UTC Comment hidden (spam)