This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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]

Problems with breakpoints in constructors


Hi,

I am trying to fix the problem with placing breakpoints in constructors for 
TimeSys Corporation.

I found that gdb is able to detect the presence of base and complete 
constructors but it can't find their addresses correctly. The reason being, 
the debugging information generated for constructors doesn't contain their 
mangled names. In absence of mangled names, gdb takes the address of the 
first function that matches the demangled name and places both the 
breakpoints at the same address.

I believe that part of the problem is with gcc's generation of debugging 
information. I am new to gcc, so some of my conclusions may not be correct. 
Can gcc gurus please help me with suggestions or directions for further 
explorations? If it's a known problem, I am ready to implement a known 
solution for it.

Mangled names are emitted in debugging information generated in the function 
add_name_and_src_coords_attributes. They are emitted as attribute 
DW_AT_MIPS_linkage_name. This attribute is emitted for all member functions 
except for constructors. It's not emitted when DECL_ABSTRACT is true, which 
applies to constructors.

I forced generation of this attribute by following hack

       if ((TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL)
 	  && TREE_PUBLIC (decl)
 	  && DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl)
	  && (!DECL_ABSTRACT (decl) || die->die_tag == DW_TAG_subprogram))
	ptr = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
      	sublen = strlen(ptr) - 12;
	if (strstr(ptr, " *INTERNAL* ") == (ptr + sublen)) {
		memcpy(tmpstr, ptr, sublen);
		tmpstr[sublen] = '\0';
		add_AT_string (die, DW_AT_MIPS_linkage_name, tmpstr);
	} else 
	add_AT_string (die, DW_AT_MIPS_linkage_name, ptr);
     }

This hack generates DW_AT_MIPS_linkage_name for only one attribute. 
add_name_and_src_coords_attributes is not called for second instance of the 
constructor since both these constructors are instance of an abstract 
declaration, for which add_name_and_src_coords_attributes has been called at 
the time of first instance.

Is there any reason why the debugging information is generated only once even 
if there are two instances of an abstract declaration? I guess this would 
create problems with multiple instances of implementations of inline 
constructors also.

Thanks.
-Amit


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