This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project. See the GDB home page for more information.


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

Patch for DW_AT_identifier_case


The dwarf2 definition has additional support for the case mapping of
identifiers.  The Aonix ObjectAda compiler takes advantage of this flexibility
and retains the case of the identifiers from the original source file.
Ada is case insensitive and gdb (at least the GNAT Ada support) prefers lower
case identifiers.  This patch simply lower cases identifiers when the
compilation unit is marked DW_ID_case_insensitive.



Mon May  3 15:24:39 1999 Brian Nettleton <bn@aonix.com>

	* dwarf2read.c: Added support for lowering case of case_insensitive
	languages (ala new function check_case).


Index: gdb/dwarf2read.c
*** ../gdb-4.17.patch/gdb/dwarf2read.c	Mon May  3 15:10:23 1999
--- gdb/dwarf2read.c	Mon May  3 15:23:13 1999
*************** static unsigned int cu_header_offset;
*** 284,289 ****
--- 284,293 ----
  static enum language cu_language;
  static const struct language_defn *cu_language_defn;
  
+ /* From the DW_AT_identifier_case for the current compile unit, or
+  * set in set_cu_language, if not specified for the compile unit */
+ static unsigned int identifier_case;
+ 
  /* Actually data from the sections.  */
  static char *dwarf_info_buffer;
  static char *dwarf_abbrev_buffer;
*************** static struct abbrev_info *dwarf_alloc_a
*** 746,751 ****
--- 750,757 ----
  
  static struct die_info *dwarf_alloc_die PARAMS ((void));
  
+ static char *check_case PARAMS ((char *));
+ 
  /* Try to locate the sections we need for DWARF 2 debugging
     information and return true if we have enough to do something.  */
  
*************** read_file_scope (die, objfile)
*** 1516,1521 ****
--- 1522,1533 ----
        set_cu_language (DW_UNSND (attr));
      }
  
+   attr = dwarf_attr (die, DW_AT_identifier_case);
+   if (attr)
+     {
+       identifier_case = DW_UNSND(attr);
+     }
+ 
  #if 0
      /* FIXME:Do something here.  */
      if (dip->at_producer != NULL)
*************** dwarf2_add_field (fip, die, objfile)
*** 1828,1834 ****
        /* Get name of field.  */
        attr = dwarf_attr (die, DW_AT_name);
        if (attr && DW_STRING (attr))
! 	fieldname = DW_STRING (attr);
        fp->name = obsavestring (fieldname, strlen (fieldname),
  			       &objfile->type_obstack);
  
--- 1840,1846 ----
        /* Get name of field.  */
        attr = dwarf_attr (die, DW_AT_name);
        if (attr && DW_STRING (attr))
! 	fieldname = check_case(DW_STRING (attr));
        fp->name = obsavestring (fieldname, strlen (fieldname),
  			       &objfile->type_obstack);
  
*************** read_structure_scope (die, objfile)
*** 2227,2233 ****
    attr = dwarf_attr (die, DW_AT_name);
    if (attr && DW_STRING (attr))
      {
!       TYPE_TAG_NAME (type) = obsavestring (DW_STRING (attr),
  					   strlen (DW_STRING (attr)),
  					   &objfile->type_obstack);
      }
--- 2239,2245 ----
    attr = dwarf_attr (die, DW_AT_name);
    if (attr && DW_STRING (attr))
      {
!       TYPE_TAG_NAME (type) = obsavestring (check_case(DW_STRING (attr)),
  					   strlen (DW_STRING (attr)),
  					   &objfile->type_obstack);
      }
*************** read_enumeration (die, objfile)
*** 2390,2396 ****
    attr = dwarf_attr (die, DW_AT_name);
    if (attr && DW_STRING (attr))
      {
!       TYPE_TAG_NAME (type) = obsavestring (DW_STRING (attr),
  					   strlen (DW_STRING (attr)),
  					   &objfile->type_obstack);
      }
--- 2402,2408 ----
    attr = dwarf_attr (die, DW_AT_name);
    if (attr && DW_STRING (attr))
      {
!       TYPE_TAG_NAME (type) = obsavestring (check_case(DW_STRING (attr)),
  					   strlen (DW_STRING (attr)),
  					   &objfile->type_obstack);
      }
*************** read_subrange_type (die, objfile)
*** 2589,2595 ****
        TYPE_TARGET_TYPE (type) = xtype;
        attr = dwarf_attr (die, DW_AT_name);
        if (attr && DW_STRING (attr))
!         TYPE_NAME (type) = obsavestring (DW_STRING (attr),
                                           strlen (DW_STRING (attr)),
                                           &objfile->type_obstack);
  
--- 2601,2607 ----
        TYPE_TARGET_TYPE (type) = xtype;
        attr = dwarf_attr (die, DW_AT_name);
        if (attr && DW_STRING (attr))
!         TYPE_NAME (type) = obsavestring (check_case(DW_STRING (attr)),
                                           strlen (DW_STRING (attr)),
                                           &objfile->type_obstack);
  
*************** read_typedef (die, objfile)
*** 3020,3026 ****
        TYPE_TARGET_TYPE (type) = xtype;
        attr = dwarf_attr (die, DW_AT_name);
        if (attr && DW_STRING (attr))
! 	TYPE_NAME (type) = obsavestring (DW_STRING (attr),
  					 strlen (DW_STRING (attr)),
  					 &objfile->type_obstack);
  
--- 3032,3038 ----
        TYPE_TARGET_TYPE (type) = xtype;
        attr = dwarf_attr (die, DW_AT_name);
        if (attr && DW_STRING (attr))
! 	TYPE_NAME (type) = obsavestring (check_case(DW_STRING (attr)),
  					 strlen (DW_STRING (attr)),
  					 &objfile->type_obstack);
  
*************** read_base_type (die, objfile)
*** 3091,3097 ****
  		    dwarf_type_encoding_name (encoding));
  	  break;
  	}
!       type = init_type (code, size, is_unsigned, DW_STRING (attr), objfile);
        if (encoding == DW_ATE_address)
  	TYPE_TARGET_TYPE (type) = dwarf2_fundamental_type (objfile, FT_VOID);
      }
--- 3103,3110 ----
  		    dwarf_type_encoding_name (encoding));
  	  break;
  	}
!       type = init_type (code, size, is_unsigned, 
! 			check_case(DW_STRING (attr)), objfile);
        if (encoding == DW_ATE_address)
  	TYPE_TARGET_TYPE (type) = dwarf2_fundamental_type (objfile, FT_VOID);
      }
*************** read_partial_die (part_die, abfd, info_p
*** 3364,3373 ****
  
  	  /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name.  */
  	  if (part_die->name == NULL)
! 	    part_die->name = DW_STRING (&attr);
  	  break;
  	case DW_AT_MIPS_linkage_name:
! 	  part_die->name = DW_STRING (&attr);
  	  break;
  	case DW_AT_low_pc:
  	  has_low_pc_attr = 1;
--- 3377,3386 ----
  
  	  /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name.  */
  	  if (part_die->name == NULL)
! 	    part_die->name = check_case(DW_STRING (&attr));
  	  break;
  	case DW_AT_MIPS_linkage_name:
! 	  part_die->name = check_case(DW_STRING (&attr));
  	  break;
  	case DW_AT_low_pc:
  	  has_low_pc_attr = 1;
*************** static void
*** 3832,3837 ****
--- 3845,3851 ----
  set_cu_language (lang)
       unsigned int lang;
  {
+   identifier_case = DW_ID_case_sensitive;
    switch (lang)
      {
      case DW_LANG_C89:
*************** set_cu_language (lang)
*** 3850,3855 ****
--- 3864,3870 ----
        break;
      case DW_LANG_Ada83:
        cu_language = language_ada;
+       identifier_case = DW_ID_case_insensitive;
        break;
      case DW_LANG_Cobol74:
      case DW_LANG_Cobol85:
*************** dwarf2_linkage_name (die)
*** 4837,4848 ****
  
    attr = dwarf_attr (die, DW_AT_MIPS_linkage_name);
    if (attr && DW_STRING (attr))
!     return DW_STRING (attr);
    attr = dwarf_attr (die, DW_AT_name);
    if (attr && DW_STRING (attr))
!     return DW_STRING (attr);
    return NULL;
  }
  
  /* Convert a DIE tag into its string name.  */
  
--- 4852,4881 ----
  
    attr = dwarf_attr (die, DW_AT_MIPS_linkage_name);
    if (attr && DW_STRING (attr))
!     return check_case(DW_STRING (attr));
    attr = dwarf_attr (die, DW_AT_name);
    if (attr && DW_STRING (attr))
!     return check_case(DW_STRING (attr));
    return NULL;
  }
+ 
+ /* Return an appropriately cased name depending on cu_language and
+    identifier_case.  */
+ 
+ static char *
+ check_case (s)
+      char *s;
+ {
+   char *tmp;
+   if (identifier_case == DW_ID_case_insensitive && s)
+     {
+       /* down case anything which is case insensitive */
+       for(tmp = s; *tmp != 0;tmp++)
+         *tmp = tolower(*tmp);
+     }
+   return s;
+ }
+ 
  
  /* Convert a DIE tag into its string name.  */