Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* PATCH: Support DW_TAG_entry_point
@ 2004-11-16  0:47 H. J. Lu
  2004-11-16 10:35 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: H. J. Lu @ 2004-11-16  0:47 UTC (permalink / raw)
  To: GDB

This patch adds the support for DW_TAG_entry_point. I tested it
with Intel Fortran compiler. It seems to work fine.


H.J.
----
2004-11-15  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-15 15:50:13.752074008 -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,9 @@ scan_partial_symbols (struct partial_die
 	      break;
 	    }
 	}
+      
+      if (pdi->has_children)
+	scan_partial_symbols (pdi->die_child, lowpc, highpc, cu);
 
       /* If the die has a sibling, skip to the sibling.  */
 
@@ -1894,6 +1898,15 @@ add_partial_symbol (struct partial_die_i
 				      cu->language, objfile);
 	}
       break;
+    case DW_TAG_entry_point:
+      /*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);
+      break;
     case DW_TAG_variable:
       if (pdi->is_external)
 	{
@@ -2625,6 +2638,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 +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);
+	  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 +3233,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 +5203,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 +5308,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 +5331,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 +5552,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 +6838,13 @@ new_symbol (struct die_info *die, struct
 	      add_symbol_to_list (sym, cu->list_in_scope);
 	    }
 	  break;
+	case DW_TAG_entry_point:
+	  /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by
+	     finish_block.  */
+	  SYMBOL_CLASS (sym) = LOC_BLOCK;
+	  /* Fortran alternate entry point is always external.  */
+	  add_symbol_to_list (sym, &global_symbols);
+	  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 +7240,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:


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: Support DW_TAG_entry_point
  2004-11-16  0:47 PATCH: Support DW_TAG_entry_point H. J. Lu
@ 2004-11-16 10:35 ` Andreas Schwab
  2004-11-16 18:51   ` H. J. Lu
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2004-11-16 10:35 UTC (permalink / raw)
  To: H. J. Lu; +Cc: GDB

"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.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: Support DW_TAG_entry_point
  2004-11-16 10:35 ` Andreas Schwab
@ 2004-11-16 18:51   ` H. J. Lu
  0 siblings, 0 replies; 3+ messages in thread
From: H. J. Lu @ 2004-11-16 18:51 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: GDB

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:


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-11-16 18:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-16  0:47 PATCH: Support DW_TAG_entry_point H. J. Lu
2004-11-16 10:35 ` Andreas Schwab
2004-11-16 18:51   ` H. J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox