PATCH for dwarf2out.c typo: parameter location missing in smallfunctions

Hans-Peter Nilsson hp@bitrange.com
Wed Jul 28 15:26:00 GMT 1999


There seems to be a typo in dwarf2out.c, causing integer type
parameters to sometimes needlessly be without a DW_AT_location
description when optimizing and the parameter size is smaller than
plain "int".
 This causes debuggers to not have any information about the location
of the parameter, and the person debugging will be even less happy.
It happens for trivially small functions that are mostly optimized away
and we only find the parameter at the "incoming" location (and hardly
even there).

In add_location_or_const_value_attribute:

...
		   && TYPE_SIZE (declared_type) <= TYPE_SIZE (passed_type)
...

But TYPE_SIZE gives a tree, not a "size", and the comparison is invalid.


Wed Jul 28 20:44:13 1999  Hans-Peter Nilsson  <hp@bitrange.com>

	* dwarf2out.c (add_location_or_const_value_attribute): Correct
	test for sizes of passed and declared parameter types.

Index: dwarf2out.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/dwarf2out.c,v
retrieving revision 1.98
diff -p -c -r1.98 dwarf2out.c
*** dwarf2out.c	1999/07/22 02:16:54	1.98
--- dwarf2out.c	1999/07/28 19:24:04
*************** add_location_or_const_value_attribute (d
*** 7186,7192 ****
  	    rtl = DECL_INCOMING_RTL (decl);
  	  else if (! BYTES_BIG_ENDIAN
  		   && TREE_CODE (declared_type) == INTEGER_TYPE
! 		   && TYPE_SIZE (declared_type) <= TYPE_SIZE (passed_type))
  		rtl = DECL_INCOMING_RTL (decl);
  	}
  
--- 7186,7193 ----
  	    rtl = DECL_INCOMING_RTL (decl);
  	  else if (! BYTES_BIG_ENDIAN
  		   && TREE_CODE (declared_type) == INTEGER_TYPE
! 		   && (GET_MODE_SIZE (TYPE_MODE (declared_type))
! 		       <= GET_MODE_SIZE (TYPE_MODE (passed_type))))
  		rtl = DECL_INCOMING_RTL (decl);
  	}


Need a testcase?  Check the following for target=arm-elf or
i686-pc-linux-gnulibc1 compiled with "-O2 -gdwarf-2 -dA"; you'll see that
without this patch, the DW_TAG_formal_parameter for parameter x2 in
function f2 has no DW_AT_location, while parameter x in function f1
has one.

int f1(int x)
{
  return x+1;
}

int f2(short int x2)
{
  return x2+1;
}

brgds, H-P



More information about the Gcc-patches mailing list