This is the mail archive of the gdb-patches@sources.redhat.com 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: PATCH: Support DW_TAG_entry_point


On Tue, Nov 16, 2004 at 11:23:02AM +0100, Andreas Schwab wrote:
> "H. J. Lu" <hjl@lucon.org> writes:
> 
> > @@ -3151,6 +3165,27 @@ dwarf2_get_pc_bounds (struct die_info *d
> >  
> >  	  ret = -1;
> >  	}
> > +      else if (die->tag == DW_TAG_entry_point)
> > +	{
> > +	  /* DW_TAG_entry_point DIE only has DW_AT_high_pc. We get
>                                              ^^^^^^^^^^^^^
> > +	     HIGH from its parent.  */
> > +	  attr = dwarf2_attr (die, DW_AT_low_pc, cu);
>                                    ^^^^^^^^^^^^
> Looks like a comment typo.
> 

Thanks for catching that. I also updated the patch to get the linkage
of DW_TAG_entry_point from its parent and only scan DW_TAG_entry_point
children of a DW_TAG_subprogram DIE.


H.J.
-----
2004-11-16  H.J. Lu  <hongjiu.lu@intel.com>

	* dwarf2read.c (scan_partial_symbols): Make a recursive call
	if a DIE has children. Handle DW_TAG_entry_point.
	(load_partial_dies): Don't skip DW_TAG_entry_point. Follow
	children of DW_TAG_subprogram if not C.
	(add_partial_symbol): Handle DW_TAG_entry_point.
	(process_die): Likewise.
	(dwarf2_get_pc_bounds): Likewise.
	(get_scope_pc_bounds): Likewise.
	(fixup_partial_die): Likewise.
	(new_symbol): Likewise.
	(read_type_die): Likewise.

--- gdb/dwarf2read.c.entry	2004-11-11 16:46:53.000000000 -0800
+++ gdb/dwarf2read.c	2004-11-16 10:48:36.655194789 -0800
@@ -1697,6 +1697,7 @@ scan_partial_symbols (struct partial_die
 	  switch (pdi->tag)
 	    {
 	    case DW_TAG_subprogram:
+	    case DW_TAG_entry_point:
 	      if (pdi->has_pc_info)
 		{
 		  if (pdi->lowpc < *lowpc)
@@ -1745,6 +1746,13 @@ scan_partial_symbols (struct partial_die
 	      break;
 	    }
 	}
+      
+      /* A DW_TAG_subprogram DIE may have DW_TAG_entry_point DIEs
+	 as children.  */ 
+      if (pdi->tag == DW_TAG_subprogram
+	  && pdi->has_children
+	  && pdi->die_child->tag == DW_TAG_entry_point)
+	scan_partial_symbols (pdi->die_child, lowpc, highpc, cu);
 
       /* If the die has a sibling, skip to the sibling.  */
 
@@ -1894,6 +1902,29 @@ add_partial_symbol (struct partial_die_i
 				      cu->language, objfile);
 	}
       break;
+    case DW_TAG_entry_point:
+      if (pdi->die_parent->tag == DW_TAG_subprogram)
+	{
+	  if (pdi->die_parent->is_external)
+	    /*prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
+	      mst_text, objfile); */
+	    psym = add_psymbol_to_list (actual_name,
+					strlen (actual_name),
+					VAR_DOMAIN, LOC_BLOCK,
+					&objfile->global_psymbols,
+					0, pdi->lowpc + baseaddr,
+					cu->language, objfile);
+	  else
+	    /*prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
+	      mst_file_text, objfile); */
+	    psym = add_psymbol_to_list (actual_name,
+					strlen (actual_name),
+					VAR_DOMAIN, LOC_BLOCK,
+					&objfile->static_psymbols,
+					0, pdi->lowpc + baseaddr,
+					cu->language, objfile);
+	}
+      break;
     case DW_TAG_variable:
       if (pdi->is_external)
 	{
@@ -2625,6 +2656,7 @@ process_die (struct die_info *die, struc
       read_file_scope (die, cu);
       break;
     case DW_TAG_subprogram:
+    case DW_TAG_entry_point:
       read_subroutine_type (die, cu);
       read_func_scope (die, cu);
       break;
@@ -3151,6 +3183,27 @@ dwarf2_get_pc_bounds (struct die_info *d
 
 	  ret = -1;
 	}
+      else if (die->tag == DW_TAG_entry_point)
+	{
+	  /* DW_TAG_entry_point DIE only has DW_AT_low_pc. We get
+	     HIGH from its parent.  */
+	  attr = dwarf2_attr (die, DW_AT_low_pc, cu);
+	  if (attr)
+	    {
+	      low = DW_ADDR (attr);
+	      if (die->parent->tag == DW_TAG_subprogram)
+		{
+		  CORE_ADDR parent_low = 0;
+		  CORE_ADDR parent_high = 0;
+		  if (dwarf2_get_pc_bounds (die->parent, &parent_low,
+					    &parent_high, cu))
+		    {
+		      high = parent_high;
+		      ret = 1;
+		    }
+		}
+	    } 
+	}
     }
 
   if (high < low)
@@ -3198,6 +3251,7 @@ get_scope_pc_bounds (struct die_info *di
 	{
 	  switch (child->tag) {
 	  case DW_TAG_subprogram:
+	  case DW_TAG_entry_point:
 	    if (dwarf2_get_pc_bounds (child, &current_low, &current_high, cu))
 	      {
 		best_low = min (best_low, current_low);
@@ -5167,6 +5221,7 @@ load_partial_dies (bfd *abfd, char *info
       if (!is_type_tag_for_partial (abbrev->tag)
 	  && abbrev->tag != DW_TAG_enumerator
 	  && abbrev->tag != DW_TAG_subprogram
+	  && abbrev->tag != DW_TAG_entry_point
 	  && abbrev->tag != DW_TAG_variable
 	  && abbrev->tag != DW_TAG_namespace)
 	{
@@ -5271,6 +5326,7 @@ load_partial_dies (bfd *abfd, char *info
 	 internal errors in find_partial_die.  */
 
       if (abbrev->tag == DW_TAG_subprogram
+	  || abbrev->tag == DW_TAG_entry_point
 	  || abbrev->tag == DW_TAG_variable
 	  || abbrev->tag == DW_TAG_namespace
 	  || part_die->is_declaration)
@@ -5293,7 +5349,8 @@ load_partial_dies (bfd *abfd, char *info
 	  && (last_die->tag == DW_TAG_namespace
 	      || last_die->tag == DW_TAG_enumeration_type
 	      || (cu->language != language_c
-		  && (last_die->tag == DW_TAG_class_type
+		  && (last_die->tag == DW_TAG_subprogram 
+		      || last_die->tag == DW_TAG_class_type
 		      || last_die->tag == DW_TAG_structure_type
 		      || last_die->tag == DW_TAG_union_type))))
 	{
@@ -5513,6 +5570,16 @@ fixup_partial_die (struct partial_die_in
       || part_die->tag == DW_TAG_class_type
       || part_die->tag == DW_TAG_union_type)
     guess_structure_name (part_die, cu);
+
+  if (part_die->tag == DW_TAG_entry_point)
+    {
+      if (part_die->die_parent->tag == DW_TAG_subprogram)
+	{
+	  part_die->highpc = part_die->die_parent->highpc;
+	  if (part_die->lowpc < part_die->highpc)
+	    part_die->has_pc_info = 1;
+	}
+    }
 }
 
 /* Read the die from the .debug_info section buffer.  Set DIEP to
@@ -6789,6 +6856,19 @@ new_symbol (struct die_info *die, struct
 	      add_symbol_to_list (sym, cu->list_in_scope);
 	    }
 	  break;
+	case DW_TAG_entry_point:
+	  if (die->parent->tag == DW_TAG_subprogram)
+	    {
+	      /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by
+		 finish_block.  */
+	      SYMBOL_CLASS (sym) = LOC_BLOCK;
+	      attr2 = dwarf2_attr (die->parent, DW_AT_external, cu);
+	      if (attr2 && (DW_UNSND (attr2) != 0))
+		add_symbol_to_list (sym, &global_symbols);
+	      else
+		add_symbol_to_list (sym, cu->list_in_scope);
+	    }
+	  break;
 	case DW_TAG_variable:
 	  /* Compilation with minimal debug info may result in variables
 	     with missing type entries. Change the misleading `void' type
@@ -7184,6 +7264,7 @@ read_type_die (struct die_info *die, str
       break;
     case DW_TAG_subprogram:
     case DW_TAG_subroutine_type:
+    case DW_TAG_entry_point:
       read_subroutine_type (die, cu);
       break;
     case DW_TAG_array_type:


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