From: Tom Tromey Date: Fri, 6 Sep 2024 18:24:41 +0000 (-0600) Subject: Handle DW_TAG_module for Ada X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8cf79a06467464fe7df292555dd0ce9e839db832;p=thirdparty%2Fbinutils-gdb.git Handle DW_TAG_module for Ada This updates read_module_type to turn DW_TAG_module into a TYPE_CODE_NAMESPACE when the CU represents Ada code. Note that the GNAT that generates this isn't generally available yet and so this shouldn't have an impact on current code. --- diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 08592624746..962d51ecc26 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -13123,25 +13123,36 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu) } } -/* Read a Fortran module as type. This DIE can be only a declaration used for - imported module. Still we need that type as local Fortran "use ... only" - declaration imports depend on the created type in determine_prefix. */ +/* Read a Fortran module or Ada package as type. For Fortran, This + DIE can be only a declaration used for imported module. Still we + need that type as local Fortran "use ... only" declaration imports + depend on the created type in determine_prefix. */ static struct type * read_module_type (struct die_info *die, struct dwarf2_cu *cu) { + enum language lang = cu->lang (); struct objfile *objfile = cu->per_objfile->objfile; - const char *module_name; struct type *type; - module_name = dwarf2_name (die, cu); - type = type_allocator (objfile, cu->lang ()).new_type (TYPE_CODE_MODULE, - 0, module_name); + if (lang == language_ada) + { + const char *pkg_name = dwarf2_full_name (nullptr, die, cu); + type = type_allocator (objfile, lang).new_type (TYPE_CODE_NAMESPACE, + 0, pkg_name); + } + else + { + const char *module_name = dwarf2_name (die, cu); + type = type_allocator (objfile, lang).new_type (TYPE_CODE_MODULE, + 0, module_name); + } return set_die_type (die, type, cu); } -/* Read a Fortran module. */ +/* Read a module. This tag is used by Fortran (for modules), but also + by Ada (for packages). */ static void read_module (struct die_info *die, struct dwarf2_cu *cu)