[Bug c++/12328] Can't set breakpoint on method taking const, non-reference/pointer scalar parameter

keiths at redhat dot com sourceware-bugzilla@sourceware.org
Thu Dec 16 17:37:00 GMT 2010


http://sourceware.org/bugzilla/show_bug.cgi?id=12328

Keith Seitz <keiths at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Ignore "const" for          |Can't set breakpoint on
                   |non-reference/pointer       |method taking const,
                   |scalar                      |non-reference/pointer
                   |                            |scalar parameter

--- Comment #1 from Keith Seitz <keiths at redhat dot com> 2010-12-16 17:34:26 UTC ---
This happens because of the constant scalar parameter for "func". Gdb thinks it
is really "int" (not "const int"), and when it goes to lookup
"myclass::func(int)", it does not find anything.

The DIEs pertaining to "myclass" and "func":

 <1><31>: Abbrev Number: 2 (DW_TAG_class_type)
    <32>   DW_AT_name        : (indirect string, offset: 0x71): myclass 
    <36>   DW_AT_byte_size   : 1        
    <37>   DW_AT_decl_file   : 1        
    <38>   DW_AT_decl_line   : 2        
    <39>   DW_AT_sibling     : <0x51>   
 <2><3d>: Abbrev Number: 3 (DW_TAG_subprogram)
    <3e>   DW_AT_external    : 1        
    <3f>   DW_AT_name        : (indirect string, offset: 0x0): func     
    <43>   DW_AT_decl_file   : 1        
    <44>   DW_AT_decl_line   : 4        
    <45>   DW_AT_MIPS_linkage_name: (indirect string, offset: 0x59):
_ZN7myclass4funcEi 
    <49>   DW_AT_declaration : 1        
 <3><4a>: Abbrev Number: 4 (DW_TAG_formal_parameter)
    <4b>   DW_AT_type        : <0x51>   
 <1><51>: Abbrev Number: 5 (DW_TAG_base_type)
    <52>   DW_AT_byte_size   : 4        
    <53>   DW_AT_encoding    : 5        (signed)
    <54>   DW_AT_name        : int      
 <1><58>: Abbrev Number: 6 (DW_TAG_subprogram)
    <59>   DW_AT_specification: <0x3d>  
    <5d>   DW_AT_low_pc      : 0x400574 
    <65>   DW_AT_high_pc     : 0x40057d 
    <6d>   DW_AT_frame_base  : 1 byte block: 9c         (DW_OP_call_frame_cfa)
    <6f>   DW_AT_sibling     : <0x81>   
 <2><73>: Abbrev Number: 7 (DW_TAG_formal_parameter)
    <74>   DW_AT_name        : aa       
    <77>   DW_AT_decl_file   : 1        
    <78>   DW_AT_decl_line   : 4        
    <79>   DW_AT_type        : <0x81>   
    <7d>   DW_AT_location    : 2 byte block: 91 6c      (DW_OP_fbreg: -20)
 <1><81>: Abbrev Number: 8 (DW_TAG_const_type)
    <82>   DW_AT_type        : <0x51>   

As you can see, when reading the fieldlists for "myclass", we add an entry for
"func" with parameter "int" NOT "const int". Later when the function definition
is seen, we correctly get "const int".

IMO, this is a compiler bug. I see no reason why the class definition and the
function definition should conflict.

However, this might be relatively painless to add something to gdb to ignore

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the Gdb-prs mailing list