[PATCH] Fix debug info of nested inline functions

Eric Botcazou ebotcazou@adacore.com
Wed Jul 28 07:46:00 GMT 2010


Hi,

Compile the attached testcase with -O3 -g -dA (no need to know Ada, it's 
C-like code) and you'll see that GCC generates broken debug info for nested 
inline functions.

More specifically, Iterate_Corresponding_Subcomponents_Rec is inlined into its 
parent Assign_Subcomponents but its child Walk_One_LHS_Component isn't.   The 
first problem is that, in the debug info, the abstract instance of I_C_S_B 
contains the out-of-line instance of W_O_L_C.

Moreover, Iterate_Corresponding_Subcomponents_Rec is also inlined into its 
child Walk_One_LHS_Component.  The out-of-line instance of W_O_L_C correctly 
contains a concrete instance of I_C_S_B but, because of the above, we have a 
cycle in the debug info through the DW_AT_abstract_origin of the latter.

The attached patch is a (partial) attempt at implementing 3.3.8.4 of the DWARF 
standard and avoiding cycles.  It makes it so that abstract instances of 
functions contain a full tree of abstract instances of their child functions; 
it also makes sure that concrete or out-of-line instances aren't contained in 
abstract instances.  I think this implements 3.3.8.4 up to 1., 2. and 3; as 
for 4., it isn't (always) fulfilled but this doesn't seem to be a problem in 
practice for GDB.

Tested on x86-64-suse-linux (GCC and GDB), OK for mainline?


2010-07-28  Eric Botcazou  <ebotcazou@adacore.com>

	* dwarf2out.c (gen_subprogram_die): Emit a definition of nested
	functions within an abstract instance of their parent.
	(gen_inlined_subroutine_die): Return if the origin is to be ignored.
	(function_possibly_abstracted_p): New static function.
	(process_scope_var): Do not emit concrete instances of abstracted
	nested functions from here.
	(gen_decl_die): Emit the abstract instance if the function is possibly
	abstracted and not only possibly inlined.
	(dwarf2out_finish): Find the first non-abstract parent instance and
	attach concrete instances on the limbo list to it.


-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-diff
Size: 3960 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100728/09d413cc/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.adb
Type: text/x-adasrc
Size: 1056 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100728/09d413cc/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.ads
Type: text/x-adasrc
Size: 99 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100728/09d413cc/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: q.ads
Type: text/x-adasrc
Size: 937 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20100728/09d413cc/attachment-0003.bin>


More information about the Gcc-patches mailing list