Bug 27333 - [dwarf-5] abort on unhandled DW_TAG_type_unit in process_psymtab_comp_unit
Summary: [dwarf-5] abort on unhandled DW_TAG_type_unit in process_psymtab_comp_unit
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: 10.2
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-03 11:55 UTC by Tom de Vries
Modified: 2021-03-06 06:34 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 cvs-commit@gcc.gnu.org 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 cvs-commit@gcc.gnu.org 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)