]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Handle DW_TAG_module for Ada
authorTom Tromey <tromey@adacore.com>
Fri, 6 Sep 2024 18:24:41 +0000 (12:24 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 6 Mar 2025 21:17:18 +0000 (14:17 -0700)
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.

gdb/dwarf2/read.c

index 0859262474659187ddc3ec2e593049f04d0d0214..962d51ecc26971d5ba09ef91d26637fe89de0372 100644 (file)
@@ -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)