public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12328] New: Ignore "const" for non-reference/pointer scalar
@ 2010-12-16 17:34 keiths at redhat dot com
  2010-12-16 17:37 ` [Bug c++/12328] Can't set breakpoint on method taking const, non-reference/pointer scalar parameter keiths at redhat dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: keiths at redhat dot com @ 2010-12-16 17:34 UTC (permalink / raw)
  To: gdb-prs

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

           Summary: Ignore "const" for non-reference/pointer scalar
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned@sourceware.org
        ReportedBy: keiths@redhat.com


Source:

class myclass
{
 public:
  static void func(const int aa) {};
};

int
main (int argc, char *argv[])
{
  myclass::func (42);
}

Example:
(gdb) break myclass::func
the class myclass does not have any method named func
Hint: try 'myclass::func<TAB> or 'myclass::func<ESC-?>
(Note leading single quote.)
Make breakpoint pending on future shared library load? (y or [n]) n

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


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

* [Bug c++/12328] Can't set breakpoint on method taking const, non-reference/pointer scalar parameter
  2010-12-16 17:34 [Bug c++/12328] New: Ignore "const" for non-reference/pointer scalar keiths at redhat dot com
@ 2010-12-16 17:37 ` keiths at redhat dot com
  2010-12-16 17:47 ` keiths at redhat dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: keiths at redhat dot com @ 2010-12-16 17:37 UTC (permalink / raw)
  To: gdb-prs

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.


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

* [Bug c++/12328] Can't set breakpoint on method taking const, non-reference/pointer scalar parameter
  2010-12-16 17:34 [Bug c++/12328] New: Ignore "const" for non-reference/pointer scalar keiths at redhat dot com
  2010-12-16 17:37 ` [Bug c++/12328] Can't set breakpoint on method taking const, non-reference/pointer scalar parameter keiths at redhat dot com
@ 2010-12-16 17:47 ` keiths at redhat dot com
  2010-12-17 17:03 ` thahn01@t-online.de
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: keiths at redhat dot com @ 2010-12-16 17:47 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from Keith Seitz <keiths at redhat dot com> 2010-12-16 17:37:29 UTC ---
(Comment #1 continued)
> However, this might be relatively painless to add something to gdb to ignore
DW_AT_const for non-pointer/reference scalar types.

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


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

* [Bug c++/12328] Can't set breakpoint on method taking const, non-reference/pointer scalar parameter
  2010-12-16 17:34 [Bug c++/12328] New: Ignore "const" for non-reference/pointer scalar keiths at redhat dot com
  2010-12-16 17:37 ` [Bug c++/12328] Can't set breakpoint on method taking const, non-reference/pointer scalar parameter keiths at redhat dot com
  2010-12-16 17:47 ` keiths at redhat dot com
@ 2010-12-17 17:03 ` thahn01@t-online.de
  2010-12-17 23:13 ` keiths at redhat dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: thahn01@t-online.de @ 2010-12-17 17:03 UTC (permalink / raw)
  To: gdb-prs

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

Thomas Hahn <thahn01@t-online.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thahn01@t-online.de

--- Comment #3 from Thomas Hahn <thahn01@t-online.de> 2010-12-17 13:34:13 UTC ---
I have tried g++-3.3, g++-4.3 and g++-4.4 on debian and they all have the
same error with gdb 7.2.
When using gdb_7.0.1-2+b1_i386.deb it is working fine and the breakpoint
can be set.

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


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

* [Bug c++/12328] Can't set breakpoint on method taking const, non-reference/pointer scalar parameter
  2010-12-16 17:34 [Bug c++/12328] New: Ignore "const" for non-reference/pointer scalar keiths at redhat dot com
                   ` (2 preceding siblings ...)
  2010-12-17 17:03 ` thahn01@t-online.de
@ 2010-12-17 23:13 ` keiths at redhat dot com
  2011-01-17  7:13 ` jan.kratochvil at redhat dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: keiths at redhat dot com @ 2010-12-17 23:13 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #4 from Keith Seitz <keiths at redhat dot com> 2010-12-17 17:03:34 UTC ---
(In reply to comment #3)
> I have tried g++-3.3, g++-4.3 and g++-4.4 on debian and they all have the
> same error with gdb 7.2.
> When using gdb_7.0.1-2+b1_i386.deb it is working fine and the breakpoint
> can be set.

That's happens because prior to 7.1, GDB used DW_AT_MIPS_linkage_name.
Nowadays, we compute a canonicalized physical name based on the debug
information. MIPS_linkage_name was too unreliable (and often "wrong" for GDB
consumption).

I just built GCC 3.4.6, and it also contains the same bug: the class
declaration and function declaration DIEs contain different types ("int" vs
"const int").

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


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

* [Bug c++/12328] Can't set breakpoint on method taking const, non-reference/pointer scalar parameter
  2010-12-16 17:34 [Bug c++/12328] New: Ignore "const" for non-reference/pointer scalar keiths at redhat dot com
                   ` (3 preceding siblings ...)
  2010-12-17 23:13 ` keiths at redhat dot com
@ 2011-01-17  7:13 ` jan.kratochvil at redhat dot com
  2011-02-06 18:17 ` jan.kratochvil at redhat dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-01-17  7:13 UTC (permalink / raw)
  To: gdb-prs

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

Jan Kratochvil <jan.kratochvil at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jan.kratochvil at redhat
                   |                            |dot com

--- Comment #5 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2011-01-17 07:13:24 UTC ---
I have not found a GCC Bug filed for this claimed GCC problem.

But it is a GDB-only regression:

C++ working draft:
13.1 Overloadable declarations
point 3, item:
- Parameter declarations that differ only in the presence or absence of const 
  and/or volatile are equivalent.

class C {
  void m(const int a) {}
  void m(int a) {}
};
g++ (GCC) 4.6.0 20110117 (experimental)
classC.C:3:8: error: ‘void C::m(int)’ cannot be overloaded
classC.C:2:8: error: with ‘void C::m(int)’

The debug info looks weird but it is irrelevant to this case as both
`(const int aa)' and `(int aa)' DIEs must generate the same linkage name.

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


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

* [Bug c++/12328] Can't set breakpoint on method taking const, non-reference/pointer scalar parameter
  2010-12-16 17:34 [Bug c++/12328] New: Ignore "const" for non-reference/pointer scalar keiths at redhat dot com
                   ` (4 preceding siblings ...)
  2011-01-17  7:13 ` jan.kratochvil at redhat dot com
@ 2011-02-06 18:17 ` jan.kratochvil at redhat dot com
  2011-02-13  9:16 ` cvs-commit at gcc dot gnu.org
  2011-02-13  9:24 ` jan.kratochvil at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-02-06 18:17 UTC (permalink / raw)
  To: gdb-prs

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

Jan Kratochvil <jan.kratochvil at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at sourceware    |jan.kratochvil at redhat
                   |dot org                     |dot com

--- Comment #6 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2011-02-06 18:17:39 UTC ---
GDB fix:
[patch 1/2] Fix physname regression: c/v types quals (PR c++/12328)
http://sourceware.org/ml/gdb-patches/2011-02/msg00112.html

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


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

* [Bug c++/12328] Can't set breakpoint on method taking const, non-reference/pointer scalar parameter
  2010-12-16 17:34 [Bug c++/12328] New: Ignore "const" for non-reference/pointer scalar keiths at redhat dot com
                   ` (5 preceding siblings ...)
  2011-02-06 18:17 ` jan.kratochvil at redhat dot com
@ 2011-02-13  9:16 ` cvs-commit at gcc dot gnu.org
  2011-02-13  9:24 ` jan.kratochvil at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2011-02-13  9:16 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #7 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> 2011-02-13 09:15:58 UTC ---
CVSROOT:    /cvs/src
Module name:    src
Changes by:    jkratoch@sourceware.org    2011-02-13 09:15:54

Modified files:
    gdb            : ChangeLog c-typeprint.c 
    gdb/testsuite  : ChangeLog 
Added files:
    gdb/testsuite/gdb.cp: overload-const.cc overload-const.exp 

Log message:
    gdb/
    Fix const/volatile qualifiers of C++ types, PR c++/12328.
    * c-typeprint.c (c_type_print_args): Update the function comment.  New
    variable param_type, initialize it.  Remove const/volatile qualifiers
    for language_cplus and !show_artificial.  Use param_type.

    gdb/testsuite/
    Fix const/volatile qualifiers of C++ types, PR c++/12328.
    * gdb.cp/overload-const.exp: New file.
    * gdb.cp/overload-const.cc: New file.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.12558&r2=1.12559
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/c-typeprint.c.diff?cvsroot=src&r1=1.68&r2=1.69
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2576&r2=1.2577
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/overload-const.cc.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/overload-const.exp.diff?cvsroot=src&r1=NONE&r2=1.1

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


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

* [Bug c++/12328] Can't set breakpoint on method taking const, non-reference/pointer scalar parameter
  2010-12-16 17:34 [Bug c++/12328] New: Ignore "const" for non-reference/pointer scalar keiths at redhat dot com
                   ` (6 preceding siblings ...)
  2011-02-13  9:16 ` cvs-commit at gcc dot gnu.org
@ 2011-02-13  9:24 ` jan.kratochvil at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-02-13  9:24 UTC (permalink / raw)
  To: gdb-prs

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

Jan Kratochvil <jan.kratochvil at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #8 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2011-02-13 09:24:45 UTC ---
Checked in.

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


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

end of thread, other threads:[~2011-02-13  9:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-16 17:34 [Bug c++/12328] New: Ignore "const" for non-reference/pointer scalar keiths at redhat dot com
2010-12-16 17:37 ` [Bug c++/12328] Can't set breakpoint on method taking const, non-reference/pointer scalar parameter keiths at redhat dot com
2010-12-16 17:47 ` keiths at redhat dot com
2010-12-17 17:03 ` thahn01@t-online.de
2010-12-17 23:13 ` keiths at redhat dot com
2011-01-17  7:13 ` jan.kratochvil at redhat dot com
2011-02-06 18:17 ` jan.kratochvil at redhat dot com
2011-02-13  9:16 ` cvs-commit at gcc dot gnu.org
2011-02-13  9:24 ` jan.kratochvil at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).