Bug 12803 - Regression: const/volatile method functions linespec `break'
Summary: Regression: const/volatile method functions linespec `break'
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: breakpoints (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: 7.3
Assignee: Keith Seitz
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-24 16:01 UTC by Jan Kratochvil
Modified: 2011-07-02 19:34 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2011-05-24 16:01:55 UTC
==> 8.h <==
class C {
public:
  void m () const;
  void n () volatile;
};
==> 8.C <==
#include "8.h"
C c;
int main () {
  c.m ();
  c.n ();
}
==> 8b.C <==
#include "8.h"
void C::m () const { }
void C::n () volatile { }

g++ -o 8b.o -c 8b.C -Wall; g++ -o 8 8.C 8b.o -Wall -g
# gcc-c++-4.6.0-7.fc15.x86_64

42284fdf9d8cdb20c8e833bdbdb2b56977fea525^ (pre-physname GDB)
(gdb) b 'C::m() const' 
Breakpoint 1 at 0x4004f8
(gdb) b 'C::n() volatile' 
Breakpoint 2 at 0x400502

42284fdf9d8cdb20c8e833bdbdb2b56977fea525 (physname GDB)
d55b1ed48098d6e48b569b5e123f2c7a8e2ea3f8 (FSF GDB HEAD)
(gdb) b 'C::m() const' 
the class C does not have any method named m() const
Hint: try 'C::m() const<TAB> or 'C::m() const<ESC-?>
(Note leading single quote.)
(gdb) b 'C::n() volatile' 
the class C does not have any method named n()
Hint: try 'C::n() volatile<TAB> or 'C::n() volatile<ESC-?>
(Note leading single quote.)

This is a physname regression.
Comment 1 Keith Seitz 2011-05-24 16:35:54 UTC
(In reply to comment #0)
> (gdb) b 'C::m() const' 
> the class C does not have any method named m() const
> Hint: try 'C::m() const<TAB> or 'C::m() const<ESC-?>
> (Note leading single quote.)
> (gdb) b 'C::n() volatile' 
> the class C does not have any method named n()
> Hint: try 'C::n() volatile<TAB> or 'C::n() volatile<ESC-?>
> (Note leading single quote.)

"break 'C::m() const'" does work, but you must "set lang c++" first. This is because keep_name_info in linespec.c is only called when the current language is set to c++. We could change this to unconditionally call this; from decode_compound, it should be relatively safe (assertion untested). What do you think?

The volatile case is a bug: keep_name_info does not include it. When it is added, then it works. I can prepare a patch and some tests for this.
Comment 2 Jan Kratochvil 2011-05-24 16:51:46 UTC
(In reply to comment #1)
> "break 'C::m() const'" does work, but you must "set lang c++" first.

Aha, again, OK.

> This is because keep_name_info in linespec.c is only called when the current
> language is set to c++. We could change this to unconditionally call this;
> from decode_compound, it should be relatively safe (assertion untested). What
> do you think?

Yes, I would prefer it, it was already so in pre-phys and getting current language correctly set does not always work.


> The volatile case is a bug: keep_name_info does not include it. When it is
> added, then it works. I can prepare a patch and some tests for this.

OK, thanks.
Comment 3 Keith Seitz 2011-05-24 17:04:41 UTC
(In reply to comment #1)
> "break 'C::m() const'" does work, but you must "set lang c++" first. This is
> because keep_name_info in linespec.c is only called when the current language
> is set to c++. We could change this to unconditionally call this; from
> decode_compound, it should be relatively safe (assertion untested). What do you
> think?

Actually, I was incorrect. keep_name_info is guarded in one place by the current language. There are other uses in decode_line_1 which are unguarded. keep_name_info does do some c++-specific things (keeping overload & template info), but I am unable to invent a specific case where this would interfere with C, and the test suite shows no regressions by removing this guard (linespec.c:1615).
Comment 4 Jan Kratochvil 2011-05-24 19:01:42 UTC
(In reply to comment #1)
> "break 'C::m() const'" does work, but you must "set lang c++" first.

But that still does not work for me, sorry for nodding it first.

(gdb) show language 
The current source language is "auto; currently c++".
(gdb) set language c++

tested with:
gcc-c++-4.6.0-7.fc15.x86_64
g++ (GCC) 4.7.0 20110524 (experimental)
g++ (GCC) 4.4.7 20110524 (prerelease)
Comment 5 Sourceware Commits 2011-05-24 21:00:14 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	kseitz@sourceware.org	2011-05-24 21:00:09

Modified files:
	gdb            : ChangeLog linespec.c 

Log message:
	PR breakpoint/12803
	* linespec.c (keep_name_info): Add handling for "volatile" keyword.
	(decode_compound): Unconditionally call	keep_name_info.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.13044&r2=1.13045
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/linespec.c.diff?cvsroot=src&r1=1.119&r2=1.120
Comment 6 Sourceware Commits 2011-05-24 21:00:50 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	kseitz@sourceware.org	2011-05-24 21:00:45

Modified files:
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.cp: cmpd-minsyms.cc cmpd-minsyms.exp 

Log message:
	PR breakpoint/12803
	* gdb.cp/cmpd-minsyms.cc (a): New method.
	(b): New method.
	(c): New method.
	* gdb.cp/cmpd-minsyms.exp: Add tests for new methods.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2723&r2=1.2724
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/cmpd-minsyms.cc.diff?cvsroot=src&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/cmpd-minsyms.exp.diff?cvsroot=src&r1=1.1&r2=1.2
Comment 7 Keith Seitz 2011-05-25 00:29:31 UTC
Fix committed. If I've missed anything, please re-open this bug.
Comment 8 Sourceware Commits 2011-07-02 19:34:48 UTC
CVSROOT:	/cvs/src
Module name:	src
Branch: 	gdb_7_3-branch
Changes by:	jkratoch@sourceware.org	2011-07-02 19:34:43

Modified files:
	gdb            : ChangeLog linespec.c 

Log message:
	commit 2bdc820adfead6aa7fdb16242280473af1040d4e
	Author: Keith Seitz <keiths@redhat.com>
	Date:   Tue May 24 21:00:04 2011 +0000
	
	gdb/
	PR breakpoint/12803
	* linespec.c (keep_name_info): Add handling for "volatile" keyword.
	(decode_compound): Unconditionally call	keep_name_info.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&only_with_tag=gdb_7_3-branch&r1=1.12887.2.45&r2=1.12887.2.46
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/linespec.c.diff?cvsroot=src&only_with_tag=gdb_7_3-branch&r1=1.117.2.1&r2=1.117.2.2