This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] dwarf2_physname FINAL


> One other issue that I uncovered: DW_AT_MIPS_linkage_name appears to
> be necessary for Ada.

That's correct. In the cases where the DW_AT_MIPS_linkage_name is used,
it provides the exported name of our entity, whereas the DW_AT_name
contains the name of the entity as it would have been encoded had
the entity not been given a specific exported name.  For instance,
consider the following declaration:

    package Pck is  
       procedure Do_Nothing;
       pragma Export (C, Do_Nothing, "__foo_bar");
    end Pck;

The associated DWARF looks like this:

        .uleb128 0x2    # (DIE (0x2d) DW_TAG_subprogram)
        .byte   0x1     # DW_AT_external
        .long   .LASF3  # DW_AT_name: "pck__do_nothing"
        .long   .LASF4  # DW_AT_MIPS_linkage_name: "__foo_bar"

> I have a patch that I used to address this (for one of our internal
> releases), but it is probably not complete.  [In other words: it's now
> just as broken as it was before.] I can submit this as a follow-up, if
> so desired.

Just to clarify a little bit, it's the compiler that is probably broken,
generating incorrect debugging info. I keep pushing internally for us
to improve the situation so that others can test Ada too, but we only
have few engineers working on this area, and it's hard to get their
attention on this :-(.

Attached is a patch that fixes all regressions for Ada.  Basically,
it updates dwarf2_compute_name to handle Ada entities...  The function
comment will probably need to be updated - something like this:

/* Compute the fully qualified name of DIE in CU:

     . For Ada, this is the DIE exported name;
     . For C++ and Java, [...]; <mention canonicalization here?>
     . For other languages, this is just the DIE name.

   The result is allocated on the objfile_obstack.  */

-- 
Joel
commit 0a992b13eb758bf26c172a67240022a9d1e1226f
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Mon Mar 8 09:56:21 2010 +0400

    Compute the name of Ada entities using the MIPS_linkage_name first.

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index d8629e4..9e4334a 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3399,6 +3399,19 @@ dwarf2_compute_name (char *name, struct die_info *die, struct dwarf2_cu *cu,
 	    }
 	}
     }
+  else if (cu->language == language_ada)
+    {
+      /* For Ada unit, we prefer the linkage name over the name, as
+	 the former contains the exported name, which the user expects
+	 to be able to reference.  Ideally, we want the user to be able
+	 to reference this entity using either natural or linkage name,
+	 but we haven't started looking at this enhancement yet.  */
+      struct attribute *attr;
+
+      attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu);
+      if (attr && DW_STRING (attr))
+	name = DW_STRING (attr);
+    }
 
   return name;
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]