OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/tags/gnu-src/gdb-7.2/gdb-7.2-or32-1.0rc3/gdb/testsuite/gdb.cp
    from Rev 330 to Rev 513
    Reverse comparison

Rev 330 → Rev 513

/mb-inline1.cc
0,0 → 1,35
/* Test gdb support for setting file:line breakpoints on inline fns.
 
This testcase is part of GDB, the GNU debugger.
 
Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
 
#include "mb-inline.h"
 
int
afn ()
{
return foo (0) + multi_line_foo (0);
}
 
int
main ()
{
int a = afn ();
int b = bfn ();
return a * b;
}
/call-c.cc
0,0 → 1,46
/* This test script is part of GDB, the GNU debugger.
 
Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
 
int func(int x)
{
return x;
}
 
struct Foo {
Foo() : x_(1) { }
int func() const { return x_; }
private:
int x_;
};
 
typedef Foo *FooHandle;
 
extern "C" {
int foo(int);
}
 
int main()
{
Foo f;
Foo *pf = &f;
Foo* &rf = pf;
FooHandle handle = pf;
rf->func(); /* set breakpoint here */
foo(0);
return func(0);
}
/cttiadd2.cc
0,0 → 1,41
/* This testcase is part of GDB, the GNU debugger.
 
Copyright 1998, 1999, 2004, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
 
template<class T> T add2(T v1, T v2)
{
T v3;
v3 = v1;
v3 += v2;
return v3;
}
 
void subr2()
{
unsigned char c;
int i;
float f;
c = 'b';
i = 3;
f = 6.5;
 
c = add2(c, c);
i = add2(i, i);
f = add2(f, f);
}
/hang1.cc
0,0 → 1,6
#include "hang.H"
 
extern int dummy2 (void);
extern int dummy3 (void);
 
int main (int argc, char **argv) { return dummy2() + dummy3(); }
/abstract-origin.exp
0,0 → 1,31
# Copyright 2009, 2010 Free Software Foundation, Inc.
 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
set testfile abstract-origin
set srcfile ${testfile}.cc
if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] {
return -1
}
 
if ![runto_main] {
untested abstract-origin
return -1
}
 
gdb_breakpoint [gdb_get_line_number "break-here"]
gdb_continue_to_breakpoint "break-here"
 
# The Bug was: No symbol "problem" in current context.
gdb_test "p problem" " = \\(int \\*\\) 0x.*"
/local.exp
0,0 → 1,308
# Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009, 2010
# Free Software Foundation, Inc.
 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
# tests for local variables
# Written by Satish Pai <pai@apollo.hp.com> 1997-07-08
# Cleaned by Michael Chastain <mec@shout.net> 2002-04-08
 
 
# This file is part of the gdb testsuite
 
set ws "\[\r\n\t \]+"
set nl "\[\r\n\]+"
 
if $tracelevel then {
strace $tracelevel
}
 
#
# test running programs
#
 
if { [skip_cplus_tests] } { continue }
 
set testfile "local"
set srcfile ${testfile}.cc
set binfile ${objdir}/${subdir}/${testfile}
 
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
untested local.exp
return -1
}
 
if [get_compiler_info $binfile "c++"] {
return -1
}
 
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
 
 
#
# set it up at a breakpoint so we can play with the variable values
#
if ![runto_main] then {
perror "couldn't run to breakpoint"
continue
}
 
if ![runto 'marker1'] then {
perror "couldn't run to marker1"
continue
}
 
gdb_test "up" ".*foobar.*" "up from marker1"
 
set sep "(\[.\]|___)\[0-9\]"
 
# ptype on a local variable.
#
# This test has six arms. The first three arms accept normal output:
# no synthetic methods; synthetic methods before user methods;
# synthetic methods after user methods.
#
# The next two arms accept "foobar__Fi.0::Local" instead of "Local".
# This is a bug. It happens in various places with various versions of
# gcc and gdb and various debugging types.
#
# The last arm accepts the user methods in duplicate. This bug happens
# with gcc 3.3.2 -gdwarf-2, and has been fixed in gcc HEAD 2004-01-22.
#
# -- chastain 2004-01-24
 
set re_class "((struct|class) Local \{${ws}public:|struct Local \{)"
set re_fields "int loc1;"
set re_methods "char loc_foo\\(char\\);"
set re_synth_gcc_23 "Local & operator=\\(Local const ?&\\);${ws}Local\\(Local const ?&\\);${ws}Local\\((void|)\\);"
 
set XX_class "((struct|class) foobar__Fi.0::Local \{${ws}public:|struct foobar__Fi.0:Local \{)"
set XX_synth_gcc_2 "Local & operator=\\(foobar__Fi.0::Local const ?&\\);${ws}Local\\(foobar__Fi.0::Local const ?&\\);${ws}Local\\((void|)\\);"
set YY_methods "$re_methods${ws}$re_methods"
 
set name "ptype l"
gdb_test_multiple "ptype l" $name {
-re "type = $re_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
# gdb 6.0, gcc 2.95.3, dwarf-2
# gdb 6.0, gcc HEAD 2004-01-22, dwarf-2
# gdb HEAD 2004-01-23, gcc HEAD 2004-01,22, dwarf-2
pass "$name"
}
-re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23${ws}$re_methods$nl\}$nl$gdb_prompt $" {
# gdb 6.0, gcc 3.3.2, stabs+
# gdb HEAD 2004-01-23, gcc 3.3.2, stabs+
pass "$name"
}
-re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23${ws}$nl\}$nl$gdb_prompt $" {
# gdb 6.0, gcc HEAD 2004-01-22, stabs+
# gdb HEAD 2004-01-23, gcc HEAD 2004-01-22, stabs+
pass "$name"
}
-re "type = $XX_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
# gdb HEAD 2004-01-23, gcc 2.95.3, dwarf-2
kfail "gdb/1516" "$name"
}
-re "type = ($re_class|$XX_class)${ws}$re_fields${ws}($re_synth_gcc_23|$XX_synth_gcc_2)${ws}$re_methods$nl\}$nl$gdb_prompt $" {
# gdb 6.0, gcc 2.95.3, stabs+
# gdb HEAD 2004-01-23, gcc 2.95.3, stabs+
kfail "gdb/1516" "$name"
}
-re "type = ($re_class|$XX_class)${ws}$re_fields${ws}$YY_methods$nl\}$nl$gdb_prompt $" {
# gdb 6.0, gcc 3.3.2, dwarf-2
# gdb HEAD 2004-01-23, gcc 3.2.2, dwarf-2
kfail "gdb/483" "$name"
}
}
 
# This is the same test with "ptype Local" (the type name)
# instead of "ptype l" (the variable name).
 
set name "ptype Local"
gdb_test_multiple "ptype Local" $name {
-re "type = $re_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
# gdb 6.0, gcc 2.95.3, dwarf-2
# gdb 6.0, gcc HEAD 2004-01-22, dwarf-2
# gdb HEAD 2004-01-23, gcc HEAD 2004-01-22, dwarf-2
pass "$name"
}
-re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23${ws}$re_methods$nl\}$nl$gdb_prompt $" {
# gdb 6.0, gcc 3.3.2, stabs+
# gdb HEAD 2004-01-23, gcc 3.3.2, stabs+
pass "$name"
}
-re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23${ws}$nl\}$nl$gdb_prompt $" {
# gdb 6.0, gcc HEAD 2004-01-22, stabs+
# gdb HEAD 2004-01-23, gcc HEAD 2004-01-22, stabs+
pass "$name"
}
-re "type = $XX_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
kfail "gdb/1516" "$name"
}
-re "type = ($re_class|$XX_class)${ws}$re_fields${ws}($re_synth_gcc_23|$XX_synth_gcc_2)${ws}$re_methods$nl\}$nl$gdb_prompt $" {
# gdb 6.0, gcc 2.95.3, stabs+
# gdb HEAD 2004-01-23, gcc 2.95.3, stabs+
kfail "gdb/1516" "$name"
}
-re "type = ($re_class|$XX_class)${ws}$re_fields${ws}$YY_methods$nl\}$nl$gdb_prompt $" {
# gdb 6.0, gcc 3.3.2, dwarf-2
# gdb HEAD 2004-01-23, gcc 3.2.2, dwarf-2
kfail "gdb/483" "$name"
}
-re "No symbol \"Local\" in current context.$nl$gdb_prompt $" {
# gdb HEAD 2004-01-23, gcc 2.95.3, dwarf-2
fail "$name"
}
}
 
gdb_test "break marker2"
gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker2.*" \
"continuing to marker2"
 
gdb_test "up" ".*main.*" "up from marker2"
 
# Make sure that `Local' isn't in scope here; it's local to foobar.
# setup_kfail "gdb/825"
 
set eol "\[\t \]*\[\r\n\]+\[\t \]*"
gdb_test_multiple "ptype Local" "Local out of scope" {
-re "No symbol \"Local\" in current context.*${gdb_prompt} $" {
pass "Local out of scope"
}
-re "ptype Local${eol}type = class Local {${eol} public:${eol} int loc1;${eol}.*${eol} char loc_foo\\(char\\);${eol}}${eol}${gdb_prompt} " {
# GCC emits STABS debugging information in a way that doesn't
# properly preserve the scoping of local classes. I think
# we'd need to start using Sun's extensions to stabs to get
# this right.
kfail gdb/825 "Local out of scope"
}
-re "ptype Local${eol}type = class Local {${eol} public:${eol} int loc1;${eol} char loc_foo\\(char\\);${eol}.*${eol}}${eol}${gdb_prompt} " {
# gcc 3.X abi-2 -gstabs+
kfail gdb/825 "Local out of scope"
}
}
 
# DTS CLLbs14316 and CLLbs17058
# coulter - I added a clause for HP's aCC compiler. We print out the type
# as xx instead of const unsigned char, but we still have an expected failure
# because of two reasons:
# There is a number at the end of InnerLocal4 which should not be there,
# DTS CLLbs14316
# The line number for the class
# setup_xfail "hppa*-*-*" CLLbs14316
 
# ---
# Pattern 1:
# PASS
# dwarf-2
# 2.95.3, 2.96-rh, 3.0.4, 3.1, gcc-3_1-branch, HEAD
#
# Pattern 2:
# PASS
# stabs+
# 2.95.3, 2.96-rh, 3.0.4, 3.1, gcc-3_1-branch, HEAD
#
# Pattern 3:
# Old hppa pattern.
#
# Pattern 4:
# Old hppa pattern.
#
# chastain 2002-05-27
 
# Pattern 5:
# PASS
# stabs+
# HEAD
#
# chastain 2004-01-02
 
gdb_test_multiple "ptype InnerLocal" "ptype InnerLocal" {
-re "type = class InnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*char ilc;\[\r\n\t \]*int \\* *ip;\[\r\n\t \]*(InnerLocal::|)NestedInnerLocal nest1;\[\r\n\t \]*int il_foo\\((unsigned char const|const unsigned char) *&\\);\[\r\n\t \]*\}.*$gdb_prompt $" {
pass "ptype InnerLocal (pattern 1)"
}
-re "type = class InnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*char ilc;\[\r\n\t \]*int \\* *ip;\[\r\n\t \]*(InnerLocal::|)NestedInnerLocal nest1;\[\r\n\t \]*InnerLocal *& operator *=\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((void|)\\);\[\r\n\t \]*int il_foo\\(unsigned char const *&\\);\[\r\n\t \]*\}.*$gdb_prompt $" {
pass "ptype InnerLocal (pattern 2)"
}
-re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*InnerLocal::NestedInnerLocal nest1;\r\n\r\n\[\t \]*.int il_foo\\(unsigned char const &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:36\\).*$gdb_prompt $" {
pass "ptype InnerLocal (old HP aCC)"
}
-re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*class InnerLocal4::NestedInnerLocal nest1;\r\n\r\n\[\t \]*int il_foo\\(unsigned char const &\\);\r\n\[\t \]*\\(Local at.*local\.cc:\[0-9\]+\\)\r\n\}.*$gdb_prompt $" {
pass "ptype InnerLocal (old HP aCC)"
}
-re "type = class InnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*char ilc;\[\r\n\t \]*int \\* *ip;\[\r\n\t \]*(InnerLocal::|)NestedInnerLocal nest1;\[\r\n\t \]* int il_foo\\(unsigned char const *&\\);\[\r\n\t \]*InnerLocal *& operator *=\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((void|)\\);\[\r\n\t \]*\}.*$gdb_prompt $" {
pass "ptype InnerLocal (pattern 5)"
}
}
 
#---
# Pattern 1:
# PASS
# dwarf-2
# gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
#
# Pattern 2:
# PASS
# stabs+
# gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
#
# chastain 2002-04-08
 
# NOTE (2004-02-24, carlton): This test really is invalid -
# 'NestedInnerLocal' shouldn't be visible, so only the third
# expression should count as a pass. I'm leaving in the earlier
# passes, however, given the current problematic state of our local
# class support, but once we fix PR gdb/482, we should delete this
# test.
 
gdb_test_multiple "ptype NestedInnerLocal" "ptype NestedInnerLocal" {
-re "type = class NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" {
pass "ptype NestedInnerLocal"
}
-re "type = class NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*NestedInnerLocal *& *operator *= *\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((void|)\\);\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" {
pass "ptype NestedInnerLocal"
}
-re "No symbol \"NestedInnerLocal\" in current context\.\r\n$gdb_prompt $" {
pass "ptype NestedInnerLocal"
}
}
 
set re_class "((struct|class) InnerLocal::NestedInnerLocal \{${ws}public:|struct InnerLocal::NestedInnerLocal \{)"
set re_fields "int nil;"
set re_methods "int nil_foo\\(int\\);"
set re_synth_gcc_23 "InnerLocal::NestedInnerLocal & operator=\\(InnerLocal::NestedInnerLocal const ?&\\);${ws}NestedInnerLocal\\(InnerLocal::NestedInnerLocal const ?&\\);${ws}NestedInnerLocal\\(\\);"
 
set name "ptype InnerLocal::NestedInnerLocal"
gdb_test_multiple "ptype InnerLocal::NestedInnerLocal" $name {
-re "type = $re_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
# gcc -gdwarf-2 should produce this but does not yet
pass $name
}
-re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23${ws}$re_methods${ws}$nl\}$nl$gdb_prompt $" {
# gcc 2.95.3 -gstabs+
# gcc v3 -gstabs+, abi 1
pass $name
}
-re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23${ws}$nl\}$nl$gdb_prompt $" {
# gcc v3 -gstabs+, abi 2
pass $name
}
-re "There is no field named NestedInnerLocal.*$gdb_prompt $" {
# gcc v3 -gdwarf-2
kfail "gdb/482" $name
}
}
/m-static1.cc
0,0 → 1,5
// 2002-08-16
 
#include "m-static.h"
 
const int gnu_obj_4::elsewhere = 221;
/ambiguous.exp
0,0 → 1,233
# Copyright 1998, 1999, 2003, 2004, 2007, 2008, 2009, 2010
# Free Software Foundation, Inc.
 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
# This file is part of the gdb testsuite
 
# tests relating to ambiguous class members
# Written by Satish Pai <pai@apollo.hp.com> 1997-07-28
 
# This file is part of the gdb testsuite
 
if $tracelevel then {
strace $tracelevel
}
 
#
# test running programs
#
 
 
if { [skip_cplus_tests] } { continue }
 
set testfile "ambiguous"
set srcfile ${testfile}.cc
set binfile ${objdir}/${subdir}/${testfile}
 
if [get_compiler_info ${binfile} "c++"] {
return -1;
}
 
if { [test_compiler_info gcc-*] } then { continue }
 
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
untested ambiguous.exp
return -1
}
 
 
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
 
 
#
# set it up at a breakpoint so we can play with the variable values
#
if ![runto_main] then {
perror "couldn't run to breakpoint"
continue
}
 
send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
send_gdb "cont\n"
gdb_expect {
-re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
send_gdb "up\n"
gdb_expect {
-re ".*$gdb_prompt $" { pass "up from marker1" }
timeout { fail "up from marker1" }
}
}
-re "$gdb_prompt $" { fail "continue to marker1" }
timeout { fail "(timeout) continue to marker1" }
}
 
# print out various class objects' members. The values aren't
# important, just check that the warning is emitted at the
# right times.
 
# X is derived from A1 and A2; both A1 and A2 have a member 'x'
send_gdb "print x.x\n"
gdb_expect {
-re "warning: x ambiguous; using X::A2::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
pass "print x.x"
}
-re "warning: x ambiguous; using X::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
pass "print x.x"
}
-re ".*$gdb_prompt $" { fail "print x.x" }
timeout { fail "(timeout) print x.x" }
}
 
 
# N is derived from A1 and A2, but not immediately -- two steps
# up in the hierarchy. Both A1 and A2 have a member 'x'.
send_gdb "print n.x\n"
gdb_expect {
-re "warning: x ambiguous; using N::M::A2::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
pass "print n.x"
}
-re "warning: x ambiguous; using N::L::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
pass "print n.x"
}
-re ".*$gdb_prompt $" { fail "print n.x" }
timeout { fail "(timeout) print n.x" }
}
 
# J is derived from A1 twice. A1 has a member x.
send_gdb "print j.x\n"
gdb_expect {
-re "warning: x ambiguous; using J::L::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
pass "print j.x"
}
-re "warning: x ambiguous; using J::K::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
pass "print j.x"
}
-re ".*$gdb_prompt $" { fail "print j.x" }
timeout { fail "(timeout) print j.x" }
}
 
# JV is derived from A1 but A1 is a virtual base. Should not
# report an ambiguity in this case.
send_gdb "print jv.x\n"
gdb_expect {
-re "warning: x ambiguous.*Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
fail "print jv.x (ambiguity reported)"
}
-re "\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { pass "print jv.x" }
-re ".*$gdb_prompt $" { fail "print jv.x (??)" }
timeout { fail "(timeout) print jv.x" }
}
 
# JVA1 is derived from A1; A1 occurs as a virtual base in two
# ancestors, and as a non-virtual immediate base. Ambiguity must
# be reported.
send_gdb "print jva1.x\n"
gdb_expect {
-re "warning: x ambiguous; using JVA1::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
pass "print jva1.x"
}
-re "warning: x ambiguous; using JVA1::KV::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
pass "print jva1.x"
}
-re ".*$gdb_prompt $" { fail "print jva1.x" }
timeout { fail "(timeout) print jva1.x" }
}
 
# JVA2 is derived from A1 & A2; A1 occurs as a virtual base in two
# ancestors, and A2 is a non-virtual immediate base. Ambiguity must
# be reported as A1 and A2 both have a member 'x'.
send_gdb "print jva2.x\n"
gdb_expect {
-re "warning: x ambiguous; using JVA2::A2::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
pass "print jva2.x"
}
-re "warning: x ambiguous; using JVA2::KV::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
pass "print jva2.x"
}
-re ".*$gdb_prompt $" { fail "print jva2.x" }
timeout { fail "(timeout) print jva2.x" }
}
 
# JVA1V is derived from A1; A1 occurs as a virtual base in two
# ancestors, and also as a virtual immediate base. Ambiguity must
# not be reported.
send_gdb "print jva1v.x\n"
gdb_expect {
-re "warning: x ambiguous.*Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
fail "print jva1v.x (ambiguity reported)"
}
-re "\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" { pass "print jva1v.x" }
-re ".*$gdb_prompt $" { fail "print jva1v.x (??)" }
timeout { fail "(timeout) print jva1v.x" }
}
 
# Now check for ambiguous bases.
 
# J is derived from A1 twice; report ambiguity if a J is
# cast to an A1.
send_gdb "print (A1)j\n"
gdb_expect {
-re "warning: A1 ambiguous; using J::L::A1. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" {
pass "print (A1)j"
}
-re "warning: A1 ambiguous; using J::K::A1. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" {
pass "print (A1)j"
}
-re ".*$gdb_prompt $" { fail "print (A1)j" }
timeout { fail "(timeout) print (A1)j" }
}
 
# JV is derived from A1 twice, but A1 is a virtual base; should
# not report ambiguity when a JV is cast to an A1.
send_gdb "print (A1)jv\n"
gdb_expect {
-re "warning: A1 ambiguous.*Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" {
fail "print (A1)jv (ambiguity reported)"
}
-re "\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" { pass "print (A1)jv" }
-re ".*$gdb_prompt $" { fail "print (A1)jv (??)" }
timeout { fail "(timeout) print (A1)jv" }
}
 
# JVA1 is derived from A1; A1 is a virtual base and also a
# non-virtual base. Must report ambiguity if a JVA1 is cast to an A1.
send_gdb "print (A1)jva1\n"
gdb_expect {
-re "warning: A1 ambiguous; using JVA1::A1. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" {
pass "print (A1)jva1"
}
-re "warning: A1 ambiguous; using JVA1::KV::A1. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" {
pass "print (A1)jva1"
}
-re ".*$gdb_prompt $" { fail "print (A1)jva1" }
timeout { fail "(timeout) print (A1)jva1" }
}
 
# JVA1V is derived from A1; A1 is a virtual base indirectly
# and also directly; must not report ambiguity when a JVA1V is cast to an A1.
send_gdb "print (A1)jva1v\n"
gdb_expect {
-re "warning: A1 ambiguous.*Use a cast to disambiguate.\r\n\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" {
fail "print (A1)jva1v (ambiguity reported)"
}
-re "\\$\[0-9\]* = \{x = \[-\]*\[0-9\]*, y = \[-\]*\[0-9\]*\}\r\n$gdb_prompt $" { pass "print (A1)jva1v"
}
-re ".*$gdb_prompt $" { fail "print (A1)jva1v (??)" }
timeout { fail "(timeout) print (A1)jva1v" }
}
 
/bool.exp
0,0 → 1,49
# Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@gnu.org
 
# This file is part of the gdb testsuite.
 
if $tracelevel then {
strace $tracelevel
}
 
# Test returning bool.
 
if { [skip_cplus_tests] } { continue }
 
 
set testfile "bool"
set srcfile ${testfile}.cc
set binfile ${objdir}/${subdir}/${testfile}
 
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
untested bool.exp
return -1
}
 
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
 
runto_main
 
# Testcases for tdep/2075.
 
gdb_test "print return_true()" "\\$.* = true"
gdb_test "print return_false()" "\\$.* = false"
/namespace.exp
0,0 → 1,285
# Copyright 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009, 2010
# Free Software Foundation, Inc.
 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
# tests for namespaces
# Originally written by Satish Pai <pai@apollo.hp.com> 1997-07-23
 
# This file is part of the gdb testsuite
 
# Note: The original tests were geared to the HP aCC compiler,
# which has an idiosyncratic way of emitting debug info
# for namespaces.
# Note: As of 2000-06-03, they passed under g++ - djb
 
 
if $tracelevel then {
strace $tracelevel
}
 
 
if { [skip_cplus_tests] } { continue }
 
set testfile "namespace"
set srcfile ${testfile}.cc
set objfile ${objdir}/${subdir}/${testfile}.o
set srcfile1 ${testfile}1.cc
set objfile1 ${objdir}/${subdir}/${testfile}1.o
set binfile ${objdir}/${subdir}/${testfile}
 
if [get_compiler_info ${binfile} c++] {
return -1;
}
 
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug c++}] != "" } {
untested namespace.exp
return -1
}
 
if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${objfile1}" object {debug c++}] != "" } {
untested namespace.exp
return -1
}
 
if { [gdb_compile "${objfile} ${objfile1}" "${binfile}" executable {debug c++}] != "" } {
untested namespace.exp
return -1
}
 
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
 
 
#
# set it up at a breakpoint so we can play with the variable values
#
if ![runto_main] then {
perror "couldn't run to breakpoint"
continue
}
 
if ![runto 'marker1'] then {
perror "couldn't run to marker1"
continue
}
 
gdb_test "up" ".*main.*" "up from marker1"
 
# Access a data item inside a namespace using colons and
# single quotes. :-(
 
# NOTE: carlton/2003-09-24: the quotes are becoming less necessary (or
# even desirable.) For tests where it should still work with quotes,
# I'm including versions both with and without quotes; for tests that
# shouldn't work with quotes, I'm only including one version.
 
gdb_test "print 'AAA::c'" \
"\\$\[0-9\]* = 0 '\\\\(0|000)'" \
"print 'AAA::c'"
 
gdb_test "print AAA::c" \
"\\$\[0-9\]* = 0 '\\\\(0|000)'" \
"print AAA::c"
 
# An object declared using "using".
 
gdb_test "print ina" "\\$\[0-9\]+ = {xx = 33}"
 
gdb_test_multiple "ptype ina" "ptype ina" {
-re "type = class (AAA::|)inA \{\r\n\[ \]*public:\r\n\[ \]*int xx;\r\n\[ \]*\r\n\[ \]*.*int fum\\(int\\);\r\n\}\r\n$gdb_prompt $" {
pass "ptype ina"
}
-re "type = class (AAA::|)inA \{\r\n\[ \]*public:\r\n\[ \]*int xx;\r\n\[ \]*\r\n\[ \]*int fum\\(int\\);\r\n.*\}\r\n$gdb_prompt $" {
pass "ptype ina"
}
}
 
# Check all functions are known to GDB
 
setup_xfail hppa*-*-*11* CLLbs14869
gdb_test_multiple "info func xyzq" "info func xyzq" {
-re "All functions.*File.*namespace.cc:\r\nint AAA::A_xyzq\\(int\\);\r\nint BBB::B_xyzq\\(int\\);\r\nchar AAA::xyzq\\(char\\);\r\nchar BBB::xyzq\\(char\\);\r\nchar BBB::CCC::xyzq\\(char\\);\r\nchar BBB::Class::xyzq\\(char\\);\r\n$gdb_prompt $" {
pass "info func xyzq"
}
-re "All functions.*File.*namespace.cc:\r\nint AAA::A_xyzq\\(int\\);\r\nchar AAA::xyzq\\(char\\);\r\nint BBB::B_xyzq\\(int\\);\r\nchar BBB::CCC::xyzq\\(char\\);\r\nchar BBB::Class::xyzq\\(char\\);\r\nchar BBB::xyzq\\(char\\);\r\n$gdb_prompt $" {
pass "info func xyzq"
}
}
 
# Call a function in a namespace
 
gdb_test "print 'AAA::xyzq'('x')" \
"\\$\[0-9\]* = 97 'a'" \
"print 'AAA::xyzq'('x')"
 
gdb_test "print AAA::xyzq('x')" \
"\\$\[0-9\]* = 97 'a'" \
"print AAA::xyzq('x')"
# Break on a function in a namespace
 
gdb_test "break AAA::xyzq" \
"Breakpoint.*at $hex: file.*namespace.cc, line 47\\."
 
# Call a function in a nested namespace
 
gdb_test "print 'BBB::CCC::xyzq'('x')" \
"\\$\[0-9\]* = 122 'z'" \
"print 'BBB::CCC::xyzq'('x')"
 
gdb_test "print BBB::CCC::xyzq('x')" \
"\\$\[0-9\]* = 122 'z'" \
"print BBB::CCC::xyzq('x')"
# Break on a function in a nested namespace
 
gdb_test "break BBB::CCC::xyzq" \
"Breakpoint.*at $hex: file.*namespace.cc, line 63\\."
 
# Print address of a function in a class in a namespace
 
gdb_test "print 'BBB::Class::xyzq'" \
"\\$\[0-9\]* = \{char \\((BBB::|)Class \\*( const|), (char|int)\\)\} $hex <BBB::Class::xyzq\\(char\\)>" \
"print 'BBB::Class::xyzq'"
 
gdb_test "print BBB::Class::xyzq" \
"\\$\[0-9\]* = \{char \\((BBB::|)Class \\*( const|), (char|int)\\)\} $hex <BBB::Class::xyzq\\(char\\)>" \
"print BBB::Class::xyzq"
 
# Break on a function in a class in a namespace
 
gdb_test "break BBB::Class::xyzq" \
"Breakpoint.*at $hex: file.*namespace.cc, line 68\\."
 
# Tests accessing static elements in namespace of other file.
 
gdb_test "whatis C::cOtherFileType" "type = short"
gdb_test "whatis ::C::cOtherFileType" "type = short"
gdb_test "whatis C::cOtherFileVar" "type = const C::cOtherFileType"
gdb_test "whatis ::C::cOtherFileVar" "type = const C::cOtherFileType"
gdb_test "print C::cOtherFileVar" "\\$\[0-9\].* = 319"
gdb_test "print ::C::cOtherFileVar" "\\$\[0-9\].* = 319"
 
if {[test_compiler_info {gcc-[0-3]-*}]
|| [test_compiler_info {gcc-4-[0-4]-*}]} {
# The type in class is missing in older GCCs.
setup_xfail *-*-*
}
gdb_test "whatis C::OtherFileClass::cOtherFileClassType" "type = short"
if {[test_compiler_info {gcc-[0-3]-*}]
|| [test_compiler_info {gcc-4-[0-4]-*}]} {
# The type in class is missing in older GCCs.
setup_xfail *-*-*
}
gdb_test "whatis ::C::OtherFileClass::cOtherFileClassType" "type = short"
gdb_test "print C::OtherFileClass::cOtherFileClassVar" " = 318"
 
# FSF GCC <=4.4 creates unqualified DIE "cOtherFileClassVar" ignoring the
# namespace the same way older GDB did.
set test "print ::cOtherFileClassVar"
set test2 "print ::C::OtherFileClass::cOtherFileClassVar"
gdb_test_multiple $test $test {
-re "No symbol \"cOtherFileClassVar\" in current context\\.\r\n$gdb_prompt $" {
pass $test
 
gdb_test $test2 " = 318"
}
-re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" {
if {[test_compiler_info {gcc-[0-3]-*}]
|| [test_compiler_info {gcc-4-[0-4]-*}]} {
# Do not permit to XFAIL on recent GCCs.
setup_xfail *-*-*
}
fail $test
 
unresolved $test2
}
}
 
# Test to see if the appropriate namespaces are in scope when trying
# to print out stuff from within a function defined within a
# namespace.
 
if ![runto "C::D::marker2"] then {
perror "couldn't run to marker2"
continue
}
 
gdb_test "print c" "\\$\[0-9\].* = 1"
gdb_test "print cc" "No symbol \"cc\" in current context."
gdb_test "print 'C::cc'" "\\$\[0-9\].* = 2"
gdb_test "print C::cc" "\\$\[0-9\].* = 2"
gdb_test "print cd" "\\$\[0-9\].* = 3"
gdb_test "print C::D::cd" "No type \"D\" within class or namespace \"C::C\"."
gdb_test "print 'E::cde'" "\\$\[0-9\].* = 5"
gdb_test "print E::cde" "\\$\[0-9\].* = 5"
gdb_test "print shadow" "\\$\[0-9\].* = 13"
gdb_test "print E::ce" "No symbol \"ce\" in namespace \"C::D::E\"."
gdb_test "ptype C" "type = namespace C::C"
gdb_test "ptype E" "type = namespace C::D::E"
 
gdb_test "ptype CClass" "type = (class C::CClass \{\r\n public:|struct C::CClass \{)\r\n int x;\r\n\}"
gdb_test "ptype CClass::NestedClass" "type = (class C::CClass::NestedClass \{\r\n public:|struct C::CClass::NestedClass \{)\r\n int y;\r\n\}"
gdb_test "ptype NestedClass" "No symbol \"NestedClass\" in current context."
gdb_test "ptype ::C::CClass" "type = class C::CClass \{\r\n public:\r\n int x;\r\n\}"
gdb_test "ptype ::C::CClass::NestedClass" "type = class C::CClass::NestedClass \{\r\n public:\r\n int y;\r\n\}"
gdb_test "ptype ::C::NestedClass" "No symbol \"NestedClass\" in namespace \"C\"."
gdb_test "ptype C::CClass" "No symbol \"CClass\" in namespace \"C::C\"."
gdb_test "ptype C::CClass::NestedClass" "No type \"CClass\" within class or namespace \"C::C\"."
gdb_test "ptype C::NestedClass" "No symbol \"NestedClass\" in namespace \"C::C\"."
 
# Tests involving multiple files
 
gdb_test "print cOtherFile" "\\$\[0-9\].* = 316"
gdb_test "ptype OtherFileClass" "type = (class C::OtherFileClass \{\r\n public:|struct C::OtherFileClass \{)\r\n int z;\r\n.*\}"
gdb_test "ptype ::C::OtherFileClass" "type = class C::OtherFileClass \{\r\n public:\r\n int z;\r\n.*\}"
gdb_test "ptype C::OtherFileClass" "No symbol \"OtherFileClass\" in namespace \"C::C\"."
 
# Test class typedefs printing.
set expect "type = class C::OtherFileClass \{\r\n.*\r\n *typedef short cOtherFileClassType;\r\n *typedef long cOtherFileClassType2;\r\n\}"
if {[test_compiler_info {gcc-[0-3]-*}]
|| [test_compiler_info {gcc-4-[0-4]-*}]} {
# The type in class is missing in older GCCs.
setup_xfail *-*-*
}
gdb_test "ptype OtherFileClass" $expect "ptype OtherFileClass typedefs"
if {[test_compiler_info {gcc-[0-3]-*}]
|| [test_compiler_info {gcc-4-[0-4]-*}]} {
# The type in class is missing in older GCCs.
setup_xfail *-*-*
}
gdb_test "ptype ::C::OtherFileClass" $expect "ptype ::C::OtherFileClass typedefs"
 
# Some anonymous namespace tests.
 
gdb_test "print cX" "\\$\[0-9\].* = 6"
gdb_test "print 'F::cXf'" "\\$\[0-9\].* = 7"
gdb_test "print F::cXf" "\\$\[0-9\].* = 7"
gdb_test "print F::cXfX" "\\$\[0-9\].* = 8"
gdb_test "print X" "\\$\[0-9\].* = 9"
gdb_test "print 'G::Xg'" "\\$\[0-9\].* = 10"
gdb_test "print G::Xg" "\\$\[0-9\].* = 10"
gdb_test "print G::XgX" "\\$\[0-9\].* = 11"
gdb_test "print cXOtherFile" "No symbol \"cXOtherFile\" in current context."
gdb_test "print XOtherFile" "No symbol \"XOtherFile\" in current context."
 
# Enum tests.
gdb_test "print AAA::ALPHA" "\\$\[0-9\].* = AAA::ALPHA"
 
# Regression tests for PR 9496.
gdb_test "whatis ::C::CClass::NestedClass" "type = C::CClass::NestedClass"
gdb_test "whatis ::C::CClass::NestedClass *" "type = C::CClass::NestedClass \\*"
/cpcompletion.exp
0,0 → 1,103
# Copyright 2009, 2010 Free Software Foundation, Inc.
 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
# This file is part of the gdb testsuite.
 
# A helper procedure to test location completions restricted by
# class.
proc test_class_complete {class expr name matches} {
global gdb_prompt
 
set matches [lsort $matches]
set cmd "complete break ${class}::$expr"
set seen {}
gdb_test_multiple $cmd $name {
"break ${class}::main" { fail "$name (saw global symbol)" }
$cmd { exp_continue }
-re "break ${class}::\[A-Za-z0-9_~\]+" {
set str $expect_out(0,string)
scan $str "break ${class}::%\[^(\]" method
lappend seen $method
exp_continue
}
-re "$gdb_prompt $" {
set failed ""
foreach got [lsort $seen] have $matches {
if {![string equal $got $have]} {
set failed $have
break
}
}
if {[string length $failed] != 0} {
fail "$name ($failed not found)"
} else {
pass $name
}
}
}
}
 
if $tracelevel then {
strace $tracelevel
}
 
if { [skip_cplus_tests] } { continue }
 
set testfile pr9594
set binfile ${objdir}/${subdir}/${testfile}
 
if {[gdb_compile "${srcdir}/${subdir}/${testfile}.cc" "${testfile}.o" object {c++ debug}] != ""} {
untested cpcompletion.exp
return -1
}
 
if {[gdb_compile "${testfile}.o" ${binfile} executable {c++ debug}] != "" } {
untested cpcompletion.exp
return -1
}
 
gdb_exit
 
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
 
set bp_location [gdb_get_line_number "Set breakpoint here" ${testfile}.cc]
 
if {![runto "${testfile}.cc:$bp_location"]} {
perror "test suppressed"
return
}
 
# This also tests inheritance -- completion should only see a single
# "get_foo".
gdb_test "complete p foo1.g" "p foo1\\.get_foo"
 
# Test inheritance without overriding.
gdb_test "complete p foo1.base" "p foo1\\.base_function_only"
 
# Test non-completion of constructor names.
gdb_test "complete p foo1.Fo" "p foo1\\.Foofoo"
 
# Test completion with an anonymous struct.
gdb_test "complete p a.g" "p a\\.get"
 
# Test that completion is restricted by class name (all methods)
test_class_complete Foo "" "complete class methods" \
[list Foo Foofoo get_foo set_foo ~Foo]
 
test_class_complete Foo F "complete class methods beginning with F" \
[list Foo Foofoo]
 
/nsrecurs.cc
0,0 → 1,57
namespace A
{
int ax = 9;
}
 
namespace B
{
using namespace A;
}
 
namespace C
{
using namespace B;
}
 
using namespace C;
 
//---------------
namespace D
{
using namespace D;
int dx = 99;
}
using namespace D;
 
//---------------
namespace
{
namespace
{
int xx = 999;
}
}
 
//---------------
namespace E
{
int ex = 9999;
}
 
namespace F
{
namespace FE = E;
}
 
namespace G
{
namespace GF = F;
}
 
//----------------
int main ()
{
using namespace D;
namespace GX = G;
return ax + dx + xx + G::GF::FE::ex;
}
/nsdecl.cc
0,0 → 1,93
int a;
int b;
int c;
int d;
int e;
int f;
int g;
int h;
int i;
int j;
int k;
int l;
int m;
int n;
int o;
int p;
int q;
int r;
int s;
int t;
int u;
int v;
int w;
int x;
int y;
int z;
 
namespace A
{
int xyz;
 
using ::a;
using ::b;
using ::c;
using ::d;
using ::e;
using ::f;
using ::g;
using ::h;
using ::i;
using ::j;
using ::k;
using ::l;
using ::m;
using ::n;
using ::o;
using ::p;
using ::q;
using ::r;
using ::s;
using ::t;
using ::u;
using ::v;
using ::w;
using ::x;
using ::y;
using ::z;
 
}
 
using A::a;
using A::b;
using A::c;
using A::d;
using A::e;
using A::f;
using A::g;
using A::h;
using A::i;
using A::j;
using A::k;
using A::l;
using A::m;
using A::n;
using A::o;
using A::p;
using A::q;
using A::r;
using A::s;
using A::t;
using A::u;
using A::v;
using A::w;
using A::x;
using A::y;
using A::z;
 
using namespace A;
 
int main ()
{
return 0;
}
/pr-1210.exp
0,0 → 1,74
# Copyright 2003, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
# Tests for PR gdb/1210.
 
# This file is part of the gdb testsuite.
 
if $tracelevel then {
strace $tracelevel
}
 
if { [skip_cplus_tests] } { continue }
 
#
# test running programs
#
 
set testfile "pr-1210"
set srcfile ${testfile}.cc
set binfile ${objdir}/${subdir}/${testfile}
 
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
untested pr-1210.exp
return -1
}
 
if [get_compiler_info ${binfile} "c++"] {
return -1
}
 
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
 
if ![runto_main] then {
perror "couldn't run to breakpoint"
continue
}
 
gdb_test "next" ".*return 0;" "step past initialization"
 
gdb_test_multiple "print *obj" "print *obj" {
-re "Cannot access memory.*$gdb_prompt $" {
fail "print *obj"
}
-re " = {<A> = {<No data fields>}, myB = {<A> = {<No data fields>}.*}}\r\n$gdb_prompt $" {
pass "print *obj"
}
}
 
gdb_test_multiple "print obj->myB" "print obj->myB" {
-re "Cannot access memory.*$gdb_prompt $" {
fail "print obj->myB"
}
-re " = {<A> = {<No data fields>}.*}\r\n$gdb_prompt $" {
pass "print obj->myB"
}
}
 
gdb_exit
return 0
/m-data.exp
0,0 → 1,117
# Copyright 2002, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
# Tests for member data
# 2002-05-13 Benjamin Kosnik <bkoz@redhat.com>
 
# This file is part of the gdb testsuite
 
if $tracelevel then {
strace $tracelevel
}
 
if { [skip_cplus_tests] } { continue }
 
#
# test running programs
#
 
set testfile "m-data"
set srcfile ${testfile}.cc
set binfile ${objdir}/${subdir}/${testfile}
 
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
untested m-data.exp
return -1
}
 
if [get_compiler_info ${binfile} "c++"] {
return -1
}
 
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
 
 
if ![runto_main] then {
perror "couldn't run to breakpoint"
continue
}
 
# First, run to after we've constructed all the gnu_obj_N's:
 
gdb_breakpoint [gdb_get_line_number "first-constructs-done"]
gdb_continue_to_breakpoint "end of first constructors"
 
# One.
 
# simple object, const bool
gdb_test "print test1.test" "\\$\[0-9\]* = true" "simple object, const bool"
 
# simple object, const int
gdb_test "print test1.key1" "\\$\[0-9\]* = 5" "simple object, const int"
 
# simple object, long
gdb_test "print test1.key2" "\\$\[0-9\]* = 4589" "simple object, long"
 
# simple object, enum
gdb_test "print test1.value" "\\$\[0-9\]* = egyptian" "simple object, enum"
 
# Two.
 
# derived template object, base const bool
gdb_test "print test2.test" "\\$\[0-9\]* = true" "derived template object, base const bool"
 
# derived template object, base const int
gdb_test "print test2.key1" "\\$\[0-9\]* = 5" "derived template object, base const int"
 
# derived template object, base long
gdb_test "print test2.key2" "\\$\[0-9\]* = 7" "derived template object, base long"
 
# derived template object, base enum
gdb_test "print test2.value" "\\$\[0-9\]* = oriental" "derived template object, base enum"
 
# derived template object, enum
gdb_test "print test2.value_derived" "\\$\[0-9\]* = roman" "derived template object, derived enum"
 
# Three.
 
# template object, derived template data member's base const bool
gdb_test "print test3.data.test" "\\$\[0-9\]* = true" "template object, const bool"
 
# template object, derived template data member's base const int
gdb_test "print test3.data.key1" "\\$\[0-9\]* = 5" "template object, const int"
 
# template object, derived template data member's base long
gdb_test "print test3.data.key2" "\\$\[0-9\]* = 7" "template object, long"
 
# template object, derived template data member's base enum
gdb_test "print test3.data.value" "\\$\[0-9\]* = oriental" "template object, base enum"
 
# template object, derived template data member's enum
gdb_test "print test3.data.value_derived" "\\$\[0-9]\* = etruscan" "template object, derived enum"
 
# Now some tests for shadowing (see PR gdb/804):
 
gdb_breakpoint "C::marker"
gdb_continue_to_breakpoint "continue to shadow breakpoint"
 
gdb_test "print shadow" "\\$\[0-9]\* = 1" "shadowing member"
gdb_test "print ::shadow" "\\$\[0-9]\* = 0" "shadowed global variable"
 
gdb_exit
return 0
/koenig.cc
0,0 → 1,306
namespace A
{
class C
{
public:
static const int x = 11;
};
 
int
first (C c)
{
return 11;
}
 
int
first (int a, C c)
{
return 22;
}
 
int
second (int a, int b, C cc, int c, int d)
{
return 33;
}
 
}
 
struct B
{
A::C c;
};
 
//------------
 
namespace E
{
class O{};
int foo (O o){return 1; }
int foo (O o, O o2){return 2; }
int foo (O o, O o2, int i){return 3; }
}
 
namespace F
{
class O{};
int foo ( O fo, ::E::O eo){ return 4;}
int foo (int i, O fo, ::E::O eo){ return 5;}
}
 
namespace G
{
class O{};
int foo (O go, ::F::O fo, ::E::O eo){ return 6; }
}
 
//------------
 
namespace H
{
class O{};
int foo (O){ return 7;}
}
 
namespace I
{
class O: public H::O {};
class X: H::O{};
}
 
//------------
 
namespace J
{
union U{};
struct S{};
enum E{};
 
class A{
public:
class B{};
};
 
class C{};
 
int foo (U){ return 8;}
int foo (S){ return 9;}
int foo (E){ return 10;}
int foo (A::B){ return 11;}
int foo (A*){ return 12;}
int foo (A**){ return 13;}
int foo (C[]){ return 14;}
 
}
//------------
 
namespace K{
class O{};
 
int foo(O, int){
return 15;
}
 
int bar(O, int){
return 15;
}
}
 
int foo(K::O, float){
return 16;
}
 
int bar(K::O, int){
return 16;
}
//------------
 
namespace L {
namespace A{
namespace B{
class O {};
 
int foo (O){
return 17;
}
 
}
}
}
 
//------------
 
namespace M {
class A{
public:
int foo(char) {
return 18;
}
};
 
int foo(A,char){
return 19;
}
 
int foo(A *,char){
return 23;
}
 
int bar(char){
return 21;
}
 
namespace N {
int foo(::M::A,int){
return 20;
}
 
int bar(int){
return 22;
}
}
}
//------------
 
namespace O {
class A{};
 
int foo(A,int){
return 23;
}
 
}
 
typedef O::A TOA;
typedef TOA TTOA;
 
//------------
 
static union {
int a;
char b;
}p_union;
 
//------------
 
namespace P {
class Q{
public:
int operator== (int)
{
return 24;
}
 
int operator== (float)
{
return 25;
}
 
int operator+ (float)
{
return 26;
}
 
};
 
int operator!= (Q, int)
{
return 27;
}
 
int operator!= (Q, double)
{
return 28;
}
 
int operator+ (Q, int)
{
return 29;
}
 
int operator++ (Q)
{
return 30;
}
}
 
//------------
 
int
main ()
{
A::C c;
B b;
 
A::first (c);
first (0, c);
second (0, 0, c, 0, 0);
A::first (b.c);
 
E::O eo;
F::O fo;
G::O go;
 
foo (eo);
foo (eo, eo);
foo (eo, eo, 1);
foo (fo, eo);
foo (1 ,fo, eo);
foo (go, fo, eo);
 
I::O io;
I::X ix;
 
foo (io);
//foo (ix);
 
J::U ju;
J::S js;
J::E je;
J::A::B jab;
J::A *jap;
J::A **japp;
J::C jca[3];
 
foo (ju);
foo (js);
foo (je);
foo (jab);
foo (jap);
foo (japp);
foo (jca);
 
K::O ko;
foo (ko, 1);
foo (ko, 1.0f);
//bar(ko,1);
 
L::A::B::O labo;
foo (labo);
M::A ma;
foo(ma,'a');
ma.foo('a');
M::N::foo(ma,'a');
 
M::bar('a');
M::N::bar('a');
 
TTOA ttoa;
foo (ttoa, 'a');
 
P::Q q;
q == 5;
q == 5.0f;
q != 5;
q != 5.0f;
q + 5;
q + 5.0f;
 
++q;
 
return first (0, c) + foo (eo) +
foo (eo, eo) + foo (eo, eo, 1) +
foo (fo, eo) + foo (1 ,fo, eo) +
foo (go, fo, eo);
}
/ref-types.cc
0,0 → 1,97
/* This test script is part of GDB, the GNU debugger.
 
Copyright 1999, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
 
int main2(void);
 
void marker1 (void)
{
}
 
 
 
int main(void)
{
short s;
short &rs = s;
short *ps;
short *&rps = ps;
short as[4];
short (&ras)[4] = as;
s = -1;
ps = &s;
as[0] = 0;
as[1] = 1;
as[2] = 2;
as[3] = 3;
 
#ifdef usestubs
set_debug_traps();
breakpoint();
#endif
marker1();
 
main2();
 
return 0;
}
 
int f()
{
int f1;
f1 = 1;
return f1;
}
 
int main2(void)
{
char C;
unsigned char UC;
short S;
unsigned short US;
int I;
unsigned int UI;
long L;
unsigned long UL;
float F;
double D;
char &rC = C;
unsigned char &rUC = UC;
short &rS = S;
unsigned short &rUS = US;
int &rI = I;
unsigned int &rUI = UI;
long &rL = L;
unsigned long &rUL = UL;
float &rF = F;
double &rD = D;
C = 'A';
UC = 21;
S = -14;
US = 7;
I = 102;
UI = 1002;
L = -234;
UL = 234;
F = 1.25E10;
D = -1.375E-123;
I = f();
 
return 0;
}
/try_catch.cc
0,0 → 1,138
/* This test script is part of GDB, the GNU debugger.
 
Copyright 2002, 2004,
Free Software Foundation, Inc.
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
 
#include <exception>
#include <stdexcept>
#include <string>
 
enum region { oriental, egyptian, greek, etruscan, roman };
 
// Test one.
class gnu_obj_1
{
public:
typedef region antiquities;
const bool test;
const int key1;
long key2;
 
antiquities value;
 
gnu_obj_1(antiquities a, long l): test(true), key1(5), key2(l), value(a) {}
};
 
// Test two.
template<typename T>
class gnu_obj_2: public virtual gnu_obj_1
{
public:
antiquities value_derived;
gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7), value_derived(b) { }
};
 
// Test three.
template<typename T>
class gnu_obj_3
{
public:
typedef region antiquities;
gnu_obj_2<int> data;
gnu_obj_3(antiquities b): data(etruscan) { }
};
 
int main()
{
bool test = true;
const int i = 5;
int j = i;
gnu_obj_2<long> test2(roman);
gnu_obj_3<long> test3(greek);
 
// 1
try
{
++j;
throw gnu_obj_1(egyptian, 4589); // marker 1-throw
}
catch (gnu_obj_1& obj)
{
++j;
if (obj.value != egyptian) // marker 1-catch
test &= false;
if (obj.key2 != 4589)
test &= false;
}
catch (...)
{
j = 0;
test &= false;
}
 
// 2
try
{
++j; // marker 2-start
try
{
++j; // marker 2-next
try
{
++j;
throw gnu_obj_1(egyptian, 4589); // marker 2-throw
}
catch (gnu_obj_1& obj)
{
++j;
if (obj.value != egyptian) // marker 2-catch
test &= false;
if (obj.key2 != 4589)
test &= false;
}
}
catch (gnu_obj_1& obj)
{
++j;
if (obj.value != egyptian)
test &= false;
if (obj.key2 != 4589)
test &= false;
}
}
catch (...)
{
j = 0;
test &= false;
}
 
// 3 use standard library
using namespace std;
try
{
if (j < 100)
throw invalid_argument("gdb.1"); // marker 3-throw
}
catch (exception& obj)
{
if (obj.what() != "gdb.1") // marker 3-catch
test &= false;
}
return 0;
}
/nsimport.exp
0,0 → 1,50
# Copyright 2008 Free Software Foundation, Inc.
 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
# Test printing from multiple namespace
# imported into the same scope.
 
if $tracelevel then {
strace $tracelevel
}
 
 
set testfile nsimport
set srcfile ${testfile}.cc
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
untested "Couldn't compile test program"
return -1
}
 
# Get things started.
 
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
 
############################################
# test printing of namespace imported within
# the function.
 
if ![runto_main] then {
perror "couldn't run to breakpoint main"
continue
}
 
gdb_test "print x" "\\$\[0-9\].* = 11"
gdb_test "print xx" "\\$\[0-9\].* = 22"
gdb_test "print xxx" "\\$\[0-9\].* = 33"
/demangle.exp
0,0 → 1,1567
# Copyright (C) 1992, 1997, 1999, 2003, 2004, 2007, 2008, 2009, 2010
# Free Software Foundation, Inc.
 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
# This file was written by Fred Fish. (fnf@cygnus.com)
 
if $tracelevel then {
strace $tracelevel
}
 
if { [skip_cplus_tests] } { continue }
 
### The demangling style we last sent to GDB.
set current_demangling_style none
 
### Set GDB's current demangling style to STYLE. Subsequent calls to
### test_demangle will include STYLE in the test name when reporting
### passes and failures.
proc set_demangling_style {style} {
global gdb_prompt
global current_demangling_style
 
gdb_test_multiple "set demangle-style $style" \
"$style: set demangle-style" {
-re "set demangle-style $style\[\r\n\]+$gdb_prompt $" {
pass "$style: set demangle-style"
}
-re ".*$gdb_prompt $" {
fail "$style: set demangle-style"
error "set_demangling_style: set style"
}
timeout {
fail "$style: set demangle-style (timeout)"
error "set_demangling_style: set style"
}
}
 
gdb_test_multiple "show demangle-style" \
"$style: check demangling style" {
-re "The current C\[+\]+ demangling style is \"$style\".\r\n$gdb_prompt $" {
pass "$style: check demangling style"
}
-re ".*$gdb_prompt $" {
fail "$style: check demangling style"
error "set_demangling_style: check style"
}
timeout {
fail "$style: check demangling style (timeout)"
error "set_demangling_style: check style"
}
}
 
set current_demangling_style $style
}
 
 
### Utility function for test_demangling and test_demangling_exact.
proc test_demangling_core {tester test result} {
global current_demangling_style
 
if {! [regexp {^([^ ]+): (.+)$} $test dummy style name]} {
error "bad test name passed to test_demangling"
}
 
if {[string compare $style $current_demangling_style]} {
set_demangling_style $style
}
 
$tester "maintenance demangle $name" $result $test
}
 
### Demangle an identifier, and check that the result matches a pattern.
###
### TEST should be of the form "STYLE: NAME", where STYLE is the name
### of a demangling style (like "gnu" or "arm"), and NAME is a mangled
### identifier to demangle. Pass when the result matches the regular
### expression RESULT. Report passes and fails using TEST as the name
### of the test.
###
### Why don't we just pass the STYLE and NAME as two separate
### arguments, or let the style be a global variable? That would be
### cleaner. However, doing it this way means that:
###
### 1) the name of the test, as recorded in the summary and log,
### appears verbatim in the script, and
###
### 2) that test names are unique, even though we try to demangle the same
### identifiers using several different mangling styles.
###
### This makes it a lot easier for people tracking down failures to
### find the one they care about.
 
proc test_demangling {test result} {
test_demangling_core gdb_test $test $result
}
 
### Like test_demangling, above, except that RESULT is not a regexp,
### but a string that must match exactly.
 
proc test_demangling_exact {test result} {
test_demangling_core gdb_test_exact $test $result
}
 
 
 
#
# Test gnu style name demangling
#
 
proc test_gnu_style_demangling {} {
global gdb_prompt
 
test_demangling "gnu: Abort__FP6EditoriPCc" \
"Abort\[(\]+Editor \[*\]+, int, (const char|char const) \[*\]+\[)\]+"
test_demangling_exact "gnu: AddAlignment__9ivTSolverUiP12ivInteractorP7ivTGlue" "ivTSolver::AddAlignment(unsigned int, ivInteractor *, ivTGlue *)"
test_demangling "gnu: Append__15NameChooserViewPCc" \
"NameChooserView::Append\[(\]+(const char|char const) \[*\]+\[)\]+"
test_demangling_exact "gnu: ArrowheadIntersects__9ArrowLineP9ArrowheadR6BoxObjP7Graphic" "ArrowLine::ArrowheadIntersects(Arrowhead *, BoxObj &, Graphic *)"
test_demangling_exact "gnu: AtEnd__13ivRubberGroup" "ivRubberGroup::AtEnd(void)"
test_demangling_exact "gnu: BgFilter__9ivTSolverP12ivInteractor" "ivTSolver::BgFilter(ivInteractor *)"
test_demangling "gnu: BitPatterntoa__FRC10BitPatternccc" \
"BitPatterntoa\[(\]+(const BitPattern|BitPattern const) &, char, char, char\[)\]+"
test_demangling_exact "gnu: Check__6UArrayi" "UArray::Check(int)"
test_demangling_exact "gnu: CoreConstDecls__8TextCodeR7ostream" "TextCode::CoreConstDecls(ostream &)"
test_demangling_exact "gnu: Detach__8StateVarP12StateVarView" "StateVar::Detach(StateVarView *)"
test_demangling_exact "gnu: Done__9ComponentG8Iterator" "Component::Done(Iterator)"
test_demangling "gnu: DrawDestinationTransformedImage__FP7_XImageiiT0iiUlUiiiUiUlUlP4_XGCRC13ivTransformeriiii" \
"DrawDestinationTransformedImage\[(\]+_XImage \[*\]+, int, int, _XImage \[*\]+, int, int, unsigned long, unsigned int, int, int, unsigned int, unsigned long, unsigned long, _XGC \[*\]+, (const ivTransformer|ivTransformer const) &, int, int, int, int\[)\]+"
 
test_demangling "gnu: Edit__12StringEditorPCcii" \
"StringEditor::Edit\[(\]+(const char|char const) \[*\]+, int, int\[)\]+"
test_demangling_exact "gnu: Effect__11RelateManipR7ivEvent" "RelateManip::Effect(ivEvent &)"
test_demangling "gnu: FilterName__FPCc" \
"FilterName\[(\]+(const char|char const) \[*\]+\[)\]+"
test_demangling "gnu: Filter__6PSTextPCci" \
"PSText::Filter\[(\]+(const char|char const) \[*\]+, int\[)\]+"
test_demangling "gnu: FindColor__7CatalogPCciii" \
"Catalog::FindColor\[(\]+(const char|char const) \[*\]+, int, int, int\[)\]+"
test_demangling_exact "gnu: FindFixed__FRP4CNetP4CNet" "FindFixed(CNet *&, CNet *)"
test_demangling "gnu: FindFont__7CatalogPCcN21" \
"Catalog::FindFont\[(\]+(const char|char const) \[*\]+, (const char|char const) \[*\]+, (const char|char const) \[*\]+\[)\]+"
test_demangling_exact "gnu: Fix48_abort__FR8twolongs" "Fix48_abort(twolongs &)"
test_demangling_exact "gnu: GetBarInfo__15iv2_6_VScrollerP13ivPerspectiveRiT2" "iv2_6_VScroller::GetBarInfo(ivPerspective *, int &, int &)"
test_demangling_exact "gnu: GetBgColor__C9ivPainter" "ivPainter::GetBgColor(void) const"
 
test_demangling "gnu: Iisdouble__FPC6IntRep" \
"Iisdouble\[(\]+(const IntRep|IntRep const) \[*\]+\[)\]+"
test_demangling_exact "gnu: InsertBody__15H_PullrightMenuii" "H_PullrightMenu::InsertBody(int, int)"
test_demangling_exact "gnu: InsertCharacter__9TextManipc" "TextManip::InsertCharacter(char)"
 
test_demangling_exact "gnu: InsertToplevel__7ivWorldP12ivInteractorT1" "ivWorld::InsertToplevel(ivInteractor *, ivInteractor *)"
test_demangling_exact "gnu: InsertToplevel__7ivWorldP12ivInteractorT1iiUi" "ivWorld::InsertToplevel(ivInteractor *, ivInteractor *, int, int, unsigned int)"
test_demangling "gnu: IsADirectory__FPCcR4stat" \
"IsADirectory\[(\]+(const char|char const) \[*\]+, stat &\[)\]+"
test_demangling_exact "gnu: IsAGroup__FP11GraphicViewP11GraphicComp" "IsAGroup(GraphicView *, GraphicComp *)"
test_demangling_exact "gnu: IsA__10ButtonCodeUl" "ButtonCode::IsA(unsigned long)"
 
test_demangling_exact "gnu: ReadName__FR7istreamPc" "ReadName(istream &, char *)"
test_demangling_exact "gnu: Redraw__13StringBrowseriiii" "StringBrowser::Redraw(int, int, int, int)"
test_demangling_exact "gnu: Rotate__13ivTransformerf" "ivTransformer::Rotate(float)"
test_demangling_exact "gnu: Rotated__C13ivTransformerf" "ivTransformer::Rotated(float) const"
test_demangling_exact "gnu: Round__Ff" "Round(float)"
 
test_demangling_exact "gnu: SetExport__16MemberSharedNameUi" "MemberSharedName::SetExport(unsigned int)"
test_demangling_exact "gnu: Set__14ivControlState13ControlStatusUi" "ivControlState::Set(ControlStatus, unsigned int)"
test_demangling_exact "gnu: Set__5DFacePcii" "DFace::Set(char *, int, int)"
 
test_demangling_exact "gnu: VConvert__9ivTSolverP12ivInteractorRP8TElementT2" "ivTSolver::VConvert(ivInteractor *, TElement *&, TElement *&)"
test_demangling_exact "gnu: VConvert__9ivTSolverP7ivTGlueRP8TElement" "ivTSolver::VConvert(ivTGlue *, TElement *&)"
test_demangling_exact "gnu: VOrder__9ivTSolverUiRP12ivInteractorT2" "ivTSolver::VOrder(unsigned int, ivInteractor *&, ivInteractor *&)"
test_demangling "gnu: Valid__7CatalogPCcRP4Tool" \
"Catalog::Valid\[(\]+(const char|char const) \[*\]+, Tool \[*\]+&\[)\]+"
test_demangling_exact "gnu: _10PageButton\$__both" "PageButton::__both"
test_demangling_exact "gnu: _3RNG\$singleMantissa" "RNG::singleMantissa"
test_demangling_exact "gnu: _5IComp\$_release" "IComp::_release"
test_demangling_exact "gnu: _\$_10BitmapComp" "BitmapComp::~BitmapComp(void)"
 
test_demangling_exact "gnu: _\$_9__io_defs" "__io_defs::~__io_defs(void)"
test_demangling_exact "gnu: _\$_Q23foo3bar" "foo::bar::~bar(void)"
test_demangling_exact "gnu: _\$_Q33foo3bar4bell" "foo::bar::bell::~bell(void)"
test_demangling_exact "gnu: __10ivTelltaleiP7ivGlyph" "ivTelltale::ivTelltale(int, ivGlyph *)"
test_demangling_exact "gnu: __10ivViewportiP12ivInteractorUi" "ivViewport::ivViewport(int, ivInteractor *, unsigned int)"
test_demangling_exact "gnu: __10ostrstream" "ostrstream::ostrstream(void)"
test_demangling_exact "gnu: __10ostrstreamPcii" "ostrstream::ostrstream(char *, int, int)"
test_demangling "gnu: __11BasicDialogiPCcP13ivButtonStateN22Ui" \
"BasicDialog::BasicDialog\[(\]+int, (const char|char const) \[*\]+, ivButtonState \[*\]+, (const char|char const) \[*\]+, (const char|char const) \[*\]+, unsigned int\[)\]+"
test_demangling_exact "gnu: __11BitmapTablei" "BitmapTable::BitmapTable(int)"
test_demangling_exact "gnu: __12ViewportCodeP12ViewportComp" "ViewportCode::ViewportCode(ViewportComp *)"
test_demangling "gnu: __12iv2_6_BorderiPCci" \
"iv2_6_Border::iv2_6_Border\[(\]+int, (const char|char const) \[*\]+, int\[)\]+"
test_demangling_exact "gnu: __12iv2_6_Borderii" "iv2_6_Border::iv2_6_Border(int, int)"
test_demangling "gnu: __12ivBackgroundiP7ivGlyphPC7ivColor" \
"ivBackground::ivBackground\[(\]+int, ivGlyph \[*\]+, (const ivColor|ivColor const) \[*\]+\[)\]+"
test_demangling_exact "gnu: __12ivBreak_Listl" "ivBreak_List::ivBreak_List(long)"
test_demangling "gnu: __14TextInteractoriPCcUi" \
"TextInteractor::TextInteractor\[(\]+int, (const char|char const) \[*\]+, unsigned int\[)\]+"
test_demangling_exact "gnu: __14iv2_6_MenuItemiP12ivInteractor" "iv2_6_MenuItem::iv2_6_MenuItem(int, ivInteractor *)"
test_demangling "gnu: __14iv2_6_MenuItemiPCcP12ivInteractor" \
"iv2_6_MenuItem::iv2_6_MenuItem\[(\]+int, (const char|char const) \[*\]+, ivInteractor \[*\]+\[)\]+"
 
test_demangling_exact "gnu: __20DisplayList_IteratorR11DisplayList" "DisplayList_Iterator::DisplayList_Iterator(DisplayList &)"
test_demangling_exact "gnu: __3fooRT0" "foo::foo(foo &)"
test_demangling_exact "gnu: __3fooiN31" "foo::foo(int, int, int, int)"
test_demangling "gnu: __3fooiPCc" \
"foo::foo\[(\]+int, (const char|char const) \[*\]+\[)\]+"
test_demangling_exact "gnu: __3fooiRT0iT2iT2" "foo::foo(int, foo &, int, foo &, int, foo &)"
test_demangling "gnu: __6GetOptiPPcPCc" \
"GetOpt::GetOpt\[(\]+int, char \[*\]+\[*\]+, (const char|char const) \[*\]+\[)\]+"
test_demangling_exact "gnu: __6KeyMapPT0" "KeyMap::KeyMap(KeyMap *)"
test_demangling "gnu: __7ivWorldPCcRiPPcPC12ivOptionDescPC14ivPropertyData" \
"ivWorld::ivWorld\[(\]+(const char|char const) \[*\]+, int &, char \[*\]+\[*\]+, (const ivOptionDesc|ivOptionDesc const) \[*\]+, (const ivPropertyData|ivPropertyData const) \[*\]+\[)\]+"
test_demangling "gnu: __7procbufPCci" \
"procbuf::procbuf\[(\]+(const char|char const) \[*\]+, int\[)\]+"
test_demangling_exact "gnu: __8ArrowCmdP6EditorUiUi" "ArrowCmd::ArrowCmd(Editor *, unsigned int, unsigned int)"
 
test_demangling_exact "gnu: __9F_EllipseiiiiP7Graphic" "F_Ellipse::F_Ellipse(int, int, int, int, Graphic *)"
test_demangling_exact "gnu: __9FrameDataP9FrameCompi" "FrameData::FrameData(FrameComp *, int)"
test_demangling_exact "gnu: __9HVGraphicP9CanvasVarP7Graphic" "HVGraphic::HVGraphic(CanvasVar *, Graphic *)"
test_demangling_exact "gnu: __Q23foo3bar" "foo::bar::bar(void)"
test_demangling_exact "gnu: __Q33foo3bar4bell" "foo::bar::bell::bell(void)"
test_demangling_exact "gnu: __aa__3fooRT0" "foo::operator&&(foo &)"
test_demangling_exact "gnu: __aad__3fooRT0" "foo::operator&=(foo &)"
test_demangling_exact "gnu: __ad__3fooRT0" "foo::operator&(foo &)"
test_demangling_exact "gnu: __adv__3fooRT0" "foo::operator/=(foo &)"
test_demangling_exact "gnu: __aer__3fooRT0" "foo::operator^=(foo &)"
test_demangling_exact "gnu: __als__3fooRT0" "foo::operator<<=(foo &)"
test_demangling_exact "gnu: __amd__3fooRT0" "foo::operator%=(foo &)"
test_demangling_exact "gnu: __ami__3fooRT0" "foo::operator-=(foo &)"
test_demangling_exact "gnu: __aml__3FixRT0" "Fix::operator*=(Fix &)"
test_demangling_exact "gnu: __aml__5Fix16i" "Fix16::operator*=(int)"
test_demangling_exact "gnu: __aml__5Fix32RT0" "Fix32::operator*=(Fix32 &)"
test_demangling_exact "gnu: __aor__3fooRT0" "foo::operator|=(foo &)"
test_demangling_exact "gnu: __apl__3fooRT0" "foo::operator+=(foo &)"
test_demangling_exact "gnu: __ars__3fooRT0" "foo::operator>>=(foo &)"
 
test_demangling_exact "gnu: __as__3fooRT0" "foo::operator=(foo &)"
test_demangling_exact "gnu: __cl__3fooRT0" "foo::operator()(foo &)"
test_demangling_exact "gnu: __cl__6Normal" "Normal::operator()(void)"
test_demangling_exact "gnu: __cl__6Stringii" "String::operator()(int, int)"
test_demangling_exact "gnu: __cm__3fooRT0" "foo::operator, (foo &)"
test_demangling_exact "gnu: __co__3foo" "foo::operator~(void)"
test_demangling_exact "gnu: __dl__3fooPv" "foo::operator delete(void *)"
test_demangling_exact "gnu: __dv__3fooRT0" "foo::operator/(foo &)"
test_demangling_exact "gnu: __eq__3fooRT0" "foo::operator==(foo &)"
test_demangling_exact "gnu: __er__3fooRT0" "foo::operator^(foo &)"
test_demangling_exact "gnu: __ge__3fooRT0" "foo::operator>=(foo &)"
test_demangling_exact "gnu: __gt__3fooRT0" "foo::operator>(foo &)"
test_demangling_exact "gnu: __le__3fooRT0" "foo::operator<=(foo &)"
test_demangling_exact "gnu: __ls__3fooRT0" "foo::operator<<(foo &)"
test_demangling_exact "gnu: __ls__FR7ostreamPFR3ios_R3ios" "operator<<(ostream &, ios &(*)(ios &))"
test_demangling_exact "gnu: __ls__FR7ostreamR3Fix" "operator<<(ostream &, Fix &)"
test_demangling_exact "gnu: __lt__3fooRT0" "foo::operator<(foo &)"
test_demangling_exact "gnu: __md__3fooRT0" "foo::operator%(foo &)"
test_demangling_exact "gnu: __mi__3fooRT0" "foo::operator-(foo &)"
test_demangling_exact "gnu: __ml__3fooRT0" "foo::operator*(foo &)"
test_demangling_exact "gnu: __mm__3fooi" "foo::operator--(int)"
 
test_demangling_exact "gnu: __ne__3fooRT0" "foo::operator!=(foo &)"
test_demangling "gnu: __ne__FRC7ComplexT0" \
"operator!=\[(\]+(const Complex|Complex const) &, (const Complex|Complex const) &\[)\]+"
test_demangling "gnu: __ne__FRC7Complexd" \
"operator!=\[(\]+(const Complex|Complex const) &, double\[)\]+"
test_demangling "gnu: __ne__FRC9SubStringRC6String" \
"operator!=\[(\]+(const SubString|SubString const) &, (const String|String const) &\[)\]+"
test_demangling_exact "gnu: __nt__3foo" "foo::operator!(void)"
test_demangling_exact "gnu: __nw__3fooi" "foo::operator new(int)"
test_demangling_exact "gnu: __oo__3fooRT0" "foo::operator||(foo &)"
test_demangling_exact "gnu: __opPc__3foo" "foo::operator char *(void)"
test_demangling_exact "gnu: __opi__3foo" "foo::operator int(void)"
test_demangling_exact "gnu: __or__3fooRT0" "foo::operator|(foo &)"
test_demangling_exact "gnu: __pl__3fooRT0" "foo::operator+(foo &)"
test_demangling_exact "gnu: __pp__3fooi" "foo::operator++(int)"
test_demangling_exact "gnu: __rf__3foo" "foo::operator->(void)"
test_demangling_exact "gnu: __rm__3fooRT0" "foo::operator->*(foo &)"
test_demangling_exact "gnu: __rs__3fooRT0" "foo::operator>>(foo &)"
test_demangling "gnu: __vc__3fooRT0" "foo::operator\\\[\\\]\\(foo &\\)"
test_demangling "gnu: _gsub__6StringRC5RegexPCci" \
"String::_gsub\[(\]+(const Regex|Regex const) &, (const char|char const) \[*\]+, int\[)\]+"
test_demangling_exact "gnu: _new_Fix__FUs" "_new_Fix(unsigned short)"
 
# gcc 2.4.5 (and earlier) style virtual tables. We want to continue to
# correctly demangle these even if newer compilers use a different form.
test_demangling_exact "gnu: _vt.foo" "foo virtual table"
test_demangling_exact "gnu: _vt.foo.bar" "foo::bar virtual table"
test_demangling_exact "gnu: _vt\$foo" "foo virtual table"
test_demangling_exact "gnu: _vt\$foo\$bar" "foo::bar virtual table"
 
test_demangling_exact "gnu: append__7ivGlyphPT0" "ivGlyph::append(ivGlyph *)"
test_demangling "gnu: arg__FRC7Complex" \
"arg\[(\]+(const Complex|Complex const) &\[)\]+"
test_demangling_exact "gnu: clearok__FP7_win_sti" "clearok(_win_st *, int)"
 
test_demangling_exact "gnu: complexfunc2__FPFPc_i" "complexfunc2(int (*)(char *))"
test_demangling_exact "gnu: complexfunc3__FPFPFPl_s_i" "complexfunc3(int (*)(short (*)(long *)))"
test_demangling_exact "gnu: complexfunc4__FPFPFPc_s_i" "complexfunc4(int (*)(short (*)(char *)))"
test_demangling_exact "gnu: complexfunc5__FPFPc_PFl_i" "complexfunc5(int (*(*)(char *))(long))"
test_demangling_exact "gnu: complexfunc6__FPFPi_PFl_i" "complexfunc6(int (*(*)(int *))(long))"
test_demangling_exact "gnu: complexfunc7__FPFPFPc_i_PFl_i" "complexfunc7(int (*(*)(int (*)(char *)))(long))"
test_demangling "gnu: contains__C9BitStringRC10BitPattern" \
"BitString::contains\[(\]+(const BitPattern|BitPattern const) &\[)\]+ const"
test_demangling "gnu: contains__C9BitStringRC12BitSubStringi" \
"BitString::contains\[(\]+(const BitSubString|BitSubString const) &, int\[)\]+ const"
test_demangling "gnu: contains__C9BitStringRT0" \
"BitString::contains\[(\]+(const BitString|BitString const) &\[)\]+ const"
test_demangling "gnu: div__FPC6IntRepT0P6IntRep" \
"div\[(\]+(const IntRep|IntRep const) \[*\]+, (const IntRep|IntRep const) \[*\]+, IntRep \[*\]+\[)\]+"
test_demangling "gnu: div__FPC6IntReplP6IntRep" \
"div\[(\]+(const IntRep|IntRep const) \[*\]+, long, IntRep \[*\]+\[)\]+"
test_demangling "gnu: div__FRC8RationalT0R8Rational" \
"div\[(\]+(const Rational|Rational const) &, (const Rational|Rational const) &, Rational &\[)\]+"
test_demangling "gnu: divide__FRC7IntegerT0R7IntegerT2" \
"divide\[(\]+(const Integer|Integer const) &, (const Integer|Integer const) &, Integer &, Integer &\[)\]+"
test_demangling "gnu: divide__FRC7IntegerlR7IntegerRl" \
"divide\[(\]+(const Integer|Integer const) &, long, Integer &, long &\[)\]+"
test_demangling "gnu: enable__14DocumentViewerPCcUi" \
"DocumentViewer::enable\[(\]+(const char|char const) \[*\]+, unsigned int\[)\]+"
 
test_demangling_exact "gnu: foo__FiN30" "foo(int, int, int, int)"
test_demangling_exact "gnu: foo__FiR3fooiT1iT1" "foo(int, foo &, int, foo &, int, foo &)"
test_demangling_exact "gnu: foo___3barl" "bar::foo_(long)"
test_demangling_exact "gnu: insert__15ivClippingStacklRP8_XRegion" "ivClippingStack::insert(long, _XRegion *&)"
test_demangling_exact "gnu: insert__16ChooserInfo_ListlR11ChooserInfo" "ChooserInfo_List::insert(long, ChooserInfo &)"
test_demangling_exact "gnu: insert__17FontFamilyRepListlRP15ivFontFamilyRep" "FontFamilyRepList::insert(long, ivFontFamilyRep *&)"
test_demangling_exact "gnu: leaveok__FP7_win_stc" "leaveok(_win_st *, char)"
test_demangling_exact "gnu: left_mover__C7ivMFKitP12ivAdjustableP7ivStyle" "ivMFKit::left_mover(ivAdjustable *, ivStyle *) const"
test_demangling "gnu: matches__C9BitStringRC10BitPatterni" \
"BitString::matches\[(\]+(const BitPattern|BitPattern const) &, int\[)\]+ const"
test_demangling "gnu: matches__C9SubStringRC5Regex" \
"SubString::matches\[(\]+(const Regex|Regex const) &\[)\]+ const"
 
test_demangling_exact "gnu: overload1arg__FSc" "overload1arg(signed char)"
test_demangling_exact "gnu: overload1arg__FUc" "overload1arg(unsigned char)"
test_demangling_exact "gnu: overload1arg__FUi" "overload1arg(unsigned int)"
test_demangling_exact "gnu: overload1arg__FUl" "overload1arg(unsigned long)"
test_demangling_exact "gnu: overload1arg__FUs" "overload1arg(unsigned short)"
test_demangling_exact "gnu: overload1arg__Fc" "overload1arg(char)"
test_demangling_exact "gnu: overload1arg__Fd" "overload1arg(double)"
test_demangling_exact "gnu: overload1arg__Ff" "overload1arg(float)"
test_demangling_exact "gnu: overload1arg__Fi" "overload1arg(int)"
test_demangling_exact "gnu: overload1arg__Fl" "overload1arg(long)"
test_demangling_exact "gnu: overload1arg__Fs" "overload1arg(short)"
test_demangling_exact "gnu: overload1arg__Fv" "overload1arg(void)"
test_demangling_exact "gnu: overloadargs__Fi" "overloadargs(int)"
test_demangling_exact "gnu: overloadargs__Fii" "overloadargs(int, int)"
test_demangling_exact "gnu: overloadargs__Fiii" "overloadargs(int, int, int)"
test_demangling_exact "gnu: overloadargs__Fiiii" "overloadargs(int, int, int, int)"
 
test_demangling_exact "gnu: overloadargs__Fiiiii" "overloadargs(int, int, int, int, int)"
test_demangling_exact "gnu: overloadargs__Fiiiiii" "overloadargs(int, int, int, int, int, int)"
test_demangling_exact "gnu: overloadargs__Fiiiiiii" "overloadargs(int, int, int, int, int, int, int)"
test_demangling_exact "gnu: overloadargs__Fiiiiiiii" "overloadargs(int, int, int, int, int, int, int, int)"
test_demangling_exact "gnu: overloadargs__Fiiiiiiiii" "overloadargs(int, int, int, int, int, int, int, int, int)"
test_demangling_exact "gnu: overloadargs__Fiiiiiiiiii" "overloadargs(int, int, int, int, int, int, int, int, int, int)"
test_demangling_exact "gnu: overloadargs__Fiiiiiiiiiii" "overloadargs(int, int, int, int, int, int, int, int, int, int, int)"
test_demangling "gnu: pick__13ivCompositionP8ivCanvasRC12ivAllocationiR5ivHit" \
"ivComposition::pick\[(\]+ivCanvas \[*\]+, (const ivAllocation|ivAllocation const) &, int, ivHit &\[)\]+"
test_demangling "gnu: pointer__C11ivHScrollerRC7ivEventRC12ivAllocation" \
"ivHScroller::pointer\[(\]+(const ivEvent|ivEvent const) &, (const ivAllocation|ivAllocation const) &\[)\]+ const"
test_demangling_exact "gnu: poke__8ivRasterUlUlffff" "ivRaster::poke(unsigned long, unsigned long, float, float, float, float)"
test_demangling_exact "gnu: polar__Fdd" "polar(double, double)"
test_demangling "gnu: read__10osStdInputRPCc" \
"osStdInput::read\[(\]+(const char|char const) \[*\]+&\[)\]+"
 
test_demangling_exact "gnu: scale__13ivTransformerff" "ivTransformer::scale(float, float)"
test_demangling "gnu: scanw__12CursesWindowPCce" \
"CursesWindow::scanw\[(\]+(const char|char const) \[*\]+,...\[)\]+"
test_demangling "gnu: scmp__FPCcT0" \
"scmp\[(\]+(const char|char const) \[*\]+, (const char|char const) \[*\]+\[)\]+"
test_demangling_exact "gnu: sgetn__7filebufPci" "filebuf::sgetn(char *, int)"
test_demangling_exact "gnu: shift__FP5_FrepiT0" "shift(_Frep *, int, _Frep *)"
test_demangling_exact "gnu: test__C6BitSeti" "BitSet::test(int) const"
test_demangling_exact "gnu: test__C6BitSetii" "BitSet::test(int, int) const"
test_demangling "gnu: testbit__FRC7Integerl" \
"testbit\[(\]+(const Integer|Integer const) &, long\[)\]+"
test_demangling_exact "gnu: text_source__8Documentl" "Document::text_source(long)"
test_demangling_exact "gnu: variance__6Erlangd" "Erlang::variance(double)"
test_demangling "gnu: vform__8iostreamPCcPc" \
"iostream::vform\[(\]+(const char|char const) \[*\]+, char \[*\]+\[)\]+"
test_demangling_exact "gnu: view__14DocumentViewerP8ItemViewP11TabularItem" "DocumentViewer::view(ItemView *, TabularItem *)"
test_demangling_exact "gnu: xy_extents__11ivExtensionffff" "ivExtension::xy_extents(float, float, float, float)"
test_demangling_exact "gnu: zero__8osMemoryPvUi" "osMemory::zero(void *, unsigned int)"
test_demangling_exact "gnu: _2T4\$N" "T4::N"
test_demangling_exact "gnu: _Q22T42t1\$N" "T4::t1::N"
test_demangling_exact "gnu: get__2T1" "T1::get(void)"
test_demangling_exact "gnu: get__Q22T11a" "T1::a::get(void)"
test_demangling_exact "gnu: get__Q32T11a1b" "T1::a::b::get(void)"
test_demangling_exact "gnu: get__Q42T11a1b1c" "T1::a::b::c::get(void)"
test_demangling_exact "gnu: get__Q52T11a1b1c1d" "T1::a::b::c::d::get(void)"
test_demangling_exact "gnu: put__2T1i" "T1::put(int)"
test_demangling_exact "gnu: put__Q22T11ai" "T1::a::put(int)"
test_demangling_exact "gnu: put__Q32T11a1bi" "T1::a::b::put(int)"
test_demangling_exact "gnu: put__Q42T11a1b1ci" "T1::a::b::c::put(int)"
test_demangling_exact "gnu: put__Q52T11a1b1c1di" "T1::a::b::c::d::put(int)"
 
test_demangling_exact "gnu: bar__3fooPv" "foo::bar(void *)"
test_demangling "gnu: bar__3fooPCv" \
"foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+"
test_demangling_exact "gnu: bar__C3fooPv" "foo::bar(void *) const"
test_demangling "gnu: bar__C3fooPCv" \
"foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+ const"
test_demangling_exact "gnu: __eq__3fooRT0" "foo::operator==(foo &)"
test_demangling "gnu: __eq__3fooRC3foo" \
"foo::operator==\[(\]+(const foo|foo const) &\[)\]+"
test_demangling_exact "gnu: __eq__C3fooR3foo" "foo::operator==(foo &) const"
test_demangling "gnu: __eq__C3fooRT0" \
"foo::operator==\[(\]+(const foo|foo const) &\[)\]+ const"
 
test_demangling_exact "gnu: elem__t6vector1Zdi" "vector<double>::elem(int)"
test_demangling_exact "gnu: elem__t6vector1Zii" "vector<int>::elem(int)"
test_demangling_exact "gnu: __t6vector1Zdi" "vector<double>::vector(int)"
test_demangling_exact "gnu: __t6vector1Zii" "vector<int>::vector(int)"
test_demangling_exact "gnu: _\$_t6vector1Zdi" "vector<double>::~vector(int)"
test_demangling_exact "gnu: _\$_t6vector1Zii" "vector<int>::~vector(int)"
 
test_demangling_exact "gnu: __nw__t2T11ZcUi" "T1<char>::operator new(unsigned int)"
test_demangling_exact "gnu: __nw__t2T11Z1tUi" "T1<t>::operator new(unsigned int)"
test_demangling_exact "gnu: __dl__t2T11ZcPv" "T1<char>::operator delete(void *)"
test_demangling_exact "gnu: __dl__t2T11Z1tPv" "T1<t>::operator delete(void *)"
test_demangling_exact "gnu: __t2T11Zci" "T1<char>::T1(int)"
test_demangling_exact "gnu: __t2T11Zc" "T1<char>::T1(void)"
test_demangling_exact "gnu: __t2T11Z1ti" "T1<t>::T1(int)"
test_demangling_exact "gnu: __t2T11Z1t" "T1<t>::T1(void)"
 
test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity3Pix" \
"List<VHDLEntity>::Pix::Pix(void)"
 
test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity3PixPQ2t4List1Z10VHDLEntity7element" \
"List<VHDLEntity>::Pix::Pix(List<VHDLEntity>::element *)"
 
test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity3PixRCQ2t4List1Z10VHDLEntity3Pix" \
"List<VHDLEntity>::Pix::Pix(List<VHDLEntity>::Pix const &)"
 
test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity7elementRC10VHDLEntityPT0" \
"List<VHDLEntity>::element::element(VHDLEntity const &, List<VHDLEntity>::element *)"
 
test_demangling_exact "gnu: __Q2t4List1Z10VHDLEntity7elementRCQ2t4List1Z10VHDLEntity7element" \
"List<VHDLEntity>::element::element(List<VHDLEntity>::element const &)"
 
test_demangling_exact "gnu: __cl__C11VHDLLibraryGt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \
"VHDLLibrary::operator()(PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >) const"
 
test_demangling_exact "gnu: __cl__Ct4List1Z10VHDLEntityRCQ2t4List1Z10VHDLEntity3Pix" \
"List<VHDLEntity>::operator()(List<VHDLEntity>::Pix const &) const"
 
test_demangling_exact "gnu: __ne__FPvRCQ2t4List1Z10VHDLEntity3Pix" \
"operator!=(void *, List<VHDLEntity>::Pix const &)"
 
test_demangling_exact "gnu: __ne__FPvRCt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \
"operator!=(void *, PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> > const &)"
 
test_demangling_exact "gnu: __t4List1Z10VHDLEntityRCt4List1Z10VHDLEntity" \
"List<VHDLEntity>::List(List<VHDLEntity> const &)"
 
test_demangling_exact "gnu: __t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \
"PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >::PixX(void)"
 
test_demangling_exact "gnu: __t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntityP14VHDLLibraryRepGQ2t4List1Z10VHDLEntity3Pix" \
"PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >::PixX(VHDLLibraryRep *, List<VHDLEntity>::Pix)"
 
test_demangling_exact "gnu: __t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntityRCt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \
"PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >::PixX(PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> > const &)"
 
test_demangling_exact "gnu: nextE__C11VHDLLibraryRt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \
"VHDLLibrary::nextE(PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> > &) const"
 
test_demangling_exact "gnu: next__Ct4List1Z10VHDLEntityRQ2t4List1Z10VHDLEntity3Pix" \
"List<VHDLEntity>::next(List<VHDLEntity>::Pix &) const"
 
test_demangling_exact "gnu: _GLOBAL_\$D\$set" "global destructors keyed to set"
 
test_demangling_exact "gnu: _GLOBAL_\$I\$set" "global constructors keyed to set"
 
test_demangling_exact "gnu: __as__t5ListS1ZUiRCt5ListS1ZUi" \
"ListS<unsigned int>::operator=(ListS<unsigned int> const &)"
 
test_demangling_exact "gnu: __cl__Ct5ListS1ZUiRCQ2t5ListS1ZUi3Vix" \
"ListS<unsigned int>::operator()(ListS<unsigned int>::Vix const &) const"
 
test_demangling_exact "gnu: __cl__Ct5SetLS1ZUiRCQ2t5SetLS1ZUi3Vix" \
"SetLS<unsigned int>::operator()(SetLS<unsigned int>::Vix const &) const"
 
test_demangling_exact "gnu: __t10ListS_link1ZUiRCUiPT0" \
"ListS_link<unsigned int>::ListS_link(unsigned int const &, ListS_link<unsigned int> *)"
 
test_demangling_exact "gnu: __t10ListS_link1ZUiRCt10ListS_link1ZUi" \
"ListS_link<unsigned int>::ListS_link(ListS_link<unsigned int> const &)"
 
test_demangling_exact "gnu: __t5ListS1ZUiRCt5ListS1ZUi" \
"ListS<unsigned int>::ListS(ListS<unsigned int> const &)"
 
test_demangling_exact "gnu: next__Ct5ListS1ZUiRQ2t5ListS1ZUi3Vix" \
"ListS<unsigned int>::next(ListS<unsigned int>::Vix &) const"
 
test_demangling_exact "gnu: __ne__FPvRCQ2t5SetLS1ZUi3Vix" \
"operator!=(void *, SetLS<unsigned int>::Vix const &)"
test_demangling_exact "gnu: __t8ListElem1Z5LabelRt4List1Z5Label" \
"ListElem<Label>::ListElem(List<Label> &)"
test_demangling_exact "gnu: __t8BDDHookV1ZPcRCPc" \
"BDDHookV<char *>::BDDHookV(char *const &)"
 
test_demangling_exact "gnu: _vt\$t8BDDHookV1ZPc" "BDDHookV<char *> virtual table"
 
test_demangling_exact "gnu: __ne__FPvRCQ211BDDFunction4VixB" \
"operator!=(void *, BDDFunction::VixB const &)"
test_demangling_exact "gnu: __eq__FPvRCQ211BDDFunction4VixB" \
"operator==(void *, BDDFunction::VixB const &)"
 
test_demangling_exact "gnu: relativeId__CQ36T_phi210T_preserve8FPC_nextRCQ26T_phi210T_preserveRC10Parameters" \
"T_phi2::T_preserve::FPC_next::relativeId(T_phi2::T_preserve const &, Parameters const &) const"
 
test_demangling_exact "gnu: _Utf390_1__1_9223372036854775807__9223372036854775" \
"Can't demangle \"_Utf390_1__1_9223372036854775807__9223372036854775\""
test_demangling_exact "gnu: foo__I40" "foo(int64_t)"
test_demangling_exact "gnu: foo__I_200_" "foo(int512_t)"
test_demangling_exact "gnu: foo__I_200" "Can't demangle \"foo__I_200\""
 
## Buffer overrun. Should make GDB crash. Woo hoo!
test_demangling_exact "gnu: foo__I_4000000000000000000000000000000000000000000000000000000000000000000000000" "Can't demangle \"foo__I_4000000000000000000000000000000000000000000000000000000000000000000000000\""
 
## 1999-04-19: "Fix from Dale Hawkins". Shouldn't segfault.
# Accept even a dubious demangling; the string is ambiguous.
 
gdb_test_multiple "maintenance demangle __thunk_64__0RL__list__Q29CosNaming20_proxy_NamingContextUlRPt25_CORBA_Unbounded_Sequence1ZQ29CosNaming7BindingRPQ29CosNaming15BindingIterator" "gnu: __thunk_64__0RL__list__Q29CosNaming20_proxy_NamingContextUlRPt25_CORBA_Unbounded_Sequence1ZQ29CosNaming7BindingRPQ29CosNaming15BindingIterator" {
-re "virtual function thunk \\(delta:-64\\) for CosNaming::_proxy_NamingContext::_0RL__list\\(unsigned long, _CORBA_Unbounded_Sequence<CosNaming::Binding> \\*\\&, CosNaming::BindingIterator \\*\\&\\)\r\n$gdb_prompt $" {
pass "gnu: __thunk_64__0RL__list__Q29CosNaming20_proxy_NamingContextUlRPt25_CORBA_Unbounded_Sequence1ZQ29CosNaming7BindingRPQ29CosNaming15BindingIterator"
}
-re ".*Can't demangle \"__thunk_64__0RL__list__Q29CosNaming20_proxy_NamingContextUlRPt25_CORBA_Unbounded_Sequence1ZQ29CosNaming7BindingRPQ29CosNaming15BindingIterator\"\r\n$gdb_prompt $" {
pass "gnu: __thunk_64__0RL__list__Q29CosNaming20_proxy_NamingContextUlRPt25_CORBA_Unbounded_Sequence1ZQ29CosNaming7BindingRPQ29CosNaming15BindingIterator"
}
}
}
 
#
# Test lucid style name demangling
#
 
proc test_lucid_style_demangling {} {
test_demangling_exact "lucid: WS__FR7istream" "WS(istream &)"
test_demangling_exact "lucid: __aa__3fooFR3foo" "foo::operator&&(foo &)"
test_demangling_exact "lucid: __aad__3fooFR3foo" "foo::operator&=(foo &)"
test_demangling_exact "lucid: __ad__3fooFR3foo" "foo::operator&(foo &)"
test_demangling_exact "lucid: __adv__3fooFR3foo" "foo::operator/=(foo &)"
test_demangling_exact "lucid: __adv__7complexF7complex" "complex::operator/=(complex)"
test_demangling_exact "lucid: __aer__3fooFR3foo" "foo::operator^=(foo &)"
test_demangling_exact "lucid: __als__3fooFR3foo" "foo::operator<<=(foo &)"
test_demangling_exact "lucid: __amd__3fooFR3foo" "foo::operator%=(foo &)"
test_demangling_exact "lucid: __ami__3fooFR3foo" "foo::operator-=(foo &)"
test_demangling_exact "lucid: __amu__3fooFR3foo" "foo::operator*=(foo &)"
test_demangling_exact "lucid: __amu__7complexF7complex" "complex::operator*=(complex)"
test_demangling_exact "lucid: __aor__3fooFR3foo" "foo::operator|=(foo &)"
test_demangling_exact "lucid: __apl__3fooFR3foo" "foo::operator+=(foo &)"
test_demangling_exact "lucid: __ars__3fooFR3foo" "foo::operator>>=(foo &)"
test_demangling_exact "lucid: __as__18istream_withassignFP9streambuf" "istream_withassign::operator=(streambuf *)"
test_demangling_exact "lucid: __as__18istream_withassignFR7istream" "istream_withassign::operator=(istream &)"
test_demangling_exact "lucid: __as__3fooFR3foo" "foo::operator=(foo &)"
test_demangling_exact "lucid: __as__3iosFR3ios" "ios::operator=(ios &)"
test_demangling_exact "lucid: __cl__3fooFR3foo" "foo::operator()(foo &)"
test_demangling_exact "lucid: __cm__3fooFR3foo" "foo::operator, (foo &)"
 
test_demangling_exact "lucid: __co__3fooFv" "foo::operator~(void)"
test_demangling_exact "lucid: __ct__10istrstreamFPc" "istrstream::istrstream(char *)"
test_demangling_exact "lucid: __ct__10istrstreamFPci" "istrstream::istrstream(char *, int)"
test_demangling_exact "lucid: __ct__10ostrstreamFPciT2" "ostrstream::ostrstream(char *, int, int)"
test_demangling_exact "lucid: __ct__10ostrstreamFv" "ostrstream::ostrstream(void)"
test_demangling_exact "lucid: __ct__10smanip_intFPFR3iosi_R3iosi" "smanip_int::smanip_int(ios &(*)(ios &, int), int)"
test_demangling "lucid: __ct__11c_exceptionFPcRC7complexT2" "c_exception::c_exception\[(\]+char \[*\]+, (const complex|complex const) &, (const complex|complex const) &\[)\]+"
test_demangling "lucid: __ct__11fstreambaseFPCciT2" "fstreambase::fstreambase\[(\]+(const char|char const) \[*\]+, int, int\[)\]+"
test_demangling_exact "lucid: __ct__11fstreambaseFi" "fstreambase::fstreambase(int)"
test_demangling_exact "lucid: __ct__11fstreambaseFiPcT1" "fstreambase::fstreambase(int, char *, int)"
test_demangling_exact "lucid: __ct__11fstreambaseFv" "fstreambase::fstreambase(void)"
test_demangling_exact "lucid: __ct__11smanip_longFPFR3iosl_R3iosl" "smanip_long::smanip_long(ios &(*)(ios &, long), long)"
test_demangling_exact "lucid: __ct__11stdiostreamFP4FILE" "stdiostream::stdiostream(FILE *)"
test_demangling_exact "lucid: __ct__12strstreambufFPFl_PvPFPv_v" "strstreambuf::strstreambuf(void *(*)(long), void (*)(void *))"
test_demangling_exact "lucid: __ct__12strstreambufFPUciT1" "strstreambuf::strstreambuf(unsigned char *, int, unsigned char *)"
test_demangling_exact "lucid: __ct__12strstreambufFPciT1" "strstreambuf::strstreambuf(char *, int, char *)"
test_demangling_exact "lucid: __ct__12strstreambufFi" "strstreambuf::strstreambuf(int)"
test_demangling_exact "lucid: __ct__12strstreambufFv" "strstreambuf::strstreambuf(void)"
test_demangling_exact "lucid: __ct__13strstreambaseFPciT1" "strstreambase::strstreambase(char *, int, char *)"
test_demangling_exact "lucid: __ct__3fooFR3foo" "foo::foo(foo &)"
 
test_demangling_exact "lucid: __ct__3fooFi" "foo::foo(int)"
test_demangling_exact "lucid: __ct__3fooFiN31" "foo::foo(int, int, int, int)"
test_demangling "lucid: __ct__3fooFiPCc" \
"foo::foo\[(\]+int, (const char|char const) \[*\]+\[)\]+"
test_demangling_exact "lucid: __ct__3fooFiR3fooT1T2T1T2" "foo::foo(int, foo &, int, foo &, int, foo &)"
test_demangling_exact "lucid: __ct__3iosFP9streambuf" "ios::ios(streambuf *)"
test_demangling_exact "lucid: __ct__7filebufFiPcT1" "filebuf::filebuf(int, char *, int)"
test_demangling "lucid: __ct__7fstreamFPCciT2" \
"fstream::fstream\[(\]+(const char|char const) \[*\]+, int, int\[)\]+"
test_demangling_exact "lucid: __ct__7fstreamFiPcT1" "fstream::fstream(int, char *, int)"
test_demangling_exact "lucid: __ct__7istreamFP9streambuf" "istream::istream(streambuf *)"
test_demangling_exact "lucid: __ct__7istreamFP9streambufiP7ostream" "istream::istream(streambuf *, int, ostream *)"
test_demangling_exact "lucid: __ct__7istreamFiPcT1" "istream::istream(int, char *, int)"
test_demangling_exact "lucid: __ct__7istreamFiT1P7ostream" "istream::istream(int, int, ostream *)"
test_demangling_exact "lucid: __ct__7ostreamFP9streambuf" "ostream::ostream(streambuf *)"
test_demangling_exact "lucid: __ct__7ostreamFiPc" "ostream::ostream(int, char *)"
test_demangling "lucid: __ct__8ifstreamFPCciT2" \
"ifstream::ifstream\[(\]+(const char|char const) \[*\]+, int, int\[)\]+"
test_demangling_exact "lucid: __ct__8ifstreamFiPcT1" "ifstream::ifstream(int, char *, int)"
 
test_demangling_exact "lucid: __ct__Q23foo3barFv" "foo::bar::bar(void)"
test_demangling_exact "lucid: __ct__Q33foo3bar4bellFv" "foo::bar::bell::bell(void)"
test_demangling_exact "lucid: __dl__3fooSFPv" "foo::operator delete(void *) static"
test_demangling_exact "lucid: __dl__FPv" "operator delete(void *)"
test_demangling_exact "lucid: __dt__10istrstreamFv" "istrstream::~istrstream(void)"
 
test_demangling_exact "lucid: __dt__Q23foo3barFv" "foo::bar::~bar(void)"
test_demangling_exact "lucid: __dt__Q33foo3bar4bellFv" "foo::bar::bell::~bell(void)"
test_demangling_exact "lucid: __dv__3fooFR3foo" "foo::operator/(foo &)"
test_demangling_exact "lucid: __dv__F7complexT1" "operator/(complex, complex)"
test_demangling_exact "lucid: __eq__3fooFR3foo" "foo::operator==(foo &)"
test_demangling_exact "lucid: __er__3fooFR3foo" "foo::operator^(foo &)"
test_demangling_exact "lucid: __ge__3fooFR3foo" "foo::operator>=(foo &)"
test_demangling_exact "lucid: __gt__3fooFR3foo" "foo::operator>(foo &)"
test_demangling_exact "lucid: __le__3fooFR3foo" "foo::operator<=(foo &)"
test_demangling_exact "lucid: __ls__3fooFR3foo" "foo::operator<<(foo &)"
test_demangling_exact "lucid: __ls__7ostreamFP9streambuf" "ostream::operator<<(streambuf *)"
 
test_demangling "lucid: __ls__7ostreamFPCc" \
"ostream::operator<<\[(\]+(const char|char const) \[*\]+\[)\]+"
test_demangling_exact "lucid: __ls__7ostreamFPFR3ios_R3ios" "ostream::operator<<(ios &(*)(ios &))"
test_demangling_exact "lucid: __ls__7ostreamFPv" "ostream::operator<<(void *)"
test_demangling_exact "lucid: __ls__7ostreamFUi" "ostream::operator<<(unsigned int)"
test_demangling_exact "lucid: __ls__7ostreamFUl" "ostream::operator<<(unsigned long)"
test_demangling_exact "lucid: __ls__7ostreamFd" "ostream::operator<<(double)"
test_demangling_exact "lucid: __ls__7ostreamFf" "ostream::operator<<(float)"
test_demangling_exact "lucid: __ls__7ostreamFi" "ostream::operator<<(int)"
test_demangling_exact "lucid: __ls__7ostreamFl" "ostream::operator<<(long)"
test_demangling_exact "lucid: __ls__FR7ostream7complex" "operator<<(ostream &, complex)"
test_demangling_exact "lucid: __lt__3fooFR3foo" "foo::operator<(foo &)"
test_demangling_exact "lucid: __md__3fooFR3foo" "foo::operator%(foo &)"
test_demangling_exact "lucid: __mi__3fooFR3foo" "foo::operator-(foo &)"
test_demangling_exact "lucid: __ml__3fooFR3foo" "foo::operator*(foo &)"
test_demangling_exact "lucid: __ml__F7complexT1" "operator*(complex, complex)"
test_demangling_exact "lucid: __mm__3fooFi" "foo::operator--(int)"
test_demangling_exact "lucid: __ne__3fooFR3foo" "foo::operator!=(foo &)"
test_demangling_exact "lucid: __nt__3fooFv" "foo::operator!(void)"
test_demangling_exact "lucid: __nw__3fooSFi" "foo::operator new(int) static"
test_demangling_exact "lucid: __nw__FUi" "operator new(unsigned int)"
test_demangling_exact "lucid: __nw__FUiPv" "operator new(unsigned int, void *)"
test_demangling_exact "lucid: __oo__3fooFR3foo" "foo::operator||(foo &)"
test_demangling_exact "lucid: __opPc__3fooFv" "foo::operator char *(void)"
test_demangling_exact "lucid: __opi__3fooFv" "foo::operator int(void)"
test_demangling_exact "lucid: __or__3fooFR3foo" "foo::operator|(foo &)"
 
test_demangling_exact "lucid: __pl__3fooFR3foo" "foo::operator+(foo &)"
test_demangling_exact "lucid: __pp__3fooFi" "foo::operator++(int)"
test_demangling_exact "lucid: __pt__3fooFv" "foo::operator->(void)"
test_demangling_exact "lucid: __rm__3fooFR3foo" "foo::operator->*(foo &)"
test_demangling_exact "lucid: __rs__3fooFR3foo" "foo::operator>>(foo &)"
test_demangling_exact "lucid: __rs__7istreamFP9streambuf" "istream::operator>>(streambuf *)"
test_demangling_exact "lucid: __rs__7istreamFPFR3ios_R3ios" "istream::operator>>(ios &(*)(ios &))"
test_demangling_exact "lucid: __rs__7istreamFPFR7istream_R7istream" "istream::operator>>(istream &(*)(istream &))"
test_demangling_exact "lucid: __rs__7istreamFPUc" "istream::operator>>(unsigned char *)"
test_demangling_exact "lucid: __rs__7istreamFPc" "istream::operator>>(char *)"
test_demangling_exact "lucid: __rs__7istreamFRUi" "istream::operator>>(unsigned int &)"
test_demangling_exact "lucid: __rs__7istreamFRUl" "istream::operator>>(unsigned long &)"
test_demangling_exact "lucid: __rs__7istreamFRUs" "istream::operator>>(unsigned short &)"
test_demangling_exact "lucid: __rs__7istreamFRd" "istream::operator>>(double &)"
test_demangling_exact "lucid: __rs__7istreamFRf" "istream::operator>>(float &)"
test_demangling_exact "lucid: __rs__7istreamFRi" "istream::operator>>(int &)"
test_demangling_exact "lucid: __rs__7istreamFRl" "istream::operator>>(long &)"
test_demangling_exact "lucid: __rs__7istreamFRs" "istream::operator>>(short &)"
test_demangling_exact "lucid: __rs__FR7istreamR7complex" "operator>>(istream &, complex &)"
test_demangling "lucid: __vc__3fooFR3foo" "foo::operator\\\[\\\]\\(foo &\\)"
test_demangling_exact "lucid: __vtbl__10istrstream" "istrstream virtual table"
test_demangling_exact "lucid: __vtbl__17ostream__iostream__19iostream_withassign" "iostream_withassign::ostream__iostream virtual table"
 
test_demangling_exact "lucid: __vtbl__3ios" "ios virtual table"
test_demangling_exact "lucid: __vtbl__3ios__13strstreambase" "strstreambase::ios virtual table"
 
# GDB 930414 demangles this as t_cc_main_ (obviously wrong).
# GDB 930701 gets into an infinite loop.
# GDB 930727 says "Can't demangle".
# What is the correct demangling? FIXME.
 
# NOTE: carlton/2003-01-17: No, don't FIXME, just obsolete lucid.
# I'm KFAILing this rather than deleting it for form's sake.
setup_kfail "gdb/945" "*-*-*"
test_demangling_exact "lucid: __vtbl__3foo__vt_cc_main_" ""
 
test_demangling_exact "lucid: abs__F7complex" "abs(complex)"
test_demangling_exact "lucid: allocate__9streambufFv" "streambuf::allocate(void)"
test_demangling_exact "lucid: attach__11fstreambaseFi" "fstreambase::attach(int)"
test_demangling_exact "lucid: bitalloc__3iosSFv" "ios::bitalloc(void) static"
test_demangling_exact "lucid: chr__FiT1" "chr(int, int)"
test_demangling_exact "lucid: complex_error__FR11c_exception" "complex_error(c_exception &)"
test_demangling_exact "lucid: complexfunc2__FPFPc_i" "complexfunc2(int (*)(char *))"
test_demangling_exact "lucid: complexfunc3__FPFPFPl_s_i" "complexfunc3(int (*)(short (*)(long *)))"
 
test_demangling_exact "lucid: complexfunc4__FPFPFPc_s_i" "complexfunc4(int (*)(short (*)(char *)))"
test_demangling_exact "lucid: complexfunc5__FPFPc_PFl_i" "complexfunc5(int (*(*)(char *))(long))"
test_demangling_exact "lucid: complexfunc6__FPFPi_PFl_i" "complexfunc6(int (*(*)(int *))(long))"
test_demangling_exact "lucid: complexfunc7__FPFPFPc_i_PFl_i" "complexfunc7(int (*(*)(int (*)(char *)))(long))"
test_demangling_exact "lucid: complicated_put__7ostreamFc" "ostream::complicated_put(char)"
test_demangling_exact "lucid: conv10__FlPc" "conv10(long, char *)"
test_demangling_exact "lucid: conv16__FUlPc" "conv16(unsigned long, char *)"
test_demangling_exact "lucid: dec__FR3ios" "dec(ios &)"
test_demangling_exact "lucid: dec__Fli" "dec(long, int)"
test_demangling_exact "lucid: dofield__FP7ostreamPciT2T3" "dofield(ostream *, char *, int, char *, int)"
 
test_demangling_exact "lucid: flags__3iosFl" "ios::flags(long)"
test_demangling_exact "lucid: flags__3iosFv" "ios::flags(void)"
test_demangling_exact "lucid: foo__FiN31" "foo(int, int, int, int)"
test_demangling_exact "lucid: foo__FiR3fooT1T2T1T2" "foo(int, foo &, int, foo &, int, foo &)"
test_demangling_exact "lucid: foo___3barFl" "bar::foo_(long)"
test_demangling "lucid: form__FPCce" "form\[(\]+(const char|char const) \[*\]+,...\[)\]+"
test_demangling_exact "lucid: get__7istreamFPcic" "istream::get(char *, int, char)"
test_demangling_exact "lucid: get__7istreamFR9streambufc" "istream::get(streambuf &, char)"
test_demangling_exact "lucid: get_complicated__7istreamFRUc" "istream::get_complicated(unsigned char &)"
test_demangling_exact "lucid: get_complicated__7istreamFRc" "istream::get_complicated(char &)"
test_demangling_exact "lucid: getline__7istreamFPUcic" "istream::getline(unsigned char *, int, char)"
test_demangling_exact "lucid: getline__7istreamFPcic" "istream::getline(char *, int, char)"
 
test_demangling_exact "lucid: ignore__7istreamFiT1" "istream::ignore(int, int)"
test_demangling_exact "lucid: init__12strstreambufFPciT1" "strstreambuf::init(char *, int, char *)"
test_demangling_exact "lucid: init__3iosFP9streambuf" "ios::init(streambuf *)"
test_demangling_exact "lucid: initcount__13Iostream_init" "Iostream_init::initcount"
test_demangling_exact "lucid: ipfx__7istreamFi" "istream::ipfx(int)"
test_demangling_exact "lucid: ls_complicated__7ostreamFUc" "ostream::ls_complicated(unsigned char)"
test_demangling_exact "lucid: ls_complicated__7ostreamFc" "ostream::ls_complicated(char)"
test_demangling "lucid: open__11fstreambaseFPCciT2" \
"fstreambase::open\[(\]+(const char|char const) \[*\]+, int, int\[)\]+"
test_demangling "lucid: open__7filebufFPCciT2" \
"filebuf::open\[(\]+(const char|char const) \[*\]+, int, int\[)\]+"
 
test_demangling_exact "lucid: overload1arg__FSc" "overload1arg(signed char)"
test_demangling_exact "lucid: overload1arg__FUc" "overload1arg(unsigned char)"
test_demangling_exact "lucid: overload1arg__FUi" "overload1arg(unsigned int)"
test_demangling_exact "lucid: overload1arg__FUl" "overload1arg(unsigned long)"
test_demangling_exact "lucid: overload1arg__FUs" "overload1arg(unsigned short)"
test_demangling_exact "lucid: overload1arg__Fc" "overload1arg(char)"
test_demangling_exact "lucid: overload1arg__Fd" "overload1arg(double)"
test_demangling_exact "lucid: overload1arg__Ff" "overload1arg(float)"
test_demangling_exact "lucid: overload1arg__Fi" "overload1arg(int)"
test_demangling_exact "lucid: overload1arg__Fl" "overload1arg(long)"
test_demangling_exact "lucid: overload1arg__Fs" "overload1arg(short)"
test_demangling_exact "lucid: overload1arg__Fv" "overload1arg(void)"
test_demangling_exact "lucid: overloadargs__FiN21" "overloadargs(int, int, int)"
test_demangling_exact "lucid: overloadargs__FiN31" "overloadargs(int, int, int, int)"
test_demangling_exact "lucid: overloadargs__FiN41" "overloadargs(int, int, int, int, int)"
test_demangling_exact "lucid: overloadargs__FiN51" "overloadargs(int, int, int, int, int, int)"
test_demangling_exact "lucid: overloadargs__FiN61" "overloadargs(int, int, int, int, int, int, int)"
 
test_demangling_exact "lucid: overloadargs__FiN71" "overloadargs(int, int, int, int, int, int, int, int)"
test_demangling_exact "lucid: overloadargs__FiN81" "overloadargs(int, int, int, int, int, int, int, int, int)"
test_demangling_exact "lucid: overloadargs__FiN91" "overloadargs(int, int, int, int, int, int, int, int, int, int)"
test_demangling_exact "lucid: overloadargs__FiN91N11" "overloadargs(int, int, int, int, int, int, int, int, int, int, int)"
test_demangling_exact "lucid: overloadargs__FiT1" "overloadargs(int, int)"
test_demangling_exact "lucid: polar__FdT1" "polar(double, double)"
test_demangling_exact "lucid: pow__F7complexT1" "pow(complex, complex)"
test_demangling_exact "lucid: pow__F7complexd" "pow(complex, double)"
test_demangling_exact "lucid: pow__F7complexi" "pow(complex, int)"
test_demangling_exact "lucid: pow__Fd7complex" "pow(double, complex)"
test_demangling_exact "lucid: pstart__FPciT2" "pstart(char *, int, int)"
test_demangling_exact "lucid: put__7ostreamFc" "ostream::put(char)"
 
test_demangling_exact "lucid: read__7istreamFPci" "istream::read(char *, int)"
test_demangling_exact "lucid: resetiosflags__FR3iosl" "resetiosflags(ios &, long)"
test_demangling_exact "lucid: restore_errno__FRi" "restore_errno(int &)"
test_demangling_exact "lucid: rs_complicated__7istreamFRUc" "istream::rs_complicated(unsigned char &)"
test_demangling_exact "lucid: rs_complicated__7istreamFRc" "istream::rs_complicated(char &)"
test_demangling_exact "lucid: seekg__7istreamFl8seek_dir" "istream::seekg(long, seek_dir)"
test_demangling_exact "lucid: seekoff__12strstreambufFl8seek_diri" "strstreambuf::seekoff(long, seek_dir, int)"
test_demangling_exact "lucid: seekoff__9streambufFlQ2_3ios12ios_seek_diri" "streambuf::seekoff(long, ios::ios_seek_dir, int)"
test_demangling_exact "lucid: seekpos__9streambufFli" "streambuf::seekpos(long, int)"
test_demangling_exact "lucid: set_new_handler__FPFv_v" "set_new_handler(void (*)(void))"
test_demangling_exact "lucid: setb__9streambufFPcT1i" "streambuf::setb(char *, char *, int)"
 
test_demangling_exact "lucid: setb__FR3iosi" "setb(ios &, int)"
test_demangling_exact "lucid: setbuf__11fstreambaseFPci" "fstreambase::setbuf(char *, int)"
test_demangling_exact "lucid: setbuf__9streambufFPUci" "streambuf::setbuf(unsigned char *, int)"
test_demangling_exact "lucid: setbuf__9streambufFPciT2" "streambuf::setbuf(char *, int, int)"
test_demangling_exact "lucid: setf__3iosFlT1" "ios::setf(long, long)"
test_demangling_exact "lucid: setfill__FR3iosi" "setfill(ios &, int)"
test_demangling_exact "lucid: setg__9streambufFPcN21" "streambuf::setg(char *, char *, char *)"
test_demangling_exact "lucid: setp__9streambufFPcT1" "streambuf::setp(char *, char *)"
 
test_demangling "lucid: sputn__9streambufFPCci" \
"streambuf::sputn\[(\]+(const char|char const) \[*\]+, int\[)\]+"
test_demangling "lucid: str__FPCci" \
"str\[(\]+(const char|char const) \[*\]+, int\[)\]+"
test_demangling_exact "lucid: tie__3iosFP7ostream" "ios::tie(ostream *)"
test_demangling_exact "lucid: uconv10__FUlPc" "uconv10(unsigned long, char *)"
 
test_demangling "lucid: write__7ostreamFPCci" \
"ostream::write\[(\]+(const char|char const) \[*\]+, int\[)\]+"
test_demangling_exact "lucid: xget__7istreamFPc" "istream::xget(char *)"
test_demangling_exact "lucid: xsgetn__9streambufFPci" "streambuf::xsgetn(char *, int)"
test_demangling "lucid: xsputn__9streambufFPCci" \
"streambuf::xsputn\[(\]+(const char|char const) \[*\]+, int\[)\]+"
 
test_demangling_exact "lucid: _Utf390_1__1_9223372036854775807__9223372036854775" \
"Can't demangle \"_Utf390_1__1_9223372036854775807__9223372036854775\""
}
 
#
# Test arm style name demangling
#
 
proc test_arm_style_demangling {} {
test_demangling_exact "arm: __dt__21T5__pt__11_PFiPPdPv_iFv" "T5<int (*)(int, double **, void *)>::~T5(void)"
 
test_demangling_exact "arm: __ct__1cFi" "c::c(int)"
 
test_demangling_exact "arm: __dt__11T5__pt__2_iFv" "T5<int>::~T5(void)"
 
test_demangling_exact "arm: __dt__11T5__pt__2_cFv" "T5<char>::~T5(void)"
 
test_demangling_exact "arm: __ct__2T2Fi" "T2::T2(int)"
test_demangling_exact "arm: __dt__2T1Fv" "T1::~T1(void)"
 
test_demangling_exact "arm: __dt__12T5__pt__3_1xFv" "T5<x>::~T5(void)"
 
test_demangling_exact "arm: __dt__17T5__pt__8_PFcPv_iFv" "T5<int (*)(char, void *)>::~T5(void)"
 
test_demangling "arm: g__FP1cPC1cT1" \
"g\[(\]+c *\[*\]+, (const c|c const) *\[*\]+, c *\[*\]+\[)\]+"
test_demangling "arm: g__FPUlPCUlT1" \
"g\[(\]+unsigned long \[*\]+, (const unsigned long|unsigned long const) \[*\]+, unsigned long \[*\]+\[)\]+"
test_demangling "arm: g__FPUiPCUiT1" \
"g\[(\]+unsigned int \[*\]+, (const unsigned int|unsigned int const) \[*\]+, unsigned int \[*\]+\[)\]+"
test_demangling "arm: g__FPUsPCUsT1" \
"g\[(\]+unsigned short \[*\]+, (const unsigned short|unsigned short const) \[*\]+, unsigned short \[*\]+\[)\]+"
test_demangling "arm: g__FPUcPCUcT1" \
"g\[(\]+unsigned char \[*\]+, (const unsigned char|unsigned char const) \[*\]+, unsigned char \[*\]+\[)\]+"
test_demangling "arm: g__F1TPlPClT2" \
"g\[(\]+T, long \[*\]+, (const long|long const) \[*\]+, long \[*\]+\[)\]+"
test_demangling "arm: g__F1RRlRClT2" \
"g\[(\]+R, long &, (const long|long const) &, long &\[)\]+"
test_demangling "arm: g__F1TPiPCiT2" \
"g\[(\]+T, int \[*\]+, (const int|int const) \[*\]+, int \[*\]+\[)\]+"
test_demangling "arm: g__F1RRiRCiT2" \
"g\[(\]+R, int &, (const int|int const) &, int &\[)\]+"
test_demangling "arm: g__F1TPsPCsT2" \
"g\[(\]+T, short \[*\]+, (const short|short const) \[*\]+, short \[*\]+\[)\]+"
test_demangling "arm: g__F1RRsRCsT2" \
"g\[(\]+R, short &, (const short|short const) &, short &\[)\]+"
test_demangling "arm: g__F1TPcPCcT2" \
"g\[(\]+T, char \[*\]+, (const char|char const) \[*\]+, char \[*\]+\[)\]+"
test_demangling "arm: g__F1RRcRCcT2" \
"g\[(\]+R, char &, (const char|char const) &, char &\[)\]+"
 
test_demangling_exact "arm: __ct__21T5__pt__11_PFiPPdPv_iFi" "T5<int (*)(int, double **, void *)>::T5(int)"
 
test_demangling "arm: __gt__FRC2T2c" \
"operator>\[(\]+(const T2|T2 const) &, char\[)\]+"
test_demangling "arm: __ge__FRC2T2c" \
"operator>=\[(\]+(const T2|T2 const) &, char\[)\]+"
test_demangling "arm: __lt__FRC2T2c" \
"operator<\[(\]+(const T2|T2 const) &, char\[)\]+"
 
test_demangling "arm: __le__FRC2T2c" \
"operator<=\[(\]+(const T2|T2 const) &, char\[)\]+"
test_demangling "arm: __ne__FRC2T2c" \
"operator!=\[(\]+(const T2|T2 const) &, char\[)\]+"
test_demangling "arm: __eq__FRC2T2c" \
"operator==\[(\]+(const T2|T2 const) &, char\[)\]+"
test_demangling_exact "arm: __amd__FR2T2i" "operator%=(T2 &, int)"
test_demangling_exact "arm: __adv__FR2T2i" "operator/=(T2 &, int)"
test_demangling_exact "arm: __amu__FR2T2i" "operator*=(T2 &, int)"
test_demangling_exact "arm: __ami__FR2T2i" "operator-=(T2 &, int)"
test_demangling_exact "arm: __apl__FR2T2i" "operator+=(T2 &, int)"
test_demangling_exact "arm: __nw__2T1SFUi" "T1::operator new(unsigned int) static"
test_demangling_exact "arm: __dl__2T1SFPv" "T1::operator delete(void *) static"
test_demangling_exact "arm: put__2T7SFi" "T7::put(int) static"
 
test_demangling_exact "arm: __dl__12T5__pt__3_1xSFPv" "T5<x>::operator delete(void *) static"
 
test_demangling_exact "arm: h__FUc" "h(unsigned char)"
test_demangling_exact "arm: f__Fic" "f(int, char)"
test_demangling_exact "arm: h__FUi" "h(unsigned int)"
test_demangling_exact "arm: h__Fci" "h(char, int)"
test_demangling_exact "arm: h__FUl" "h(unsigned long)"
test_demangling_exact "arm: h__Fcl" "h(char, long)"
test_demangling_exact "arm: h__FUs" "h(unsigned short)"
test_demangling_exact "arm: h__Fcs" "h(char, short)"
test_demangling "arm: __amd__FR2T2RC2T2" \
"operator%=\[(\]+T2 &, (const T2|T2 const) &\[)\]+"
test_demangling "arm: __adv__FR2T2RC2T2" \
"operator/=\[(\]+T2 &, (const T2|T2 const) &\[)\]+"
test_demangling "arm: __amu__FR2T2RC2T2" \
"operator\[*\]+=\[(\]+T2 &, (const T2|T2 const) &\[)\]+"
test_demangling "arm: __ami__FR2T2RC2T2" \
"operator-=\[(\]+T2 &, (const T2|T2 const) &\[)\]+"
test_demangling "arm: __apl__FR2T2RC2T2" \
"operator\[+\]+=\[(\]+T2 &, (const T2|T2 const) &\[)\]+"
 
test_demangling "arm: g__F1SRPUlRPCUlT2" \
"g\[(\]+S, unsigned long \[*\]+&, (const unsigned long|unsigned long const) \[*\]+&, unsigned long \[*\]+&\[)\]+"
test_demangling "arm: g__F1SRPUiRPCUiT2" \
"g\[(\]+S, unsigned int \[*\]+&, (const unsigned int|unsigned int const) \[*\]+&, unsigned int \[*\]+&\[)\]+"
test_demangling "arm: g__F1SRPUsRPCUsT2" \
"g\[(\]+S, unsigned short \[*\]+&, (const unsigned short|unsigned short const) \[*\]+&, unsigned short \[*\]+&\[)\]+"
test_demangling "arm: g__F1SRPUcRPCUcT2" \
"g\[(\]+S, unsigned char \[*\]+&, (const unsigned char|unsigned char const) \[*\]+&, unsigned char \[*\]+&\[)\]+"
test_demangling "arm: g__F1T1SRPlRPClT3" \
"g\[(\]+T, S, long \[*\]+&, (const long|long const) \[*\]+&, long \[*\]+&\[)\]+"
test_demangling "arm: g__F1T1SRPiRPCiT3" \
"g\[(\]+T, S, int \[*\]+&, (const int|int const) \[*\]+&, int \[*\]+&\[)\]+"
test_demangling "arm: g__F1T1SRPcRPCcT3" \
"g\[(\]+T, S, char \[*\]+&, (const char|char const) \[*\]+&, char \[*\]+&\[)\]+"
 
test_demangling_exact "arm: X__12T5__pt__3_1x" "T5<x>::X"
 
test_demangling_exact "arm: __ct__11T5__pt__2_iFi" "T5<int>::T5(int)"
 
test_demangling_exact "arm: __ct__11T5__pt__2_cFi" "T5<char>::T5(int)"
 
test_demangling "arm: __gt__FRC2T2T1" \
"operator>\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
test_demangling "arm: __ge__FRC2T2T1" \
"operator>=\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
test_demangling "arm: __lt__FRC2T2T1" \
"operator<\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
test_demangling "arm: __le__FRC2T2T1" \
"operator<=\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
test_demangling "arm: __ne__FRC2T2T1" \
"operator!=\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
test_demangling "arm: __eq__FRC2T2T1" \
"operator==\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
test_demangling "arm: g__FcR1cRC1cT2" \
"g\[(\]+char, c &, (const c|c const) &, c &\[)\]+"
test_demangling "arm: g__FcRPdRPCdT2" \
"g\[(\]+char, double *\[*\]+&, (const double|double const) *\[*\]+&, double *\[*\]+&\[)\]+"
test_demangling "arm: g__FcRPfRPCfT2" \
"g\[(\]+char, float *\[*\]+&, (const float|float const) *\[*\]+&, float *\[*\]+&\[)\]+"
test_demangling_exact "arm: h__FcT1" "h(char, char)"
test_demangling_exact "arm: f__Ficd" "f(int, char, double)"
test_demangling "arm: g__F1T1SdRPsRPCsT4" \
"g\[(\]+T, S, double, short \[*\]+&, (const short|short const) \[*\]+&, short \[*\]+&\[)\]+"
test_demangling "arm: g__F1cC1cT1" \
"g\[(\]+c, (const c|c const), c\[)\]+"
test_demangling "arm: g__FPdPCdT1" \
"g\[(\]+double *\[*\]+, (const double|double const) *\[*\]+, double *\[*\]+\[)\]+"
test_demangling "arm: g__FPfPCfT1" \
"g\[(\]+float *\[*\]+, (const float|float const) *\[*\]+, float *\[*\]+\[)\]+"
 
test_demangling "arm: g__FUlCUlT1" \
"g\[(\]+unsigned long, (const unsigned long|unsigned long const), unsigned long\[)\]+"
test_demangling "arm: g__FPlPClT1" \
"g\[(\]+long \[*\]+, (const long|long const) \[*\]+, long \[*\]+\[)\]+"
test_demangling "arm: g__FUiCUiT1" \
"g\[(\]+unsigned int, (const unsigned int|unsigned int const), unsigned int\[)\]+"
test_demangling "arm: g__FPiPCiT1" \
"g\[(\]+int \[*\]+, (const int|int const) \[*\]+, int \[*\]+\[)\]+"
test_demangling "arm: g__FUsCUsT1" \
"g\[(\]+unsigned short, (const unsigned short|unsigned short const), unsigned short\[)\]+"
test_demangling "arm: g__FPsPCsT1" \
"g\[(\]+short \[*\]+, (const short|short const) \[*\]+, short \[*\]+\[)\]+"
test_demangling "arm: g__FUcCUcT1" \
"g\[(\]+unsigned char, (const unsigned char|unsigned char const), unsigned char\[)\]+"
test_demangling "arm: g__FPcPCcT1" \
"g\[(\]+char \[*\]+, (const char|char const) \[*\]+, char \[*\]+\[)\]+"
test_demangling "arm: g__F1TlClT2" \
"g\[(\]+T, long, (const long|long const), long\[)\]+"
test_demangling "arm: g__F1TiCiT2" \
"g\[(\]+T, int, (const int|int const), int\[)\]+"
test_demangling "arm: g__F1TsCsT2" \
"g\[(\]+T, short, (const short|short const), short\[)\]+"
test_demangling "arm: g__F1TcCcT2" \
"g\[(\]+T, char, (const char|char const), char\[)\]+"
 
test_demangling_exact "arm: __dl__17T5__pt__8_PFcPv_iSFPv" "T5<int (*)(char, void *)>::operator delete(void *) static"
 
test_demangling "arm: printf__FPCce" \
"printf\[(\]+(const char|char const) \[*\]+,...\[)\]+"
 
test_demangling_exact "arm: X__17T5__pt__8_PFcPv_i" "T5<int (*)(char, void *)>::X"
 
test_demangling_exact "arm: __ct__12T5__pt__3_1xFi" "T5<x>::T5(int)"
 
test_demangling "arm: g__F1SRUlRCUlT2" \
"g\[(\]+S, unsigned long &, (const unsigned long|unsigned long const) &, unsigned long &\[)\]+"
test_demangling "arm: g__F1SRPlRPClT2" \
"g\[(\]+S, long \[*\]+&, (const long|long const) \[*\]+&, long \[*\]+&\[)\]+"
test_demangling "arm: g__F1RRUiRCUiT2" \
"g\[(\]+R, unsigned int &, (const unsigned int|unsigned int const) &, unsigned int &\[)\]+"
test_demangling "arm: g__F1SRPiRPCiT2" \
"g\[(\]+S, int \[*\]+&, (const int|int const) \[*\]+&, int \[*\]+&\[)\]+"
test_demangling "arm: g__F1RRUsRCUsT2" \
"g\[(\]+R, unsigned short &, (const unsigned short|unsigned short const) &, unsigned short &\[)\]+"
test_demangling "arm: g__F1SRPsRPCsT2" \
"g\[(\]+S, short \[*\]+&, (const short|short const) \[*\]+&, short \[*\]+&\[)\]+"
test_demangling "arm: g__F1RRUcRCUcT2" \
"g\[(\]+R, unsigned char &, (const unsigned char|unsigned char const) &, unsigned char &\[)\]+"
test_demangling "arm: g__F1SRPcRPCcT2" \
"g\[(\]+S, char \[*\]+&, (const char|char const) \[*\]+&, char \[*\]+&\[)\]+"
test_demangling "arm: g__F1T1RRlRClT3" \
"g\[(\]+T, R, long &, (const long|long const) &, long &\[)\]+"
test_demangling "arm: g__F1T1RRiRCiT3" \
"g\[(\]+T, R, int &, (const int|int const) &, int &\[)\]+"
test_demangling "arm: g__F1T1RRsRCsT3" \
"g\[(\]+T, R, short &, (const short|short const) &, short &\[)\]+"
test_demangling "arm: g__F1T1RRcRCcT3" \
"g\[(\]+T, R, char &, (const char|char const) &, char &\[)\]+"
 
test_demangling_exact "arm: __dl__21T5__pt__11_PFiPPdPv_iSFPv" "T5<int (*)(int, double **, void *)>::operator delete(void *) static"
 
test_demangling_exact "arm: __std__foo" "global destructors keyed to foo"
 
test_demangling_exact "arm: __sti__bar" "global constructors keyed to bar"
 
test_demangling_exact "arm: f__FicdPcPFci_v" "f(int, char, double, char *, void (*)(char, int))"
test_demangling_exact "arm: f__FicdPcPFic_v" "f(int, char, double, char *, void (*)(int, char))"
test_demangling_exact "arm: get__2T7SFv" "T7::get(void) static"
 
test_demangling_exact "arm: X__21T5__pt__11_PFiPPdPv_i" "T5<int (*)(int, double **, void *)>::X"
 
test_demangling "arm: g__FcRdRCdT2" \
"g\[(\]+char, double &, (const double|double const) &, double &\[)\]+"
test_demangling "arm: g__FcRfRCfT2" \
"g\[(\]+char, float &, (const float|float const) &, float &\[)\]+"
test_demangling "arm: __md__FC2T2i" \
"operator%\[(\]+(const T2|T2 const), int\[)\]+"
test_demangling "arm: __dv__FC2T2i" \
"operator/\[(\]+(const T2|T2 const), int\[)\]+"
test_demangling "arm: __ml__FC2T2i" \
"operator\[*\]+\[(\]+(const T2|T2 const), int\[)\]+"
test_demangling "arm: __mi__FC2T2i" \
"operator-\[(\]+(const T2|T2 const), int\[)\]+"
test_demangling "arm: __pl__FC2T2i" \
"operator\[+\]+\[(\]+(const T2|T2 const), int\[)\]+"
 
test_demangling_exact "arm: __dl__11T5__pt__2_iSFPv" "T5<int>::operator delete(void *) static"
 
test_demangling_exact "arm: __dl__11T5__pt__2_cSFPv" "T5<char>::operator delete(void *) static"
 
test_demangling_exact "arm: h__Fc" "h(char)"
test_demangling_exact "arm: h__Fd" "h(double)"
test_demangling_exact "arm: h__Ff" "h(float)"
test_demangling_exact "arm: h__Fi" "h(int)"
test_demangling_exact "arm: f__Fi" "f(int)"
test_demangling_exact "arm: h__Fl" "h(long)"
 
test_demangling_exact "arm: h__Fs" "h(short)"
test_demangling "arm: __md__FC2T2RC2T2" \
"operator%\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+"
test_demangling "arm: __dv__FC2T2RC2T2" \
"operator/\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+"
test_demangling "arm: __ml__FC2T2RC2T2" \
"operator\[*\]+\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+"
test_demangling "arm: __mi__FC2T2RC2T2" \
"operator-\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+"
test_demangling "arm: __pl__FC2T2RC2T2" \
"operator\[+\]+\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+"
test_demangling "arm: g__FcRP1cRPC1cT2" \
"g\[(\]+char, c *\[*\]+&, (const c|c const) *\[*\]+&, c *\[*\]+&\[)\]+"
 
test_demangling_exact "arm: X__11T5__pt__2_c" "T5<char>::X"
 
test_demangling_exact "arm: X__11T5__pt__2_i" "T5<int>::X"
 
test_demangling "arm: g__FdCdT1" \
"g\[(\]+double, (const double|double const), double\[)\]+"
test_demangling "arm: g__FfCfT1" \
"g\[(\]+float, (const float|float const), float\[)\]+"
test_demangling "arm: g__FlClT1" \
"g\[(\]+long, (const long|long const), long\[)\]+"
test_demangling "arm: g__FiCiT1" \
"g\[(\]+int, (const int|int const), int\[)\]+"
test_demangling "arm: g__FsCsT1" \
"g\[(\]+short, (const short|short const), short\[)\]+"
test_demangling "arm: g__FcCcT1" \
"g\[(\]+char, (const char|char const), char\[)\]+"
 
test_demangling_exact "arm: __ct__17T5__pt__8_PFcPv_iFi" "T5<int (*)(char, void *)>::T5(int)"
 
test_demangling_exact "arm: f__FicdPc" "f(int, char, double, char *)"
test_demangling_exact "arm: __nw__FUi" "operator new(unsigned int)"
test_demangling_exact "arm: __ct__Q3_2T11a1bSFi" "T1::a::b::b(int) static"
test_demangling_exact "arm: __dt__Q3_2T11a1bSFi" "T1::a::b::~b(int) static"
test_demangling_exact "arm: put__Q3_2T11a1bSFi" "T1::a::b::put(int) static"
test_demangling_exact "arm: get__Q2_2T11aSFv" "T1::a::get(void) static"
test_demangling_exact "arm: put__2T1SFi" "T1::put(int) static"
test_demangling_exact "arm: put__Q5_2T11a1b1c1dSFi" "T1::a::b::c::d::put(int) static"
test_demangling_exact "arm: get__Q4_2T11a1b1cSFv" "T1::a::b::c::get(void) static"
test_demangling_exact "arm: put__Q2_2T11aSFi" "T1::a::put(int) static"
test_demangling_exact "arm: put__Q4_2T11a1b1cSFi" "T1::a::b::c::put(int) static"
test_demangling_exact "arm: get__Q3_2T11a1bSFv" "T1::a::b::get(void) static"
test_demangling_exact "arm: get__2T1SFv" "T1::get(void) static"
test_demangling_exact "arm: get__Q5_2T11a1b1c1dSFv" "T1::a::b::c::d::get(void) static"
 
test_demangling_exact "arm: __dt__11T1__pt__2_cFv" "T1<char>::~T1(void)"
 
test_demangling_exact "arm: __dt__12T1__pt__3_1tFv" "T1<t>::~T1(void)"
 
test_demangling_exact "arm: __dl__12T1__pt__3_1tSFPv" "T1<t>::operator delete(void *) static"
 
test_demangling_exact "arm: __ct__11T1__pt__2_cFi" "T1<char>::T1(int)"
 
test_demangling_exact "arm: __ct__11T1__pt__2_cFv" "T1<char>::T1(void)"
 
test_demangling_exact "arm: __ct__12T1__pt__3_1tFi" "T1<t>::T1(int)"
 
test_demangling_exact "arm: __ct__12T1__pt__3_1tFv" "T1<t>::T1(void)"
 
test_demangling_exact "arm: __dl__11T1__pt__2_cSFPv" "T1<char>::operator delete(void *) static"
 
test_demangling_exact "arm: bar__3fooFPv" "foo::bar(void *)"
test_demangling "arm: bar__3fooFPCv" \
"foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+"
test_demangling_exact "arm: bar__3fooCFPv" "foo::bar(void *) const"
test_demangling "arm: bar__3fooCFPCv" \
"foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+ const"
test_demangling_exact "arm: __eq__3fooFR3foo" "foo::operator==(foo &)"
test_demangling "arm: __eq__3fooFRC3foo" \
"foo::operator==\[(\]+(const foo|foo const) &\[)\]+"
test_demangling_exact "arm: __eq__3fooCFR3foo" "foo::operator==(foo &) const"
test_demangling "arm: __eq__3fooCFRC3foo" \
"foo::operator==\[(\]+(const foo|foo const) &\[)\]+ const"
 
test_demangling_exact "arm: elem__15vector__pt__2_dFi" "vector<double>::elem(int)"
 
test_demangling_exact "arm: elem__15vector__pt__2_iFi" "vector<int>::elem(int)"
 
test_demangling_exact "arm: __ct__15vector__pt__2_dFi" "vector<double>::vector(int)"
 
test_demangling_exact "arm: __ct__15vector__pt__2_iFi" "vector<int>::vector(int)"
 
test_demangling_exact "arm: __ct__25DListNode__pt__9_R6RLabelFR6RLabelP25DListNode__pt__9_R6RLabelT2" \
"DListNode<RLabel &>::DListNode(RLabel &, DListNode<RLabel &> *, DListNode<RLabel &> *)"
 
test_demangling_exact "arm: bar__3fooFiT16FooBar" "foo::bar(int, int, FooBar)"
 
test_demangling_exact "arm: bar__3fooFPiN51PdN37PcN211T1iN215" \
"foo::bar(int *, int *, int *, int *, int *, int *, double *, double *, double *, double *, char *, char *, char *, int *, int, int, int)"
 
test_demangling_exact "arm: _Utf390_1__1_9223372036854775807__9223372036854775" \
"Can't demangle \"_Utf390_1__1_9223372036854775807__9223372036854775\""
}
 
proc test_hp_style_demangling {} {
 
# HP aCC mangling style is based on ARM for all the basic stuff,
# so first we use some of the ARM tests here. Later we have HP-specific
# tests.
test_demangling "hp: g__FP1cPC1cT1" \
"g\[(\]+c *\[*\]+, (const c|c const) *\[*\]+, c *\[*\]+\[)\]+"
test_demangling "hp: g__FPUlPCUlT1" \
"g\[(\]+unsigned long \[*\]+, (const unsigned long|unsigned long const) \[*\]+, unsigned long \[*\]+\[)\]+"
test_demangling "hp: g__FPUiPCUiT1" \
"g\[(\]+unsigned int \[*\]+, (const unsigned int|unsigned int const) \[*\]+, unsigned int \[*\]+\[)\]+"
test_demangling "hp: g__FPUsPCUsT1" \
"g\[(\]+unsigned short \[*\]+, (const unsigned short|unsigned short const) \[*\]+, unsigned short \[*\]+\[)\]+"
test_demangling "hp: g__FPUcPCUcT1" \
"g\[(\]+unsigned char \[*\]+, (const unsigned char|unsigned char const) \[*\]+, unsigned char \[*\]+\[)\]+"
test_demangling "hp: g__F1TPlPClT2" \
"g\[(\]+T, long \[*\]+, (const long|long const) \[*\]+, long \[*\]+\[)\]+"
test_demangling "hp: g__F1RRlRClT2" \
"g\[(\]+R, long &, (const long|long const) &, long &\[)\]+"
test_demangling "hp: g__F1TPiPCiT2" \
"g\[(\]+T, int \[*\]+, (const int|int const) \[*\]+, int \[*\]+\[)\]+"
test_demangling "hp: g__F1RRiRCiT2" \
"g\[(\]+R, int &, (const int|int const) &, int &\[)\]+"
test_demangling "hp: g__F1TPsPCsT2" \
"g\[(\]+T, short \[*\]+, (const short|short const) \[*\]+, short \[*\]+\[)\]+"
test_demangling "hp: g__F1RRsRCsT2" \
"g\[(\]+R, short &, (const short|short const) &, short &\[)\]+"
test_demangling "hp: g__F1TPcPCcT2" \
"g\[(\]+T, char \[*\]+, (const char|char const) \[*\]+, char \[*\]+\[)\]+"
test_demangling "hp: g__F1RRcRCcT2" \
"g\[(\]+R, char &, (const char|char const) &, char &\[)\]+"
 
test_demangling "hp: __gt__FRC2T2c" \
"operator>\[(\]+(const T2|T2 const) &, char\[)\]+"
test_demangling "hp: __ge__FRC2T2c" \
"operator>=\[(\]+(const T2|T2 const) &, char\[)\]+"
test_demangling "hp: __lt__FRC2T2c" \
"operator<\[(\]+(const T2|T2 const) &, char\[)\]+"
 
test_demangling "hp: __le__FRC2T2c" \
"operator<=\[(\]+(const T2|T2 const) &, char\[)\]+"
test_demangling "hp: __ne__FRC2T2c" \
"operator!=\[(\]+(const T2|T2 const) &, char\[)\]+"
test_demangling "hp: __eq__FRC2T2c" \
"operator==\[(\]+(const T2|T2 const) &, char\[)\]+"
test_demangling_exact "hp: __amd__FR2T2i" "operator%=(T2 &, int)"
test_demangling_exact "hp: __adv__FR2T2i" "operator/=(T2 &, int)"
test_demangling_exact "hp: __amu__FR2T2i" "operator*=(T2 &, int)"
test_demangling_exact "hp: __ami__FR2T2i" "operator-=(T2 &, int)"
test_demangling_exact "hp: __apl__FR2T2i" "operator+=(T2 &, int)"
test_demangling_exact "hp: __nw__2T1SFUi" "T1::operator new(unsigned int) static"
test_demangling_exact "hp: __dl__2T1SFPv" "T1::operator delete(void *) static"
test_demangling_exact "hp: put__2T7SFi" "T7::put(int) static"
 
test_demangling_exact "hp: h__FUc" "h(unsigned char)"
test_demangling_exact "hp: f__Fic" "f(int, char)"
test_demangling_exact "hp: h__FUi" "h(unsigned int)"
test_demangling_exact "hp: h__Fci" "h(char, int)"
test_demangling_exact "hp: h__FUl" "h(unsigned long)"
test_demangling_exact "hp: h__Fcl" "h(char, long)"
test_demangling_exact "hp: h__FUs" "h(unsigned short)"
test_demangling_exact "hp: h__Fcs" "h(char, short)"
test_demangling "hp: __amd__FR2T2RC2T2" \
"operator%=\[(\]+T2 &, (const T2|T2 const) &\[)\]+"
test_demangling "hp: __adv__FR2T2RC2T2" \
"operator/=\[(\]+T2 &, (const T2|T2 const) &\[)\]+"
test_demangling "hp: __amu__FR2T2RC2T2" \
"operator\[*\]+=\[(\]+T2 &, (const T2|T2 const) &\[)\]+"
test_demangling "hp: __ami__FR2T2RC2T2" \
"operator-=\[(\]+T2 &, (const T2|T2 const) &\[)\]+"
test_demangling "hp: __apl__FR2T2RC2T2" \
"operator\[+\]+=\[(\]+T2 &, (const T2|T2 const) &\[)\]+"
 
test_demangling "hp: g__F1SRPUlRPCUlT2" \
"g\[(\]+S, unsigned long \[*\]+&, (const unsigned long|unsigned long const) \[*\]+&, unsigned long \[*\]+&\[)\]+"
test_demangling "hp: g__F1SRPUiRPCUiT2" \
"g\[(\]+S, unsigned int \[*\]+&, (const unsigned int|unsigned int const) \[*\]+&, unsigned int \[*\]+&\[)\]+"
test_demangling "hp: g__F1SRPUsRPCUsT2" \
"g\[(\]+S, unsigned short \[*\]+&, (const unsigned short|unsigned short const) \[*\]+&, unsigned short \[*\]+&\[)\]+"
test_demangling "hp: g__F1SRPUcRPCUcT2" \
"g\[(\]+S, unsigned char \[*\]+&, (const unsigned char|unsigned char const) \[*\]+&, unsigned char \[*\]+&\[)\]+"
test_demangling "hp: g__F1T1SRPlRPClT3" \
"g\[(\]+T, S, long \[*\]+&, (const long|long const) \[*\]+&, long \[*\]+&\[)\]+"
test_demangling "hp: g__F1T1SRPiRPCiT3" \
"g\[(\]+T, S, int \[*\]+&, (const int|int const) \[*\]+&, int \[*\]+&\[)\]+"
test_demangling "hp: g__F1T1SRPcRPCcT3" \
"g\[(\]+T, S, char \[*\]+&, (const char|char const) \[*\]+&, char \[*\]+&\[)\]+"
 
 
test_demangling "hp: __gt__FRC2T2T1" \
"operator>\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
test_demangling "hp: __ge__FRC2T2T1" \
"operator>=\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
test_demangling "hp: __lt__FRC2T2T1" \
"operator<\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
test_demangling "hp: __le__FRC2T2T1" \
"operator<=\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
test_demangling "hp: __ne__FRC2T2T1" \
"operator!=\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
test_demangling "hp: __eq__FRC2T2T1" \
"operator==\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
test_demangling "hp: g__FcR1cRC1cT2" \
"g\[(\]+char, c &, (const c|c const) &, c &\[)\]+"
test_demangling "hp: g__FcRPdRPCdT2" \
"g\[(\]+char, double *\[*\]+&, (const double|double const) *\[*\]+&, double *\[*\]+&\[)\]+"
test_demangling "hp: g__FcRPfRPCfT2" \
"g\[(\]+char, float *\[*\]+&, (const float|float const) *\[*\]+&, float *\[*\]+&\[)\]+"
test_demangling_exact "hp: h__FcT1" "h(char, char)"
test_demangling_exact "hp: f__Ficd" "f(int, char, double)"
test_demangling "hp: g__F1T1SdRPsRPCsT4" \
"g\[(\]+T, S, double, short \[*\]+&, (const short|short const) \[*\]+&, short \[*\]+&\[)\]+"
test_demangling "hp: g__F1cC1cT1" \
"g\[(\]+c, (const c|c const), c\[)\]+"
test_demangling "hp: g__FPdPCdT1" \
"g\[(\]+double *\[*\]+, (const double|double const) *\[*\]+, double *\[*\]+\[)\]+"
test_demangling "hp: g__FPfPCfT1" \
"g\[(\]+float *\[*\]+, (const float|float const) *\[*\]+, float *\[*\]+\[)\]+"
 
test_demangling "hp: g__FUlCUlT1" \
"g\[(\]+unsigned long, (const unsigned long|unsigned long const), unsigned long\[)\]+"
test_demangling "hp: g__FPlPClT1" \
"g\[(\]+long \[*\]+, (const long|long const) \[*\]+, long \[*\]+\[)\]+"
test_demangling "hp: g__FUiCUiT1" \
"g\[(\]+unsigned int, (const unsigned int|unsigned int const), unsigned int\[)\]+"
test_demangling "hp: g__FPiPCiT1" \
"g\[(\]+int \[*\]+, (const int|int const) \[*\]+, int \[*\]+\[)\]+"
test_demangling "hp: g__FUsCUsT1" \
"g\[(\]+unsigned short, (const unsigned short|unsigned short const), unsigned short\[)\]+"
test_demangling "hp: g__FPsPCsT1" \
"g\[(\]+short \[*\]+, (const short|short const) \[*\]+, short \[*\]+\[)\]+"
test_demangling "hp: g__FUcCUcT1" \
"g\[(\]+unsigned char, (const unsigned char|unsigned char const), unsigned char\[)\]+"
test_demangling "hp: g__FPcPCcT1" \
"g\[(\]+char \[*\]+, (const char|char const) \[*\]+, char \[*\]+\[)\]+"
test_demangling "hp: g__F1TlClT2" \
"g\[(\]+T, long, (const long|long const), long\[)\]+"
test_demangling "hp: g__F1TiCiT2" \
"g\[(\]+T, int, (const int|int const), int\[)\]+"
test_demangling "hp: g__F1TsCsT2" \
"g\[(\]+T, short, (const short|short const), short\[)\]+"
test_demangling "hp: g__F1TcCcT2" \
"g\[(\]+T, char, (const char|char const), char\[)\]+"
 
test_demangling "hp: printf__FPCce" \
"printf\[(\]+(const char|char const) \[*\]+,...\[)\]+"
 
 
test_demangling "hp: g__F1SRUlRCUlT2" \
"g\[(\]+S, unsigned long &, (const unsigned long|unsigned long const) &, unsigned long &\[)\]+"
test_demangling "hp: g__F1SRPlRPClT2" \
"g\[(\]+S, long \[*\]+&, (const long|long const) \[*\]+&, long \[*\]+&\[)\]+"
test_demangling "hp: g__F1RRUiRCUiT2" \
"g\[(\]+R, unsigned int &, (const unsigned int|unsigned int const) &, unsigned int &\[)\]+"
test_demangling "hp: g__F1SRPiRPCiT2" \
"g\[(\]+S, int \[*\]+&, (const int|int const) \[*\]+&, int \[*\]+&\[)\]+"
test_demangling "hp: g__F1RRUsRCUsT2" \
"g\[(\]+R, unsigned short &, (const unsigned short|unsigned short const) &, unsigned short &\[)\]+"
test_demangling "hp: g__F1SRPsRPCsT2" \
"g\[(\]+S, short \[*\]+&, (const short|short const) \[*\]+&, short \[*\]+&\[)\]+"
test_demangling "hp: g__F1RRUcRCUcT2" \
"g\[(\]+R, unsigned char &, (const unsigned char|unsigned char const) &, unsigned char &\[)\]+"
test_demangling "hp: g__F1SRPcRPCcT2" \
"g\[(\]+S, char \[*\]+&, (const char|char const) \[*\]+&, char \[*\]+&\[)\]+"
test_demangling "hp: g__F1T1RRlRClT3" \
"g\[(\]+T, R, long &, (const long|long const) &, long &\[)\]+"
test_demangling "hp: g__F1T1RRiRCiT3" \
"g\[(\]+T, R, int &, (const int|int const) &, int &\[)\]+"
test_demangling "hp: g__F1T1RRsRCsT3" \
"g\[(\]+T, R, short &, (const short|short const) &, short &\[)\]+"
test_demangling "hp: g__F1T1RRcRCcT3" \
"g\[(\]+T, R, char &, (const char|char const) &, char &\[)\]+"
 
 
test_demangling_exact "hp: f__FicdPcPFci_v" "f(int, char, double, char *, void (*)(char, int))"
test_demangling_exact "hp: f__FicdPcPFic_v" "f(int, char, double, char *, void (*)(int, char))"
test_demangling_exact "hp: get__2T7SFv" "T7::get(void) static"
 
 
test_demangling "hp: g__FcRdRCdT2" \
"g\[(\]+char, double &, (const double|double const) &, double &\[)\]+"
test_demangling "hp: g__FcRfRCfT2" \
"g\[(\]+char, float &, (const float|float const) &, float &\[)\]+"
test_demangling "hp: __md__FC2T2i" \
"operator%\[(\]+(const T2|T2 const), int\[)\]+"
test_demangling "hp: __dv__FC2T2i" \
"operator/\[(\]+(const T2|T2 const), int\[)\]+"
test_demangling "hp: __ml__FC2T2i" \
"operator\[*\]+\[(\]+(const T2|T2 const), int\[)\]+"
test_demangling "hp: __mi__FC2T2i" \
"operator-\[(\]+(const T2|T2 const), int\[)\]+"
test_demangling "hp: __pl__FC2T2i" \
"operator\[+\]+\[(\]+(const T2|T2 const), int\[)\]+"
 
 
test_demangling_exact "hp: h__Fc" "h(char)"
test_demangling_exact "hp: h__Fd" "h(double)"
test_demangling_exact "hp: h__Ff" "h(float)"
test_demangling_exact "hp: h__Fi" "h(int)"
test_demangling_exact "hp: f__Fi" "f(int)"
test_demangling_exact "hp: h__Fl" "h(long)"
 
test_demangling_exact "hp: h__Fs" "h(short)"
test_demangling "hp: __md__FC2T2RC2T2" \
"operator%\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+"
test_demangling "hp: __dv__FC2T2RC2T2" \
"operator/\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+"
test_demangling "hp: __ml__FC2T2RC2T2" \
"operator\[*\]+\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+"
test_demangling "hp: __mi__FC2T2RC2T2" \
"operator-\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+"
test_demangling "hp: __pl__FC2T2RC2T2" \
"operator\[+\]+\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+"
test_demangling "hp: g__FcRP1cRPC1cT2" \
"g\[(\]+char, c *\[*\]+&, (const c|c const) *\[*\]+&, c *\[*\]+&\[)\]+"
 
 
test_demangling "hp: g__FdCdT1" \
"g\[(\]+double, (const double|double const), double\[)\]+"
test_demangling "hp: g__FfCfT1" \
"g\[(\]+float, (const float|float const), float\[)\]+"
test_demangling "hp: g__FlClT1" \
"g\[(\]+long, (const long|long const), long\[)\]+"
test_demangling "hp: g__FiCiT1" \
"g\[(\]+int, (const int|int const), int\[)\]+"
test_demangling "hp: g__FsCsT1" \
"g\[(\]+short, (const short|short const), short\[)\]+"
test_demangling "hp: g__FcCcT1" \
"g\[(\]+char, (const char|char const), char\[)\]+"
 
 
test_demangling_exact "hp: f__FicdPc" "f(int, char, double, char *)"
test_demangling_exact "hp: __nw__FUi" "operator new(unsigned int)"
test_demangling_exact "hp: __ct__Q3_2T11a1bSFi" "T1::a::b::b(int) static"
test_demangling_exact "hp: __dt__Q3_2T11a1bSFi" "T1::a::b::~b(int) static"
test_demangling_exact "hp: put__Q3_2T11a1bSFi" "T1::a::b::put(int) static"
test_demangling_exact "hp: get__Q2_2T11aSFv" "T1::a::get(void) static"
test_demangling_exact "hp: put__2T1SFi" "T1::put(int) static"
test_demangling_exact "hp: put__Q5_2T11a1b1c1dSFi" "T1::a::b::c::d::put(int) static"
test_demangling_exact "hp: get__Q4_2T11a1b1cSFv" "T1::a::b::c::get(void) static"
test_demangling_exact "hp: put__Q2_2T11aSFi" "T1::a::put(int) static"
test_demangling_exact "hp: put__Q4_2T11a1b1cSFi" "T1::a::b::c::put(int) static"
test_demangling_exact "hp: get__Q3_2T11a1bSFv" "T1::a::b::get(void) static"
test_demangling_exact "hp: get__2T1SFv" "T1::get(void) static"
test_demangling_exact "hp: get__Q5_2T11a1b1c1dSFv" "T1::a::b::c::d::get(void) static"
 
 
test_demangling_exact "hp: bar__3fooFPv" "foo::bar(void *)"
test_demangling "hp: bar__3fooFPCv" \
"foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+"
test_demangling_exact "hp: bar__3fooCFPv" "foo::bar(void *) const"
test_demangling "hp: bar__3fooCFPCv" \
"foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+ const"
test_demangling_exact "hp: __eq__3fooFR3foo" "foo::operator==(foo &)"
test_demangling "hp: __eq__3fooFRC3foo" \
"foo::operator==\[(\]+(const foo|foo const) &\[)\]+"
test_demangling_exact "hp: __eq__3fooCFR3foo" "foo::operator==(foo &) const"
test_demangling "hp: __eq__3fooCFRC3foo" \
"foo::operator==\[(\]+(const foo|foo const) &\[)\]+ const"
 
test_demangling_exact "hp: bar__3fooFiT16FooBar" "foo::bar(int, int, FooBar)"
 
test_demangling_exact "hp: bar__3fooFPiN51PdN37PcN211T1iN215" \
"foo::bar(int *, int *, int *, int *, int *, int *, double *, double *, double *, double *, char *, char *, char *, int *, int, int, int)"
 
 
# HP aCC specific tests. HP aCC demangling does not use __pt__ for
# template specifications. There are other differences as well.
 
test_demangling_exact "hp: __dt__2T5XTPFiPPdPv_i__Fv" "T5<int (*)(int, double **, void *)>::~T5(void)"
 
test_demangling_exact "hp: __ct__1cFi" "c::c(int)"
 
test_demangling_exact "hp: __dt__2T5XTi__Fv" "T5<int>::~T5(void)"
 
test_demangling_exact "hp: __dt__2T5XTc__Fv" "T5<char>::~T5(void)"
 
test_demangling_exact "hp: __ct__2T2Fi" "T2::T2(int)"
test_demangling_exact "hp: __dt__2T1Fv" "T1::~T1(void)"
 
test_demangling_exact "hp: __dt__2T5XT1x__Fv" "T5<x>::~T5(void)"
 
test_demangling_exact "hp: __dt__2T5XTPFcPv_i__Fv" "T5<int (*)(char, void *)>::~T5(void)"
test_demangling_exact "hp: __ct__2T5XTPFiPPdPv_i__Fi" "T5<int (*)(int, double **, void *)>::T5(int)"
 
test_demangling_exact "hp: __dl__2T5XT1x__SFPv" "T5<x>::operator delete(void *) static"
test_demangling_exact "hp: X__2T5XT1x" "T5<x>::X"
 
test_demangling_exact "hp: __ct__2T5XTi__Fi" "T5<int>::T5(int)"
 
test_demangling_exact "hp: __ct__2T5XTc__Fi" "T5<char>::T5(int)"
 
test_demangling_exact "hp: __dl__2T5XTPFcPv_i__SFPv" "T5<int (*)(char, void *)>::operator delete(void *) static"
 
test_demangling_exact "hp: X__2T5XTPFcPv_i" "T5<int (*)(char, void *)>::X"
 
test_demangling_exact "hp: __ct__2T5XT1x__Fi" "T5<x>::T5(int)"
 
test_demangling_exact "hp: __dl__2T5XTPFiPPdPv_i__SFPv" "T5<int (*)(int, double **, void *)>::operator delete(void *) static"
test_demangling_exact "hp: X__2T5XTPFiPPdPv_i" "T5<int (*)(int, double **, void *)>::X"
 
test_demangling_exact "hp: __dl__2T5XTi__SFPv" "T5<int>::operator delete(void *) static"
 
test_demangling_exact "hp: __dl__2T5XTc__SFPv" "T5<char>::operator delete(void *) static"
 
test_demangling_exact "hp: X__2T5XTc" "T5<char>::X"
 
test_demangling_exact "hp: X__2T5XTi" "T5<int>::X"
 
test_demangling_exact "hp: __ct__2T5XTPFcPv_i__Fi" "T5<int (*)(char, void *)>::T5(int)"
test_demangling_exact "hp: __dt__2T1XTc__Fv" "T1<char>::~T1(void)"
 
test_demangling_exact "hp: __dt__2T1XT1t__Fv" "T1<t>::~T1(void)"
 
test_demangling_exact "hp: __dl__2T1XT1t__SFPv" "T1<t>::operator delete(void *) static"
 
test_demangling_exact "hp: __ct__2T1XTc__Fi" "T1<char>::T1(int)"
 
test_demangling_exact "hp: __ct__2T1XTc__Fv" "T1<char>::T1(void)"
 
test_demangling_exact "hp: __ct__2T1XT1t__Fi" "T1<t>::T1(int)"
 
test_demangling_exact "hp: __ct__2T1XT1t__Fv" "T1<t>::T1(void)"
 
test_demangling_exact "hp: __dl__2T1XTc__SFPv" "T1<char>::operator delete(void *) static"
 
test_demangling_exact "hp: elem__6vectorXTd__Fi" "vector<double>::elem(int)"
 
test_demangling_exact "hp: elem__6vectorXTi__Fi" "vector<int>::elem(int)"
 
test_demangling_exact "hp: __ct__6vectorXTd__Fi" "vector<double>::vector(int)"
 
test_demangling_exact "hp: __ct__6vectorXTi__Fi" "vector<int>::vector(int)"
 
test_demangling_exact "hp: __ct__9DListNodeXTR6RLabel__FR6RLabelP9DListNodeXTR6RLabel_T2" \
"DListNode<RLabel &>::DListNode(RLabel &, DListNode<RLabel &> *, DListNode<RLabel &> *)"
 
 
# Absolute integer constants in template args
 
test_demangling_exact "hp: elem__6vectorXTiUP34__Fi" "vector<int,34U>::elem(int)"
test_demangling_exact "hp: elem__6vectorXUP2701Td__Fi" "vector<2701U,double>::elem(int)"
test_demangling_exact "hp: elem__6vectorXTiSP334__Fi" "vector<int,334>::elem(int)"
test_demangling_exact "hp: elem__6vectorXTiSN67__Fi" "vector<int,-67>::elem(int)"
test_demangling_exact "hp: elem__6vectorXTiSM__SCFPPd" "vector<int,-2147483648>::elem(double **) static const"
test_demangling_exact "hp: elem__6vectorXTiSN67UP4000TRs__Fi" "vector<int,-67,4000U,short &>::elem(int)"
test_demangling_exact "hp: elem__6vectorXTiSN67TRdTFPv_i__Fi" "vector<int,-67,double &,int (void *)>::elem(int)"
test_demangling_exact "hp: X__6vectorXTiSN67TdTPvUP5TRs" "vector<int,-67,double,void *,5U,short &>::X"
 
# Named constants in template args
 
test_demangling_exact "hp: elem__6vectorXTiA3foo__Fi" "vector<int,&foo>::elem(int)"
test_demangling_exact "hp: elem__6vectorXTiA3fooTPvA5Label__FiPPvT2" "vector<int,&foo,void *,&Label>::elem(int, void **, void **)"
test_demangling_exact "hp: elem__6vectorXTiSN42A3foo__Fi" "vector<int,-42,&foo>::elem(int)"
 
# Alternate entry points for functions
 
test_demangling_exact "hp: __ct__2T5XTPFcPv_i__Fi_2" "T5<int (*)(char, void *)>::T5(int)"
test_demangling_exact "hp: __ct__2T5XTPFcPv_i__Fi_19" "T5<int (*)(char, void *)>::T5(int)"
test_demangling_exact "hp: f__FicdPcPFci_v_34" "f(int, char, double, char *, void (*)(char, int))"
 
 
# Template partial specializations
 
# FIXME! The # characters don't go through expect, and backslashes don't seem to work.
# test_demangling_exact "hp: spec__13Spec<#1,#1.*>XTiTPi_FPi" "Spec<int,int *>::spec(int *)"
# test_demangling_exact "hp: spec__16Spec<#1,#1.&,#1>XTiTRiTi_FPi" "Spec<int,int &, int>::spec(int *)"
# Fake test -- replace # with %
test_demangling_exact "hp: spec__13Spec<%1,%1.*>XTiTPi_FPi" "Spec<int,int *>::spec(int *)"
test_demangling_exact "hp: spec__16Spec<%1,%1.&,%1>XTiTRiTi_FPi" "Spec<int,int &,int>::spec(int *)"
 
# Global template functions
 
test_demangling_exact "hp: add__XTc_FcT1" "add<char>(char, char)"
test_demangling_exact "hp: add__XTcSP9A5label_FcPPlT1" "add<char,9,&label>(char, long **, char)"
test_demangling_exact "hp: add__XTPfTFPd_f_FcT1" "add<float *,float (double *)>(char, char)"
 
# Template for template arg
 
test_demangling_exact "hp: unLink__12basic_stringXTcT18string_char_traitsXTc_T9allocator_Fv" "basic_string<char,string_char_traits<char>,allocator>::unLink(void)"
 
test_demangling_exact "hp: _Utf390_1__1_9223372036854775807__9223372036854775" \
"Can't demangle \"_Utf390_1__1_9223372036854775807__9223372036854775\""
}
 
 
proc catch_demangling_errors {command} {
if {[catch $command result]} {
puts "ERROR: demangle.exp: while running $command: $result"
}
}
 
# Test support for different demangling styles. Note that this does
# not depend upon running the test program and does not depend upon
# gdb being able to lookup any C++ symbols. It simply calls the
# internal demangler with synthesized strings and tests the results.
 
proc do_tests {} {
global subdir
global gdb_prompt
 
 
# Start with a fresh gdb.
 
gdb_exit
gdb_start
 
gdb_test_no_output "set language c++"
gdb_test_no_output "set width 0"
 
# Using catch_demangling_errors this way ensures that, if one of
# the functions raises a Tcl error, then it'll get reported, and
# the rest of the functions will still run.
catch_demangling_errors test_lucid_style_demangling
catch_demangling_errors test_gnu_style_demangling
catch_demangling_errors test_arm_style_demangling
catch_demangling_errors test_hp_style_demangling
}
 
do_tests
/rtti.h
0,0 → 1,54
/* Code to go along with tests in rtti.exp.
Copyright 2003, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
Contributed by David Carlton <carlton@bactrian.org> and by Kealia,
Inc.
 
This file is part of GDB.
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
 
namespace n2 {
 
class C2;
 
class Base2 {
public:
virtual ~Base2() { }
};
 
 
class C2: public Base2 {
public:
};
 
class D2 : public C2{
public:
D2(C2 *, C2 *);
C2* expr_1_;
C2* expr_2_;
};
 
extern C2 *create2();
 
namespace n3 {
class C3 : public C2 {
public:
};
}
 
extern n3::C3 *create3();
}
rtti.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: namespace-nested-import.cc =================================================================== --- namespace-nested-import.cc (nonexistent) +++ namespace-nested-import.cc (revision 513) @@ -0,0 +1,12 @@ +namespace A{ + namespace B{ + namespace C{ + int x = 5; + } + } +} + +int main(){ + using namespace A::B; + return C::x; +} Index: ref-types.exp =================================================================== --- ref-types.exp (nonexistent) +++ ref-types.exp (revision 513) @@ -0,0 +1,286 @@ +# Tests for reference types with short type variables in GDB. +# Copyright 1998, 1999, 2000, 2004, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# written by Elena Zannoni (ezannoni@cygnus.com) + +if $tracelevel then { + strace $tracelevel + } + +# +# test running programs +# + +if { [skip_cplus_tests] } { continue } + +set testfile "ref-types" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested ref-types.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +# +# set it up at a breakpoint so we can play with the variable values +# +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +if ![runto 'marker1'] then { + perror "couldn't run to marker1" + continue +} + +gdb_test "up" ".*main.*" "up from marker1 1" + +proc gdb_start_again {} { + global srcdir + global subdir + global binfile + global gdb_prompt + global decimal + + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load ${binfile} + + # + # set it up at a breakpoint so we can play with the variable values + # + if ![runto_main] then { + perror "couldn't run to breakpoint" + continue + } + + if ![runto 'marker1'] then { + perror "couldn't run to marker1" + continue + } + + gdb_test "up" ".*main.*" "up from marker1 2" +} + + +gdb_test "print s" ".\[0-9\]* = -1" "print value of s" +gdb_test "ptype s" "type = short" + +gdb_test "print *ps" ".\[0-9\]* = -1" "print value of ps" +gdb_test "ptype ps" "type = short \\*" + +gdb_test "print as\[0\]" ".\[0-9\]* = 0" "print value of as\[0\]" +gdb_test_multiple "ptype as" "ptype as" { + -re "type = short \\\[4\\\].*$gdb_prompt $" { pass "ptype as" } + -re "type = short int \\\[4\\\].*$gdb_prompt $" { pass "ptype as" } +} + +gdb_test "print as\[1\]" ".\[0-9\]* = 1" "print value of as\[1\]" +gdb_test "print as\[2\]" ".\[0-9\]* = 2" "print value of as\[2\]" +gdb_test "print as\[3\]" ".\[0-9\]* = 3" "print value of as\[3\]" + +gdb_test_multiple "print rs" "print value of rs" { + -re ".\[0-9\]* = \\(short &\\) @$hex: -1.*$gdb_prompt $" { + pass "print value of rs" + } + -re ".\[0-9\]* = \\(short int &\\) @$hex: -1.*$gdb_prompt $" { + pass "print value of rs" + } + eof { fail "print rs ($GDB dumped core) (FIXME)" ; gdb_start_again ; } +} + +gdb_test_multiple "ptype rs" "ptype rs" { + -re "type = short &.*$gdb_prompt $" { pass "ptype rs" } + -re "type = short int &.*$gdb_prompt $" { pass "ptype rs" } +} + +gdb_test "print *rps" ".\[0-9\]* = -1" "print value of *rps" + +# GDB had a bug about dereferencing a pointer type +# that would lead to wrong results +# if we try to examine memory at pointer value. + +gdb_test "x /hd rps" "$hex:\[ \t\]*-1" "examine value at rps" + +gdb_test_multiple "ptype rps" "ptype rps" { + -re "type = short \\*&.*$gdb_prompt $" { pass "ptype rps" } + -re "type = short int \\*&.*$gdb_prompt $" { pass "ptype rps" } +} + + +gdb_test "print ras\[0\]" ".\[0-9\]* = 0" "print value of ras\[0\]" + +gdb_test_multiple "ptype ras" "ptype ras" { + -re "type = short \\\(&\\\)\\\[4\\\].*$gdb_prompt $" { pass "ptype ras" } + -re "type = short int \\\(&\\\)\\\[4\\\].*$gdb_prompt $" { pass "ptype ras" } +} + +gdb_test "print ras\[1\]" ".\[0-9\]* = 1" "print value of ras\[1\]" +gdb_test "print ras\[2\]" ".\[0-9\]* = 2" "print value of ras\[2\]" +gdb_test "print ras\[3\]" ".\[0-9\]* = 3" "print value of ras\[3\]" + + +if ![runto 'f'] then { + perror "couldn't run to f" + continue +} + +gdb_test "up" ".main2.*" "up from f" + +gdb_test "print C" ".\[0-9\]* = 65 \'A\'" "print value of C" +gdb_test "ptype C" "type = char" + +gdb_test "print UC" ".\[0-9\]* = 21 '\.025'" "print value of UC" +gdb_test "ptype UC" "type = unsigned char" + +gdb_test "print S" ".\[0-9\]* = -14" "print value of S" +gdb_test "ptype S" "type = short.*" + +gdb_test "print US" ".\[0-9\]* = 7" "print value of US" +gdb_test_multiple "ptype US" "ptype US" { + -re "type = unsigned short.*$gdb_prompt $" { pass "ptype US" } + -re "type = short unsigned.*$gdb_prompt $" { pass "ptype US" } +} + +gdb_test "print I" ".\[0-9\]* = 102" "print value of I" +gdb_test "ptype I" "type = int" + +gdb_test "print UI" ".\[0-9\]* = 1002" "print value of UI" +gdb_test "ptype UI" "type = unsigned int" + +gdb_test "print L" ".\[0-9\]* = -234" "print value of L" +gdb_test "ptype L" "type = long.*" + +gdb_test "print UL" ".\[0-9\]* = 234" "print value of UL" +gdb_test_multiple "ptype UL" "ptype UL" { + -re "type = unsigned long.*$gdb_prompt $" { pass "ptype UL" } + -re "type = long unsigned.*$gdb_prompt $" { pass "ptype UL" } +} + +gdb_test "print F" ".\[0-9\]* = 1.2\[0-9\]*e\\+0?10.*" \ + "print value of F" + +gdb_test "ptype F" "type = float.*" + +gdb_test "print D" ".\[0-9\]* = -1.375e-123.*" \ + "print value of D" + +gdb_test "ptype D" "type = double.*" + + +# +# test reference types +# + +gdb_test "ptype rC" "type = char &" + +gdb_test "ptype rUC" "type = unsigned char &" + +gdb_test_multiple "ptype rS" "ptype rS" { + -re "type = short &.*$gdb_prompt $" { pass "ptype rS" } + -re "type = short int &.*$gdb_prompt $" { pass "ptype rS" } +} + +gdb_test_multiple "ptype rUS" "ptype rUS" { + -re "type = unsigned short &.*$gdb_prompt $" { pass "ptype rUS" } + -re "type = short unsigned int &.*$gdb_prompt $" { pass "ptype rUS" } +} + +gdb_test "ptype rI" "type = int &" + +gdb_test "ptype rUI" "type = unsigned int &" + +gdb_test_multiple "ptype rL" "ptype rL" { + -re "type = long &.*$gdb_prompt $" { pass "ptype rL" } + -re "type = long int &.*$gdb_prompt $" { pass "ptype rL" } +} + +gdb_test_multiple "ptype rUL" "ptype rUL" { + -re "type = unsigned long &.*$gdb_prompt $" { pass "ptype rUL" } + -re "type = long unsigned int &.*$gdb_prompt $" { pass "ptype rUL" } +} + +gdb_test "ptype rF" "type = float &" + +gdb_test "ptype rD" "type = double &" + +gdb_test "print rC" ".\[0-9\]* = \\(char &\\) @$hex: 65 \'A\'" \ + "print value of rC" + +gdb_test "print rUC" \ + ".\[0-9\]* = \\(unsigned char &\\) @$hex: 21 \'.025\'" \ + "print value of rUC" + +gdb_test_multiple "print rS" "print value of rS" { + -re ".\[0-9\]* = \\(short &\\) @$hex: -14.*$gdb_prompt $" { + pass "print value of rS" + } + -re ".\[0-9\]* = \\(short int &\\) @$hex: -14.*$gdb_prompt $" { + pass "print value of rS" + } +} + +gdb_test_multiple "print rUS" "print value of rUS" { + -re ".\[0-9\]* = \\(unsigned short &\\) @$hex: 7.*$gdb_prompt $" { + pass "print value of rUS" + } + -re ".\[0-9\]* = \\(short unsigned int &\\) @$hex: 7.*$gdb_prompt $" { + pass "print value of rUS" + } +} + +gdb_test "print rI" ".\[0-9\]* = \\(int &\\) @$hex: 102" \ + "print value of rI" + +gdb_test "print rUI" \ + ".\[0-9\]* = \\(unsigned int &\\) @$hex: 1002" \ + "print value of UI" + +gdb_test_multiple "print rL" "print value of rL" { + -re ".\[0-9\]* = \\(long &\\) @$hex: -234.*$gdb_prompt $" { + pass "print value of rL" + } + -re ".\[0-9\]* = \\(long int &\\) @$hex: -234.*$gdb_prompt $" { + pass "print value of rL" + } +} + +gdb_test_multiple "print rUL" "print value of rUL" { + -re ".\[0-9\]* = \\(unsigned long &\\) @$hex: 234.*$gdb_prompt $" { + pass "print value of rUL" + } + -re ".\[0-9\]* = \\(long unsigned int &\\) @$hex: 234.*$gdb_prompt $" { + pass "print value of rUL" + } +} + +gdb_test "print rF" \ + ".\[0-9\]* = \\(float &\\) @$hex: 1.2\[0-9\]*e\\+0?10.*" \ + "print value of rF" + +gdb_test "print rD" \ + ".\[0-9\]* = \\(double &\\) @$hex: -1.375e-123.*" \ + "print value of rD" + Index: gdb2495.exp =================================================================== --- gdb2495.exp (nonexistent) +++ gdb2495.exp (revision 513) @@ -0,0 +1,166 @@ +# Copyright 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +# In gdb inferior function calls, if a C++ exception is raised in the +# dummy-frame, and the exception handler is (normally, and expected to +# be) out-of-frame, the default C++ handler will (wrongly) be called +# in an inferior function call. +# This is incorrect as an exception can normally and legally be handled +# out-of-frame. The confines of the dummy frame prevent the unwinder +# from finding the correct handler (or any handler, unless it is +# in-frame). The default handler calls std::terminate. This will kill +# the inferior. Assert that terminate should never be called in an +# inferior function call. These tests test the functionality around +# unwinding that sequence and also tests the flag behaviour gating this +# functionality. +# +# PR c++/9600. + +# This test is largely based of gdb.base/callfuncs.exp. + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +if [target_info exists gdb,nosignals] { + verbose "Skipping gdb2495.exp because of nosignals." + continue +} + +# On SPU this test fails because the executable exceeds local storage size. +if { [istarget "spu*-*-*"] } { + return 0 +} + +set testfile "gdb2495" +set srcfile ${testfile}.cc +set binfile $objdir/$subdir/$testfile + +# Create and source the file that provides information about the compiler +# used to compile the test case. +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested gdb2495.exp + return -1 +} + +# Some targets can't do function calls, so don't even bother with this +# test. +if [target_info exists gdb,cannot_call_functions] { + setup_xfail "*-*-*" 2416 + fail "This target can not call functions" + continue +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to main" + continue +} + +# See http://sourceware.org/gdb/bugs/2495 + +# Test normal baseline behaviour. Call a function that +# does not raise an exception. +gdb_test "p exceptions.no_throw_function()" " = 1" +# And one that does but handles it in-frame. +gdb_test "p exceptions.throw_function_with_handler()" " = 2" +# Both should return normally. + +# Test basic unwind. Call a function that raises an exception but +# does not handle it. It should be rewound. +gdb_test "p exceptions.throw_function()" \ + "The program being debugged entered a std::terminate call, .*" \ + "Call a function that raises an exception without a handler." + +# Make sure that after rewinding we are back at the call parent. +gdb_test "bt" \ + "#0 main.*" \ + "bt after returning from a popped frame" + +# Make sure the only breakpoint is the one set via the runto_main +# call and that the std::terminate breakpoint has evaporated and +# cleaned-up. +gdb_test "info breakpoints" \ + "gdb.cp/gdb2495\.cc.*" + +# Turn off this new behaviour. +gdb_test_multiple "set unwind-on-terminating-exception off" \ + "Turn unwind-on-terminating-exception off" { + -re "$gdb_prompt $" {pass "set unwinn-on-terminating-exception off"} + timeout {fail "(timeout) set unwind-on-terminating-exception off"} +} + +# Check that it is turned off. +gdb_test "show unwind-on-terminating-exception" \ + "exception is unhandled while in a call dummy is off.*" \ + "Turn off unwind on terminating exception flag" + +# Check that the old behaviour is restored. +gdb_test "p exceptions.throw_function()" \ + "The program being debugged was signaled while in a function called .*" \ + "Call a function that raises an exception with unwinding off.." + +# Restart the inferior back at main. +if ![runto_main] then { + perror "couldn't run to main" + continue +} + + +# Check to see if the new behaviour alters the unwind signal +# behaviour; it should not. Test both on and off states. + +# Turn on unwind on signal behaviour. +gdb_test_multiple "set unwindonsignal on" "Turn unwindonsignal on" { + -re "$gdb_prompt $" {pass "set unwindonsignal on"} + timeout {fail "(timeout) set unwindonsignal on"} +} + +# Check that it is turned on. +gdb_test "show unwindonsignal" \ + "signal is received while in a call dummy is on.*" \ + "Turn on unwind on signal" + +# Check to see if new behaviour interferes with +# normal signal handling in inferior function calls. +gdb_test "p exceptions.raise_signal(1)" \ + "To change this behavior use \"set unwindonsignal off\".*" + +# And reverse - turn off again. +gdb_test_multiple "set unwindonsignal off" "Turn unwindonsignal off" { + -re "$gdb_prompt $" {pass "set unwindonsignal off"} + timeout {fail "(timeout) set unwindonsignal off"} +} + +# Check that it is actually turned off. +gdb_test "show unwindonsignal" \ + "signal is received while in a call dummy is off.*" \ + "Turn off unwind on signal" + +# Check to see if new behaviour interferes with +# normal signal handling in inferior function calls. +gdb_test "p exceptions.raise_signal(1)" \ + "To change this behavior use \"set unwindonsignal on\".*" Index: pr10728-x.cc =================================================================== --- pr10728-x.cc (nonexistent) +++ pr10728-x.cc (revision 513) @@ -0,0 +1,7 @@ +#include "pr10728-x.h" + +int main() +{ + X* x = y(); + return 0; // marker 1 +} Index: pr-574.cc =================================================================== --- pr-574.cc (nonexistent) +++ pr-574.cc (revision 513) @@ -0,0 +1,40 @@ +/* This test script is part of GDB, the GNU debugger. + + Copyright 2002, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +/* + An attempt to replicate PR gdb/574 with a shorter program. + + Printing out *theB failed if the program was compiled with GCC 2.95. +*/ + +class A { +public: + virtual void foo() {}; // Stick in a virtual function. + int a; // Stick in a data member. +}; + +class B : public A { + static int b; // Stick in a static data member. +}; + +int main() +{ + B *theB = new B; + + return 0; // breakpoint: constructs-done +} Index: pr10687.exp =================================================================== --- pr10687.exp (nonexistent) +++ pr10687.exp (revision 513) @@ -0,0 +1,31 @@ +#Copyright 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set testfile pr10687 +set srcfile ${testfile}.cc +if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] { + return -1 +} + +if ![runto_main] then { + fail "Can't run to main" + return +} + +gdb_breakpoint [gdb_get_line_number "marker"] +gdb_continue_to_breakpoint "marker" + +gdb_test "p a" "{static axis = {{static axis = . + */ + +// Pls try the following program on virtual functions and try to do print on +// most of the code in main(). Almost none of them works ! + +// +// The inheritance structure is: +// +// V : VA VB +// A : (V) +// B : A +// D : AD (V) +// C : (V) +// E : B (V) D C +// + +class VA +{ +public: + int va; +}; + +class VB +{ +public: + int vb; + int fvb(); + virtual int vvb(); +}; + +class V : public VA, public VB +{ +public: + int f(); + virtual int vv(); + int w; +}; + +class A : virtual public V +{ +public: + virtual int f(); +private: + int a; +}; + +class B : public A +{ +public: + int f(); +private: + int b; +}; + +class C : public virtual V +{ +public: + int c; +}; + +class AD +{ +public: + virtual int vg() = 0; +}; + +class D : public AD, virtual public V +{ +public: + static void s(); + virtual int vg(); + virtual int vd(); + int fd(); + int d; +}; + +class E : public B, virtual public V, public D, public C +{ +public: + int f(); + int vg(); + int vv(); + int e; +}; + +D dd; +D* ppd = ⅆ +AD* pAd = ⅆ + +A a; +B b; +C c; +D d; +E e; +V v; +VB vb; + + +A* pAa = &a; +A* pAe = &e; + +B* pBe = &e; + +D* pDd = &d; +D* pDe = &e; + +V* pVa = &a; +V* pVv = &v; +V* pVe = &e; +V* pVd = &d; + +AD* pADe = &e; + +E* pEe = &e; + +VB* pVB = &vb; + +void init() +{ + a.vb = 1; + b.vb = 2; + c.vb = 3; + d.vb = 4; + e.vb = 5; + v.vb = 6; + vb.vb = 7; + + d.d = 1; + e.d = 2; +} + +extern "C" int printf(const char *, ...); + +int all_count = 0; +int failed_count = 0; + +#define TEST(EXPR, EXPECTED) \ + ret = EXPR; \ + if (ret != EXPECTED) {\ + printf("Failed %s is %d, should be %d!\n", #EXPR, ret, EXPECTED); \ + failed_count++; } \ + all_count++; + +int ret; + +void test_calls() +{ + TEST(pAe->f(), 20); + TEST(pAa->f(), 1); + + TEST(pDe->vg(), 202); + TEST(pADe->vg(), 202); + TEST(pDd->vg(), 101); + + TEST(pEe->vvb(), 411); + + TEST(pVB->vvb(), 407); + + TEST(pBe->vvb(), 411); + TEST(pDe->vvb(), 411); + + TEST(pEe->vd(), 282); + TEST(pEe->fvb(), 311); + + TEST(pEe->D::vg(), 102); + printf("Did %d tests, of which %d failed.\n", all_count, failed_count); +} +#ifdef usestubs +extern "C" { + void set_debug_traps(); + void breakpoint(); +}; +#endif + +int main() +{ +#ifdef usestubs + set_debug_traps(); + breakpoint(); +#endif + init(); + + e.w = 7; + e.vb = 11; + + test_calls(); + return 0; + +} + +int A::f() {return 1;} +int B::f() {return 2;} +void D::s() {} +int E::f() {return 20;} +int D::vg() {return 100+d;} +int E::vg() {return 200+d;} +int V::f() {return 600+w;} +int V::vv() {return 400+w;} +int E::vv() {return 450+w;} +int D::fd() {return 250+d;} +int D::vd() {return 280+d;} +int VB::fvb() {return 300+vb;} +int VB::vvb() {return 400+vb;} Index: static-print-quit.cc =================================================================== --- static-print-quit.cc (nonexistent) +++ static-print-quit.cc (revision 513) @@ -0,0 +1,32 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +class D + { + public: + int loooooooooooooooooooooooooooooooooooooooooooooong; + }; + +class C + { + public: + int loooooooooooooooooooooooooooooooooooooooooooooong; + static D field; + }; + +D C::field; +C c; Index: misc.exp =================================================================== --- misc.exp (nonexistent) +++ misc.exp (revision 513) @@ -0,0 +1,130 @@ +# Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2002, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file was written by Fred Fish. (fnf@cygnus.com) + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +set testfile "misc" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested misc.exp + return -1 +} + +# +# Deduce language of main() +# + +proc deduce_language_of_main {} { + global gdb_prompt + + # See what language gdb thinks main() is, prior to reading full symbols. + # I think this fails for COFF targets. + gdb_test "show language" \ + "source language is \"auto; currently c\[+\]+\".*" \ + "deduced language is C++, before full symbols" + + runto_main + + # See if our idea of the language has changed. + + gdb_test "show language" \ + "source language is \"auto; currently c\[+\]+\".*" \ + "deduced language is C++, after full symbols" +} + +proc test_expr { args } { + if { [llength $args] % 2 } { + warning "an even # of arguments should be passed to test_expr" + } + set last_ent [expr [llength $args] - 1]; + set testname [lindex $args $last_ent]; + if [gdb_test_no_output [lindex $args 0] "$testname (setup)"] { + gdb_suppress_tests; + } + for {set x 1} {$x < $last_ent} {set x [expr $x + 2]} { + if [gdb_test [lindex $args $x] [lindex $args [expr $x + 1]] "$testname ([lindex $args $x])"] { + gdb_suppress_tests; + } + } + gdb_stop_suppressing_tests; +} + +proc do_tests {} { + global subdir + global objdir + global srcdir + global binfile + global gdb_prompt + + + # Start with a fresh gdb. + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load $binfile + + deduce_language_of_main + # Check for fixes for PRs 8916 and 8630 + gdb_test "print s.a" ".* = 0" "print s.a for foo struct (known gcc 2.7.2 and earlier bug)" +} + +do_tests + +test_expr "set language c++" \ + "print 1 == 1" "print.*\\$\[0-9\]* = true" \ + "print 1 == 2" "print.*\\$\[0-9\]* = false" \ + "print as bool" + +# Test bool type printing, etc. +# Note: Language is already set to C++ above! +gdb_test "print v_bool" "\\$\[0-9\]* = false" "print a bool var" + +# set a bool variable +test_expr "set variable v_bool = true" \ + "print v_bool" "\\$\[0-9\]* = true" \ + "set a bool var" + +# next print an array of bool +gdb_test "print v_bool_array" "\\$\[0-9\]* = \\{false, false\\}" "print a bool array" + +# set elements of a bool array +test_expr "set variable v_bool_array\[1\] = true" \ + "print v_bool_array" "\\$\[0-9\]* = \\{false, true\\}" \ + "set a bool array elem" + +# bool constants +gdb_test "print true" "\\$\[0-9\]* = true" "print true" +gdb_test "print false" "\\$\[0-9\]* = false" "print false" + +# arithmetic conversions +gdb_test "print 1 + true" "\\$\[0-9\]* = 2" "1 + true" +gdb_test "print 3 + false" "\\$\[0-9\]* = 3" "3 + false" +gdb_test "print 1 < 2 < 3" "\\$\[0-9\]* = true" "1 < 2 < 3" +gdb_test "print 2 < 1 > 4" "\\$\[0-9\]* = false" "2 < 1 > 4" +gdb_test "print (bool)43" "\\$\[0-9\]* = true" "(bool)43" +gdb_test "print (bool)0" "\\$\[0-9\]* = false" "(bool)0" +gdb_test "print (bool)17.93" "\\$\[0-9\]* = true" "(bool)17.93" +gdb_test "print (bool)0.0" "\\$\[0-9\]* = false" "(bool)0.0" +gdb_test "print (int)true" "\\$\[0-9\]* = 1" "(int)true" +gdb_test "print (int)false" "\\$\[0-9\]* = 0" "(int)false" Index: printmethod.exp =================================================================== --- printmethod.exp (nonexistent) +++ printmethod.exp (revision 513) @@ -0,0 +1,72 @@ +# Copyright 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This tries to print out methods of classes. + +# 2002-08-16 David Carlton + +# This file is part of the gdb testsuite + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + +# +# test running programs +# + +set testfile "printmethod" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested printmethod.exp + return -1 +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +# First, run to after we've constructed the object: + +gdb_breakpoint [gdb_get_line_number "constructs-done"] +gdb_continue_to_breakpoint "end of constructors" + +# The first of these is for PR gdb/653. + +gdb_test "print theA->virt" \ + "\\$\[0-9\]* = {void \\(A \\*\\)} $hex " \ + "print virtual method." +gdb_test "print theA->nonvirt" \ + "\\$\[0-9\]* = {void \\(A \\*\\)} $hex " \ + "print nonvirtual method." + +gdb_exit +return 0 Index: pr-574.exp =================================================================== --- pr-574.exp (nonexistent) +++ pr-574.exp (revision 513) @@ -0,0 +1,70 @@ +# Copyright 2002, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Tests for the bug mentioned in PR gdb/574. It's a bit +# idiosyncratic, so I gave it its own file. + +# 2002-08-16 David Carlton + +# This file is part of the gdb testsuite + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + +# +# test running programs +# + +set testfile "pr-574" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested pr-574.exp + return -1 +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +# First, run to after we've constructed the object: + +gdb_breakpoint [gdb_get_line_number "constructs-done"] +gdb_continue_to_breakpoint "end of constructors" + +# This failed, as long as the code was compiled with GCC v. 2. + +# Different compilers order the data for differently, so I'm not +# matching the result exactly. + +gdb_test "print *theB" "\\$\[0-9\]* = { = {\[^}\]*}, static b = }" "PR gdb/574" + +gdb_exit +return 0 Index: ovldbreak.cc =================================================================== --- ovldbreak.cc (nonexistent) +++ ovldbreak.cc (revision 513) @@ -0,0 +1,184 @@ +#include + +class foo { +public: + foo (int); + foo (int, const char *); + foo (foo&); + ~foo (); + void foofunc (int); + void foofunc (int, signed char *); + int ifoo; + const char *ccpfoo; + +int overload1arg (void); +int overload1arg (char); +int overload1arg (signed char); +int overload1arg (unsigned char); +int overload1arg (short); +int overload1arg (unsigned short); +int overload1arg (int); +int overload1arg (unsigned int); +int overload1arg (long); +int overload1arg (unsigned long); +int overload1arg (float); +int overload1arg (double); + +int overloadargs (int a1); +int overloadargs (int a1, int a2); +int overloadargs (int a1, int a2, int a3); +int overloadargs (int a1, int a2, int a3, int a4); +int overloadargs (int a1, int a2, int a3, int a4, int a5); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10, int a11); + + +}; + +void marker1() +{} + +int main () +{ + char arg2 = 2; + signed char arg3 =3; + unsigned char arg4 =4; + short arg5 =5; + unsigned short arg6 =6; + int arg7 =7; + unsigned int arg8 =8; + long arg9 =9; + unsigned long arg10 =10; + float arg11 =100.0; + double arg12 = 200.0; + + char ch='A'; + foo foo_instance1(111); + foo foo_instance2(222, &ch); + foo foo_instance3(foo_instance2); + + foo_instance1.overload1arg(); + foo_instance1.overload1arg(arg2); + foo_instance1.overload1arg(arg3); + foo_instance1.overload1arg(arg4); + foo_instance1.overload1arg(arg5); + foo_instance1.overload1arg(arg6); + foo_instance1.overload1arg(arg7); + foo_instance1.overload1arg(arg8); + foo_instance1.overload1arg(arg9); + foo_instance1.overload1arg(arg10); + foo_instance1.overload1arg(arg11); + foo_instance1.overload1arg(arg12); + + foo_instance1.overloadargs(1); + foo_instance1.overloadargs(1, 2); + foo_instance1.overloadargs(1, 2, 3); + foo_instance1.overloadargs(1, 2, 3, 4); + foo_instance1.overloadargs(1, 2, 3, 4, 5); + foo_instance1.overloadargs(1, 2, 3, 4, 5, 6); + foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7); + foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8); + foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9); + foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); + + + #ifdef usestubs + set_debug_traps(); + breakpoint(); + #endif + + + marker1(); + return 0; +} + +foo::foo (int i) { ifoo = i;} +foo::foo (int i, const char *ccp) { ifoo = i; ccpfoo = ccp; } +foo::foo (foo& afoo) { ifoo = afoo.ifoo; ccpfoo = afoo.ccpfoo;} +foo::~foo () {} + + +/* Some functions to test overloading by varying one argument type. */ + +int foo::overload1arg (void) { return 1; } +int foo::overload1arg (char arg) { arg = 0; return 2;} +int foo::overload1arg (signed char arg) { arg = 0; return 3;} +int foo::overload1arg (unsigned char arg) { arg = 0; return 4;} +int foo::overload1arg (short arg) { arg = 0; return 5;} +int foo::overload1arg (unsigned short arg) { arg = 0; return 6;} +int foo::overload1arg (int arg) { arg = 0; return 7;} +int foo::overload1arg (unsigned int arg) { arg = 0; return 8;} +int foo::overload1arg (long arg) { arg = 0; return 9;} +int foo::overload1arg (unsigned long arg) { arg = 0; return 10;} +int foo::overload1arg (float arg) { arg = 0; return 11;} +int foo::overload1arg (double arg) { arg = 0; return 12;} + + +/* Some functions to test overloading by varying argument count. */ + +int foo::overloadargs (int a1) +{ a1 = 0; +return 1;} + +int foo::overloadargs (int a1, int a2) +{ a1 = a2 = 0; +return 2;} + +int foo::overloadargs (int a1, int a2, int a3) +{ a1 = a2 = a3 = 0; +return 3;} + +int foo::overloadargs (int a1, int a2, int a3, int a4) +{ a1 = a2 = a3 = a4 = 0; +return 4;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5) +{ a1 = a2 = a3 = a4 = a5 = 0; +return 5;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6) +{ a1 = a2 = a3 = a4 = a5 = a6 = 0; +return 6;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7) +{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = 0; +return 7;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8) +{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = 0; +return 8;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9) +{ + a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = 0; + return 9; +} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = + a10 = 0; return 10;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10, int a11) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = + a10 = a11 = 0; return 11;} + + +void foo::foofunc (int a) +{ +} + +void foo::foofunc (int b, signed char *c) +{ +} + Index: mb-ctor.exp =================================================================== --- mb-ctor.exp (nonexistent) +++ mb-ctor.exp (revision 513) @@ -0,0 +1,87 @@ +# Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test that breakpoints on C++ constructors work, despite the +# fact that gcc generates several versions of constructor function. + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + + +set testfile "mb-ctor" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested mb-ctor.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +# Set a breakpoint with multiple locations +# and a condition. + +gdb_test "break 'Derived::Derived(int)'" \ + "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \ + "set-breakpoint at ctor" + +gdb_breakpoint [gdb_get_line_number "set breakpoint here"] + +gdb_test "break 'Derived::~Derived()'" \ + "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \ + "set-breakpoint at dtor" + +gdb_test "continue" \ + ".*Breakpoint.*Derived.*i=7.*" \ + "run to breakpoint 1 v1" + +gdb_continue_to_breakpoint "set breakpoint here" ".* breakpoint here" + +gdb_test "continue" \ + ".*Breakpoint.*Derived.*i=15.*" \ + "run to breakpoint 1 v2" + +gdb_continue_to_breakpoint "set breakpoint here" ".* breakpoint here" + +gdb_test "continue" \ + ".*Breakpoint.*~Derived.*" \ + "run to breakpoint 3 v1" + +gdb_test "continue" \ + ".*Breakpoint.*~Derived.*" \ + "run to breakpoint 3 v2" + +gdb_test "continue" \ + ".*exited normally.*" \ + "run to exit" + + + Index: mb-inline.h =================================================================== --- mb-inline.h (nonexistent) +++ mb-inline.h (revision 513) @@ -0,0 +1,37 @@ +/* Test gdb support for setting multiple file:line breakpoints on static + functions. In practice the functions may be inline fns compiled with -O0. + We avoid using inline here for simplicity's sake. + + This testcase is part of GDB, the GNU debugger. + + Copyright 2008, 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +static int +foo (int i) +{ + return i; // set breakpoint here +} + +static int +multi_line_foo (int i) +{ + return // set multi-line breakpoint here + i; +} + +extern int afn (); +extern int bfn ();
mb-inline.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pr9594.cc =================================================================== --- pr9594.cc (nonexistent) +++ pr9594.cc (revision 513) @@ -0,0 +1,52 @@ + +class Base +{ +public: + virtual int get_foo () { return 1; } + int base_function_only () { return 2; } +}; + +class Foo : public Base +{ + +private: + int foo_value; + +public: + Foo () { foo_value = 0;} + Foo (int i) { foo_value = i;} + ~Foo () { } + void set_foo (int value); + int get_foo (); + + // Something similar to a constructor name. + void Foofoo (); + + bool operator== (const Foo &other) { return foo_value == other.foo_value; } +}; + +void Foo::set_foo (int value) +{ + foo_value = value; +} + +int Foo::get_foo () +{ + return foo_value; +} + +void Foo::Foofoo () +{ +} + +int main () +{ + // Anonymous struct with method. + struct { + int get() { return 5; } + } a; + Foo foo1; + foo1.set_foo (42); // Set breakpoint here. + a.get(); // Prevent compiler from throwing 'a' away. + return 0; +} Index: m-static.cc =================================================================== --- m-static.cc (nonexistent) +++ m-static.cc (revision 513) @@ -0,0 +1,83 @@ +// 2002-05-13 + +enum region { oriental, egyptian, greek, etruscan, roman }; + +// Test one. +class gnu_obj_1 +{ +protected: + typedef region antiquities; + static const bool test = true; + static const int key1 = 5; + static long key2; + + static antiquities value; + +public: + gnu_obj_1(antiquities a, long l) {} + + long method () + { + static bool svar = true; + return key2; + } +}; + +const bool gnu_obj_1::test; +const int gnu_obj_1::key1; +long gnu_obj_1::key2 = 77; +gnu_obj_1::antiquities gnu_obj_1::value = oriental; + + +// Test two. +template +class gnu_obj_2: public virtual gnu_obj_1 +{ +public: + static antiquities value_derived; + +public: + gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7) { } +}; + +template +typename gnu_obj_2::antiquities gnu_obj_2::value_derived = etruscan; + +// Test three. +template +class gnu_obj_3 +{ +public: + typedef region antiquities; + static gnu_obj_2 data; + +public: + gnu_obj_3(antiquities b) { } +}; + +template +gnu_obj_2 gnu_obj_3::data(etruscan); + +// 2002-08-16 +// Test four. +#include "m-static.h" + +// instantiate templates explicitly so their static members will exist +template class gnu_obj_2; +template class gnu_obj_2; +template class gnu_obj_3; + +int main() +{ + gnu_obj_1 test1(egyptian, 4589); + gnu_obj_2 test2(roman); + gnu_obj_3 test3(greek); + gnu_obj_4 test4; + + test4.dummy = test4.elsewhere; + test4.dummy = 0; + + test1.method (); // breakpoint: constructs-done + + return test4.dummy; +} Index: re-set-overloaded.cc =================================================================== --- re-set-overloaded.cc (nonexistent) +++ re-set-overloaded.cc (revision 513) @@ -0,0 +1,26 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +class C + { + public: + C() {} + C(int x) {} + }; + +C a; +C b(1); Index: virtfunc2.cc =================================================================== --- virtfunc2.cc (nonexistent) +++ virtfunc2.cc (revision 513) @@ -0,0 +1,39 @@ + /* This test script is part of GDB, the GNU debugger. + + Copyright 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +class interface +{ + virtual int do_print3() { return 111111; } +}; + +class Obj : virtual public interface +{ +public: + virtual int do_print() { return 123456; } +}; + +class Obj2 : Obj, virtual public interface +{ + virtual int do_print2() { return 654321; } +}; + +int main(int argc, char** argv) { + Obj o; + Obj2 o2; + return 0; // marker 1 +} Index: casts.exp =================================================================== --- casts.exp (nonexistent) +++ casts.exp (revision 513) @@ -0,0 +1,170 @@ +# Copyright 2002, 2003, 2004, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the gdb testsuite + +# Test casting, especially between class types or pointer-to-class +# types. + +# This file is part of the gdb testsuite + +if $tracelevel then { + strace $tracelevel + } + +# +# test running programs +# + + +if { [skip_cplus_tests] } { continue } + +set testfile "casts" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile} "c++"] { + return -1; +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested casts.exp + return -1 +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +gdb_test "break [gdb_get_line_number "casts.exp: 1"]" \ + "Breakpoint.*at.* file .*" \ + "" + +gdb_test "continue" "Breakpoint .* at .*casts.cc.*" "" + +# Casting a pointer to a base class to a pointer to a derived class +# should yield the entire derived class. Until August 2002, GDB got +# the enclosing type on `(B *) a' wrong: while the value's static type +# was `B *', as it should be, the enclosing type (which is supposed to +# be the dynamic type) was `A *'. It's senseless to have a static +# type derived from the dynamic type; it should be the other way +# 'round. Dereferencing this oddly typed pointer yielded a value in +# which only the base class's members were initialized, since GDB uses +# the enclosing type to decide how many bytes to read. Members from +# the derived class were garbage, from GDB's address space. +gdb_test "print * (B *) a" ".* = { = {a = 42}, b = 1729}" \ + "cast base class pointer to derived class pointer" + +# Check also that we get the same results from letting the compiler do +# the dereference. +gdb_test "print * b" ".* = { = {a = 42}, b = 1729}" \ + "let compiler cast base class pointer to derived class pointer" + +# Check upcasting (it is trivial but still). +gdb_test "print * (A *) b" ".* = {a = 42}" \ + "cast derived class pointer to base class pointer" + +# Casting References. +# Check upcasting. +gdb_test "print (A &) br" ".* = .A &.* {a = 42}" \ + "cast derived class reference to base class reference" + +# Check downcasting. +gdb_test "print (B &) ar" ".* = .B.* { = {a = 42}, b = 1729}" \ + "cast base class reference to derived class reference" + +# Check compiler casting +gdb_test "print br" ".* = .B.* { = {a = 42}, b = 1729}" \ + "let compiler cast base class reference to derived class reference" + + +# A few basic tests of "new" casts. + +gdb_test "print const_cast (b)" " = \\(const B \\*\\) $hex" \ + "basic test of const_cast" + +gdb_test "print const_cast (0)" " = \\(void \\*\\) 0x0" \ + "const_cast of 0" + +gdb_test "print static_cast (b)" " = \\(A \\*\\) $hex" \ + "basic test of static_cast" + +gdb_test "print static_cast (*b)" " = \\(A \\&\\) @$hex: {a = 42}" \ + "static_cast to reference type" + +gdb_test "print reinterpret_cast (b)" " = \\(A \\*\\) $hex" \ + "basic test of reinterpret_cast" + +gdb_test "print reinterpret_cast (b)" "Invalid reinterpret_cast" \ + "test invalid reinterpret_cast" + +gdb_test "print reinterpret_cast (*b)" " = \\(A \\&\\) @$hex: {a = 42}" \ + "reinterpret_cast to reference type" + +# Tests of dynamic_cast. + +set nonzero_hex "0x\[0-9A-Fa-f\]\[0-9A-Fa-f\]+" + +gdb_test "print dynamic_cast (a)" \ + ".*must be a pointer or reference type" \ + "invalid dynamic_cast" + +gdb_test "print dynamic_cast (0)" \ + " = \\(void \\*\\) 0x0" \ + "dynamic_cast of 0 to void*" + +gdb_test "print dynamic_cast (&derived)" \ + " = \\(Alpha \\*\\) $nonzero_hex" \ + "dynamic_cast simple upcast" + +gdb_test "print dynamic_cast (&doublyderived)" \ + " = \\(Alpha \\*\\) $nonzero_hex" \ + "dynamic_cast upcast to unique base" + +gdb_test "print dynamic_cast (derived)" \ + " = \\(Alpha \\&\\) @$nonzero_hex: {.* = $nonzero_hex}" \ + "dynamic_cast simple upcast to reference" + +gdb_test "print dynamic_cast (ad)" \ + " = \\(Derived \\*\\) $nonzero_hex" \ + "dynamic_cast simple downcast" + +gdb_test "print dynamic_cast (add)" \ + " = \\(VirtuallyDerived \\*\\) $nonzero_hex" \ + "dynamic_cast simple downcast to intermediate class" + +gdb_test "print dynamic_cast (ad)" \ + " = \\(VirtuallyDerived \\*\\) 0x0" \ + "dynamic_cast to non-existing base" + +gdb_test "print dynamic_cast (*ad)" \ + "dynamic_cast failed" \ + "dynamic_cast to reference to non-existing base" + +gdb_test "print dynamic_cast (add)" \ + " = \\(DoublyDerived \\*\\) $nonzero_hex" \ + "dynamic_cast unique downcast" + +gdb_test "print dynamic_cast (add)" \ + " = \\(Gamma \\*\\) $nonzero_hex" \ + "dynamic_cast to sibling" Index: gdb2384.exp =================================================================== --- gdb2384.exp (nonexistent) +++ gdb2384.exp (revision 513) @@ -0,0 +1,94 @@ +# Copyright 2007, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# When gdb resolves type information for class "derived" from objfile +# gdb2384, it use to fill in the TYPE_VPTR_BASETYPE field with class "base" +# from objfile gdb2384-base.so. When the program is rerun the type +# information for base-in-so-base.so is discarded leaving +# TYPE_VPTR_BASETYPE dangling. +# +# PR c++/9489. + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } +if { [skip_shlib_tests] } { continue } + +set testfile "gdb2384" +set srcfile ${testfile}.cc +set binfile $objdir/$subdir/$testfile + +set libfile "gdb2384-base" +set libsrcfile ${libfile}.cc +set sofile $objdir/$subdir/${libfile}.so + +# Create and source the file that provides information about the compiler +# used to compile the test case. +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +if { [gdb_compile_shlib $srcdir/$subdir/$libsrcfile $sofile {debug c++}] != "" + || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug "c++" shlib=${sofile}]] != ""} { + untested gdb2384.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} +gdb_load_shlibs ${sofile} + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + return -1 +} + +gdb_breakpoint [gdb_get_line_number "set breakpoint here"] +gdb_continue_to_breakpoint "set breakpoint here" + +gdb_test "print d1.meth ()" \ + ".*42.*" \ + "print d1.meth ()" + +# Now try again. gdb's without the fix will hopefully segv here + +runto_main +gdb_breakpoint [gdb_get_line_number "set breakpoint here"] +gdb_continue_to_breakpoint "set breakpoint here" +gdb_test "print d1.meth ()" \ + ".*42.*" \ + "gdb2384" + +# second case + +runto_main +gdb_breakpoint [gdb_get_line_number "set breakpoint here (second)"] +gdb_continue_to_breakpoint "set breakpoint here (second)" +gdb_test "print d2.meth ()" \ + ".*24.*" \ + "print d2.meth()" + +runto_main +gdb_breakpoint [gdb_get_line_number "set breakpoint here (second)"] +gdb_continue_to_breakpoint "set breakpoint here (second)" +gdb_test "print d2.meth ()" \ + ".*24.*" \ + "gdb2384 (second)" + Index: operator.cc =================================================================== --- operator.cc (nonexistent) +++ operator.cc (revision 513) @@ -0,0 +1,211 @@ +class A +{ +}; + +int operator== (A, int) +{ + return 11; +} + +int operator== (A, char) +{ + return 12; +} + +//------------------ + +namespace B +{ + class C + { + }; + + int operator== (C, int) + { + return 22; + } + + int operator== (C, char) + { + return 23; + } + + namespace BD + { + int operator== (C, int) + { + return 24; + } + } +} + +//------------------ + +class D +{ +}; +namespace +{ + int operator== (D, int) + { + return 33; + } + + int operator== (D, char) + { + return 34; + } +} + +int operator== (D, float) +{ + return 35; +} + +//------------------ + +class E +{ +}; +namespace F +{ + int operator== (E, int) + { + return 44; + } + + int operator== (E, char) + { + return 45; + } +} + +int operator== (E, float) +{ + return 46; +} + +using namespace F; + +//----------------- + +class G +{ +public: + int operator== (int) + { + return 55; + } +}; + +int operator== (G, char) +{ + return 56; +} + +//------------------ + +class H +{ +}; +namespace I +{ + int operator== (H, int) + { + return 66; + } +} + +namespace ALIAS = I; + +//------------------ + +class J +{ +}; + +namespace K +{ + int i; + int operator== (J, int) + { + return 77; + } +} + +using K::i; + +//------------------ + +class L +{ +}; +namespace M +{ + int operator== (L, int) + { + return 88; + } +} + +namespace N +{ + using namespace M; +} + +using namespace N; + +//------------------ + +namespace O +{ + namespace P + { + using namespace ::O; + } + using namespace P; +} + +using namespace O; + +class test { }; +test x; + +//------------------ + +int main () +{ + A a; + a == 1; + a == 'a'; + + B::C bc; + bc == 1; + bc == 'a'; + B::BD::operator== (bc,'a'); + + D d; + d == 1; + d == 'a'; + d == 1.0f; + + E e; + e == 1; + e == 'a'; + e == 1.0f; + + G g; + g == 1; + g == 'a'; + + H h; + I::operator== (h, 1); + + J j; + K::operator== (j, 1); + + L l; + l == 1; + + return 0; +} Index: namespace.cc =================================================================== --- namespace.cc (nonexistent) +++ namespace.cc (revision 513) @@ -0,0 +1,209 @@ +namespace AAA { + char c; + int i; + int A_xyzq (int); + char xyzq (char); + class inA { + public: + int xx; + int fum (int); + }; + enum SomeEnum { + ALPHA, + BETA, + DELTA + }; +}; + +int AAA::inA::fum (int i) +{ + return 10 + i; +} + +namespace BBB { + char c; + int i; + int B_xyzq (int); + char xyzq (char); + + namespace CCC { + char xyzq (char); + }; + + class Class { + public: + char xyzq (char); + int dummy; + }; +}; + +int AAA::A_xyzq (int x) +{ + return 2 * x; +} + +char AAA::xyzq (char c) +{ + return 'a'; +} + + +int BBB::B_xyzq (int x) +{ + return 3 * x; +} + +char BBB::xyzq (char c) +{ + return 'b'; +} + +char BBB::CCC::xyzq (char c) +{ + return 'z'; +} + +char BBB::Class::xyzq (char c) +{ + return 'o'; +} + +void marker1(void) +{ + return; +} + +namespace +{ + int X = 9; + + namespace G + { + int Xg = 10; + + namespace + { + int XgX = 11; + } + } +} + +namespace C +{ + int c = 1; + int shadow = 12; + + class CClass { + public: + int x; + class NestedClass { + public: + int y; + }; + }; + + void ensureRefs () { + // NOTE (2004-04-23, carlton): This function is here only to make + // sure that GCC 3.4 outputs debug info for these classes. + static CClass *c = new CClass(); + static CClass::NestedClass *n = new CClass::NestedClass(); + } + + namespace + { + int cX = 6; + + namespace F + { + int cXf = 7; + + namespace + { + int cXfX = 8; + } + } + } + + namespace C + { + int cc = 2; + } + + namespace E + { + int ce = 4; + } + + namespace D + { + int cd = 3; + int shadow = 13; + + namespace E + { + int cde = 5; + } + + void marker2 (void) + { + // NOTE: carlton/2003-04-23: I'm listing the expressions that I + // plan to have GDB try to print out, just to make sure that the + // compiler and I agree which ones should be legal! It's easy + // to screw up when testing the boundaries of namespace stuff. + c; + //cc; + C::cc; + cd; + //C::D::cd; + E::cde; + shadow; + //E::ce; + cX; + F::cXf; + F::cXfX; + X; + G::Xg; + //cXOtherFile; + //XOtherFile; + G::XgX; + + return; + } + + } +} + +extern int ensureOtherRefs (); + +int main () +{ + using AAA::inA; + char c1; + AAA::SomeEnum var = AAA::ALPHA; + + using namespace BBB; + + c1 = xyzq ('x'); + c1 = AAA::xyzq ('x'); + c1 = BBB::CCC::xyzq ('m'); + + inA ina; + + ina.xx = 33; + + int y; + + y = AAA::A_xyzq (33); + y += B_xyzq (44); + + BBB::Class cl; + + c1 = cl.xyzq('e'); + + marker1(); + + C::D::marker2 (); + + C::ensureRefs (); + ensureOtherRefs (); +} Index: printmethod.cc =================================================================== --- printmethod.cc (nonexistent) +++ printmethod.cc (revision 513) @@ -0,0 +1,35 @@ +/* This test script is part of GDB, the GNU debugger. + + Copyright 2002, 2004, 2005, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +/* Create some objects, and try to print out their methods. */ + +class A { +public: + virtual void virt() {}; + void nonvirt() {}; +}; + +int main() +{ + A *theA = new A; + theA->virt (); + theA->nonvirt (); + + return 0; // breakpoint: constructs-done +} Index: exception.cc =================================================================== --- exception.cc (nonexistent) +++ exception.cc (revision 513) @@ -0,0 +1,69 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 1997, 1998, 2004, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + + + +// Test file for exception handling support. + +#include +using namespace std; + +int foo (int i) +{ + if (i < 32) + throw (int) 13; + else + return i * 2; +} + +extern "C" int bar (int k, unsigned long eharg, int flag); + +int bar (int k, unsigned long eharg, int flag) +{ + cout << "k is " << k << " eharg is " << eharg << " flag is " << flag << endl; + return 1; +} + +int main() +{ + int j; + + try { + j = foo (20); + } + catch (int x) { + cout << "Got an except " << x << endl; + } + + try { + try { + j = foo (20); + } + catch (int x) { + cout << "Got an except " << x << endl; + throw; + } + } + catch (int y) { + cout << "Got an except (rethrown) " << y << endl; + } + + // Not caught + foo (20); +} Index: annota3.cc =================================================================== --- annota3.cc (nonexistent) +++ annota3.cc (revision 513) @@ -0,0 +1,28 @@ +#include + +class A { +public: + int x; + int y; + int foo (int arg); +}; + + +int A::foo (int arg) +{ + x += arg; + return arg *2; +} + +int main() +{ + A a; + + a.x = 0; + a.x = 1; + a.y = 2; + + printf ("a.x is %d\n", a.x); + return 0; +} + Index: ref-params.exp =================================================================== --- ref-params.exp (nonexistent) +++ ref-params.exp (revision 513) @@ -0,0 +1,78 @@ +# Tests for reference parameters of types and their subtypes in GDB. +# Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# written by Paul N. Hilfinger (Hilfinger@adacore.com) + +if $tracelevel then { + strace $tracelevel + } + +# +# test running programs +# + +if { [skip_cplus_tests] } { continue } + +set testfile "ref-params" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested ref-params.exp + return -1 +} + +gdb_exit + +proc gdb_start_again { text } { + global srcdir + global subdir + global binfile + global srcfile + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load ${binfile} + + runto ${srcfile}:[gdb_get_line_number $text] +} + +gdb_start_again "marker1 here" +gdb_test "print Q" ".*id = 42.*" "print value of a Child in main" +gdb_test "print f1(Q)" ".* = 42.*" "print value of f1 on Child in main" +gdb_test "print f2(Q)" ".* = 42.*" "print value of f2 on Child in main" + +gdb_start_again "marker1 here" +gdb_test "print f1(QR)" ".* = 42.*" "print value of f1 on (Child&) in main" + +gdb_start_again "marker1 here" +gdb_test "print f2(QR)" ".* = 42.*" "print value of f2 on (Child&) in main" + +gdb_start_again "marker2 here" +gdb_test "print C" ".*id = 42.*" "print value of Child& in f2" +gdb_test "print f1(C)" ".* = 42.*" "print value of f1 on Child& in f2" + +gdb_start_again "marker3 here" +gdb_test "print R" ".*id = 42.*" "print value of Parent& in f1" + +gdb_start_again "breakpoint MQ here" +gdb_test "print f1(MQ)" ".* = 53" +gdb_test "print mf1(MQ)" ".* = 106" +gdb_test "print mf2(MQ)" ".* = 106" +gdb_test "print f1(MQR)" ".* = 53" +gdb_test "print mf1(MQR)" ".* = 106" +gdb_test "print mf2(MQR)" ".* = 106" Index: rtti2.cc =================================================================== --- rtti2.cc (nonexistent) +++ rtti2.cc (revision 513) @@ -0,0 +1,38 @@ +/* Code to go along with tests in rtti.exp. + + Copyright 2003, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + Contributed by David Carlton and by Kealia, + Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "rtti.h" + +namespace n2 { + + D2::D2(C2 *expr_1, C2 *expr_2) + : expr_1_(expr_1), expr_2_(expr_2) { } + + C2 *create2() { + return new D2(0, 0); + } + + n3::C3 *create3() { + return new n3::C3(); + } + +} Index: exception.exp =================================================================== --- exception.exp (nonexistent) +++ exception.exp (revision 513) @@ -0,0 +1,232 @@ +# Copyright 1997, 1998, 2004, 2005, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the gdb testsuite. +# tests for exception-handling support +# Written by Satish Pai 1997-07-23 +# Rewritten by Michael Chastain 2004-01-08 + +# This file used to have two copies of the tests with different +# compiler flags for hp-ux. Instead, the user should set CXXOPTS +# or run runtest with --target_board unix/gdb:debug_flags="..." +# to choose the compiler flags. +# +# The interesting compiler flags are: "aCC +A -Wl,-a,-archive" . +# Static-linked executables use a different mechanism to get the +# address of the notification hook in the C++ support library. + +# TODO: this file has many absolute line numbers. +# Replace them with gdb_get_line_number. + +set ws "\[\r\n\t \]+" +set nl "\[\r\n\]+" + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_stl_tests] } { continue } + +# On SPU this test fails because the executable exceeds local storage size. +if { [istarget "spu*-*-*"] } { + return 0 +} + +set testfile "exception" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested exception.exp + return -1 +} + +# Start with a fresh gdb + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +# Set a catch catchpoint + +gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)" \ + "catch catch (before inferior run)" + +# Set a throw catchpoint + +gdb_test "catch throw" "Catchpoint \[0-9\]+ \\(throw\\)" \ + "catch throw (before inferior run)" + + +# The catchpoints should be listed in the list of breakpoints. +# In case of a statically linked test, we won't have a pending breakpoint. +# Hence we allow for both an address or "". If we ever become able +# to tell whether the target is linked statically or not, we can be more +# precise and require exact output. +set addr "\(|$hex\)" +set re_head "Num${ws}Type${ws}Disp${ws}Enb${ws}Address${ws}What" +set re_2_bp "1${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception catch" +set re_3_bp "2${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception throw" + +set name "info breakpoints (before inferior run)" +gdb_test_multiple "info breakpoints" $name { + -re "$re_head${ws}$re_2_bp${ws}$re_3_bp\r\n$gdb_prompt $" { + pass $name + } + -re ".*$gdb_prompt $" + { + fail $name + } +} + +gdb_test "tbreak main" "Temporary breakpoint 3.*" \ + "Set temporary breakpoint at main" + +set ok 0 +gdb_run_cmd +gdb_test_multiple "" "Run to main" { + -re "Temporary breakpoint 3,.*$gdb_prompt $" { + pass "Run to main" + set ok 1 + } +} + +if { !$ok } { + continue +} + +set addr "$hex" +set re_head "Num${ws}Type${ws}Disp${ws}Enb${ws}Address${ws}What" +set re_2_bp "1${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception catch" +set re_3_bp "2${ws}breakpoint${ws}keep${ws}y${ws}$addr${ws}exception throw" + +set name "info breakpoints (after inferior run)" +gdb_test_multiple "info breakpoints" $name { + -re "$re_head${ws}$re_2_bp${ws}$re_3_bp\r\n$gdb_prompt $" { + pass $name + } + -re ".*$gdb_prompt $" + { + send_user "\n---\n$expect_out(buffer)\n---\n" + fail $name + } +} + +# Get the first exception thrown + +set name "continue to first throw" +gdb_test_multiple "continue" $name { + -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception thrown\\), throw location.*${srcfile}:30, catch location .*${srcfile}:50\r\n$gdb_prompt $" { + pass $name + } + -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception thrown\\).*\r\n$gdb_prompt $" { + pass $name + } +} + +# Backtrace from the throw point. +# This should get to user code. + +set name "backtrace after first throw" +gdb_test_multiple "backtrace" $name { + -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_throw\[\[:>:\]\].*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" { + # Either __cxxabiv1::__cxa_throw or __cxa_throw can be printed + # depending on debug info presence. + pass $name + } +} + +# Continue to the catch. + +set name "continue to first catch" +gdb_test_multiple "continue" $name { + -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\), throw location.*${srcfile}:30, catch location .*${srcfile}:50\r\n$gdb_prompt $" { + pass $name + } + -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\).*\r\n$gdb_prompt $" { + pass $name + } +} + +# Backtrace from the catch point. +# This should get to user code. + +set name "backtrace after first catch" +gdb_test_multiple "backtrace" $name { + -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_begin_catch\[\[:>:\]\].*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" { + pass $name + } +} + +# Continue to second throw. + +set name "continue to second throw" +gdb_test_multiple "continue" $name { + -re "Continuing.${ws}Got an except 13${ws}Catchpoint \[0-9\]+ \\(exception thrown\\), throw location.*${srcfile}:30, catch location .*${srcfile}:58\r\n$gdb_prompt $" { + pass $name + } + -re "Continuing.${ws}Got an except 13${ws}Catchpoint \[0-9\]+ \\(exception thrown\\).*\r\n$gdb_prompt $" { + pass $name + } +} + +# Backtrace from the throw point. +# This should get to user code. + +set name "backtrace after second throw" +gdb_test_multiple "backtrace" $name { + -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_throw\[\[:>:\]\].*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:\[0-9\]+\r\n#\[0-9\]+${ws}$hex in main \\(.*\\) at .*${srcfile}:\[0-9\]+\r\n$gdb_prompt $" { + pass $name + } +} + +# Continue to second catch. + +set name "continue to second catch" +gdb_test_multiple "continue" $name { + -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\), throw location.*${srcfile}:30, catch location .*${srcfile}:58\r\n$gdb_prompt $" { + pass $name + } + -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\).*\r\n$gdb_prompt $" { + pass $name + } +} + +# Backtrace from the catch point. +# This should get to user code. + +set name "backtrace after second catch" +gdb_test_multiple "backtrace" $name { + -re ".*#\[0-9\]+.*\[\[:<:\]\]__cxa_begin_catch\[\[:>:\]\].*#\[0-9\]+${ws}$hex in main \\(.*\\) at .*$srcfile:\[0-9\]+\r\n$gdb_prompt $" { + pass $name + } +} + +# That is all for now. +# +# The original code had: +# +# continue to re-throw ; backtrace +# continue to catch ; backtrace +# continue to throw out of main +# +# The problem is that "re-throw" does not show a throw; only a catch. +# I do not know if this is because of a bug, or because the generated +# code is optimized for a throw into the same function. +# +# -- chastain 2004-01-09 Index: psmang1.cc =================================================================== --- psmang1.cc (nonexistent) +++ psmang1.cc (revision 513) @@ -0,0 +1,178 @@ +/* This test script is part of GDB, the GNU debugger. + + Copyright 2002, 2004, + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +/* Do not move this definition into a header file! See the comments + in psmang.exp. */ +struct s +{ + int value; + void method1 (void); + void method2 (void); +}; + +void +s::method1 () +{ + value = 42; +} + +int +main (int argc, char **argv) +{ + s si; + + si.method1 (); + si.method2 (); +} + + +/* The presence of these variables ensures there will be so many + symbols in psmang1.cc's symtab's global block that it will have a + non-trivial hash table. When there are only a very few symbols, + the block only has one hash bucket, so even if we compute the hash + value for the wrong symbol name, we'll still find a symbol that + matches. */ +int ax; +int bx; +int a1x; +int b1x; +int a2x; +int b2x; +int a12x; +int b12x; +int a3x; +int b3x; +int a13x; +int b13x; +int a23x; +int b23x; +int a123x; +int b123x; +int a4x; +int b4x; +int a14x; +int b14x; +int a24x; +int b24x; +int a124x; +int b124x; +int a34x; +int b34x; +int a134x; +int b134x; +int a234x; +int b234x; +int a1234x; +int b1234x; +int a5x; +int b5x; +int a15x; +int b15x; +int a25x; +int b25x; +int a125x; +int b125x; +int a35x; +int b35x; +int a135x; +int b135x; +int a235x; +int b235x; +int a1235x; +int b1235x; +int a45x; +int b45x; +int a145x; +int b145x; +int a245x; +int b245x; +int a1245x; +int b1245x; +int a345x; +int b345x; +int a1345x; +int b1345x; +int a2345x; +int b2345x; +int a12345x; +int b12345x; +int a6x; +int b6x; +int a16x; +int b16x; +int a26x; +int b26x; +int a126x; +int b126x; +int a36x; +int b36x; +int a136x; +int b136x; +int a236x; +int b236x; +int a1236x; +int b1236x; +int a46x; +int b46x; +int a146x; +int b146x; +int a246x; +int b246x; +int a1246x; +int b1246x; +int a346x; +int b346x; +int a1346x; +int b1346x; +int a2346x; +int b2346x; +int a12346x; +int b12346x; +int a56x; +int b56x; +int a156x; +int b156x; +int a256x; +int b256x; +int a1256x; +int b1256x; +int a356x; +int b356x; +int a1356x; +int b1356x; +int a2356x; +int b2356x; +int a12356x; +int b12356x; +int a456x; +int b456x; +int a1456x; +int b1456x; +int a2456x; +int b2456x; +int a12456x; +int b12456x; +int a3456x; +int b3456x; +int a13456x; +int b13456x; +int a23456x; +int b23456x; +int a123456x; +int b123456x; Index: pr9167.cc =================================================================== --- pr9167.cc (nonexistent) +++ pr9167.cc (revision 513) @@ -0,0 +1,36 @@ +#include + +template +struct ATB +{ + int data; + ATB() : data(0) {} +}; + + +template +class A : public ATB +{ +public: + static DerivedType const DEFAULT_INSTANCE; +}; + +template +const DerivedType A::DEFAULT_INSTANCE; + +class B : public A +{ + +}; + +int main() +{ + B b; + // If this if-block is removed then GDB shall + // not infinitely recurse when trying to print b. + + return 0; // marker +} + + Index: method2.exp =================================================================== --- method2.exp (nonexistent) +++ method2.exp (revision 513) @@ -0,0 +1,70 @@ +# Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the gdb testsuite + +# This tests setting a break in an ambiguous c++ method with +# current_language set to c. + +if { [skip_cplus_tests] } { continue } + +set testfile "method2" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested method2.exp + return -1 +} + +if [get_compiler_info $binfile "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +proc test_break { lang } { + global gdb_prompt + + gdb_test "set lang $lang" \ + "" \ + "setting language $lang" + + gdb_test_multiple "break A::method" "breaking in method ($lang)" { + -re ".0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2. A::method\\(A\\*\\) at .*\[\r\n\]*.3. A::method\\(int\\) at .*\[\r\n\]*\[\r\n\]*.4. A::method\\(\\) at .*\[\r\n\]*> $" { + gdb_test "0" \ + "canceled" \ + "breaking in method ($lang)" + } + } +} + +# We want in this test to double-check the contents of the multiple-choice +# menu that's printed when a breakpoint location is ambiguous. So we need +# to set multiple-symbols to "ask" first. +gdb_test_no_output "set multiple-symbols ask" + +test_break "c" +test_break "c++" + +gdb_continue_to_end "continue to end" Index: bs15503.exp =================================================================== --- bs15503.exp (nonexistent) +++ bs15503.exp (revision 513) @@ -0,0 +1,107 @@ +# Copyright 1992, 2004, 2005, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +# Test case for CLLbs15503 +# This file was written by Sue Kimura (sue_kimura@hp.com) +# Rewritten by Michael Chastain (mec.gnu@mindspring.com) + +if $tracelevel { + strace $tracelevel +} + +if { [skip_stl_tests] } { continue } + +# On SPU this test fails because the executable exceeds local storage size. +if { [istarget "spu*-*-*"] } { + return 0 +} + +set testfile "bs15503" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile}] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug c++"] != "" } { + untested bs15503.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +# Set breakpoint on template function + +gdb_test "break StringTest::testFunction" \ + "Breakpoint $decimal at $hex: file .*${srcfile}, line $decimal." + +gdb_test "continue" \ + ".*Breakpoint $decimal, StringTest::testFunction \\(this=$hex\\).*" \ + "continue to StringTest" + +# Run to some random point in the middle of the function. + +gdb_breakpoint [gdb_get_line_number "find position where blank needs to be inserted"] +gdb_continue_to_breakpoint "find position where blank needs to be inserted" + +# Call some string methods. + +gdb_test "print s.length()" "\\$\[0-9\]+ = 42" +gdb_test "print s\[0\]" "\\$\[0-9\]+ =.* 'I'" +gdb_test "print s\[s.length()-1\]" "\\$\[0-9\]+ =.* 'g'" +gdb_test "print (const char *) s" \ + "\\$\[0-9\]+ = $hex \"I am a short stringand now a longer string\"" + +# TODO: tests that do not work with gcc 2.95.3 +# -- chastain 2004-01-07 +# +# gdb_test "print s.compare(s)" "\\$\[0-9\]+ = 0" +# gdb_test "print s.compare(\"AAA\")" "\\$\[0-9\]+ = 1" +# gdb_test "print s.compare(\"ZZZ\")" "\\$\[0-9\]+ = -1" + +# TODO: tests that do not work with gcc 2.95.3 and gcc 3.3.2. +# cannot call overloaded non-member operator. -- chastain 2004-01-07 +# +# gdb_test "print s == s" "\\$\[0-9\]+ = true" +# gdb_test "print s > "AAA" "\\$\[0-9\]+ = true" +# gdb_test "print s < "ZZZ" "\\$\[0-9\]+ = true" + +# TODO: GDB doesn't know to convert the string to a const char *, and +# instead tries to use the string as a structure initializer. +# +# gdb_test "print s == \"I am a short stringand now a longer string\"" \ +# "\\$\[0-9\]+ = true" + +gdb_test "print (const char *) s.substr(0,4)" "\\$\[0-9\]+ = $hex \"I am\"" +gdb_test "print (const char *) (s=s.substr(0,4))" \ + "\\$\[0-9\]+ = $hex \"I am\"" + +# TODO: cannot call overloaded non-member operator again. +# -- chastain 2004-01-07 +# +# gdb_test "print (const char *) (s + s)" \ +# "\\$\[0-9\]+ = $hex \"I amI am\"" +# gdb_test "print (const char *) (s + \" \" + s)" \ +# "\\$\[0-9\]+ = $hex \"I am I am\"" Index: ctti.exp =================================================================== --- ctti.exp (nonexistent) +++ ctti.exp (revision 513) @@ -0,0 +1,212 @@ +# Copyright 1998, 1999, 2001, 2003, 2004, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the gdb testsuite +# file written by Elena Zannoni (ezannoni@cygnus.com) +# rewritten by Michael Chastain (mec.gnu@mindspring.com) +# +# source files cttiadd.cc, cttiadd1.cc, cttiadd2.cc, cttiadd3.cc + +# Call to template instantiations. + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +set testfile "cttiadd" +set srcfile "${testfile}.cc" +set srcfile1 "${testfile}1.cc" +set srcfile2 "${testfile}2.cc" +set srcfile3 "${testfile}3.cc" +set objfile "${testfile}.o" +set objfile1 "${testfile}1.o" +set objfile2 "${testfile}2.o" +set objfile3 "${testfile}3.o" +set binfile "${objdir}/${subdir}/${testfile}" + +if { [gdb_compile "$srcdir/$subdir/$srcfile" "$objdir/$subdir/$objfile" object {debug c++}] != "" } { + untested ctti.exp + return -1 +} + +if { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } { + untested ctti.exp + return -1 +} + +if { [gdb_compile "$srcdir/$subdir/$srcfile2" "$objdir/$subdir/$objfile2" object {debug c++}] != "" } { + untested ctti.exp + return -1 +} + +if { [gdb_compile "$srcdir/$subdir/$srcfile3" "$objdir/$subdir/$objfile3" object {debug c++}] != "" } { + untested ctti.exp + return -1 +} + +if { [gdb_compile "$objdir/$subdir/$objfile $objdir/$subdir/$objfile1 $objdir/$subdir/$objfile2 $objdir/$subdir/$objfile3" "${binfile}" executable {debug c++}] != "" } { + untested ctti.exp + return -1 +} + +if [get_compiler_info ${binfile} "c++"] { + return -1; +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +gdb_breakpoint [gdb_get_line_number "marker add1"] +gdb_continue_to_breakpoint "marker add1" + +gdb_test "print c" "\\$\[0-9\]+ = 194 .*" +gdb_test "print f" "\\$\[0-9\]+ = 9" +gdb_test "print i" "\\$\[0-9\]+ = 4" + +# TODO: this needs more work before actually deploying it. +# So bail out here. + +if { [ test_compiler_info gcc-*] } then { continue } + +gdb_test_multiple "print add(2,2)" "print add(2,2)" { + -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" { + pass "print add(2,2)" + } + -re "No symbol \"add\" in current context.\r\n$gdb_prompt $" { + # TODO: kfail or xfail this + fail "print add(2,2)" + } +} + +# Note: 2.25 and 4.5 are exactly representable in IEEE-ish formats +gdb_test_multiple "print add(2.25,2.25)" "print add(2.25,2.25)" { + -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" { + pass "print add(2.25,2.25)" + } + -re "No symbol \"add\" in current context.\r\n$gdb_prompt $" { + # TODO: kfail or xfail this + fail "print add(2.25,2.25)" + } +} + +gdb_test_multiple "print add('A','A')" "print add('A','A')" { + -re "\\$\[0-9\]+ = 130 .*\r\n$gdb_prompt $" { + pass "print add('A','A')" + } + -re "No symbol \"add\" in current context.\r\n$gdb_prompt $" { + # TODO: kfail or xfail this + fail "print add('A','A')" + } +} + +gdb_test_multiple "print add2(2,2)" "print add2(2,2)" { + -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" { + pass "print add2(2,2)" + } + -re "No symbol \"add2\" in current context.\r\n$gdb_prompt $" { + # TODO: kfail or xfail this + fail "print add2(2,2)" + } +} + +gdb_test_multiple "print add2(2.25,2.25)" "print add2(2.25,2.25)" { + -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" { + pass "print add2(2.25,2.25)" + } + -re "No symbol \"add2\" in current context.\r\n$gdb_prompt $" { + # TODO: kfail or xfail this + fail "print add2(2.25,2.25)" + } +} + +gdb_test_multiple "print add2('A','A')" "print add2('A','A')" { + -re "\\$\[0-9]+ = 130 .*$gdb_prompt $" { + pass "print add2('A','A')" + } + -re "No symbol \"add2\" in current context.\r\n$gdb_prompt $" { + # TODO: kfail or xfail this + fail "print add2('A','A')" + } +} + +gdb_test_multiple "print add3(2,2)" "print add3(2,2)" { + -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" { + pass "print add3(2,2)" + } + -re "No symbol \"add3\" in current context.\r\n$gdb_prompt $" { + # TODO: kfail or xfail this + fail "print add3(2,2)" + } +} + +gdb_test_multiple "print add3(2.25,2.25)" "print add3(2.25,2.25)" { + -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" { + pass "print add3(2.25,2.25)" + } + -re "No symbol \"add3\" in current context.\r\n$gdb_prompt $" { + # TODO: kfail or xfail this + fail "print add3(2.25,2.25)" + } +} + +gdb_test_multiple "print add3('A','A')" "print add3('A','A')" { + -re "\\$\[0-9]+ = 130 .*$gdb_prompt $" { + pass "print add3('A','A')" + } + -re "No symbol \"add3\" in current context.\r\n$gdb_prompt $" { + # TODO: kfail or xfail this + fail "print add3('A','A')" + } +} + +gdb_test_multiple "print add4(2,2)" "print add4(2,2)" { + -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" { + pass "print add4(2,2)" + } + -re "No symbol \"add4\" in current context.\r\n$gdb_prompt $" { + # TODO: kfail or xfail this + fail "print add4(2,2)" + } +} + +gdb_test_multiple "print add4(2.25,2.25)" "print add4(2.25,2.25)" { + -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" { + pass "print add4(2.25,2.25)" + } + -re "No symbol \"add4\" in current context.\r\n$gdb_prompt $" { + # TODO: kfail or xfail this + fail "print add4(2.25,2.25)" + } +} + +gdb_test_multiple "print add4('A','A')" "print add4('A','A')" { + -re "\\$\[0-9]+ = 130 .*$gdb_prompt $" { + pass "print add4('A','A')" + } + -re "No symbol \"add4\" in current context.\r\n$gdb_prompt $" { + # TODO: kfail or xfail this + fail "print add4('A','A')" + } +} Index: casts.cc =================================================================== --- casts.cc (nonexistent) +++ casts.cc (revision 513) @@ -0,0 +1,52 @@ +struct A +{ + int a; + A (int aa): a (aa) {} +}; + +struct B: public A +{ + int b; + B (int aa, int bb): A (aa), b(bb) {} +}; + + +struct Alpha +{ + virtual void x() { } +}; + +struct Gamma +{ +}; + +struct Derived : public Alpha +{ +}; + +struct VirtuallyDerived : public virtual Alpha +{ +}; + +struct DoublyDerived : public VirtuallyDerived, + public virtual Alpha, + public Gamma +{ +}; + +int +main (int argc, char **argv) +{ + A *a = new B(42, 1729); + B *b = (B *) a; + A &ar = *b; + B &br = (B&)ar; + + Derived derived; + DoublyDerived doublyderived; + + Alpha *ad = &derived; + Alpha *add = &doublyderived; + + return 0; /* breakpoint spot: casts.exp: 1 */ +} Index: gdb2384.cc =================================================================== --- gdb2384.cc (nonexistent) +++ gdb2384.cc (revision 513) @@ -0,0 +1,53 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2008, 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#include "gdb2384-base.h" + +class derived1 : public base +{ + public: + derived1 (int); +}; + +derived1::derived1 (int _x) + : base (_x) +{ +} + +class derived2 : public derived +{ + public: + derived2 (int); +}; + +derived2::derived2 (int _x) + : derived (_x) +{ +} + +int g; + +int +main () +{ + derived1 d1 (42); + derived2 d2 (24); + g = d1.meth (); // set breakpoint here + g = d2.meth (); // set breakpoint here (second) + return 0; +} Index: nsdecl.exp =================================================================== --- nsdecl.exp (nonexistent) +++ nsdecl.exp (revision 513) @@ -0,0 +1,50 @@ +# Copyright 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Stress test the lookup of declarations + +if $tracelevel then { + strace $tracelevel +} + + +set testfile nsdecl +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested "Couldn't compile test program" + return -1 +} + +if [get_compiler_info ${binfile}] { + return -1; +} + +# Get things started. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint main" + continue +} + +############################################ +# Test that the search can fail efficiently + +gdb_test "print fakex" "No symbol \"fakex\" in current context." Index: hang.H =================================================================== --- hang.H (nonexistent) +++ hang.H (revision 513) @@ -0,0 +1,12 @@ +struct A +{ + struct B *b_ptr_in_a; +}; + +struct C +{ + struct B + { + int member_of_B_in_C; + }; +};
hang.H Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: anon-union.cc =================================================================== --- anon-union.cc (nonexistent) +++ anon-union.cc (revision 513) @@ -0,0 +1,56 @@ + +struct Foo { + union { + int zero; + unsigned int one; + } num1; + struct X { + int rock; + unsigned int rock2; + }; + union { + int pebble; + X x; + union { + int qux; + unsigned int mux; + }; + unsigned int boulder; + }; + union { + int paper; + unsigned int cloth; + }; + union { + int two; + unsigned int three; + } num2; +}; + +union Bar { + int x; + unsigned int y; +}; + + +int main() +{ + Foo foo = {0, 0}; + + foo.paper = 33; + foo.pebble = 44; + foo.mux = 55; + + Bar bar = {0}; + + union { + int z; + unsigned int w; + }; w = 0; + + bar.x = 33; + + w = 45; + + int j = 0; +} Index: try_catch.exp =================================================================== --- try_catch.exp (nonexistent) +++ try_catch.exp (revision 513) @@ -0,0 +1,80 @@ +# Copyright 2002, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Tests for member data +# 2002-05-27 Benjamin Kosnik + +# This file is part of the gdb testsuite + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_stl_tests] } { continue } + +# +# test running programs +# + +set testfile "try_catch" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested try_catch.exp + return -1 +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +gdb_breakpoint [gdb_get_line_number "marker 1-throw"] +gdb_continue_to_breakpoint "marker 1-throw" + +gdb_breakpoint [gdb_get_line_number "marker 1-catch"] +gdb_continue_to_breakpoint "marker 1-catch" + +gdb_breakpoint [gdb_get_line_number "marker 2-start"] +gdb_continue_to_breakpoint "marker 2-start" + +gdb_breakpoint [gdb_get_line_number "marker 2-next"] +gdb_continue_to_breakpoint "marker 2-next" + +gdb_breakpoint [gdb_get_line_number "marker 2-throw"] +gdb_continue_to_breakpoint "marker 2-throw" + +gdb_breakpoint [gdb_get_line_number "marker 2-catch"] +gdb_continue_to_breakpoint "marker 2-catch" + +gdb_breakpoint [gdb_get_line_number "marker 3-throw"] +gdb_continue_to_breakpoint "marker 3-throw" + +gdb_breakpoint [gdb_get_line_number "marker 3-catch"] +gdb_continue_to_breakpoint "marker 3-catch" + +gdb_exit +return 0 Index: ambiguous.cc =================================================================== --- ambiguous.cc (nonexistent) +++ ambiguous.cc (revision 513) @@ -0,0 +1,110 @@ + +void marker1() +{ + return; +} + +class A1 { +public: + int x; + int y; +}; + +class A2 { +public: + int x; + int y; +}; + +class A3 { +public: + int x; + int y; +}; + +class X : public A1, public A2 { +public: + int z; +}; + +class L : public A1 { +public: + int z; +}; + +class LV : public virtual A1 { +public: + int z; +}; + +class M : public A2 { +public: + int w; +}; + +class N : public L, public M { +public: + int r; +}; + +class K : public A1 { +public: + int i; +}; + +class KV : public virtual A1 { +public: + int i; +}; + +class J : public K, public L { +public: + int j; +}; + +class JV : public KV, public LV { +public: + int jv; +}; + +class JVA1 : public KV, public LV, public A1 { +public: + int jva1; +}; + +class JVA2 : public KV, public LV, public A2 { +public: + int jva2; +}; + +class JVA1V : public KV, public LV, public virtual A1 { +public: + int jva1v; +}; + +int main() +{ + A1 a1; + A2 a2; + A3 a3; + X x; + L l; + M m; + N n; + K k; + J j; + JV jv; + JVA1 jva1; + JVA2 jva2; + JVA1V jva1v; + + int i; + + i += k.i + m.w + a1.x + a2.x + a3.x + x.z + l.z + n.r + j.j; + + marker1(); + +} + + + Index: bool.cc =================================================================== --- bool.cc (nonexistent) +++ bool.cc (revision 513) @@ -0,0 +1,37 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +bool +return_true () +{ + return true; +} + +bool +return_false () +{ + return false; +} + +int +main () +{ + return_true (); + return_false (); +} Index: mb-inline2.cc =================================================================== --- mb-inline2.cc (nonexistent) +++ mb-inline2.cc (revision 513) @@ -0,0 +1,25 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2008, 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#include "mb-inline.h" + +int +bfn () +{ + return foo (1) + multi_line_foo (1); +} Index: extern-c.exp =================================================================== --- extern-c.exp (nonexistent) +++ extern-c.exp (revision 513) @@ -0,0 +1,65 @@ +# Copyright 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test breakpoints on extern "C" functions implemented in C++. + +if { [skip_cplus_tests] } { continue } + +set testfile "extern-c" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested extern-c.exp + return -1 +} + +# Start with a fresh gdb + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +runto_main + +if { [gdb_breakpoint "c_func"] == 1 } { + pass "setting breakpoint at c_func" +} +gdb_continue_to_breakpoint "c_func" ".*c_func.*" + +gdb_test_no_output "set \$counter = 0" "initialize counter" + +gdb_test "rbreak c_funcs" \ + "Breakpoint.* at .*c_funcs_1.*Breakpoint.* at .*c_funcs_2.*" + +# Test that "commands" without an argument puts commands on both +# breakpoints. +gdb_test_multiple "commands" "set commands on multiple breakpoints" { + -re "Type commands for breakpoint\\(s\\) 3-4, one per line\.\r\nEnd with a line saying just \"end\".\r\n>$" { + gdb_test_multiple "set \$counter = \$counter + 1\nend" \ + "command details for multiple breakpoints" { + -re "$gdb_prompt $" { + pass "command details for multiple breakpoints" + } + } + pass "set commands on multiple breakpoints" + } +} + +gdb_continue_to_breakpoint "c_funcs_1" ".*c_funcs_1.*" +gdb_test "print \$counter" " = 1" "verify counter at first breakpoint" +gdb_continue_to_breakpoint "c_funcs_2" ".*c_funcs_2.*" +gdb_test "print \$counter" " = 2" "verify counter at second breakpoint" Index: ref-params.cc =================================================================== --- ref-params.cc (nonexistent) +++ ref-params.cc (revision 513) @@ -0,0 +1,78 @@ +/* This test script is part of GDB, the GNU debugger. + + Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +/* Author: Paul N. Hilfinger, AdaCore Inc. */ + +struct Parent { + Parent (int id0) : id(id0) { } + int id; +}; + +struct Child : public Parent { + Child (int id0) : Parent(id0) { } +}; + +int f1(Parent& R) +{ + return R.id; /* Set breakpoint marker3 here. */ +} + +int f2(Child& C) +{ + return f1(C); /* Set breakpoint marker2 here. */ +} + +struct OtherParent { + OtherParent (int other_id0) : other_id(other_id0) { } + int other_id; +}; + +struct MultiChild : public Parent, OtherParent { + MultiChild (int id0) : Parent(id0), OtherParent(id0 * 2) { } +}; + +int mf1(OtherParent& R) +{ + return R.other_id; +} + +int mf2(MultiChild& C) +{ + return mf1(C); +} + +int main(void) +{ + Child Q(42); + Child& QR = Q; + + #ifdef usestubs + set_debug_traps(); + breakpoint(); + #endif + + /* Set breakpoint marker1 here. */ + + f2(Q); + f2(QR); + + MultiChild MQ(53); + MultiChild& MQR = MQ; + + mf2(MQ); /* Set breakpoint MQ here. */ +} Index: templates.cc =================================================================== --- templates.cc (nonexistent) +++ templates.cc (revision 513) @@ -0,0 +1,802 @@ +/* This test code is from Wendell Baker (wbaker@comet.berkeley.edu) */ + +#include + +int a_i; +char a_c; +double a_d; + +typedef void *Pix; + +int +f(int i) +{ return 0; } + +int +f(int i, char c) +{ return 0; } + +int +f(int i, char c, double d) +{ return 0; } + +int +f(int i, char c, double d, char *cs) +{ return 0; } + +int +f(int i, char c, double d, char *cs, void (*fig)(int, char)) +{ return 0; } + +int +f(int i, char c, double d, char *cs, void (*fig)(char, int)) +{ return 0; } + +class R { +public: + int i; +}; +class S { +public: + int i; +}; +class T { +public: + int i; +}; + +char g(char, const char, volatile char) +{ return 'c'; } +char g(R, char&, const char&, volatile char&) +{ return 'c'; } +char g(char*, const char*, volatile char*) +{ return 'c'; } +char g(S, char*&, const char*&, volatile char*&) +{ return 'c'; } + +signed char g(T,signed char, const signed char, volatile signed char) +{ return 'c'; } +signed char g(T, R, signed char&, const signed char&, volatile signed char&) +{ return 'c'; } +signed char g(T, signed char*, const signed char*, volatile signed char*) +{ return 'c'; } +signed char g(T, S, signed char*&, const signed char*&, volatile signed char*&) +{ return 'c'; } + +unsigned char g(unsigned char, const unsigned char, volatile unsigned char) +{ return 'c'; } +unsigned char g(R, unsigned char&, const unsigned char&, volatile unsigned char&) +{ return 'c'; } +unsigned char g(unsigned char*, const unsigned char*, volatile unsigned char*) +{ return 'c'; } +unsigned char g(S, unsigned char*&, const unsigned char*&, volatile unsigned char*&) +{ return 'c'; } + +short g(short, const short, volatile short) +{ return 0; } +short g(R, short&, const short&, volatile short&) +{ return 0; } +short g(short*, const short*, volatile short*) +{ return 0; } +short g(S, short*&, const short*&, volatile short*&) +{ return 0; } + +signed short g(T, signed short, const signed short, volatile signed short) +{ return 0; } +signed short g(T, R, signed short&, const signed short&, volatile signed short&) +{ return 0; } +signed short g(T, signed short*, const signed short*, volatile signed short*) +{ return 0; } +signed short g(T, S, double, signed short*&, const signed short*&, volatile signed short*&) +{ return 0; } + +unsigned short g(unsigned short, const unsigned short, volatile unsigned short) +{ return 0; } +unsigned short g(R, unsigned short&, const unsigned short&, volatile unsigned short&) +{ return 0; } +unsigned short g(unsigned short*, const unsigned short*, volatile unsigned short*) +{ return 0; } +unsigned short g(S, unsigned short*&, const unsigned short*&, volatile unsigned short*&) +{ return 0; } + +int g(int, const int, volatile int) +{ return 0; } +int g(R, int&, const int&, volatile int&) +{ return 0; } +int g(int*, const int*, volatile int*) +{ return 0; } +int g(S, int*&, const int*&, volatile int*&) +{ return 0; } + +signed int g(T, signed int, const signed int, volatile signed int) +{ return 0; } +signed int g(T, R, signed int&, const signed int&, volatile signed int&) +{ return 0; } +signed int g(T, signed int*, const signed int*, volatile signed int*) +{ return 0; } +signed int g(T, S, signed int*&, const signed int*&, volatile signed int*&) +{ return 0; } + +unsigned int g(unsigned int, const unsigned int, volatile unsigned int) +{ return 0; } +unsigned int g(R, unsigned int&, const unsigned int&, volatile unsigned int&) +{ return 0; } +unsigned int g(unsigned int*, const unsigned int*, volatile unsigned int*) +{ return 0; } +unsigned int g(S, unsigned int*&, const unsigned int*&, volatile unsigned int*&) +{ return 0; } + +long g(long, const long, volatile long) +{ return 0; } +long g(R, long&, const long&, volatile long&) +{ return 0; } +long g(long*, const long*, volatile long*) +{ return 0; } +long g(S, long*&, const long*&, volatile long*&) +{ return 0; } + +signed long g(T, signed long, const signed long, volatile signed long) +{ return 0; } +signed long g(T, R, signed long&, const signed long&, volatile signed long&) +{ return 0; } +signed long g(T, signed long*, const signed long*, volatile signed long*) +{ return 0; } +signed long g(T, S, signed long*&, const signed long*&, volatile signed long*&) +{ return 0; } + +unsigned long g(unsigned long, const unsigned long, volatile unsigned long) +{ return 0; } +unsigned long g(S, unsigned long&, const unsigned long&, volatile unsigned long&) +{ return 0; } +unsigned long g(unsigned long*, const unsigned long*, volatile unsigned long*) +{ return 0; } +unsigned long g(S, unsigned long*&, const unsigned long*&, volatile unsigned long*&) +{ return 0; } + +#ifdef __GNUC__ +long long g(long long, const long long, volatile long long) +{ return 0; } +long long g(S, long long&, const long long&, volatile long long&) +{ return 0; } +long long g(long long*, const long long*, volatile long long*) +{ return 0; } +long long g(R, long long*&, const long long*&, volatile long long*&) +{ return 0; } + +signed long long g(T, signed long long, const signed long long, volatile signed long long) +{ return 0; } +signed long long g(T, R, signed long long&, const signed long long&, volatile signed long long&) +{ return 0; } +signed long long g(T, signed long long*, const signed long long*, volatile signed long long*) +{ return 0; } +signed long long g(T, S, signed long long*&, const signed long long*&, volatile signed long long*&) +{ return 0; } + +unsigned long long g(unsigned long long, const unsigned long long, volatile unsigned long long) +{ return 0; } +unsigned long long g(R, unsigned long long*, const unsigned long long*, volatile unsigned long long*) +{ return 0; } +unsigned long long g(unsigned long long&, const unsigned long long&, volatile unsigned long long&) +{ return 0; } +unsigned long long g(S, unsigned long long*&, const unsigned long long*&, volatile unsigned long long*&) +{ return 0; } +#endif + +float g(float, const float, volatile float) +{ return 0; } +float g(char, float&, const float&, volatile float&) +{ return 0; } +float g(float*, const float*, volatile float*) +{ return 0; } +float g(char, float*&, const float*&, volatile float*&) +{ return 0; } + +double g(double, const double, volatile double) +{ return 0; } +double g(char, double&, const double&, volatile double&) +{ return 0; } +double g(double*, const double*, volatile double*) +{ return 0; } +double g(char, double*&, const double*&, volatile double*&) +{ return 0; } + +#ifdef __GNUC__ +long double g(long double, const long double, volatile long double) +{ return 0; } +long double g(char, long double&, const long double&, volatile long double&) +{ return 0; } +long double g(long double*, const long double*, volatile long double*) +{ return 0; } +long double g(char, long double*&, const long double*&, volatile long double*&) +{ return 0; } +#endif + +class c { +public: + c(int) {}; + int i; +}; + +class c g(c, const c, volatile c) +{ return 0; } +c g(char, c&, const c&, volatile c&) +{ return 0; } +c g(c*, const c*, volatile c*) +{ return 0; } +c g(char, c*&, const c*&, volatile c*&) +{ return 0; } + +/* +void h(char = 'a') +{ } +void h(char, signed char = 'a') +{ } +void h(unsigned char = 'a') +{ } +*/ +/* +void h(char = (char)'a') +{ } +void h(char, signed char = (signed char)'a') +{ } +void h(unsigned char = (unsigned char)'a') +{ } + + +void h(short = (short)43) +{ } +void h(char, signed short = (signed short)43) +{ } +void h(unsigned short = (unsigned short)43) +{ } + +void h(int = (int)43) +{ } +void h(char, signed int = (signed int)43) +{ } +void h(unsigned int = (unsigned int)43) +{ } + + +void h(long = (long)43) +{ } +void h(char, signed long = (signed long)43) +{ } +void h(unsigned long = (unsigned long)43) +{ } + +#ifdef __GNUC__ +void h(long long = 43) +{ } +void h(char, signed long long = 43) +{ } +void h(unsigned long long = 43) +{ } +#endif + +void h(float = 4.3e-10) +{ } +void h(double = 4.3) +{ } +#ifdef __GNUC__ +void h(long double = 4.33e33) +{ } +#endif +*/ + +/* An unneeded printf() definition - actually, just a stub - used to occupy + this space. It has been removed and replaced with this comment which + exists to occupy some lines so that templates.exp won't need adjustment. */ + +class T1 { +public: + static void* operator new(size_t) throw (); + static void operator delete(void *pointer); + + void operator=(const T1&); + T1& operator=(int); + + int operator==(int) const; + int operator==(const T1&) const; + int operator!=(int) const; + int operator!=(const T1&) const; + + int operator<=(int) const; + int operator<=(const T1&) const; + int operator<(int) const; + int operator<(const T1&) const; + int operator>=(int) const; + int operator>=(const T1&) const; + int operator>(int) const; + int operator>(const T1&) const; + + void operator+(int) const; + T1& operator+(const T1&) const; + void operator+=(int) const; + T1& operator+=(const T1&) const; + + T1& operator++() const; + + void operator-(int) const; + T1& operator-(const T1&) const; + void operator-=(int) const; + T1& operator-=(const T1&) const; + + T1& operator--() const; + + void operator*(int) const; + T1& operator*(const T1&) const; + void operator*=(int) const; + T1& operator*=(const T1&) const; + + void operator/(int) const; + T1& operator/(const T1&) const; + void operator/=(int) const; + T1& operator/=(const T1&) const; + + void operator%(int) const; + T1& operator%(const T1&) const; + void operator%=(int) const; + T1& operator%=(const T1&) const; + + void operator&&(int) const; + T1& operator&&(const T1&) const; + + void operator||(int) const; + T1& operator||(const T1&) const; + + void operator&(int) const; + T1& operator&(const T1&) const; + void operator&=(int) const; + T1& operator&=(const T1&) const; + + void operator|(int) const; + T1& operator|(const T1&) const; + void operator|=(int) const; + T1& operator|=(const T1&) const; + + void operator^(int) const; + T1& operator^(const T1&) const; + void operator^=(int) const; + T1& operator^=(const T1&) const; + + T1& operator!() const; + T1& operator~() const; +}; + +void* +T1::operator new(size_t) throw () +{ return 0; } + +void +T1::operator delete(void *pointer) +{ } + +class T2 { +public: + T2(int i): integer(i) + { } + int integer; +}; + +int operator==(const T2&, const T2&) +{ return 0; } +int operator==(const T2&, char) +{ return 0; } +int operator!=(const T2&, const T2&) +{ return 0; } +int operator!=(const T2&, char) +{ return 0; } + +int operator<=(const T2&, const T2&) +{ return 0; } +int operator<=(const T2&, char) +{ return 0; } +int operator<(const T2&, const T2&) +{ return 0; } +int operator<(const T2&, char) +{ return 0; } +int operator>=(const T2&, const T2&) +{ return 0; } +int operator>=(const T2&, char) +{ return 0; } +int operator>(const T2&, const T2&) +{ return 0; } +int operator>(const T2&, char) +{ return 0; } + +T2 operator+(const T2 t, int i) +{ return t.integer + i; } +T2 operator+(const T2 a, const T2& b) +{ return a.integer + b.integer; } +T2& operator+=(T2& t, int i) +{ t.integer += i; return t; } +T2& operator+=(T2& a, const T2& b) +{ a.integer += b.integer; return a; } + +T2 operator-(const T2 t, int i) +{ return t.integer - i; } +T2 operator-(const T2 a, const T2& b) +{ return a.integer - b.integer; } +T2& operator-=(T2& t, int i) +{ t.integer -= i; return t; } +T2& operator-=(T2& a, const T2& b) +{ a.integer -= b.integer; return a; } + +T2 operator*(const T2 t, int i) +{ return t.integer * i; } +T2 operator*(const T2 a, const T2& b) +{ return a.integer * b.integer; } +T2& operator*=(T2& t, int i) +{ t.integer *= i; return t; } +T2& operator*=(T2& a, const T2& b) +{ a.integer *= b.integer; return a; } + +T2 operator/(const T2 t, int i) +{ return t.integer / i; } +T2 operator/(const T2 a, const T2& b) +{ return a.integer / b.integer; } +T2& operator/=(T2& t, int i) +{ t.integer /= i; return t; } +T2& operator/=(T2& a, const T2& b) +{ a.integer /= b.integer; return a; } + +T2 operator%(const T2 t, int i) +{ return t.integer % i; } +T2 operator%(const T2 a, const T2& b) +{ return a.integer % b.integer; } +T2& operator%=(T2& t, int i) +{ t.integer %= i; return t; } +T2& operator%=(T2& a, const T2& b) +{ a.integer %= b.integer; return a; } + +template +class T5 { +public: + T5(int); + T5(const T5&); + ~T5(); + static void* operator new(size_t) throw (); + static void operator delete(void *pointer); + int value(); + + static T X; + T x; + int val; +}; + +template +T5::T5(int v) +{ val = v; } + +template +T5::T5(const T5&) +{} + +template +T5::~T5() +{} + +template +void* +T5::operator new(size_t) throw () +{ return 0; } + +template +void +T5::operator delete(void *pointer) +{ } + +template +int +T5::value() +{ return val; } + +template +T GetMax (T a, T b) { + T result; + result = (a>b)? a : b; + // set breakpoint on a line with no real code + return (result); +} + +#if ! defined(__GNUC__) || defined(GCC_BUG) +template +T T5::X; +#endif + + + + +T5 t5c(1); +T5 t5i(2); +T5 t5fi1(3); +T5 t5fi2(4); + + + + + + +class x { +public: + int (*manage[5])(double, + void *(*malloc)(unsigned size), + void (*free)(void *pointer)); + int (*device[5])(int open(const char *, unsigned mode, unsigned perms, int extra), + int *(*read)(int fd, void *place, unsigned size), + int *(*write)(int fd, void *place, unsigned size), + void (*close)(int fd)); +}; +T5 t5x(5); + +#if !defined(__GNUC__) || (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6) +template class T5; +template class T5; +template class T5; +template class T5; +template class T5; +#endif + +class T7 { +public: + static int get(); + static void put(int); +}; + +int +T7::get() +{ return 1; } + +void +T7::put(int i) +{ + // nothing +} + +// More template kinds. GDB 4.16 didn't handle these, but +// Wildebeest does. Note: Assuming HP aCC is used to compile +// this file; with g++ or HP cfront or other compilers the +// demangling may not get done correctly. + +// Ordinary template, to be instantiated with different types +template +class Foo { +public: + int x; + T t; + T foo (int, T); +}; + + +template T Foo::foo (int i, T tt) +{ + return tt; +} + +// Template with int parameter + +template +class Bar { +public: + int x; + T t; + T bar (int, T); +}; + + +template T Bar::bar (int i, T tt) +{ + if (i < sz) + return tt; + else + return 0; +} + +// function template with int parameter +template int dummy (T tt, int i) +{ + return tt; +} + +// Template with partial specializations +template +class Spec { +public: + int x; + T1 spec (T2); +}; + +template +T1 Spec::spec (T2 t2) +{ + return 0; +} + +template +class Spec { +public: + int x; + T spec (T*); +}; + +template +T Spec::spec (T * tp) +{ + return *tp; +} + +// Template with char parameter +template +class Baz { +public: + ~Baz () { }; + int x; + T t; + T baz (int, T); +}; + +template T Baz::baz (int i, T tt) +{ + if (i < sz) + return tt; + else + return 0; +} + +typedef Baz intBazOne; + +// Template with char * parameter +template +class Qux { +public: + int x; + T t; + T qux (int, T); +}; + +template T Qux::qux (int i, T tt) +{ + if (sz[0] == 'q') + return tt; + else + return 0; +} + +// Template with a function pointer parameter +template +class Qux1 { +public: + int x; + T t; + T qux (int, T); +}; + +template T Qux1::qux (int i, T tt) +{ + if (f != 0) + return tt; + else + return 0; +} + +// Some functions to provide as arguments to template +int gf1 (int a) { + return a * 2 + 13; +} +int gf2 (int a) { + return a * 2 + 26; +} + +char string[3]; + + +// Template for nested instantiations + +template +class Garply { +public: + int x; + T t; + T garply (int, T); +}; + +template T Garply::garply (int i, T tt) +{ + if (i > x) + return tt; + else + { + x += i; + return tt; + } +} + + +int main() +{ + int i; + long l, m, n; +#ifdef usestubs + set_debug_traps(); + breakpoint(); +#endif + i = i + 1; + + // New tests added here + + Foo fint={0,0}; + Foo fchar={0,0}; + Foo fvpchar = {0, 0}; + + Bar bint; + Bar 3)> bint2; + + Baz bazint; + Baz bazint2; + + Qux quxint2; + Qux quxint; + + Qux1 qux11; + + int x = fint.foo(33, 47); + char c = fchar.foo(33, 'x'); + volatile char * cp = fvpchar.foo(33, 0); + + int y = dummy (400, 600); + + int z = bint.bar(55, 66); + z += bint2.bar(55, 66); + + c = bazint2.baz(4, 'y'); + c = quxint2.qux(4, 'z'); + + y = bazint.baz(4,3); + y = quxint.qux(4, 22); + y += qux11.qux(4, 22); + + y *= gf1(y) - gf2(y); + + Spec sic; + Spec siip; + + sic.spec ('c'); + siip.spec (&x); + + Garply f; + Garply fc; + f.x = 13; + + Garply > nf; + nf.x = 31; + + x = f.garply (3, 4); + + fc = nf.garply (3, fc); + + y = x + fc.x; + + i=GetMax(x,y); + n=GetMax(l,m); + + intBazOne ibo; + z = ibo.baz (2, 21); + + t5i.value(); + + return 0; +} + + + + + + + + + + + + + Index: hang2.cc =================================================================== --- hang2.cc (nonexistent) +++ hang2.cc (revision 513) @@ -0,0 +1,13 @@ +#include "hang.H" + +struct B +{ + int member_of_B; +}; + +int var_in_b = 1729; + +int dummy2 (void) +{ + return var_in_b; +} Index: formatted-ref.cc =================================================================== --- formatted-ref.cc (nonexistent) +++ formatted-ref.cc (revision 513) @@ -0,0 +1,48 @@ +/* Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Author: Paul N. Hilfinger, AdaCore Inc. */ + +enum Enum1 { Val10=10, Val11, Val12 }; + +struct Struct1 +{ + int x, y; +}; + +int f1 (Struct1& s, Enum1& e, int& i) +{ + return s.x; /* Set breakpoint marker here. */ +} + +Struct1 s1 = { 13, 19 }; + +int i1 = 23; + +Enum1 e1 = Val11; + +int main(void) +{ + + #ifdef usestubs + set_debug_traps(); + breakpoint(); + #endif + + f1 (s1, e1, i1); + +} Index: cttiadd3.cc =================================================================== --- cttiadd3.cc (nonexistent) +++ cttiadd3.cc (revision 513) @@ -0,0 +1,52 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 1998, 1999, 2004, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +template T add3(T v1, T v2) +{ + T v3; + v3 = v1; + v3 += v2; + return v3; +} + +template T add4(T v1, T v2) +{ + T v3; + v3 = v1; + v3 += v2; + return v3; +} + +void subr3() +{ + unsigned char c; + int i; + float f; + + c = 'b'; + i = 3; + f = 6.5; + + c = add3(c, c); + i = add3(i, i); + f = add3(f, f); + c = add4(c, c); + i = add4(i, i); + f = add4(f, f); +} Index: mb-templates.exp =================================================================== --- mb-templates.exp (nonexistent) +++ mb-templates.exp (revision 513) @@ -0,0 +1,187 @@ +# Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This test verifies that setting breakpoint on line in template +# function will fire in all instantiations of that template. + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_stl_tests] } { continue } + +# On SPU this test fails because the executable exceeds local storage size. +if { [istarget "spu*-*-*"] } { + return 0 +} + + +set testfile "mb-templates" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested mb-templates.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +set bp_location [gdb_get_line_number "set breakpoint here"] + +# Set a breakpoint with multiple locations +# and a condition. + +gdb_test "break $srcfile:$bp_location if i==1" \ + "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \ + "initial condition: set breakpoint" + +gdb_run_cmd +gdb_expect { + -re "Breakpoint \[0-9\]+,.*foo \\(i=1\\).*$gdb_prompt $" { + pass "initial condition: run to breakpoint" + } + -re "$gdb_prompt $" { + fail "initial condition: run to breakpoint" + } + timeout { + fail "initial condition: run to breakpoint (timeout)" + } +} + +gdb_test "continue" \ + ".*Breakpoint.*foo \\(i=1\\).*" \ + "initial condition: run to breakpoint 2" + +# Set breakpoint with multiple locations. +# Separately set the condition. +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +gdb_test "break $srcfile:$bp_location" \ + "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \ + "separate condition: set breakpoint" + +gdb_test_no_output "condition 1 i==1" \ + "separate condition: set condition" + +gdb_run_cmd +gdb_expect { + -re "Breakpoint \[0-9\]+,.*foo \\(i=1\\).*$gdb_prompt $" { + pass "separate condition: run to breakpoint" + } + -re "$gdb_prompt $" { + fail "separate condition: run to breakpoint" + } + timeout { + fail "separate condition: run to breakpoint (timeout)" + } +} + +gdb_test "continue" \ + ".*Breakpoint.*foo \\(i=1\\).*" \ + "separate condition: run to breakpoint 2" + +# Try disabling a single location. We also test +# that at least in simple cases, the enable/disable +# state of locations surive "run". +gdb_test_no_output "disable 1.1" "disabling location: disable" + +gdb_run_cmd +gdb_expect { + -re "Breakpoint \[0-9\]+,.*foo \\(i=1\\).*$gdb_prompt $" { + pass "disabling location: run to breakpoint" + } + -re "$gdb_prompt $" { + fail "disabling location: run to breakpoint" + } + timeout { + fail "disabling location: run to breakpoint (timeout)" + } +} + +# Try disabling entire breakpoint +gdb_test_no_output "enable 1.1" "disabling location: enable" + + +gdb_test_no_output "disable 1" "disable breakpoint: disable" + +gdb_run_cmd +gdb_expect { + -re "Program exited normally.*$gdb_prompt $" { + pass "disable breakpoint: run to breakpoint" + } + -re "$gdb_prompt $" { + fail "disable breakpoint: run to breakpoint" + } + timeout { + fail "disable breakpoint: run to breakpoint (timeout)" + } +} + +# Make sure breakpoint can be set on a specific instantion. +delete_breakpoints +gdb_test "break 'void foo(int)'" ".*" \ + "instantiation: set breakpoint" + + +gdb_run_cmd +gdb_expect { + -re ".*Breakpoint \[0-9\]+,.*foo \\(i=0\\).*$gdb_prompt $" { + pass "instantiation: run to breakpoint" + } + -re "$gdb_prompt $" { + fail "instantiation: run to breakpoint" + } + timeout { + fail "instantiation: run to breakpoint (timeout)" + } +} + +gdb_test "continue" \ + ".*Breakpoint.*foo \\(i=1\\).*" \ + "instantiation: run to breakpoint 2" + + +# Make sure we can set a breakpoint on a source statement that spans +# multiple lines. + +delete_breakpoints + +set bp_location [gdb_get_line_number "set multi-line breakpoint here"] + +if { ![runto_main] } { + fail "Can't run to main for multi_line_foo tests." + return 0 +} + +gdb_test "break $srcfile:$bp_location" \ + "Breakpoint.*at.* file .*$srcfile, line.*\\(2 locations\\).*" \ + "set multi_line_foo breakpoint" +gdb_test "continue" \ + ".*Breakpoint.*multi_line_foo \\(i=0\\).*" \ + "run to multi_line_foo breakpoint 2 " +gdb_test "continue" \ + ".*Breakpoint.*multi_line_foo \\(i=0\\).*" \ + "run to multi_line_foo breakpoint 2 " Index: m-data.cc =================================================================== --- m-data.cc (nonexistent) +++ m-data.cc (revision 513) @@ -0,0 +1,64 @@ +// 2002-05-13 + +enum region { oriental, egyptian, greek, etruscan, roman }; + +// Test one. +class gnu_obj_1 +{ +protected: + typedef region antiquities; + const bool test; + const int key1; + long key2; + + antiquities value; + +public: + gnu_obj_1(antiquities a, long l): test(true), key1(5), key2(l), value(a) {} +}; + +// Test two. +template +class gnu_obj_2: public virtual gnu_obj_1 +{ +protected: + antiquities value_derived; + +public: + gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7), value_derived(b) { } +}; + +// Test three. +template +class gnu_obj_3 +{ +protected: + typedef region antiquities; + gnu_obj_2 data; + +public: + gnu_obj_3(antiquities b): data(etruscan) { } +}; + +int shadow = 0; + +class C +{ +public: + C (int x) : shadow (x) {} + void marker () {} +private: + int shadow; +}; + +int main() +{ + gnu_obj_1 test1(egyptian, 4589); + gnu_obj_2 test2(roman); + gnu_obj_3 test3(greek); + + C theC (1); // breakpoint: first-constructs-done + theC.marker (); + + return shadow; +} Index: userdef.exp =================================================================== --- userdef.exp (nonexistent) +++ userdef.exp (revision 513) @@ -0,0 +1,157 @@ +# Tests of overloaded operators resolution. +# Copyright 1998, 1999, 2002, 2004, 2005, 2006, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# written by Elena Zannoni (ezannoni@cygnus.com) +# +# source file "userdef.cc" +# + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_stl_tests] } { continue } + +# On SPU this test fails because the executable exceeds local storage size. +if { [istarget "spu*-*-*"] } { + return 0 +} + +set testfile "userdef" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested userdef.exp + return -1 +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +gdb_test "break marker1" \ + "Breakpoint .*${srcfile}.*" + +gdb_test "cont" \ + "Break.* marker1(\\(\\)|) \\(\\) at .*:$decimal.*" \ + "continue to marker1" + +gdb_test "up" " in main .*" "up from marker1" + +gdb_test "print one + two" "\\\$\[0-9\]* = {x = 6, y = 8}" + +# If GDB fails to restore the selected frame properly after the +# inferior function call above (see GDB PR 1155 for an explanation of +# why this might happen), all the subsequent tests will fail. We +# should detect report that failure, but let the marker call finish so +# that the rest of the tests can run undisturbed. +gdb_test_multiple "frame" "re-selected 'main' frame after inferior call" { + -re "#0 marker1.*$gdb_prompt $" { + setup_kfail "gdb/1155" s390-*-linux-gnu + fail "re-selected 'main' frame after inferior call" + gdb_test "finish" ".*main.*at .*userdef.cc:.*// marker1-returns-here.*" \ + "finish call to marker1" + } + -re "#1 ($hex in )?main.*$gdb_prompt $" { + pass "re-selected 'main' frame after inferior call" + } +} + +gdb_test "print one - two" "\\\$\[0-9\]* = {x = -2, y = -2}" + +gdb_test "print one * two" "\\\$\[0-9\]* = {x = 8, y = 15}" + +gdb_test "print one / two" "\\\$\[0-9\]* = {x = 0, y = 0}" + +gdb_test "print one % two" "\\\$\[0-9\]* = {x = 2, y = 3}" + +gdb_test "print one && two" "\\\$\[0-9\]* = 1\[\r\n\]" + +gdb_test "print one || two" "\\\$\[0-9\]* = 1\[\r\n\]" + +gdb_test "print one & two" "\\\$\[0-9\]* = {x = 0, y = 1}" + +gdb_test "print one | two" "\\\$\[0-9\]* = {x = 6, y = 7}" + +gdb_test "print one ^ two" "\\\$\[0-9\]* = {x = 6, y = 6}" + +gdb_test "print one < two" "\\\$\[0-9\]* = 1\[\r\n\]" + +gdb_test "print one <= two" "\\\$\[0-9\]* = 1\[\r\n\]" + +gdb_test "print one > two" "\\\$\[0-9\]* = 0\[\r\n\]" + +gdb_test "print one >= two" "\\\$\[0-9\]* = 0\[\r\n\]" + +gdb_test "print one == two" "\\\$\[0-9\]* = 0\[\r\n\]" +gdb_test "print one.operator== (two)" "\\\$\[0-9\]* = 0\[\r\n\]" + +gdb_test "print one != two" "\\\$\[0-9\]* = 1\[\r\n\]" + +# Can't really check the output of this one without knowing +# target integer width. Make sure we don't try to call +# the iostreams operator instead, though. +gdb_test "print one << 31" "\\\$\[0-9\]* = {x = -?\[0-9\]*, y = -?\[0-9\]*}" + +# Should be fine even on < 32-bit targets. +gdb_test "print one >> 31" "\\\$\[0-9\]* = {x = 0, y = 0}" + +gdb_test "print !one" "\\\$\[0-9\]* = 0\[\r\n\]" + +# Assumes 2's complement. So does everything... +gdb_test "print +one" "\\\$\[0-9\]* = {x = 2, y = 3}" + +gdb_test "print ~one" "\\\$\[0-9\]* = {x = -3, y = -4}" + +gdb_test "print -one" "\\\$\[0-9\]* = {x = -2, y = -3}" + +gdb_test "print one++" "\\\$\[0-9\]* = {x = 2, y = 4}" + +gdb_test "print ++one" "\\\$\[0-9\]* = {x = 3, y = 4}" + +gdb_test "print one--" "\\\$\[0-9\]* = {x = 3, y = 3}" + +gdb_test "print --one" "\\\$\[0-9\]* = {x = 2, y = 3}" + +gdb_test "print one += 7" "\\\$\[0-9\]* = {x = 9, y = 10}" + +gdb_test "print two = one" "\\\$\[0-9\]* = {x = 9, y = 10}" + +# Check that GDB tolerates whitespace in operator names. +gdb_test "break A2::'operator+'" ".*Breakpoint $decimal at.*" +gdb_test "break A2::'operator +'" ".*Breakpoint $decimal at.*" + +# Check that GDB handles operator* correctly. +gdb_test "print c" "\\\$\[0-9\]* = {m = {z = .*}}" +gdb_test "print *c" "\\\$\[0-9\]* = \\(Member &\\) @$hex: {z = .*}" +gdb_test "print &*c" "\\\$\[0-9\]* = \\(Member \\*\\) $hex" +gdb_test "ptype &*c" "type = (struct|class) Member {(\[\r\n \]+public:)?\[\r\n \]+int z;\[\r\n\].*} &\\*" + +gdb_test "print operator== (mem1, mem2)" " = false" +gdb_test "print operator== (mem1, mem1)" " = true" + +gdb_exit +return 0 Index: templates.exp =================================================================== --- templates.exp (nonexistent) +++ templates.exp (revision 513) @@ -0,0 +1,543 @@ +# Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2007, +# 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file was written by Fred Fish. (fnf@cygnus.com) + +set ws "\[\r\n\t \]+" + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +set testfile "templates" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +# Create and source the file that provides information about the compiler +# used to compile the test case. +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested templates.exp + return -1 +} + +# +# Test printing of the types of templates. +# + +proc test_ptype_of_templates {} { + global gdb_prompt + global ws + + gdb_test_multiple "ptype T5" "ptype T5" { + -re "type = class T5 \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5 & operator=\\(T5 const ?&\\);${ws}T5\\(int\\);${ws}T5\\((T5 const|const T5) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { + pass "ptype T5" + } + -re "type = class T5 \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5\\(int\\);${ws}T5\\((T5 const|const T5) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}T5 & operator=\\(T5 const ?&\\);${ws}\}\r\n$gdb_prompt $" { + pass "ptype T5" + } + -re "type = class T5 \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}${ws}T5 \\(int\\);${ws}T5 \\(const class T5 &\\);${ws}void ~T5 \\(int\\);${ws}static void \\* new \\(unsigned int\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}${ws}$gdb_prompt $" { + pass "ptype T5 -- new with unsigned int" + } + -re "type = class T5 \\{.*public:.*static int X;.*int x;.*int val;.*T5 \\(int\\);.*T5 \\(const class T5 &\\);.*void ~T5 \\(int\\);.*static void \\* new \\(unsigned long\\);.*static void delete \\(void ?\\*\\);.*int value \\((void|)\\);.*\\}\r\n$gdb_prompt $" { + pass "ptype T5 -- new with unsigned long" + } + -re "type = class T5 \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;((${ws}T5 & operator=\\(T5 const ?&\\);)|(${ws}T5\\(int\\);)|(${ws}T5\\((T5 const|const T5) ?&\\);)|(${ws}~T5\\((void|)\\);)|(${ws}static void \\* operator new\\(unsigned( int| long)?\\);)|(${ws}static void operator delete\\(void ?\\*\\);)|(${ws}int value\\((void|)\\);))*${ws}\}\r\n$gdb_prompt $" { + pass "ptype T5 (obsolescent gcc or gdb)" + } + -re "type = class T5 \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}void T5\\(int\\);${ws}void T5\\((T5 const|const T5) ?&\\);${ws}~T5\\(int\\);${ws}static void \\* operator new\\(unsigned( int| long|)\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { + # This also triggers gdb/1113... + kfail "gdb/1111" "ptype T5" + } + } + + gdb_test_multiple "ptype t5i" "ptype t5i" { + -re "type = class T5 \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;\r\n${ws}T5\\(int\\);${ws}T5\\(T5 const ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\\}\r\n$gdb_prompt $" { + pass "ptype T5 -- with several fixes from 4.17" + } + -re "type = class T5 \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;\r\n${ws}T5 \\(int\\);${ws}T5 \\(const class T5 &\\);${ws}void ~T5 \\(int\\);${ws}static void \\* new \\(unsigned int\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}\r\n$gdb_prompt $" { + pass "ptype t5i -- new with unsigned int" + } + -re "type = class T5 \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;\r\n${ws}T5 \\(int\\);${ws}T5 \\(const class T5 &\\);${ws}void ~T5 \\(int\\);${ws}static void \\* new \\(unsigned long\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}\r\n$gdb_prompt $" { + pass "ptype t5i -- new with unsigned long" + } + -re "type = class T5 \{.*public:.*static int X;.*int x;.*int val;.*.*T5 \\(int\\);.*.*void ~T5 \\(int\\).*.*.*int value \\((void|)\\);.*\}.*$gdb_prompt $" { + pass "ptype t5i" + } + -re "type = class T5 \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5 & operator=\\(T5 const ?&\\);${ws}T5\\(int\\);${ws}T5\\((T5 const|const T5) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { + pass "ptype t5i" + } + -re "type = class T5 \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5\\(int\\);${ws}T5\\((T5 const|const T5) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}T5 & operator=\\(T5 const ?&\\);${ws}\}\r\n$gdb_prompt $" { + pass "ptype t5i" + } + -re "type = class T5 \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;((${ws}T5 & operator=\\(T5 const ?&\\);)|(${ws}T5\\(int\\);)|(${ws}T5\\(T5 const ?&\\);)|(${ws}~T5\\((void|)\\);)|(${ws}static void \\* operator new\\(unsigned( int| long)?\\);)|(${ws}static void operator delete\\(void ?\\*\\);)|(${ws}int value\\((void|)\\);))*${ws}\}\r\n$gdb_prompt $" { + pass "ptype t5i (obsolescent gcc or gdb)" + } + -re "type = class T5 \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}void T5\\(int\\);${ws}void T5\\((T5 const|const T5) ?&\\);${ws}~T5\\(int\\);${ws}static void \\* operator new\\(unsigned( int| long|)\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" { + # This also triggers gdb/1113... + kfail "gdb/1111" "ptype T5" + } + } +} + +# +# Test breakpoint setting on template methods. +# + +proc test_template_breakpoints {} { + global gdb_prompt + global testfile + global srcdir + global hp_aCC_compiler + + gdb_test_multiple "break T5::T5" "constructor breakpoint" { + -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2. T5::T5\\(int\\) at .*\[\r\n\]*.3. T5::T5\\((T5 const|const T5) ?&\\) at .*\[\r\n\]*> $" { + gdb_test "0" \ + "canceled" \ + "constructor breakpoint (obsolete format!)" + } + -re ".0. cancel\[\r\n\]*.1. all\[\r\n\]*.2. T5::T5\\((T5 const|const T5) ?&\\) at .*templates.cc:.*\[\r\n\]*.3. T5::T5\\(int\\) at .*templates.cc:.*\[\r\n\]*> $" { + gdb_test "0" \ + "canceled" \ + "constructor breakpoint" + } + -re "0. cancel.*\[\r\n\]*.1. all.*\[\r\n\]*.2. T5 at .*\[\r\n\]*.3. T5 at .*\[\r\n\]*> $" { + setup_kfail "gdb/1062" "*-*-*" + gdb_test "0" \ + "nonsense intended to insure that this test fails" \ + "constructor breakpoint" + } + -re ".*\n> $" { + gdb_test "0" \ + "nonsense intended to insure that this test fails" \ + "constructor breakpoint (bad menu choices)" + } + } + +# See CLLbs14792 + if {$hp_aCC_compiler} {setup_xfail hppa*-*-* CLLbs14792} + + gdb_test_multiple "break T5::~T5" "destructor_breakpoint" { + -re "Breakpoint.*at.* file .*${testfile}.cc, line.*$gdb_prompt $" + { + pass "destructor breakpoint" + } + -re "the class `T5' does not have destructor defined\r\nHint: try 'T5::~T5 or 'T5::~T5\r\n\\(Note leading single quote.\\)\r\n$gdb_prompt $" + { + kfail "gdb/1112" "destructor breakpoint" + } + } + + gdb_test "break T5::value" \ + "Breakpoint.*at.* file .*${testfile}.cc, line.*" \ + "value method breakpoint" + + set bp_location [gdb_get_line_number \ + "set breakpoint on a line with no real code"] + gdb_test "break ${testfile}.cc:${bp_location}" \ + "Breakpoint.*at.* file .*${testfile}.cc, line.*(2 locations).*" \ + "breakpoint on a line with no real code" + delete_breakpoints +} + +# +# Test calling of template methods. +# + +proc test_template_calls {} { + global gdb_prompt + global hp_aCC_compiler + + if [target_info exists gdb,cannot_call_functions] { + setup_xfail "*-*-*" 2416 + fail "This target can not call functions" + return + } + + if {!$hp_aCC_compiler} {setup_xfail hppa*-*-*} + gdb_test_multiple "print t5i.value()" "print t5i.value()" { + -re ".* = 2\[\r\n\]*$gdb_prompt $" { + pass "print t5i.value()" + } + -re "Cannot invoke functions on this machine.*$gdb_prompt $" { + fail "print t5i.value()" + } + -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" { + setup_xfail hppa*-*-* CLLbs16899 + xfail "print t5i.value" + } + } +} + +proc test_template_typedef {} { + + gdb_test "print intBazOne::baz" ".*baz\\(int, int\\)>" \ + "print method of template typedef" + + gdb_test "print intBazOne::~Baz" ".*~Baz(\\(\\))?>" \ + "print destructor of template typedef" +} + +proc do_tests {} { + global subdir + global objdir + global srcdir + global binfile + global gdb_prompt + + + # Start with a fresh gdb. + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load $binfile + + # Change multiple-symbols to "ask" in order to get the multiple-choice + # menu when breaking on overloaded methods. + gdb_test_no_output "set multiple-symbols ask" + + runto_main + + test_ptype_of_templates + test_template_breakpoints + test_template_typedef + + if [ runto_main] { + test_template_calls + } +} + +do_tests + + +# More tests for different kinds of template parameters, +# templates with partial specializations, nested templates, etc. +# These have been tested only with HP aCC. They probably won't +# work with other compilers because of differences in mangling +# schemes. +# Added by Satish Pai 1997-09-25 +# As of 2000-06-03, C++ support has been improved to the point that g++ can +# pass all of theses, excluding what appears to be one that exposes a stabs bug. - djb + +# I don't know how HP could be passing these tests without this. They +# weren't breakpointing past a point where the below expressions were +# initialized in the actual source. - djb + +gdb_test "b 770" \ + "Breakpoint .* at .*, line 770." + +gdb_test "c" \ + "Continuing.*Breakpoint .*" \ + "continue to line 770" + +gdb_test "print fint" \ + "\\$\[0-9\]* = \\{x = 0, t = 0\\}" + +gdb_test "print fvpchar" \ + "\\$\[0-9\]* = \\{x = 0, t = 0x0\\}" + +# Template Foo + +# Neither stabs nor DWARF-2 contains type information about templates +# (as opposed to instantiations of templates), so in those +# circumstances we expect GDB to not find a symbol. HP has a debug +# format that contains more info, though, so it's also correct to +# print out template info. (This affects several subsequent tests as +# well.) + +# NOTE: carlton/2003-02-26: However, because of a bug in the way GDB +# handles nested types, we don't get this right in the DWARF-2 case. + +gdb_test_multiple "ptype Foo" "ptype Foo" { + -re "type = template <(class |)T> (class |)Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Foo\r\n\[ \t\]*(class |)Foo\r\n\[ \t\]*(class |)Foo\r\n$gdb_prompt $" { + pass "ptype Foo" + } + -re "type = template <(class |)T> (class |)Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" { + xfail "ptype Foo" + } + -re "type = class Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int foo\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { + # GCC 3.1, DWARF-2 output. + kfail "gdb/57" "ptype Foo" + } + -re "No symbol \"Foo\" in current context.\r\n$gdb_prompt $" { + # GCC 2.95.3, stabs+ output. + pass "ptype Foo" + } +} + +# -re "type = class Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int foo(int, int);\r\n\\}\r\n$gdb_prompt $" + +# ptype Foo + +gdb_test_multiple "ptype fint" "ptype fint" { + -re "type = (class |)Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int foo\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { + pass "ptype fint" + } + -re "type = (class |)Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int foo\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { + pass "ptype fint" + } +} + +# ptype Foo + +gdb_test_multiple "ptype fchar" "ptype fchar" { + -re "type = (class |)Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*.*char foo\\(int, char\\);\r\n\\}\r\n$gdb_prompt $" { + pass "ptype fchar" + } + -re "type = (class |)Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char foo\\(int, char\\);.*\r\n\\}\r\n$gdb_prompt $" { + pass "ptype fchar" + } +} + +# ptype Foo + +gdb_test_multiple "ptype fvpchar" "ptype fvpchar" { + -re "type = (class |)Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*char.*\\*t;\r\n\r\n\[ \t\]*.*char \\* foo\\(int,.*char.*\\*\\);\r\n\\}\r\n$gdb_prompt $" { + pass "ptype fvpchar" + } + -re "type = (class |)Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*char.*\\*t;\r\n\r\n\[ \t\]*.*char \\* foo\\(int,.*char.*\\*\\);.*\r\n\\}\r\n$gdb_prompt $" { + pass "ptype fvpchar" + } + -re "type = (class |)Foo \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*char.*\\*t;\r\n\r\n\[ \t\]*.*char \\* foo\\(int,.*char.*\\*\\);\r\n\\}\r\n$gdb_prompt $" { + kfail "gdb/1512" "ptype fvpchar" + } +} + +# print a function from Foo + +# This test is sensitive to whitespace matching, so we'll do it twice, +# varying the spacing, because of PR gdb/33. + +gdb_test_multiple "print Foo::foo" "print Foo::foo" { + -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<(volatile char|char volatile) ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex ::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { + pass "print Foo::foo" + } + -re "No symbol \"Foo\" in current context.\r\n$gdb_prompt $" { + # This used to be a kfail gdb/33 and then kfail gdb/931. + fail "print Foo::foo" + } +} + +gdb_test_multiple "print Foo::foo" "print Foo::foo" { + -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<(volatile char|char volatile) ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex ::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { + pass "print Foo::foo" + } + -re "No symbol \"Foo\" in current context.\r\n$gdb_prompt $" { + # This used to be a kfail gdb/33 and then kfail gdb/931. + fail "print Foo::foo" + } +} + +# Template Bar + +# same as Foo for g++ +gdb_test_multiple "ptype Bar" "ptype Bar" { + -re "type = template <(class |)T, (class |)sz> (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Bar\r\n\[ \t\]*(class |)Bar\r\n$gdb_prompt $" { + pass "ptype Bar" + } + -re "type = <(class |)T, (class |)sz> (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" { + xfail "ptype Bar" + } + -re "ptype Bar\r\ntype = class Bar {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);\r\n}\r\n$gdb_prompt $" { + # GCC 3.1, DWARF-2 output. + kfail "gdb/57" "ptype Bar" + } + -re "No symbol \"Bar\" in current context.\r\n$gdb_prompt $" { + # GCC 2.95.3, stabs+ output. + pass "ptype Bar" + } +} + + +# ptype Bar + +gdb_test_multiple "ptype bint" "ptype bint" { + -re "type = (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int bar\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { + pass "ptype bint" + } + -re "type = (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { + pass "ptype bint" + } +} + +# ptype Bar3)> + +gdb_test_multiple "ptype bint2" "ptype bint2" { + -re "type = (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int bar\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { + pass "ptype bint2" + } + -re "type = (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { + pass "ptype bint2" + } +} + +# Template Baz + +# Same as Foo, for g++ +gdb_test_multiple "ptype Baz" "ptype Baz" { + -re "type = template <(class |)T, ?(class |)sz> (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Baz\r\n\[ \t\]*(class |)Baz\r\n$gdb_prompt $" { + pass "ptype Baz" + } + -re "type = <(class |)T, ?(class |)sz> (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" { + xfail "ptype Baz" + } + -re "type = class Baz {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int baz\\(int, int\\);\r\n}\r\n$gdb_prompt $" { + # GCC 3.1, DWARF-2 output. + kfail "gdb/57" "ptype Baz" + } + -re "type = class Baz {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int baz\\(int, int\\);\r\n}\r\n$gdb_prompt $" { + # GCC 3.x, DWARF-2 output, running into gdb/57 and gdb/1512. + kfail "gdb/57" "ptype Baz" + } + -re "No symbol \"Baz\" in current context.\r\n$gdb_prompt $" { + # GCC 2.95.3, stabs+ output. + pass "ptype Baz" + } +} + + +# ptype Baz + +gdb_test_multiple "ptype bazint" "ptype bazint" { + -re "type = (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int baz\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { + pass "ptype bazint" + } + -re "type = (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int baz\\(int, int\\).*;\r\n\\}\r\n$gdb_prompt $" { + pass "ptype bazint" + } +} + +# ptype Baz + +gdb_test_multiple "ptype bazint2" "ptype bazint2" { + -re "type = (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*.*char baz\\(int, char\\);\r\n\\}\r\n$gdb_prompt $" { + pass "ptype bazint2" + } + -re "type = (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char baz\\(int, char\\);.*\r\n\\}\r\n$gdb_prompt $" { + pass "ptype bazint2" + } +} + +# Template Qux +# Same as Foo for g++ +gdb_test_multiple "ptype Qux" "ptype Qux" { + -re "type = template <(class |)T, ?(class |)sz> (class |)Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Qux\r\n\[ \t\]*(class |)Qux\r\n$gdb_prompt $" { + pass "ptype Qux" + } + -re ".*type = template <(class |)T.*, ?(class |)sz> (class |)Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}.*$gdb_prompt $" { + pass "ptype Qux" + } + -re "type = class Qux {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char qux\\(int, char\\);\r\n}\r\n$gdb_prompt $" { + # GCC 3.1, DWARF-2 output. + kfail "gdb/57" "ptype Qux" + } + -re "type = class Qux {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char qux\\(int, char\\);\r\n}\r\n$gdb_prompt $" { + # GCC 3.x, DWARF-2 output; gdb/57 + gdb/1512. + kfail "gdb/57" "ptype Qux" + } + -re "No symbol \"Qux\" in current context.\r\n$gdb_prompt $" { + # GCC 2.95.3, stabs+ output. + pass "ptype Qux" + } +} + +# pt Qux + +gdb_test_multiple "ptype quxint" "ptype quxint" { + -re "type = class Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int qux\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { + pass "ptype quxint" + } + -re "type = class Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int qux\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { + pass "ptype quxint" + } + -re "type = class Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int qux\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { + pass "ptype quxint" + } + -re "type = class Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int qux\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { + kfail "gdb/1512" "ptype quxint" + } +} + + +# Template Spec + +# Same as Foo for g++ +gdb_test_multiple "ptype Spec" "ptype Spec" { + -re "type = template <(class |)T1, (class |)T2> (class |)Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Spec\r\n\[ \t\]*(class |)Spec\r\n$gdb_prompt $" { + pass "ptype Spec" + } + -re "type = <(class |)T1, (class |)T2> (class |)Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\\}\r\n$gdb_prompt $" { + xfail "ptype Spec" + } + -re "type = class Spec {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*int spec\\(char\\);\r\n}\r\n$gdb_prompt $" { + # GCC 3.1, DWARF-2 output. + kfail "gdb/57" "ptype Spec" + } + -re "No symbol \"Spec\" in current context.\r\n$gdb_prompt $" { + # GCC 2.95.3, stabs+ output. + pass "ptype Spec" + } +} + +# pt Spec + +gdb_test_multiple "ptype siip" "ptype siip" { + -re "type = class Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*.*int spec\\(int ?\\*\\);\r\n\\}\r\n$gdb_prompt $" { + pass "ptype siip" + } + -re "type = class Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*int spec\\(int ?\\*\\);.*\r\n\\}\r\n$gdb_prompt $" { + pass "ptype siip" + } +} + +# pt Garply + +gdb_test_multiple "ptype Garply" "ptype Garply" { + -re "type = class Garply \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int garply\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { + pass "ptype Garply" + } + -re "type = class Garply \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int garply\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { + pass "ptype Garply" + } +} + +# ptype of nested template name + +gdb_test_multiple "ptype Garply >" "ptype Garply >" { + -re "type = (class |)Garply > \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*(class |)Garply t;\r\n\r\n\[ \t\]*.*(class |)Garply garply\\(int, (class |)Garply\\);\r\n\\}\r\n$gdb_prompt $" { + pass "ptype Garply >" + } + -re "type = (class |)Garply > \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*(class |)Garply t;\r\n\r\n\[ \t\]*(class |)Garply garply\\(int, (class |)Garply\\);.*\r\n\\}\r\n$gdb_prompt $" { + pass "ptype Garply >" + } +} + +# print out a function from a nested template name + +gdb_test "print Garply >::garply" \ + "\\$\[0-9\]* = \\{(class |)Garply \\((class |)Garply > \\*(| const), int, (class |)Garply\\)\\} $hex \[ \t\]*>::garply\\(int, (class |)Garply\\)>" \ + "print Garply >::garply" + +# djb - 06-03-2000 +# Now should work fine +gdb_test "break Garply >::garply" \ + "Breakpoint \[0-9\]* at $hex: file .*templates.cc, line.*" Index: virtfunc.exp =================================================================== --- virtfunc.exp (nonexistent) +++ virtfunc.exp (revision 513) @@ -0,0 +1,261 @@ +# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, +# 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file was written by Fred Fish. (fnf@cygnus.com) +# And rewritten by Michael Chastain . + +set nl "\[\r\n\]+" + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +load_lib "cp-support.exp" + +set testfile "virtfunc" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {c++ debug}] != "" } { + untested virtfunc.exp + return -1 +} + +proc test_ptype_of_classes {} { + + # class VA + + cp_test_ptype_class \ + "ptype VA" "" "class" "VA" \ + { + { field public "int va;" } + } + + # class VB + + cp_test_ptype_class \ + "ptype VB" "" "class" "VB" \ + { + { field public "int vb;" } + { method public "int fvb();" } + { method public "virtual int vvb();" } + } + + # class V + + cp_test_ptype_class \ + "ptype V" "" "class" "V" \ + { + { base "public VA" } + { base "public VB" } + { field public "int w;" } + { method public "int f();" } + { method public "virtual int vv();" } + } + + # class A + + cp_test_ptype_class \ + "ptype A" "" "class" "A" \ + { + { base "public virtual V" } + { vbase "V" } + { field private "int a;" } + { method public "virtual int f();" } + } + + # class B + + cp_test_ptype_class \ + "ptype B" "" "class" "B" \ + { + { base "public A" } + { field private "int b;" } + { method public "virtual int f();" } + } + + # class C + + cp_test_ptype_class \ + "ptype C" "" "class" "C" \ + { + { base "public virtual V" } + { vbase "V" } + { field public "int c;" } + } + + # class AD + + cp_test_ptype_class \ + "ptype AD" "" "class" "AD" \ + { + { method public "virtual int vg();" } + } + + # class D + + cp_test_ptype_class \ + "ptype D" "" "class" "D" \ + { + { base "public AD" } + { base "public virtual V" } + { vbase "V" } + { method public "static void s();" } + { method public "virtual int vg();" } + { method public "virtual int vd();" } + { method public "int fd();" } + { field public "int d;" } + } + + # class E + + cp_test_ptype_class \ + "ptype E" "" "class" "E" \ + { + { base "public B" } + { base "public virtual V" } + { base "public D" } + { base "public C" } + { vbase "V" } + { method public "virtual int f();" } + { method public "virtual int vg();" } + { method public "virtual int vv();" } + { field public "int e;" } + } + + # An instance of D + + cp_test_ptype_class "ptype dd" "" "class" "D" ibid + + # An instance of D * + + cp_test_ptype_class "ptype ppd" "" "class" "D" ibid "*" + + # An instance of AD * + # TODO: this should be named pADd, not pAd. + + cp_test_ptype_class "ptype pAd" "" "class" "AD" ibid "*" + + # Instances of these classes. + + cp_test_ptype_class "ptype a" "" "class" "A" ibid + cp_test_ptype_class "ptype b" "" "class" "B" ibid + cp_test_ptype_class "ptype c" "" "class" "C" ibid + cp_test_ptype_class "ptype d" "" "class" "D" ibid + cp_test_ptype_class "ptype e" "" "class" "E" ibid + cp_test_ptype_class "ptype v" "" "class" "V" ibid + cp_test_ptype_class "ptype vb" "" "class" "VB" ibid + + # Instances of pointers to these classes. + + cp_test_ptype_class "ptype pAa" "" "class" "A" ibid "*" + cp_test_ptype_class "ptype pAe" "" "class" "A" ibid "*" + cp_test_ptype_class "ptype pBe" "" "class" "B" ibid "*" + cp_test_ptype_class "ptype pDd" "" "class" "D" ibid "*" + cp_test_ptype_class "ptype pDe" "" "class" "D" ibid "*" + cp_test_ptype_class "ptype pVa" "" "class" "V" ibid "*" + cp_test_ptype_class "ptype pVv" "" "class" "V" ibid "*" + cp_test_ptype_class "ptype pVe" "" "class" "V" ibid "*" + cp_test_ptype_class "ptype pVd" "" "class" "V" ibid "*" + cp_test_ptype_class "ptype pADe" "" "class" "AD" ibid "*" + cp_test_ptype_class "ptype pEe" "" "class" "E" ibid "*" + cp_test_ptype_class "ptype pVB" "" "class" "VB" ibid "*" + +} + +# Call virtual functions. + +proc test_virtual_calls {} { + global gdb_prompt + global nl + + if [target_info exists gdb,cannot_call_functions] { + setup_xfail "*-*-*" 2416 + fail "This target can not call functions" + return 0 + } + + gdb_test "print pAe->f()" "\\$\[0-9\]+ = 20" + gdb_test "print pAa->f()" "\\$\[0-9\]+ = 1" + gdb_test "print pDe->vg()" "\\$\[0-9\]+ = 202" + gdb_test "print pADe->vg()" "\\$\[0-9\]+ = 202" + gdb_test "print pDd->vg()" "\\$\[0-9\]+ = 101" + gdb_test "print pEe->vvb()" "\\$\[0-9\]+ = 411" + gdb_test "print pVB->vvb()" "\\$\[0-9\]+ = 407" + gdb_test "print pBe->vvb()" "\\$\[0-9\]+ = 411" + gdb_test "print pDe->vvb()" "\\$\[0-9\]+ = 411" + gdb_test "print pEe->vd()" "\\$\[0-9\]+ = 282" + gdb_test "print pEe->fvb()" "\\$\[0-9\]+ = 311" + + # more recent results: + # wrong value "202" + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + # attempt to take addres of value not located in memory + # gcc 3.3.2 -gdwarf-2 + # gcc 3.3.2 -gstabs+ + # + # -- chastain 2003-12-31 + + gdb_test_multiple "print pEe->D::vg()" "print pEe->D::vg()" { + -re "\\$\[0-9]+ = 102$nl$gdb_prompt $" { + pass "print pEe->D::vg()" + } + -re "\\$\[0-9]+ = 202$nl$gdb_prompt $" { + # To get this result, we have called pEe->*(&D::vg) (). + # That's how GDB interprets this, but it's wrong; in fact + # the explicit D:: means to bypass virtual function lookup, + # and call D::vg as if it were non-virtual. We still have + # to e.g. adjust "this", though. + kfail "gdb/1064" "print pEe->D::vg()" + } + -re "Attempt to take address of value not located in memory.$nl$gdb_prompt $" { + kfail "gdb/1064" "print pEe->D::vg()" + } + } +} + +proc do_tests {} { + global srcdir subdir binfile + global gdb_prompt + + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load $binfile + + gdb_test_no_output "set language c++" "" + gdb_test_no_output "set width 0" "" + + if ![runto_main] then { + perror "couldn't run to breakpoint" + return + } + test_ptype_of_classes + + gdb_breakpoint test_calls + gdb_test "continue" ".*Breakpoint .* test_calls.*" "" + test_virtual_calls + + gdb_test "next" ".*pAa->f.*" "next to pAa->f call" + gdb_test "next" ".*pDe->vg.*" "next to pDe->vg call" + gdb_test "step" ".*E::vg.*" "step through thunk into E::vg" +} + +do_tests Index: annota2.exp =================================================================== --- annota2.exp (nonexistent) +++ annota2.exp (revision 513) @@ -0,0 +1,212 @@ +# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file was written by Elena Zannoni (ezannoni@cygnus.com) + +if $tracelevel then { + strace $tracelevel +} + + +# +# test running programs +# + +if { [skip_cplus_tests] } { continue } + +set testfile "annota2" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ nowarnings}] != "" } { + untested annota2.exp + return -1 +} + +# are we on a target board? If so, don't run these tests. +# note: this is necessary because we cannot use runto_main (which would +# work for remote targets too) because of the different prompt we get +# when using annotation level 2. +# +if [is_remote target] then { + return 0 +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if [target_info exists gdb_stub] { + gdb_step_for_stub; +} + +# +# line number where we need to stop in main +# +set main_line 25 + +# The commands we test here produce many lines of output; disable "press +# to continue" prompts. +gdb_test_no_output "set height 0" + +# +# break at main +# +gdb_test "break 25" \ + "Breakpoint.*at.* file .*$srcfile, line.*" \ + "breakpoint main" + + +# +# NOTE: this prompt is OK only when the annotation level is > 1 +# NOTE: When this prompt is in use the gdb_test procedure cannot be used because +# it assumes that the last char of the gdb_prompt is a white space. This is not +# true with this annotated prompt. So we must use send_gdb and gdb_expect. +# + +set old_gdb_prompt $gdb_prompt +set gdb_prompt "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n" + +send_gdb "set annotate 2\n" +gdb_expect { + -re "set annotate 2\r\n$gdb_prompt$" { pass "annotation set at level 2" } + -re ".*$gdb_prompt$" { fail "annotation set at level 2" } + timeout { fail "annotation set at level 2 (timeout)" } + } + +gdb_test_multiple "run" "run until main breakpoint" { + -re "$main_line.*$gdb_prompt$" { + pass "run until main breakpoint" + } +} + +# +# print class 'a' with public fields. +# this will test: +# annotate-field-begin +# annotate-field-name-end +# annotate-field-value +# annotate-field-end +# +gdb_test_multiple "print a" "print class" { + -re "\r\n\032\032post-prompt\r\n\r\n\032\032value-history-begin 1 -\r\n.*= \r\n\032\032value-history-value\r\n\\{\r\n\032\032field-begin -\r\nx\r\n\032\032field-name-end\r\n = \r\n\032\032field-value\r\n1\r\n\032\032field-end\r\n, \r\n\032\032field-begin -\r\ny\r\n\032\032field-name-end\r\n = \r\n\032\032field-value\r\n2\r\n\032\032field-end\r\n\\}\r\n\r\n\032\032value-history-end\r\n$gdb_prompt$" { + pass "print class" + } +} + +# +# continue until exit +# this will test: +# annotate-exited +# `a.x is 1' is asynchronous regarding to `frames-invalid'. +# +gdb_test_multiple "continue" "continue until exit" { + -re "\r\n\032\032post-prompt\r\nContinuing.\r\n\r\n\032\032starting\(\r\n\r\n\032\032frames-invalid\)*\r\na.x is 1\r\n\(\r\n\032\032frames-invalid\r\n\)*\r\n\032\032exited 0\r\n\r\nProgram exited normally.\r\n\r\n\032\032stopped\r\n$gdb_prompt$" { + pass "continue until exit" + } +} + +# +# delete all breakpoints +# +send_gdb "delete\n" +gdb_expect { + -re ".*Delete all breakpoints. \\(y or n\\) \r\n\032\032query.*$" { + send_gdb "y\n" + gdb_expect { + -re "\r\n\032\032post-query\r\n$gdb_prompt$" { pass "delete bps" } + -re ".*$gdb_prompt$" { fail "delete bps" } + timeout { fail "delete bps (timeout)" } + } + } + -re ".*$gdb_prompt$" { fail "delete bps" } + timeout { fail "delete bps (timeout)" } +} + +# +# break at first line of main. +# +gdb_test_multiple "break 22" "break at main" { + -re "\r\n\032\032post-prompt\r\n\r\n\032\032breakpoints-invalid\r\nBreakpoint.*at $hex: file.*$srcfile, line.*\r\n$gdb_prompt$" { + pass "breakpoint at main" + } +} + +# +# change value of main_line +# +set main_line 22 + +# +# run program up to breakpoint. +# + +gdb_test_multiple "run" "run until main breakpoint" { + -re "$main_line.*$gdb_prompt$" { + pass "run until main breakpoint" + } +} + +# +# set up a watch point on a.x +# +gdb_test_multiple "watch a.x" "set watch on a.x" { + -re "\r\n\032\032post-prompt\r\n\r\n\032\032breakpoints-invalid\r\n.*atchpoint 3: a.x\r\n$gdb_prompt$" { + pass "set watch on a.x" + } +} + +# +# do a next, so that the watchpoint triggers. This will test: +# annotate-watchpoint +# +gdb_test_multiple "next" "watch triggered on a.x" { + -re "\r\n\032\032post-prompt\r\n\r\n(\032\032breakpoints-invalid\r\n\r\n)*\032\032starting\r\n\r\n(\032\032frames-invalid\r\n\r\n)*\032\032watchpoint 3\r\n.*atchpoint 3: a.x\r\n\r\nOld value = 0\r\nNew value = 1\r\n\r\n\032\032frame-begin 0 $hex\r\n\r\n\032\032frame-function-name\r\nmain\r\n\032\032frame-args\r\n \\(\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n.*$srcfile\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n$decimal\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped\r\n.*$gdb_prompt$" { + pass "watch triggered on a.x" + } + -re "\r\n\032\032post-prompt\r\n\r\n(\032\032breakpoints-invalid\r\n\r\n)*\032\032starting\r\n\r\n(\032\032frames-invalid\r\n\r\n)*\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped\r\n$gdb_prompt$" { + kfail "gdb/38" "watch triggered on a.x" + } +} + + +# +# send ^C to gdb, so that the quit() function gets called +# and annotate-quit is tested +# test: +# annotate-quit +# +send_gdb "\003" +gdb_expect { + -re "\r\n\032\032error-begin\r\nQuit\r\n\r\n\032\032quit\r\n$gdb_prompt$" \ + { pass "annotate-quit" } + -re ".*$gdb_prompt$" { fail "annotate-quit" } + timeout { fail "annotate-quit (timeout)" } +} + +# +# FIXME: the testsuite does not currently have tests for +# annotate_catchpoints and annotate_function_call +# and a few variants of the annotations that are +# tested (marked by FIXME on the annot?.exp files) +# + +# reinstall the old prompt for the rest of the testsuite. + +set gdb_prompt $old_gdb_prompt + Index: inherit.exp =================================================================== --- inherit.exp (nonexistent) +++ inherit.exp (revision 513) @@ -0,0 +1,767 @@ +# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003, +# 2004, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file was written by Fred Fish. (fnf@cygnus.com) +# And rewritten by Michael Chastain. (mec.gnu@mindspring.com) + +set ws "\[\r\n\t \]+" +set nl "\[\r\n\]+" +set vhn "\\$\[0-9\]+" + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +load_lib "cp-support.exp" + +set testfile "inherit" +set srcfile misc.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested inherit.exp + return -1 +} + +# Single inheritance, print type definitions. + +proc test_ptype_si { } { + global gdb_prompt + global ws + global nl + + # A simple class. + + cp_test_ptype_class \ + "ptype A" "ptype A (FIXME)" "class" "A" \ + { + { field public "int a;" } + { field public "int x;" } + } + cp_test_ptype_class "ptype class A" "ptype class A (FIXME)" "class" "A" ibid + cp_test_ptype_class "ptype g_A" "ptype g_A (FIXME)" "class" "A" ibid + + # A derived class. + + cp_test_ptype_class \ + "ptype B" "" "class" "B" \ + { + { base "public A" } + { field public "int b;" } + { field public "int x;" } + } + cp_test_ptype_class "ptype class B" "" "class" "B" ibid + cp_test_ptype_class "ptype g_B" "" "class" "B" ibid + + # Another derived class. + + cp_test_ptype_class \ + "ptype C" "" "class" "C" \ + { + { base "public A" } + { field public "int c;" } + { field public "int x;" } + } + cp_test_ptype_class "ptype class C" "" "class" "C" ibid + cp_test_ptype_class "ptype g_C" "" "class" "C" ibid + + # A structure with no tag. + # TODO: move this mess into a separate file, and re-specify + # which results are PASS, KFAIL, XFAIL, and FAIL. + + set re_tag "tagless_struct" + set XX_tag "\\._1" + set re_class "(class $re_tag \{${ws}public:|class \{${ws}public:|struct $re_tag \{|struct \{)" + set XX_class "(class $XX_tag \{${ws}public:|struct $XX_tag \{)" + set re_fields "int one;${ws}int two;" + set re_synth_gcc_23 "$re_tag & operator=\\($re_tag const ?&\\);${ws}$re_tag\\($re_tag const ?&\\);${ws}$re_tag\\((void|)\\);" + set XX_synth_gcc_23 "($re_tag|$XX_tag) & operator=\\($XX_tag const ?&\\);${ws}$XX_tag\\($XX_tag const ?&\\);${ws}$XX_tag\\((void|)\\);" + + set name "ptype tagless struct" + gdb_test_multiple "ptype tagless_struct" $name { + -re "type = $XX_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + pass "$name" + } + -re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + pass "$name" + } + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 3.3.4 -gdwarf-2 + # gcc 3.4.1 -gdwarf-2 + # gcc HEAD 2004-07-31 -gdwarf-2 + # gcc HEAD 2004-07-31 -gstabs+ + pass "$name" + } + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + # gcc 3.3.4 -gstabs+ + # gcc 3.4.1 -gstabs+ + pass "$name" + } + -re "No symbol \"tagless_struct\" in current context.$nl$gdb_prompt $" { + # Several GCC 4.x versions provide neither a DW_TAG_typedef DIE + # nor use the typedef name as struct tag name. + xfail "$name" + } + } + + set name "ptype variable of type tagless struct" + gdb_test_multiple "ptype v_tagless" $name { + -re "type = $XX_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + pass "$name" + } + -re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + pass "$name" + } + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 3.3.4 -gdwarf-2 + # gcc 3.4.1 -gdwarf-2 + # gcc HEAD 2004-07-31 -gdwarf-2 + # gcc HEAD 2004-07-31 -gstabs+ + pass "$name" + } + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + # gcc 3.3.4 -gstabs+ + # gcc 3.4.1 -gstabs+ + pass "$name" + } + } +} + +# Multiple inheritance, print type definitions. + +proc test_ptype_mi { } { + + # A class with two bases. + + cp_test_ptype_class \ + "ptype D" "" "class" "D" \ + { + { base "public B" } + { base "public C" } + { field public "int d;" } + { field public "int x;" } + } + cp_test_ptype_class "ptype class D" "" "class" "D" ibid + cp_test_ptype_class "ptype g_D" "" "class" "D" ibid + + # A class derived from the previous class. + + cp_test_ptype_class \ + "ptype E" "" "class" "E" \ + { + { base "public D" } + { field public "int e;" } + { field public "int x;" } + } + cp_test_ptype_class "ptype class E" "" "class" "E" ibid + cp_test_ptype_class "ptype g_E" "" "class" "E" ibid +} + +# Single virtual inheritance, print type definitions. + +proc test_ptype_vi { } { + + # class vA + + cp_test_ptype_class \ + "ptype vA" "" "class" "vA" \ + { + { field public "int va;" } + { field public "int vx;" } + } + cp_test_ptype_class "ptype class vA" "" "class" "vA" ibid + cp_test_ptype_class "ptype g_vA" "" "class" "vA" ibid + + # class vB + + cp_test_ptype_class \ + "ptype vB" "" "class" "vB" \ + { + { base "public virtual vA" } + { vbase "vA" } + { field public "int vb;" } + { field public "int vx;" } + } + cp_test_ptype_class "ptype class vB" "" "class" "vB" ibid + cp_test_ptype_class "ptype g_vB" "" "class" "vB" ibid + + # class vC + + cp_test_ptype_class \ + "ptype vC" "" "class" "vC" \ + { + { base "public virtual vA" } + { vbase "vA" } + { field public "int vc;" } + { field public "int vx;" } + } + cp_test_ptype_class "ptype class vC" "" "class" "vC" ibid + cp_test_ptype_class "ptype g_vC" "" "class" "vC" ibid + +} + +# Multiple virtual inheritance, print type definitions. + +proc test_ptype_mvi { } { + + # class vD + + cp_test_ptype_class \ + "ptype vD" "" "class" "vD" \ + { + { base "public virtual vB" } + { base "public virtual vC" } + { vbase "vC" } + { vbase "vB" } + { field public "int vd;" } + { field public "int vx;" } + } + cp_test_ptype_class "ptype class vD" "" "class" "vD" ibid + cp_test_ptype_class "ptype g_vD" "" "class" "vD" ibid + + # class vE + + cp_test_ptype_class \ + "ptype vE" "" "class" "vE" \ + { + { base "public virtual vD" } + { vbase "vD" } + { field public "int ve;" } + { field public "int vx;" } + } + cp_test_ptype_class "ptype class vE" "" "class" "vE" ibid + cp_test_ptype_class "ptype g_vE" "" "class" "vE" ibid + +} + +# Single inheritance, print individual members. + +proc test_print_si_members { } { + global vhn + + # Print all members of g_A using fully qualified form. + gdb_test "print g_A.A::a" "$vhn = 1" + gdb_test "print g_A.A::x" "$vhn = 2" + + # Print members of g_A using nonambiguous compact form. + gdb_test "print g_A.a" "$vhn = 1" + gdb_test "print g_A.x" "$vhn = 2" + + # Print all members of g_B using fully qualified form. + gdb_test "print g_B.A::a" "$vhn = 3" + gdb_test "print g_B.A::x" "$vhn = 4" + gdb_test "print g_B.B::b" "$vhn = 5" + gdb_test "print g_B.B::x" "$vhn = 6" + + # Print members of g_B using nonambiguous compact form. + gdb_test "print g_B.a" "$vhn = 3" + gdb_test "print g_B.b" "$vhn = 5" + gdb_test "print g_B.x" "$vhn = 6" + + # Print all members of g_C using fully qualified form. + gdb_test "print g_C.A::a" "$vhn = 7" + gdb_test "print g_C.A::x" "$vhn = 8" + gdb_test "print g_C.C::c" "$vhn = 9" + gdb_test "print g_C.C::x" "$vhn = 10" + + # Print members of g_C using nonambiguous compact form. + gdb_test "print g_C.a" "$vhn = 7" + gdb_test "print g_C.c" "$vhn = 9" + gdb_test "print g_C.x" "$vhn = 10" +} + +# Single inheritance, print complete classes. + +proc test_print_si_classes { } { + global vhn + + # Print all members of g_A, g_B, g_C. + gdb_test "print g_A" "$vhn = \{a = 1, x = 2\}" + gdb_test "print g_B" "$vhn = \{<(class A|A)> = \{a = 3, x = 4\}, b = 5, x = 6\}" + gdb_test "print g_C" "$vhn = \{<(class A|A)> = \{a = 7, x = 8\}, c = 9, x = 10\}" +} + +# Multiple inheritance, print individual members. + +proc test_print_mi_members {} { + global gdb_prompt + global nl + global vhn + + # Print all members of g_A. + gdb_test "print g_A.A::a" "$vhn = 1" + gdb_test "print g_A.A::x" "$vhn = 2" + + # Print all members of g_B. + gdb_test "print g_B.A::a" "$vhn = 3" + gdb_test "print g_B.A::x" "$vhn = 4" + gdb_test "print g_B.B::b" "$vhn = 5" + gdb_test "print g_B.B::x" "$vhn = 6" + + # Print all members of g_C. + gdb_test "print g_C.A::a" "$vhn = 7" + gdb_test "print g_C.A::x" "$vhn = 8" + gdb_test "print g_C.C::c" "$vhn = 9" + gdb_test "print g_C.C::x" "$vhn = 10" + + # Print all members of g_D. + # + # g_D.A::a and g_D.A::x are ambiguous member accesses, and gdb + # should detect these. There are no ways to PASS these tests + # because I don't know what the gdb message will be. -- chastain + # 2004-01-27. + + set name "print g_D.A::a" + gdb_test_multiple "print g_D.A::a" $name { + -re "$vhn = (15|11)$nl$gdb_prompt $" { + kfail "gdb/68" "print g_D.A::a" + } + } + + set name "print g_D.A::x" + gdb_test_multiple "print g_D.A::x" $name { + -re "$vhn = (16|12)$nl$gdb_prompt $" { + kfail "gdb/68" "print g_D.A::x" + } + } + + gdb_test "print g_D.B::b" "$vhn = 13" + gdb_test "print g_D.B::x" "$vhn = 14" + gdb_test "print g_D.C::c" "$vhn = 17" + gdb_test "print g_D.C::x" "$vhn = 18" + gdb_test "print g_D.D::d" "$vhn = 19" + gdb_test "print g_D.D::x" "$vhn = 20" + + # Print all members of g_E. + # g_E.A::a and g_E.A::x are ambiguous. + + set name "print g_E.A::a" + gdb_test_multiple "print g_E.A::a" $name { + -re "$vhn = (21|25)$nl$gdb_prompt $" { + kfail "gdb/68" "print g_E.A::a" + } + } + + set name "print g_E.A::x" + gdb_test_multiple "print g_E.A::x" $name { + -re "$vhn = (26|22)$nl$gdb_prompt $" { + kfail "gdb/68" "print g_E.A::x" + } + } + + gdb_test "print g_E.B::b" "$vhn = 23" + gdb_test "print g_E.B::x" "$vhn = 24" + gdb_test "print g_E.C::c" "$vhn = 27" + gdb_test "print g_E.C::x" "$vhn = 28" + gdb_test "print g_E.D::d" "$vhn = 29" + gdb_test "print g_E.D::x" "$vhn = 30" + gdb_test "print g_E.E::e" "$vhn = 31" + gdb_test "print g_E.E::x" "$vhn = 32" +} + +# Multiple inheritance, print individual member types. + +proc test_print_mi_member_types {} { + global gdb_prompt + global nl + global vhn + + # Print the types of some members of g_D without qualifying them. + gdb_test "ptype g_D.b" "type = int" + gdb_test "ptype g_D.c" "type = int" + gdb_test "ptype g_D.d" "type = int" + + # Print the types of qualified members; none of these tests pass today. + + # Print all members of g_A. + gdb_test "ptype g_A.A::a" "type = int" + gdb_test "ptype g_A.A::x" "type = int" + + # Print all members of g_B. + gdb_test "ptype g_B.A::a" "type = int" + gdb_test "ptype g_B.A::x" "type = int" + gdb_test "ptype g_B.B::b" "type = int" + gdb_test "ptype g_B.B::x" "type = int" + + # Print all members of g_C. + gdb_test "ptype g_C.A::a" "type = int" + gdb_test "ptype g_C.A::x" "type = int" + gdb_test "ptype g_C.C::c" "type = int" + gdb_test "ptype g_C.C::x" "type = int" + + # Print all members of g_D. + # + # g_D.A::a and g_D.A::x are ambiguous member accesses, and gdb + # should detect these. There are no ways to PASS these tests + # because I don't know what the gdb message will be. -- chastain + # 2004-01-27. + + set name "ptype g_D.A::a" + gdb_test_multiple "ptype g_D.A::a" $name { + -re "type = int$nl$gdb_prompt $" { + kfail "gdb/68" "ptype g_D.A::a" + } + } + + set name "ptype g_D.A::x" + gdb_test_multiple "ptype g_D.A::x" $name { + -re "type = int$nl$gdb_prompt $" { + kfail "gdb/68" "ptype g_D.A::x" + } + } + + gdb_test "ptype g_D.B::b" "type = int" + gdb_test "ptype g_D.B::x" "type = int" + gdb_test "ptype g_D.C::c" "type = int" + gdb_test "ptype g_D.C::x" "type = int" + gdb_test "ptype g_D.D::d" "type = int" + gdb_test "ptype g_D.D::x" "type = int" + + # Print all members of g_E. + # g_E.A::a and g_E.A::x are ambiguous. + + set name "ptype g_E.A::a" + gdb_test_multiple "ptype g_E.A::a" $name { + -re "type = int$nl$gdb_prompt $" { + kfail "gdb/68" "ptype g_E.A::a" + } + } + + set name "ptype g_E.A::x" + gdb_test_multiple "ptype g_E.A::x" $name { + -re "type = int$nl$gdb_prompt $" { + kfail "gdb/68" "ptype g_E.A::x" + } + } + + gdb_test "ptype g_E.B::b" "type = int" + gdb_test "ptype g_E.B::x" "type = int" + gdb_test "ptype g_E.C::c" "type = int" + gdb_test "ptype g_E.C::x" "type = int" + gdb_test "ptype g_E.D::d" "type = int" + gdb_test "ptype g_E.D::x" "type = int" + gdb_test "ptype g_E.E::e" "type = int" + gdb_test "ptype g_E.E::x" "type = int" +} + +# Multiple inheritance, print complete classes. + +proc test_print_mi_classes { } { + global vhn + + # Print all members of g_D. + gdb_test "print g_D" "$vhn = \{\<(class |)B\> = \{\<(class |)A\> = \{a = 11, x = 12\}, b = 13, x = 14\}, \<(class |)C\> = \{\<(class |)A\> = \{a = 15, x = 16\}, c = 17, x = 18\}, d = 19, x = 20\}" + + # Print all members of g_E. + gdb_test "print g_E" "$vhn = \{\<(class |)D\> = \{\<(class |)B\> = \{\<(class |)A\> = \{a = 21, x = 22\}, b = 23, x = 24\}, \<(class |)C\> = \{\<(class |)A\> = \{a = 25, x = 26\}, c = 27, x = 28\}, d = 29, x = 30\}, e = 31, x = 32\}" +} + +# Single inheritance, print anonymous unions. +# GDB versions prior to 4.14 entered an infinite loop when printing +# the type of a class containing an anonymous union, and they were also +# incapable of printing the member of an anonymous union. +# We test the printing of the member first, and perform the other tests +# only if the test succeeds, to avoid the infinite loop. +# +# GDB HEAD 2004-01-27 with hp aCC A.03.45 crashes on the first test. +# -- chastain 2004-01-27 + +proc test_print_anon_union {} { + global gdb_prompt + global ws + global nl + global vhn + + gdb_test "print g_anon_union.a" "$vhn = 2" "print anonymous union member" + + set name "print variable of type anonymous union" + gdb_test_multiple "print g_anon_union" $name { + -re "$vhn = \{one = 1, \{a = 2, b = \[0-9\]+\}\}$nl$gdb_prompt $" { + pass $name + } + } + + set name "print type of anonymous union" + set re_tag "class_with_anon_union" + set re_class "(class $re_tag \{${ws}public:|struct $re_tag \{)" + set re_fields "int one;${ws}union \{${ws}int a;${ws}long( int)? b;${ws}\};" + gdb_test_multiple "ptype g_anon_union" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name + } + } +} + + +# Single virtual inheritance, print individual members. + +proc test_print_svi_members { } { + global vhn + + # Print all members of g_vA. + gdb_test "print g_vA.vA::va" "$vhn = 1" + gdb_test "print g_vA.vA::vx" "$vhn = 2" + + # Print members of g_vA using compact form. + gdb_test "print g_vA.va" "$vhn = 1" + gdb_test "print g_vA.vx" "$vhn = 2" + + # Print all members of g_vB. + gdb_test "print g_vB.vA::va" "$vhn = 3" + gdb_test "print g_vB.vA::vx" "$vhn = 4" + gdb_test "print g_vB.vB::vb" "$vhn = 5" + gdb_test "print g_vB.vB::vx" "$vhn = 6" + + # Print members of g_vB using compact form. + gdb_test "print g_vB.va" "$vhn = 3" + gdb_test "print g_vB.vb" "$vhn = 5" + gdb_test "print g_vB.vx" "$vhn = 6" + + # Print all members of g_vC. + gdb_test "print g_vC.vA::va" "$vhn = 7" + gdb_test "print g_vC.vA::vx" "$vhn = 8" + gdb_test "print g_vC.vC::vc" "$vhn = 9" + gdb_test "print g_vC.vC::vx" "$vhn = 10" + + # Print members of g_vC using compact form. + gdb_test "print g_vC.va" "$vhn = 7" "print g_vC.va" + gdb_test "print g_vC.vc" "$vhn = 9" "print g_vC.vc" + gdb_test "print g_vC.vx" "$vhn = 10" "print g_vC.vx" +} + +# Single virtual inheritance, print complete classes. + +proc test_print_svi_classes { } { + global gdb_prompt + global hex + global nl + global vhn + + # Print all members of g_vA. + gdb_test "print g_vA" "$vhn = \{va = 1, vx = 2\}" + + # Print all members of g_vB. + set re_vbptr_2 "(_vb.2vA|_vb.vA)" + set re_vbptr_3 "_vptr.vB" + + set name "print g_vB" + gdb_test_multiple "print g_vB" $name { + -re "$vhn = \{ = \{va = 3, vx = 4\}, $re_vbptr_2 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + pass $name + } + -re "$vhn = \{ = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" { + # gcc 3.3.4 -gdwarf-2 + # gcc 3.4.1 -gdwarf-2 + # gcc 3.4.1 -gstabs+ + # gcc HEAD 2004-07-31 -gdwarf-2 + pass "$name (FIXME v3 vtbl ptr)" + } + -re "$vhn = \{ = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex , vb = 5, vx = 6\}$nl$gdb_prompt $" { + # gcc 3.3.4 -gstabs+ + pass $name + } + -re "$vhn = \{ = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex , vb = 5, vx = 6\}$nl$gdb_prompt $" { + # gcc HEAD 2004-07-31 -gstabs+ + pass $name + } + } + + # Print all members of g_vC. + set re_vbptr_2 "(_vb.2vA|_vb.vA)" + set re_vbptr_3 "_vptr.vC" + + set name "print g_vC" + gdb_test_multiple "print g_vC" $name { + -re "$vhn = \{ = \{va = 7, vx = 8\}, $re_vbptr_2 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + pass $name + } + -re "$vhn = \{ = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" { + # gcc 3.3.4 -gdwarf-2 + # gcc 3.4.1 -gdwarf-2 + # gcc 3.4.1 -gstabs+ + # gcc HEAD 2004-07-31 -gdwarf-2 + pass "$name (FIXME v3 vtbl ptr)" + } + -re "$vhn = \{ = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex , vc = 9, vx = 10\}$nl$gdb_prompt $" { + # gcc 3.3.4 -gstabs+ + pass $name + } + -re "$vhn = \{ = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex , vc = 9, vx = 10\}$nl$gdb_prompt $" { + # gcc HEAD 2004-07-31 -gstabs+ + pass $name + } + } +} + +# Multiple virtual inheritance, print individual members. + +proc test_print_mvi_members { } { + global vhn + + # Print all members of g_vD. + gdb_test "print g_vD.vA::va" "$vhn = 19" + gdb_test "print g_vD.vA::vx" "$vhn = 20" + gdb_test "print g_vD.vB::vb" "$vhn = 21" + gdb_test "print g_vD.vB::vx" "$vhn = 22" + gdb_test "print g_vD.vC::vc" "$vhn = 23" + gdb_test "print g_vD.vC::vx" "$vhn = 24" + gdb_test "print g_vD.vD::vd" "$vhn = 25" + gdb_test "print g_vD.vD::vx" "$vhn = 26" + + # Print all members of g_vE. + gdb_test "print g_vE.vA::va" "$vhn = 0" + gdb_test "print g_vE.vA::vx" "$vhn = 0" + gdb_test "print g_vE.vB::vb" "$vhn = 0" + gdb_test "print g_vE.vB::vx" "$vhn = 0" + gdb_test "print g_vE.vC::vc" "$vhn = 0" + gdb_test "print g_vE.vC::vx" "$vhn = 0" + gdb_test "print g_vE.vD::vd" "$vhn = 0" + gdb_test "print g_vE.vD::vx" "$vhn = 0" + gdb_test "print g_vE.vE::ve" "$vhn = 27" + gdb_test "print g_vE.vE::vx" "$vhn = 28" +} + +# Multiple virtual inheritance, print complete classes. + +proc test_print_mvi_classes { } { + global gdb_prompt + global hex + global ws + global nl + global vhn + + # Virtual base pointers for everybody. + + set re_vbptr_2_vA "(_vb.2vA|_vb.vA)" + set re_vbptr_2_vB "(_vb.2vB|_vb.vB)" + set re_vbptr_2_vC "(_vb.2vC|_vb.vC)" + set re_vbptr_2_vD "(_vb.2vD|_vb.vD)" + set re_vbptr_3_vA "_vptr.vA" + set re_vbptr_3_vB "_vptr.vB" + set re_vbptr_3_vC "_vptr.vC" + set re_vbptr_3_vD "_vptr.vD" + set re_vbptr_3_vE "_vptr.vE" + + # Print all members of g_vD. + + set name "print g_vD" + gdb_test_multiple "print g_vD" $name { + -re "$vhn = \{ = \{ = \{va = 19, vx = 20\}, $re_vbptr_2_vA = $hex, vb = 21, vx = 22\}, = \{$re_vbptr_2_vA = $hex, vc = 23, vx = 24\}, $re_vbptr_2_vC = $hex, $re_vbptr_2_vB = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + pass $name + } + -re "$vhn = \{ = \{ = \{va = 19, vx = 20\}, $re_vbptr_3_vB = $hex, vb = 21, vx = 22\}, = \{$re_vbptr_3_vC = $hex, vc = 23, vx = 24\}, $re_vbptr_3_vD = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name (FIXME v3 vtbl ptr)" + } + -re "$vhn = \{ = \{ = \{va = 19, vx = 20\}, $re_vbptr_3_vB = $hex, vb = 21, vx = 22\}, = \{$re_vbptr_3_vC = $hex , vc = 23, vx = 24\}, $re_vbptr_3_vD = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + pass "$name" + } + } + + # Print all members of g_vE. + + set name "print g_vE" + gdb_test_multiple "print g_vE" $name { + -re "$vhn = \{ = \{ = \{ = \{va = 0, vx = 0\}, $re_vbptr_2_vA = $hex, vb = 0, vx = 0\}, = \{$re_vbptr_2_vA = $hex, vc = 0, vx = 0\}, $re_vbptr_2_vC = $hex, $re_vbptr_2_vB = $hex, vd = 0, vx = 0\}, $re_vbptr_2_vD = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + pass $name + } + -re "$vhn = \{ = \{ = \{ = \{va = 0, vx = 0\}, $re_vbptr_3_vB = $hex, vb = 0, vx = 0\}, = \{$re_vbptr_3_vC = $hex, vc = 0, vx = 0\}, $re_vbptr_3_vD = $hex, vd = 0, vx = 0\}, $re_vbptr_3_vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" { + # gcc 3.3.4 -gdwarf-2 + # gcc 3.3.4 -gstabs+ + # gcc 3.4.1 -gdwarf-2 + # gcc 3.4.1 -gstabs+ + # gcc HEAD 2004-07-31 -gdwarf-2 + pass "$name (FIXME v3 vtbl ptr)" + } + -re "$vhn = \{ = \{ = \{ = \{va = 0, vx = 0\}, $re_vbptr_3_vB = $hex, vb = 0, vx = 0\}, = \{$re_vbptr_3_vC = $hex , vc = 0, vx = 0\}, $re_vbptr_3_vD = $hex, vd = 0, vx = 0\}, $re_vbptr_3_vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" { + # gcc 3.2.7-rh -gstabs+ + pass $name + } + -re "$vhn = \{ = \{ = \{ = \{va = 0, vx = 0\}, $re_vbptr_3_vB = $hex, vb = 0, vx = 0\}, = \{$re_vbptr_3_vC = $hex , vc = 0, vx = 0\}, $re_vbptr_3_vD = $hex, vd = 0, vx = 0\}, $re_vbptr_3_vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" { + # gcc HEAD 2004-07-31 -gstabs+ + pass $name + } + } +} + +proc do_tests { } { + global subdir + global objdir + global srcdir + global binfile + + + # Start with a fresh gdb. + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load $binfile + + gdb_test_no_output "set language c++" + gdb_test_no_output "set width 0" + + if { ![runto_main] } then { + perror "couldn't run to main" + return + } + + test_ptype_si + test_ptype_mi + test_ptype_vi + test_ptype_mvi + + if { ![runto 'inheritance2'] } then { + perror "couldn't run to inheritance2" + return + } + + test_print_si_members + test_print_si_classes + test_print_mi_members + test_print_mi_member_types + test_print_mi_classes + test_print_anon_union + + if { ![runto 'inheritance4'] } { + perror "couldn't run to inheritance4" + return + } + + test_print_svi_members + test_print_svi_classes + test_print_mvi_members + test_print_mvi_classes +} + +do_tests Index: gdb1355.cc =================================================================== --- gdb1355.cc (nonexistent) +++ gdb1355.cc (revision 513) @@ -0,0 +1,36 @@ +struct mystruct +{ + int m_int; + char m_char; + long int m_long_int; + unsigned int m_unsigned_int; + long unsigned int m_long_unsigned_int; + // long long int m_long_long_int; + // long long unsigned int m_long_long_unsigned_int; + short int m_short_int; + short unsigned int m_short_unsigned_int; + unsigned char m_unsigned_char; + float m_float; + double m_double; + long double m_long_double; + // complex int m_complex_int; + // complex float m_complex_float; + // complex long double m_complex_long_double; + // wchar_t m_wchar_t; + bool m_bool; +}; + +struct mystruct s1 = +{ + 117, 'a', 118, 119, 120, + // 121, 122, + 123, 124, 'b', 125.0, 126.0, 127.0, + // complex int, complex float, complex long double, wchar_t, + true +}; + +int main () +{ + /* Reference s1 so that it is included. */ + return s1.m_int - 117; +} Index: pr9631.exp =================================================================== --- pr9631.exp (nonexistent) +++ pr9631.exp (revision 513) @@ -0,0 +1,48 @@ +# Copyright 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the gdb testsuite. + +if { [skip_cplus_tests] } { continue } + +set testfile "pr9631" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested pr9631.exp + return -1 +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +gdb_breakpoint [gdb_get_line_number "set breakpoint here"] +gdb_continue_to_breakpoint "after bar tender is initialized" + +gdb_test \ + "print tender" \ + "\\\$1 = { = {_vptr.vbase = $hex}, = {}, }" Index: nsimport.cc =================================================================== --- nsimport.cc (nonexistent) +++ nsimport.cc (revision 513) @@ -0,0 +1,20 @@ +namespace A { + int x = 11; + namespace{ + int xx = 22; + } +} + +using namespace A; + +namespace{ + int xxx = 33; +}; + +int main() +{ + x; + xx; + xxx; + return 0; +} Index: cttiadd.cc =================================================================== --- cttiadd.cc (nonexistent) +++ cttiadd.cc (revision 513) @@ -0,0 +1,49 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 1998, 1999, 2004, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +template T add(T v1, T v2) +{ + T v3; + v3 = v1; + v3 += v2; + return v3; + } + +int main() +{ + unsigned char c; + int i; + float f; + extern void add1(); + extern void subr2(); + extern void subr3(); + + c = 'a'; + i = 2; + f = 4.5; + + c = add(c, c); + i = add(i, i); + f = add(f, f); + + // marker add1 + add1(); + subr2(); + subr3(); +} Index: arg-reference.exp =================================================================== --- arg-reference.exp (nonexistent) +++ arg-reference.exp (revision 513) @@ -0,0 +1,45 @@ +# Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@gnu.org + +# This file is part of the gdb testsuite. + +# Test G++ has compiled debuginfo without a C++ '&' reference where it should +# not be. GCC Bug 33537. + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + + +set testfile "arg-reference" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested ${testfile}.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +gdb_test "ptype foo" "type = int \\\(Obj\\\)" "No false reference" Index: namespace1.cc =================================================================== --- namespace1.cc (nonexistent) +++ namespace1.cc (revision 513) @@ -0,0 +1,67 @@ +/* Copyright 2003, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + + + +namespace C +{ + class OtherFileClass { + public: + int z; + + typedef short cOtherFileClassType; + typedef long cOtherFileClassType2; + static const cOtherFileClassType cOtherFileClassVar = 318; + static const cOtherFileClassType2 cOtherFileClassVar2 = 320; + cOtherFileClassType cOtherFileClassVar_use (); + }; + OtherFileClass::cOtherFileClassType OtherFileClass::cOtherFileClassVar_use () + { + return cOtherFileClassVar + cOtherFileClassVar2; + } + + namespace { + int cXOtherFile = 29; + }; + + int cOtherFile = 316; + + void ensureOtherRefs () { + // NOTE (2004-04-23, carlton): This function is here only to make + // sure that GCC 3.4 outputs debug info for this class. + static OtherFileClass *c = new OtherFileClass(); + c->z = cOtherFile + cXOtherFile; + } + + typedef short cOtherFileType; + typedef long cOtherFileType2; + static const cOtherFileType cOtherFileVar = 319; + static const cOtherFileType2 cOtherFileVar2 = 321; + cOtherFileType cOtherFileVar_use () + { + return cOtherFileVar + cOtherFileVar2; + } +} + +namespace { + int XOtherFile = 317; +} + +int ensureOtherRefs () +{ + C::ensureOtherRefs (); + return XOtherFile; +} Index: maint.exp =================================================================== --- maint.exp (nonexistent) +++ maint.exp (revision 513) @@ -0,0 +1,126 @@ +# Copyright 2003, 2004, 2006 Free Software Foundation Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +# This file tests C++-specific maintenance commands and help on those. + +# Currently, no source file is used. + +if $tracelevel then { + strace $tracelevel + } + +# Test the help messages. + +proc test_help {} { + set first_component_help "Print the first class/namespace component of NAME" + set namespace_help "Print the list of possible C\\+\\+ namespaces" + + test_prefix_command_help {"maintenance cplus"} { + "C\\+\\+ maintenance commands\.\[\r\n\]+" + } + + test_prefix_command_help {"maint cp" "maintenance cplus"} { + "C\\+\\+ maintenance commands.\r\n\r\n" + } + + set multiple_help_body "List of maintenance cplus subcommands:\r\n\r\nmaintenance cplus first_component -- ${first_component_help}\r\nmaintenance cplus namespace -- ${namespace_help}\r\n\r\nType \"help maintenance cplus\" followed by maintenance cplus subcommand name for full documentation.\r\nCommand name abbreviations are allowed if unambiguous." + + gdb_test "maint cp" "\"maintenance cplus\" must be followed by the name of a command.\r\n.*" + + gdb_test "help maint cp first_component" "${first_component_help}." + gdb_test "help maint cp namespace" "${namespace_help}." +} + +# This is used when NAME should contain only a single component. Be +# careful to make sure that parentheses get escaped properly. +proc test_single_component {name} { + set matchname [string_to_regexp "$name"] + gdb_test "maint cp first_component $name" "$matchname" +} + +# This is used when NAME is invalid. +proc test_invalid_name {name} { + set matchname [string_to_regexp "$name"] + gdb_test "maint cp first_component $name" \ + "During symbol reading, unexpected demangled name '$matchname'.\r\n$matchname" +} + +proc test_first_component {} { + # The function in question might complain; make sure that we see + # all complaints. + + gdb_test_no_output "set complaints 1000" + + test_single_component "foo" + test_single_component "operator<<" + test_single_component "operator>>" + test_single_component "operator ->" + test_single_component "operator()" + test_single_component "operator>" + test_single_component "operator<" + test_single_component "operator ->" + test_single_component "operator ->" + + test_single_component "foo()" + test_single_component "foo(int)" + test_single_component "foo(X::Y)" + test_single_component "foo(X::Y, A::B)" + test_single_component "foo(std::basic_streambuf >)" + test_single_component "operator>(X::Y)" + + # Operator names can show up in weird places. + + test_single_component "int operator<< ()" + test_single_component "T" + + # NOTE: carlton/2003-04-23: I've only seen the first of these + # produced by the demangler, but I'm including two more just to be + # on the safe side. + test_single_component "int foo<&(operator<<(C, C))>()" + test_single_component "int foo<&operator<<(C, C)>()" + test_single_component "int foo()" + + gdb_test "maint cp first_component foo::bar" "foo" + gdb_test "maint cp first_component foo::bar::baz" "foo" + gdb_test "maint cp first_component C::bar" "C" + gdb_test "maint cp first_component C > >::bar" "C > >" + + # Make sure we behave appropriately on invalid input. + + # NOTE: carlton/2003-06-25: As of today, the demangler can in fact + # produce examples like the third case below: there really should + # be a space between the two <'s. See PR gdb/1245. + + test_invalid_name "foo<" + test_invalid_name "foo(" + test_invalid_name "bool operator<" +} + +proc test_namespace {} { + # There's not a lot we can do to test this. + + gdb_test "maint cp namespace" "Possible namespaces:" +} + +gdb_exit +gdb_start + +test_help +test_first_component +test_namespace + +gdb_exit +return 0 Index: member-ptr.exp =================================================================== --- member-ptr.exp (nonexistent) +++ member-ptr.exp (revision 513) @@ -0,0 +1,662 @@ +# Copyright 1998, 1999, 2003, 2004, 2006, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This file is part of the gdb testsuite + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Tests for pointer-to-member support +# Written by Satish Pai 1997-08-19 +# Rewritten by Michael Chastain 2004-01-11 + +set vhn "\\$\[0-9\]+" + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + + +set testfile "member-ptr" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested member-ptr.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +gdb_breakpoint [gdb_get_line_number "Breakpoint 1 here"] +gdb_continue_to_breakpoint "continue to pmi = NULL" + +# ====================== +# pointer to member data +# ====================== + +# ptype on pointer to data member + +set name "ptype pmi (A::j)" +gdb_test_multiple "ptype pmi" $name { + -re "type = int A::\\*\r\n$gdb_prompt $" { + pass $name + } +} + +# print pointer to data member + +set name "print pmi (A::j) " +gdb_test_multiple "print pmi" $name { + -re "$vhn = &A::j\r\n$gdb_prompt $" { + pass $name + } + -re "$vhn = \\(int ?\\( ?A::\\*\\)\\) &A::j\r\n$gdb_prompt $" { + pass $name + } + -re "$vhn = \\(int ?\\( ?A::\\*\\)\\) ?&A::j ?\\+ ?1 bytes\r\n$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + kfail "gdb/NNNN" $name + } + -re "$vhn = &A::j ?\\+ ?1 bytes\r\n$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + kfail "gdb/NNNN" $name + } + -re "$vhn = not implemented: member type in c_val_print\r\n$gdb_prompt $" { + # gcc HEAD 2004-01-11 05:33:21 -gdwarf-2 + # gcc HEAD 2004-01-11 05:33:21 -gstabs+ + kfail "gdb/NNNN" $name + } + -re "$vhn = \\(int ?\\( A::\\*\\)\\) 536870920\r\n$gdb_prompt $" { + # the value is 0x20000008 hex. 0x20000000 is an internal flag. + # Use '|' to add in more values as needed. + # hpacc A.03.45 + kfail "gdb/NNNN" $name + } +} + +# print dereferenced pointer to data member + +set name "print a.*pmi (A::j)" +gdb_test_multiple "print a.*pmi" $name { + -re "$vhn = 121\r\n$gdb_prompt $" { + pass $name + } + -re "$vhn = 855638016\r\n$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + kfail "gdb/NNNN" $name + } + -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# print dereferenced pointer to data member +# this time, dereferenced through a pointer + +set name "print a_p->*pmi (A::j)" +gdb_test_multiple "print a_p->*pmi" $name { + -re "$vhn = 121\r\n$gdb_prompt $" { + pass $name + } + -re "$vhn = 855638016\r\n$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + kfail "gdb/NNNN" $name + } + -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# set the pointer to a different data member + +set name "set var pmi = &A::jj" +gdb_test_multiple "set var pmi = &A::jj" $name { + -re "Invalid cast.\r\n$gdb_prompt $" { + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } + -re "set var pmi = &A::jj\r\n$gdb_prompt $" { + # I have to match the echo'ed input explicitly here. + # If I leave it out, the pattern becomes too general + # and matches anything that ends in "$gdb_prompt $". + pass $name + } +} + +# print the pointer again + +set name "print pmi (A::jj)" +gdb_test_multiple "print pmi" $name { + -re "$vhn = &A::jj\r\n$gdb_prompt $" { + pass $name + } + -re "$vhn = \\(int ?\\( ?A::\\*\\)\\) &A::jj\r\n$gdb_prompt $" { + pass $name + } + -re "$vhn = not implemented: member type in c_val_print\r\n$gdb_prompt $" { + # gcc HEAD 2004-01-11 05:33:21 -gdwarf-2 + # gcc HEAD 2004-01-11 05:33:21 -gstabs+ + kfail "gdb/NNNN" $name + } + -re "$vhn = \\(int ?\\( A::\\*\\)\\) 536870924\r\n$gdb_prompt $" { + # the value is 0x20000008 hex. 0x20000000 is an internal flag. + # Use '|' to add in more values as needed. + # hpacc A.03.45 + kfail "gdb/NNNN" $name + } +} + +# print dereferenced pointer to data member again + +set name "print a.*pmi (A::jj)" +gdb_test_multiple "print a.*pmi" $name { + -re "$vhn = 1331\r\n$gdb_prompt $" { + pass $name + } + -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# set the pointer to data member back to A::j + +set name "set var pmi = &A::j" +gdb_test_multiple "set var pmi = &A::j" $name { + -re "Invalid cast.\r\n$gdb_prompt $" { + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } + -re "set var pmi = &A::j\r\n$gdb_prompt $" { + # I have to match the echo'ed input explicitly here. + # If I leave it out, the pattern becomes too general + # and matches anything that ends in "$gdb_prompt $". + pass $name + } +} + +# print dereferenced pointer to data member yet again (extra check, why not) + +set name "print a.*pmi (A::j) (again)" +gdb_test_multiple "print a.*pmi" $name { + -re "$vhn = 121\r\n$gdb_prompt $" { + pass $name + } + -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# Set the data member pointed to. + +set name "print a.*pmi = 33" +gdb_test_multiple "print a.*pmi = 33" $name { + -re "$vhn = 33\r\n$gdb_prompt $" { + pass $name + } + -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# Now check that the data really was changed + +set name "print a.*pmi (A::j) (33)" +gdb_test_multiple "print a.*pmi" $name { + -re "$vhn = 33\r\n$gdb_prompt $" { + pass $name + } + -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# Double-check by printing a. + +set name "print a (j = 33)" +gdb_test_multiple "print a" $name { + -re "$vhn = \{c = 120 'x', j = 33, jj = 1331, (static|static int) s = 10, (_vptr.A|_vptr\\$) = ($hex|$hex )\}\r\n$gdb_prompt $" { + pass $name + } + -re "$vhn = \{c = 120 'x', j = 33, jj = 1331, (static|static int) s = 10, Virtual table at $hex\}\r\n$gdb_prompt $" { + pass $name + } + -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 33, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" { + pass $name + } + -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 121, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" { + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# Set the data member pointed to, using ->* + +set name "print a_p->*pmi = 44" +gdb_test_multiple "print a_p->*pmi = 44" $name { + -re "$vhn = 44\r\n$gdb_prompt $" { + pass $name + } + -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# Check that the data really was changed + +set name "print a_p->*pmi (44)" +gdb_test_multiple "print a_p->*pmi" $name { + -re "$vhn = 44\r\n$gdb_prompt $" { + pass $name + } + -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# Double-check by printing a. + +set name "print a (j = 44)" +gdb_test_multiple "print a" $name { + -re "$vhn = \{c = 120 'x', j = 44, jj = 1331, (static|static int) s = 10, (_vptr.A|_vptr\\$) = ($hex|$hex )\}\r\n$gdb_prompt $" { + pass $name + } + -re "$vhn = \{c = 120 'x', j = 44, jj = 1331, (static|static int) s = 10, Virtual table at $hex\}\r\n$gdb_prompt $" { + pass $name + } + -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 44, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" { + pass $name + } + -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 121, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" { + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# ptype the dereferenced pointer to member. + +set name "ptype a.*pmi" +gdb_test_multiple "ptype a.*pmi" $name { + -re "type = int\r\n$gdb_prompt" { + pass $name + } + -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" { + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# dereference the pointer to data member without any object +# this is not allowed: a pmi must be bound to an object to dereference + +set name "print *pmi" +gdb_test_multiple "print *pmi" $name { + -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" { + pass $name + } + -re "Cannot access memory at address 0x4\r\n$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + kfail "gdb/NNNN" $name + } + -re "Cannot access memory at address 0x8\r\n$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc 3.3.2 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# dereference the pointer to data member without any object +# this is not allowed: a pmi must be bound to an object to dereference + +set name "ptype *pmi" +gdb_test_multiple "ptype *pmi" $name { + -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" { + pass $name + } + -re "type = int A::\r\n$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# Check cast of pointer to member to integer. +# This is similar to "offset-of". +# such as "A a; print (size_t) &A.j - (size_t) &A". + +set name "print (int) pmi" +gdb_test_multiple "print (int) pmi" $name { + -re "$vhn = (4|8|12)\r\n$gdb_prompt" { + pass $name + } +} + +# Check "(int) pmi" explicitly for equality. + +set name "print ((int) pmi) == ((char *) &a.j - (char *) &a)" +gdb_test_multiple "print ((int) pmi) == ((char *) &a.j - (char *) & a)" $name { + -re "$vhn = true\r\n$gdb_prompt" { + pass $name + } +} + +# ========================== +# pointer to member function +# ========================== + +# ptype a pointer to a method + +set name "ptype pmf" +gdb_test_multiple "ptype pmf" $name { + -re "type = int \\( ?A::\\*\\)\\(A \\*, int\\)\r\n$gdb_prompt $" { + pass $name + } + -re "type = int \\( ?A::\\*\\)\\(void\\)\r\n$gdb_prompt $" { + # hpacc A.03.45 + kfail "gdb/NNNN" $name + } + -re "type = struct \{.*\}\r\n$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + # gcc 3.2.2 -gdwarf-2 + # gcc 3.2.2 -gstabs+ + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# print a pointer to a method + +set name "print pmf" +gdb_test_multiple "print pmf" $name { + -re "$vhn = \\(int \\(A::\\*\\)\\(A \\*, int\\)\\) $hex \r\n$gdb_prompt $" { + pass $name + } + -re "$vhn = .*not supported with HP aCC.*\r\n$gdb_prompt $" { + # hpacc A.03.45 + kfail "gdb/NNNN" $name + } + -re "$vhn = \{.*\}\r\n$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + # gcc 3.2.2 -gdwarf-2 + # gcc 3.2.2 -gstabs+ + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# ptype a pointer to a pointer to a method + +set name "ptype pmf_p" +gdb_test_multiple "ptype pmf_p" $name { + -re "type = int \\( ?A::\\*\\*\\)\\(A \\*, int\\)\r\n$gdb_prompt $" { + pass $name + } + -re "type = int \\( ?A::\\*\\*\\)\\(void\\)\r\n$gdb_prompt $" { + # hpacc A.03.45 + kfail "gdb/NNNN" $name + } + -re "type = struct \{.*\} \\*\r\n$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + # gcc 3.2.2 -gdwarf-2 + # gcc 3.2.2 -gstabs+ + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# print a pointer to a pointer to a method + +set name "print pmf_p" +gdb_test_multiple "print pmf_p" $name { + -re "$vhn = \\(int \\( ?A::\\*\\*\\)\\)\\(int\\)\\) $hex\r\n$gdb_prompt $" { + pass $name + } + -re "$vhn = \\(PMF \\*\\) $hex\r\n$gdb_prompt $" { + pass "gdb/NNNN" + } + -re "$vhn = \\(int \\( ?A::\\*\\*\\)\\(void\\)\\) $hex\r\n$gdb_prompt $" { + # hpacc A.03.45 + kfail "gdb/NNNN" $name + } + -re "$vhn = \\(struct \{.*\} \\*\\) $hex\r\n$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + kfail "gdb/NNNN" $name + } +} + +# print dereferenced pointer to method + +set name "print a.*pmf" +gdb_test_multiple "print a.*pmf" $name { + -re "$vhn = {int \\(A \\*, int\\)} $hex \r\n$gdb_prompt $" { + pass $name + } + -re "Pointers to methods not supported with HP aCC\r\n$gdb_prompt $" { + # hpacc A.03.45 + kfail "gdb/NNNN" $name + } + -re "Value can't be converted to integer.\r\n$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + # gcc 3.2.2 -gdwarf-2 + # gcc 3.2.2 -gstabs+ + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# print dereferenced pointer to method, using ->* + +set name "print a_p->*pmf" +gdb_test_multiple "print a_p->*pmf" $name { + -re "$vhn = {int \\(A \\*, int\\)} $hex \r\n$gdb_prompt $" { + pass $name + } + -re "Pointers to methods not supported with HP aCC\r\n$gdb_prompt $" { + # hpacc A.03.45 + kfail "gdb/NNNN" $name + } + -re "Value can't be converted to integer.\r\n$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + # gcc 3.2.2 -gdwarf-2 + # gcc 3.2.2 -gstabs+ + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# set the pointer to data member + +set name "set var pmf = &A::foo" +gdb_test_multiple "set var pmf = &A::foo" $name { + -re "set var pmf = &A::foo\r\n$gdb_prompt $" { + # I have to match the echo'ed input explicitly here. + # If I leave it out, the pattern becomes too general + # and matches anything that ends in "$gdb_prompt $". + pass $name + } + -re "Invalid cast.\r\n$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + # gcc 3.2.2 -gdwarf-2 + # gcc 3.2.2 -gstabs+ + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } + -re "Assignment to pointers to methods not implemented with HP aCC\r\n$gdb_prompt $" { + kfail "gdb/NNNN" $name + } +} + +# dereference the pointer to data member without any object +# this is not allowed: a pmf must be bound to an object to dereference + +set name "print *pmf" +gdb_test_multiple "print *pmf" $name { + -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" { + pass $name + } + -re "Structure has no component named operator\\*.\r\n$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + # gcc 3.3.2 -gdwarf-2 + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# dereference the pointer to data member without any object +# this is not allowed: a pmf must be bound to an object to dereference + +set name "ptype *pmf" +gdb_test_multiple "ptype *pmf" $name { + -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" { + pass $name + } + -re "Structure has no component named operator\\*.\r\n$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + # gcc 3.3.2 -gdwarf-2 + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +# Call a function through a pmf. + +set name "print (a.*pmf)(3)" +gdb_test_multiple "print (a.*pmf)(3)" $name { + -re "$vhn = 50\r\n$gdb_prompt $" { + pass $name + } + -re "Not implemented: function invocation through pointer to method with HP aCC\r\n$gdb_prompt $" { + # hpacc A.03.45 + kfail "gdb/NNNN" $name + } + -re "Value can't be converted to integer.\r\n$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + # gcc 3.3.2 -gdwarf-2 + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-10 -gdwarf-2 + # gcc HEAD 2004-01-10 -gstabs+ + kfail "gdb/NNNN" $name + } +} + +gdb_test "ptype a.*pmf" "type = int \\(A \\*, int\\)" + +# Print out a pointer to data member which requires looking into +# a base class. +gdb_test "print diamond_pmi" "$vhn = &Base::x" +gdb_test "print diamond.*diamond_pmi" "$vhn = 77" + +# Examine some more complicated pmfs, which require adjusting "this" +# and looking through virtual tables. + +# These two have a different object adjustment, but call the same method. +gdb_test "print diamond.*left_pmf" \ + "$vhn = {int \\(Diamond \\*\\)} $hex " +gdb_test "print diamond.*right_pmf" \ + "$vhn = {int \\(Diamond \\*\\)} $hex " + +gdb_test "print (diamond.*left_pmf) ()" "$vhn = 77" +gdb_test "print (diamond.*right_pmf) ()" "$vhn = 88" + +# These two point to different methods, although they have the same +# virtual table offsets. +gdb_test "print diamond.*left_vpmf" \ + "$vhn = {int \\(Diamond \\*\\)} $hex " +gdb_test "print diamond.*right_vpmf" \ + "$vhn = {int \\(Diamond \\*\\)} $hex " + +gdb_test "print (diamond.*left_vpmf) ()" "$vhn = 177" +gdb_test "print (diamond.*left_base_vpmf) ()" "$vhn = 2077" +gdb_test "print (diamond.*right_vpmf) ()" "$vhn = 288" + +# We should be able to figure out left_vpmf even without an object, +# because it comes from a non-virtual base. The same for right_vpmf. +gdb_test "print left_vpmf" "$vhn = &virtual Left::vget\\(\\)" +gdb_test "print right_vpmf" "$vhn = &virtual Right::vget\\(\\)" + +# But we should gracefully fail to figure out base_vpmf, because +# its runtime type is more derived than its static type. This +# is a valid but unspecified cast (it is value preserving, i.e. +# can be casted back to the correct type and used). +gdb_test "print base_vpmf" \ + "$vhn = &virtual table offset \[0-9\]*, this adjustment -\[0-9\]*" + +# Make sure we parse this correctly; it's invalid. +gdb_test "print diamond.*left_vpmf ()" \ + "Invalid data type for function to be called\\." + +# NULL pointer to member tests. +gdb_test "print null_pmi" "$vhn = NULL" +gdb_test "print null_pmi = &A::j" "$vhn = &A::j" +gdb_test "print null_pmi = 0" "$vhn = NULL" + +gdb_test "print null_pmf" "$vhn = NULL" +gdb_test "print null_pmf = &A::foo" "$vhn = \\(int \\(A::\\*\\)\\(A \\*, int\\)\\) $hex " +gdb_test "print null_pmf = 0" "$vhn = NULL" Index: overload.exp =================================================================== --- overload.exp (nonexistent) +++ overload.exp (revision 513) @@ -0,0 +1,360 @@ +# Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# written by Elena Zannoni (ezannoni@cygnus.com) +# Rewritten by Michael Chastain + +# This file is part of the gdb testsuite + +# Tests for overloaded member functions. + +if $tracelevel then { + strace $tracelevel +} + +set ws "\[\r\n\t \]+" +set nl "\[\r\n\]+" + + +if { [skip_cplus_tests] } { continue } + +set testfile "overload" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested overload.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +# Set it up at a breakpoint so we can play with the variable values. + +if ![runto 'marker1'] then { + perror "couldn't run to marker1" + continue +} + +gdb_test "up" ".*main.*" "up from marker1" + +# Print the monster class type. +# See virtfunc.exp for a discussion of ptype. +# +# This is hairy to begin with. It is even more hairy because of the +# XX_* alternate patterns to catch the KFAIL and XFAIL cases. + +set re_class "((struct|class) foo \{${ws}public:|struct foo \{)" +set re_fields "int ifoo;${ws}const char ?\\* ?ccpfoo;" +set XX_fields "int ifoo;${ws}char ?\\* ?ccpfoo;" +set re_ctor "foo\\(int\\);${ws}foo\\(int, (char const|const char) ?\\*\\);${ws}foo\\(foo ?&\\);" +set re_dtor "~foo\\((void|)\\);" +set XX_dtor "~foo\\(int\\);" +set re_methods "void foofunc\\(int\\);" +set re_methods "${re_methods}${ws}void foofunc\\(int, signed char ?\\*\\);" +set re_methods "${re_methods}${ws}int overload1arg\\((void|)\\);" +set re_methods "${re_methods}${ws}int overload1arg\\(char\\);" +set re_methods "${re_methods}${ws}int overload1arg\\(signed char\\);" +set re_methods "${re_methods}${ws}int overload1arg\\(unsigned char\\);" +set re_methods "${re_methods}${ws}int overload1arg\\(short( int)?\\);" +set re_methods "${re_methods}${ws}int overload1arg\\((unsigned short|short unsigned)( int)?\\);" +set re_methods "${re_methods}${ws}int overload1arg\\(int\\);" +set re_methods "${re_methods}${ws}int overload1arg\\(unsigned int\\);" +set re_methods "${re_methods}${ws}int overload1arg\\(long( int)?\\);" +set re_methods "${re_methods}${ws}int overload1arg\\((unsigned long|long unsigned)( int)?\\);" +set re_methods "${re_methods}${ws}int overload1arg\\(float\\);" +set re_methods "${re_methods}${ws}int overload1arg\\(double\\);" +set re_methods "${re_methods}${ws}int overloadfnarg\\((void|)\\);" +set re_methods "${re_methods}${ws}int overloadfnarg\\(int\\);" +set re_methods "${re_methods}${ws}int overloadfnarg\\(int, int ?\\(\\*\\) ?\\(int\\)\\);" +set re_methods "${re_methods}${ws}int overloadargs\\(int\\);" +set re_methods "${re_methods}${ws}int overloadargs\\(int, int\\);" +set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int\\);" +set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int, int\\);" +set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int, int, int\\);" +set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int\\);" +set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int, int\\);" +set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int, int, int\\);" +set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int, int, int, int\\);" +set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int, int, int, int, int\\);" +set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int, int, int, int, int, int\\);" +set re_synth "foo & operator=\\(foo const ?&\\);" + +gdb_test "print foo_instance1" "\\$\[0-9\]+ = \{ifoo = 111, ccpfoo = 0x0\}" + +gdb_test_multiple "ptype foo_instance1" "ptype foo_instance1" { + -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # TODO: this is not a quirk! + pass "ptype foo_instance1 (HP aCC -- known quirk with ~foo parameter list)" + } + -re "type = $re_class${ws}$XX_fields${ws}$re_synth${ws}$re_dtor${ws}$re_ctor${ws}$re_methods$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+, no "const" on "const char *" + # TODO: gdb.base/constvar.exp has XFAILed this kind of problem for a + # long time, but an XFAIL really needs an external bug report. + # -- chastain 2003-12-31 + # setup_xfail "*-*-*" + # fail "ptype foo_instance1" + # TODO: this should be a KFAIL. + pass "ptype foo_instance1 (shorter match)" + } + -re "type = $re_class${ws}$re_fields${ws}$re_synth${ws}$re_dtor${ws}$re_ctor${ws}$re_methods$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ if "const char *" ever gets fixed + pass "ptype foo_instance1" + } + -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$XX_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2, "~foo(int)" + # TODO: kfail this + # kfail "gdb/1113" "ptype foo_instance1" + pass "ptype foo_instance1 (shorter match)" + } + -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2, if the dtor bug gets fixed + # gcc HEAD -gdwarf-2 (abi-2) + # TODO: just pass this + pass "ptype foo_instance1 (shorter match)" + } + -re "type = $re_class${ws}$re_fields${ws}$re_synth${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + # TODO: enough with the "shorter match" + pass "ptype foo_instance1 (shorter match)" + } + -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$re_dtor${ws}$re_methods${ws}$re_synth$nl\}$nl$gdb_prompt $" { + # gcc HEAD -gstabs+ (abi-2) + pass "ptype foo_instance1 (shorter match)" + } +} + +# Print variables and method calls. +# This is a walk in the park. + +gdb_test "print foo_instance2" "\\$\[0-9\]+ = \{ifoo = 222, ccpfoo = $hex \"A\"\}" +gdb_test "print foo_instance3" "\\$\[0-9\]+ = \{ifoo = 222, ccpfoo = $hex \"A\"\}" + +gdb_test "print foo_instance1.overloadargs(1)" "\\$\[0-9\]+ = 1" \ + "print call overloaded func 1 arg" + +# If GDB fails to restore the selected frame properly after the +# inferior function call above (see GDB PR 1155 for an explanation of +# why this might happen), all the subsequent tests will fail. We +# should detect and report that failure, but let the marker call +# finish so that the rest of the tests can run undisturbed. + +gdb_test_multiple "frame" "re-selected 'main' frame after inferior call" { + -re "#0 marker1.*$gdb_prompt $" { + setup_kfail "gdb/1155" s390-*-linux-gnu + fail "re-selected 'main' frame after inferior call" + gdb_test "finish" ".*main.*at .*overload.cc:.*// marker1-returns-here.*" \ + "finish call to marker1" + } + -re "#1 ($hex in )?main.*$gdb_prompt $" { + pass "re-selected 'main' frame after inferior call" + } +} + +gdb_test "print foo_instance1.overloadargs(1, 2)" \ + "\\$\[0-9\]+ = 2" \ + "print call overloaded func 2 args" + +gdb_test "print foo_instance1.overloadargs(1, 2, 3)" \ + "\\$\[0-9\]+ = 3" \ + "print call overloaded func 3 args" + +gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4)" \ + "\\$\[0-9\]+ = 4" \ + "print call overloaded func 4 args" + +gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5)" \ + "\\$\[0-9\]+ = 5" \ + "print call overloaded func 5 args" + +gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6)" \ + "\\$\[0-9\]+ = 6" \ + "print call overloaded func 6 args" + +gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7)" \ + "\\$\[0-9\]+ = 7" \ + "print call overloaded func 7 args" + +gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8)" \ + "\\$\[0-9\]+ = 8" \ + "print call overloaded func 8 args" + +gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9)" \ + "\\$\[0-9\]+ = 9" \ + "print call overloaded func 9 args" + +gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)" \ + "\\$\[0-9\]+ = 10" \ + "print call overloaded func 10 args" + +gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)" \ + "\\$\[0-9\]+ = 11" \ + "print call overloaded func 11 args" + +gdb_test "print foo_instance1.overload1arg()" \ + "\\$\[0-9\]+ = 1" \ + "print call overloaded func void arg" + +gdb_test "print foo_instance1.overload1arg((char)arg2)" \ + "\\$\[0-9\]+ = 2" \ + "print call overloaded func char arg" + +gdb_test "print foo_instance1.overload1arg((signed char)arg3)" \ + "\\$\[0-9\]+ = 3" \ + "print call overloaded func signed char arg" + +gdb_test "print foo_instance1.overload1arg((unsigned char)arg4)" \ + "\\$\[0-9\]+ = 4" \ + "print call overloaded func unsigned char arg" + +gdb_test "print foo_instance1.overload1arg((short)arg5)" \ + "\\$\[0-9\]+ = 5" \ + "print call overloaded func short arg" + +gdb_test "print foo_instance1.overload1arg((unsigned short)arg6)" \ + "\\$\[0-9\]+ = 6" \ + "print call overloaded func unsigned short arg" + +gdb_test "print foo_instance1.overload1arg((int)arg7)" \ + "\\$\[0-9\]+ = 7" \ + "print call overloaded func int arg" + +gdb_test "print foo_instance1.overload1arg((unsigned int)arg8)" \ + "\\$\[0-9\]+ = 8" \ + "print call overloaded func unsigned int arg" + +gdb_test "print foo_instance1.overload1arg((long)arg9)" \ + "\\$\[0-9\]+ = 9" \ + "print call overloaded func long arg" + +gdb_test "print foo_instance1.overload1arg((unsigned long)arg10)" \ + "\\$\[0-9\]+ = 10" \ + "print call overloaded func unsigned long arg" + +gdb_test "print foo_instance1.overload1arg((float)arg11)" \ + "\\$\[0-9\]+ = 11" \ + "print call overloaded func float arg" + +gdb_test "print foo_instance1.overload1arg((double)arg12)" \ + "\\$\[0-9\]+ = 12" \ + "print call overloaded func double arg" + +# --- + +# List overloaded functions. + +# The void case is tricky because some compilers say "(void)" +# and some compilers say "()". + +gdb_test_no_output "set listsize 1" "" +gdb_test_multiple "info func overloadfnarg" "list overloaded function with no args" { + -re ".*overloadfnarg\\(void\\).*$gdb_prompt $" { + # gcc 2 + gdb_test "list foo::overloadfnarg(void)"\ + ".*int foo::overloadfnarg.*\\(void\\).*" \ + "list overloaded function with no args" + } + -re ".*overloadfnarg\\(\\).*$gdb_prompt $" { + # gcc 3 + gdb_test "list foo::overloadfnarg()"\ + ".*int foo::overloadfnarg.*\\(void\\).*" \ + "list overloaded function with no args" + } +} + +gdb_test "list foo::overloadfnarg(int)" \ + "int foo::overloadfnarg.*\\(int arg\\).*" \ + "list overloaded function with int arg" + +gdb_test "list foo::overloadfnarg(int, int (*)(int))" \ + "int foo::overloadfnarg.*\\(int arg, int \\(\\*foo\\) \\(int\\)\\).*" \ + "list overloaded function with function ptr args" + +gdb_test "list \"foo::overloadfnarg(int, int (*)(int))\"" \ + "int foo::overloadfnarg.*\\(int arg, int \\(\\*foo\\) \\(int\\)\\).*" \ + "list overloaded function with function ptr args - quotes around argument" + +# Test list with filename. + +gdb_test "list ${srcfile}:intToChar" "int intToChar.*" +gdb_test "list ${srcfile}:intToChar(char)" "int intToChar.*" +gdb_test "list ${srcfile}:'intToChar(char)'" "int intToChar.*" +gdb_test "list '${srcfile}:intToChar(char)'" "int intToChar.*" +gdb_test "list '${srcfile}':intToChar(char)" "int intToChar.*" +gdb_test "list '${srcfile}':'intToChar(char)'" "int intToChar.*" + +# And with filename and namespace... which does not work. + +setup_kfail gdb/11289 *-*-* +gdb_test "list ${srcfile}:foo::overloadfnarg(int)" "int foo::overloadfnarg" + +setup_kfail gdb/11289 *-*-* +gdb_test "list ${srcfile}:'foo::overloadfnarg(int)'" "int foo::overloadfnarg" + +# Now some tests to see how overloading and namespaces interact. + +gdb_test "print overloadNamespace(1)" ".\[0-9\]* = 1" +gdb_test "print overloadNamespace('a')" ".\[0-9\]* = 1" +gdb_test "print overloadNamespace(dummyInstance)" ".\[0-9\]* = 2" + +# Static methods. +gdb_test "print K::staticoverload ()" " = 1" +gdb_test "print K::staticoverload (2)" " = 2" +gdb_test "print K::staticoverload (2, 3)" " = 5" + +# Namespace-qualified functions. +gdb_test "print N::nsoverload ()" " = 1" +gdb_test "print N::nsoverload (2)" " = 2" +gdb_test "print N::nsoverload (2, 3)" " = 5" + +if ![runto 'XXX::marker2'] then { + perror "couldn't run to XXX::marker2" + continue +} + +gdb_test "print overloadNamespace(1)" ".\[0-9\]* = 3" "print overloadNamespace(1) in XXX" +gdb_test "print overloadNamespace('a')" ".\[0-9\]* = 3" "print overloadNamespace('a') in XXX" +gdb_test "print overloadNamespace(dummyInstance)" ".\[0-9\]* = 2" "print overloadNamespace(dummyInstance) in XXX" + +# One last mysterious test. +# I wonder what this is for? + +gdb_test "print intToChar(1)" "\\$\[0-9\]+ = 297" + +# Test expression evaluation with overloaded methods +gdb_test "print foo::overload1arg" \ + "non-unique member `overload1arg' requires type instantiation" \ + "print foo::overload1arg" + +gdb_test "print foo::overload1arg(char***)" \ + "no member function matches that type instantiation" \ + "print foo::overload1arg(char***)" + +gdb_test "print foo::overload1arg(void)" \ + "\\$$decimal = {int \\(foo \\*( const|)\\)} $hex " \ + "print foo::overload1arg(void)" + +foreach t [list char "signed char" "unsigned char" "short" \ + "unsigned short" int "unsigned int" long "unsigned long" \ + float double] { + gdb_test "print foo::overload1arg($t)" \ + "\\$$decimal = {int \\(foo \\*( const|), $t\\)} $hex " \ + "print foo::overload1arg($t)" +} Index: m-static.h =================================================================== --- m-static.h (nonexistent) +++ m-static.h (revision 513) @@ -0,0 +1,14 @@ +// 2002-08-16 + +class gnu_obj_4 +{ + public: + static const int elsewhere; + static const int nowhere; + static const int everywhere = 317; + static const float somewhere = 3.14159; + + // try to ensure test4 is actually allocated + int dummy; +}; +
m-static.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: extern-c.cc =================================================================== --- extern-c.cc (nonexistent) +++ extern-c.cc (revision 513) @@ -0,0 +1,38 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +extern "C" int c_func (void) +{ + return 0; /* Breakpoint in c_func. */ +} + +extern "C" int c_funcs_1 (void) +{ + return 1; /* Breakpoint in c_funcs_1. */ +} + +extern "C" int c_funcs_2 (void) +{ + return 2; /* Breakpoint in c_funcs_2. */ +} + +int main() +{ + c_func (); + c_funcs_1 (); + c_funcs_2 (); +} Index: call-c-1.c =================================================================== --- call-c-1.c (nonexistent) +++ call-c-1.c (revision 513) @@ -0,0 +1,19 @@ +/* This test script is part of GDB, the GNU debugger. + + Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +int foo(int x) { return x; }
call-c-1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: nsusing.cc =================================================================== --- nsusing.cc (nonexistent) +++ nsusing.cc (revision 513) @@ -0,0 +1,139 @@ +namespace M +{ + int x = 911; +} + +namespace N +{ + int x = 912; +} + +int marker10 () +{ + using namespace M; + int y = x + 1; // marker10 stop + using namespace N; + return y; +} + +namespace J +{ + int jx = 44; +} + +namespace K +{ + int marker9 () + { + //x; + return marker10 (); + } +} + +namespace L +{ + using namespace J; + int marker8 () + { + jx; + return K::marker9 (); + } +} + +namespace G +{ + namespace H + { + int ghx = 6; + } +} + +namespace I +{ + int marker7 () + { + using namespace G::H; + ghx; + return L::marker8 (); + } +} + +namespace E +{ + namespace F + { + int efx = 5; + } +} + +using namespace E::F; +int marker6 () +{ + efx; + return I::marker7 (); +} + +namespace A +{ + int _a = 1; + int x = 2; +} + +namespace C +{ + int cc = 3; +} + +namespace D +{ + int dx = 4; +} + +using namespace C; +int marker5 () +{ + cc; + return marker6 (); +} + +int marker4 () +{ + using D::dx; + return marker5 (); +} + +int marker3 () +{ + return marker4 (); +} + +int marker2 () +{ + namespace B = A; + B::_a; + return marker3 (); +} + +int marker1 () +{ + int total = 0; + { + int b = 1; + { + using namespace A; + int c = 2; + { + int d = 3; + total = _a + b + c + d + marker2 (); // marker1 stop + } + } + } + return marker2 () + total; +} + +int main () +{ + using namespace A; + _a; + return marker1 (); +} Index: gdb2384-base.h =================================================================== --- gdb2384-base.h (nonexistent) +++ gdb2384-base.h (revision 513) @@ -0,0 +1,35 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2008, 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +namespace B{ + int x; +} + +class base +{ + public: + base (int _x); + int x; + virtual int meth (); +}; + +class derived : public base +{ + public: + derived (int _x); +};
gdb2384-base.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: class2.cc =================================================================== --- class2.cc (nonexistent) +++ class2.cc (revision 513) @@ -0,0 +1,82 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2003, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +struct A +{ + virtual ~A (); + int a1; +}; + +A::~A() +{ + a1 = 800; +} + +struct B : public A +{ + virtual ~B (); + int b1; + int b2; +}; + +B::~B() +{ + a1 = 900; + b1 = 901; + b2 = 902; +} + +struct C : public B +{ + A *c1; + A *c2; +}; + +// Stop the compiler from optimizing away data. +void refer (A *) +{ + ; +} + +struct empty {}; + +// Stop the compiler from optimizing away data. +void refer (empty *) +{ + ; +} + +int main (void) +{ + A alpha, *aap, *abp, *acp; + B beta, *bbp; + C gamma; + empty e; + + alpha.a1 = 100; + beta.a1 = 200; beta.b1 = 201; beta.b2 = 202; + gamma.c1 = 0; gamma.c2 = (A *) ~0UL; + + aap = α refer (aap); + abp = β refer (abp); + bbp = β refer (bbp); + acp = γ refer (acp); + refer (&e); + + return 0; // marker return 0 +} // marker close brace Index: rtti.exp =================================================================== --- rtti.exp (nonexistent) +++ rtti.exp (revision 513) @@ -0,0 +1,145 @@ +# Copyright 2003, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the gdb testsuite. + +# This contains tests for GDB's use of RTTI information. This stems +# from a bug reported in PR gdb/488 and other places, which leads to +# statements like 'warning: can't find class named 'C::D', as given by +# C++ RTTI'. It arises from GDB not knowing about classes that are +# defined in namespaces. + +# NOTE: carlton/2003-05-16: I suspect it could arise from nested class +# issues, too, and even once we fix that, there might be situations +# (involving templates, in particular) where this problem triggers +# because GDB and GCC have different ideas what a class is called. + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + +# +# test running programs +# + +set testfile "rtti" +set srcfile1 "${testfile}1.cc" +set objfile1 "${testfile}1.o" +set srcfile2 "${testfile}2.cc" +set objfile2 "${testfile}2.o" +set binfile "${objdir}/${subdir}/${testfile}" + +if { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } { + untested rtti.exp + return -1 +} + +if { [gdb_compile "$srcdir/$subdir/$srcfile2" "$objdir/$subdir/$objfile2" object {debug c++}] != "" } { + untested rtti.exp + return -1 +} + +if { [gdb_compile "$objdir/$subdir/$objfile1 $objdir/$subdir/$objfile2" "${binfile}" executable {debug c++}] != "" } { + untested rtti.exp + return -1 +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +# First, run to after we've constructed the object: + +gdb_breakpoint [gdb_get_line_number "main-constructs-done" "$srcfile1"] +gdb_continue_to_breakpoint "end of constructors in main" + +gdb_test_multiple "print *e1" "print *e1" { + -re "warning: RTTI symbol not found for class 'n1::D1'.*$gdb_prompt $" { + # gdb HEAD 2003-12-05 + kfail "gdb/488" "print *e1" + } + -re "warning: can't find class named `n1::D1', as given by C\\+\\+ RTTI.*$gdb_prompt $" { + # gdb 6.0 + kfail "gdb/488" "print *e1" + } + -re "\\$\[0-9\]* = { = .*}\r\n$gdb_prompt $" { + pass "print *e1" + } + -re "\\$\[0-9\]* = { = .*}\r\n$gdb_prompt $" { + # NOTE: carlton/2003-05-16: If code is compiled by GCC2, we + # don't print the warning (for no particular reason), but we + # still call the class via the wrong name; PR gdb/57 is our + # catch-all PR for nested type problems. + kfail "gdb/57" "print *e1" + } +} + +# NOTE: carlton/2004-01-14: This test with an "" +# message because, within rtt1.cc, GDB has no way of knowing that the +# class is called 'n2::D2' instead of just 'D2'. This is an artifical +# test case, though: if we were using these classes in a more +# substantial way, G++ would emit more debug info. As is, I don't +# think there's anything that GDB can do about this case until G++ +# starts emitting DW_TAG_namespace info; this should arrive with GCC +# 3.4. + +gdb_test_multiple "print *e2" "print *e2" { + -re "warning: RTTI symbol not found for class 'n2::D2'.*$gdb_prompt $" { + # gdb HEAD 2003-12-05 + kfail "gdb/488" "print *e2" + } + -re "warning: can't find class named `n2::D2', as given by C\\+\\+ RTTI.*$gdb_prompt $" { + # gdb 6.0 + kfail "gdb/488" "print *e2" + } + -re "\\$\[0-9\]* = \r\n$gdb_prompt $" { + kfail "gdb/1511" "print *e2" + } + -re "\\$\[0-9\]* = { = .*}\r\n$gdb_prompt $" { + pass "print *e2" + } + -re "\\$\[0-9\]* = { = .*}\r\n$gdb_prompt $" { + kfail "gdb/57" "print *e2" + } +} + +# Now we test the hack that's been implemented to get around some +# instances of PR gdb/1511. + +gdb_breakpoint [gdb_get_line_number "func-constructs-done" "$srcfile1"] +gdb_continue_to_breakpoint "end of constructors in func" + +gdb_test "print *obj" "\\$\[0-9\]* = { = .*}" + +gdb_breakpoint [gdb_get_line_number "func3-constructs-done" "$srcfile1"] +gdb_continue_to_breakpoint "end of constructors in func3" + +gdb_test "print *obj3" "\\$\[0-9\]* = { = .*}" + +gdb_exit +return 0 Index: pr10728-y.cc =================================================================== --- pr10728-y.cc (nonexistent) +++ pr10728-y.cc (revision 513) @@ -0,0 +1,11 @@ +#include "pr10728-x.h" +struct Y{}; + +X* y() +{ + static X xx; + static Y yy; + xx.y1 = &yy; + xx.y2 = xx.y1+1; + return &xx; +} Index: local.cc =================================================================== --- local.cc (nonexistent) +++ local.cc (revision 513) @@ -0,0 +1,66 @@ +// Tests for local types + +void marker1 (void) +{ +} + +void marker2 (void) +{ +} + +int foobar (int x) +{ + class Local { + public: + int loc1; + char loc_foo (char c) + { + return c + 3; + } + }; + + Local l; + static Local l1; + char c; + + marker1 (); + + l.loc1 = 23; + + c = l.loc_foo('x'); + return c + 2; +} + +int main() +{ + int c; + + c = foobar (31); + + { // inner block + class InnerLocal { + public: + char ilc; + int * ip; + int il_foo (unsigned const char & uccr) + { + return uccr + 333; + } + class NestedInnerLocal { + public: + int nil; + int nil_foo (int i) + { + return i * 27; + } + }; + NestedInnerLocal nest1; + }; + + InnerLocal il; + + il.ilc = 'b'; + il.ip = &c; + marker2(); + } +} Index: pr10728-x.h =================================================================== --- pr10728-x.h (nonexistent) +++ pr10728-x.h (revision 513) @@ -0,0 +1,9 @@ +struct Y; +struct X +{ + Y* y1; + Y* y2; +}; + +X* y(); +
pr10728-x.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: cpexprs.exp =================================================================== --- cpexprs.exp (nonexistent) +++ cpexprs.exp (revision 513) @@ -0,0 +1,727 @@ +# cpexprs.exp - C++ expressions tests +# +# Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +# +# Contributed by Red Hat, originally written by Keith Seitz. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the gdb testsuite. + +# A helper proc which sets a breakpoint at FUNC and attempts to +# run to the breakpoint. +proc test_breakpoint {func} { + global DEC + + # Restart every time + if {![runto_main]} { + perror "could not run to main when attempting to break at $func" + } else { + gdb_breakpoint "$func" + set i [expr {[string last : $func] + 1}] + set efunc [string_to_regexp [string range $func $i end]] + gdb_test "continue" \ + "Continuing.\r\n\r\nBreakpoint $DEC+,.*$efunc.*" \ + "continue to $func" + } +} + +# Add a function to the list of tested functions +# FUNC is the name of the function (which will be passed to gdb commands) +# TYPE is the type of the function, as expected from the "print" command +# PRINT is the name of the function, as expected result of the print command +# *OR* "-", indicating that FUNC should be used (needed for virtual/inherited +# funcs) +# LST is either the expected result of the list command (the comment from +# the source code) *OR* "-", in which case FUNC will be used +# +# Usage: +# add NAME TYPE PRINT LST +# add NAME TYPE PRINT - +proc add {func type print lst} { + global all_functions CONVAR ADDR + + set all_functions($func,type) $type + if {$print == "-"} { + set print $func + } + + # An exception: since gdb canonicalizes C++ output, + # "(void)" must be mutated to "()". + regsub {\(void\)} $print {()} print + + set all_functions($func,print) \ + "$CONVAR = {[string_to_regexp $type]} $ADDR <[string_to_regexp $print].*>" + if {$lst == "-"} { + set lst "$func" + } + set all_functions($func,list) ".*// [string_to_regexp $lst]" +} + +proc get {func cmd} { + global all_functions + return $all_functions($func,$cmd) +} + +# Returns a list of function names for a given command +proc get_functions {cmd} { + global all_functions + set result {} + foreach i [array names all_functions *,$cmd] { + if {$all_functions($i) != ""} { + set idx [string last , $i] + if {$idx != -1} { + lappend result [string range $i 0 [expr {$idx - 1}]] + } + } + } + + return [lsort $result] +} + +# Some convenience variables for this test +set DEC {[0-9]}; # a decimal number +set HEX {[0-9a-fA-F]}; # a hexidecimal number +set CONVAR "\\\$$DEC+"; # convenience variable regexp +set ADDR "0x$HEX+"; # address + +# An array of functions/methods that we are testing... +# Each element consists is indexed by NAME,COMMAND, where +# NAME is the function name and COMMAND is the gdb command that +# we are testing. The value of the array for any index pair is +# the expected result of running COMMAND with the NAME as argument. + +# The array holding all functions/methods to test. Valid subindexes +# are (none need character escaping -- "add" will take care of that): + +# add name type print_name list +# NAME,type: value is type of function +# NAME,print: value is print name of function (careful w/inherited/virtual!) +# NAME,list: value is comment in source code on first line of function +# (without the leading "//") +array set all_functions {} + +# "Normal" functions/methods +add {main} \ + {int (int, char **)} \ + - \ + - +add {derived::a_function} \ + {void (const derived * const)} \ + - \ + - +add {base1::a_function} \ + {void (const base1 * const)} \ + - \ + - +add {base2::a_function} \ + {void (const base2 * const)} \ + - \ + - + +# Constructors + +# On targets using the ARM EABI, the constructor is expected to return +# "this". +proc ctor { type arglist } { + if { [istarget arm*-*eabi*] } { + set ret "$type *" + } else { + set ret "void " + } + if { $arglist != "" } { + set arglist ", $arglist" + } + return "${ret}($type * const$arglist)" +} + +add {derived::derived} \ + [ctor derived ""] \ + - \ + - +add {base1::base1(void)} \ + [ctor base1 "const void ** const"] \ + - \ + - +add {base1::base1(int)} \ + [ctor base1 "int"] \ + - \ + - +add {base2::base2} \ + [ctor base2 "const void ** const"] \ + - \ + - +add {base::base(void)} \ + [ctor base ""] \ + - \ + - +add {base::base(int)} \ + [ctor base "int"] \ + - \ + - + +# Destructors + +# On targets using the ARM EABI, some destructors are expected +# to return "this". Others are void. For internal reasons, +# GCC returns void * instead of $type *; RealView appears to do +# the same. +proc dtor { type } { + if { [istarget arm*-*eabi*] } { + set ret "void *" + } else { + set ret "void " + } + return "${ret}($type * const)" +} + +add {base::~base} \ + [dtor base] \ + - \ + - + +# Overloaded methods (all are const -- we try to use the void +# method with and without specifying "const") +add {base::overload(void)} \ + {int (const base * const)} \ + - \ + {base::overload(void) const} +add {base::overload(void) const} \ + {int (const base * const)} \ + - \ + {base::overload(void) const} +add {base::overload(int) const} \ + {int (const base * const, int)} \ + - \ + - +add {base::overload(short) const} \ + {int (const base * const, short)} \ + - \ + - +add {base::overload(long) const} \ + {int (const base * const, long)} \ + - \ + - +add {base::overload(char*) const} \ + {int (const base * const, char *)} \ + - \ + - +add {base::overload(base&) const} \ + {int (const base * const, base &)} \ + - \ + - + +# Operators +add {base::operator+} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator++} \ + {base (base * const)} \ + - \ + - +add {base::operator+=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator-} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator--} \ + {base (base * const)} \ + - \ + - +add {base::operator-=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator*} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator*=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator/} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator/=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator%} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator%=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator<} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator<=} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator>} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator>=} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator!=} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator==} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator!} \ + {bool (const base * const)} \ + - \ + - +add {base::operator&&} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator||} \ + {bool (const base * const, const base &)} \ + - \ + - +add {base::operator<<} \ + {int (const base * const, int)} \ + - \ + - +add {base::operator<<=} \ + {base (base * const, int)} \ + - \ + - +add {base::operator>>} \ + {int (const base * const, int)} \ + - \ + - +add {base::operator>>=} \ + {base (base * const, int)} \ + - \ + - +add {base::operator~} \ + {int (const base * const)} \ + - \ + - +add {base::operator&} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator&=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator|} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator|=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator^} \ + {int (const base * const, const base &)} \ + - \ + - +add {base::operator^=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator=} \ + {base (base * const, const base &)} \ + - \ + - +add {base::operator()} \ + {void (const base * const)} \ + - \ + - +add {base::operator[]} \ + {int (const base * const, int)} \ + - \ + - +add {base::operator new} \ + {void *(size_t)} \ + - \ + - +add {base::operator delete} \ + {void (void *)} \ + - \ + - +add {base::operator new[]} \ + {void *(size_t)} \ + - \ + - +add {base::operator delete[]} \ + {void (void *)} \ + - \ + - +add {base::operator char*} \ + {char *(const base * const)} \ + - \ + - +add {base::operator fluff*} \ + {fluff *(const base * const)} \ + - \ + - +add {base::operator fluff**} \ + {fluff **(const base * const)} \ + - \ + - +add {base::operator int} \ + {int (const base * const)} \ + - \ + - + +# Templates +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + - +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + - +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + - +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + - +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + - +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {flubber} \ + {void (void)} \ + - \ + flubber +add {tclass::do_something} \ + {void (tclass * const)} \ + - \ + {tclass::do_something} +add {policy1::policy} \ + [ctor "policy >" "int"] \ + {policy >::policy} \ + {policy::policy} +add {policy2::policy} \ + [ctor "policy >" int] \ + {policy >::policy} \ + {policy::policy} +add {policy3::policy} \ + [ctor "policy >" "int"] \ + {policy >::policy} \ + {policy::policy} +add {policy4::policy} \ + [ctor "policy >" "int"] \ + {policy >::policy} \ + {policy::policy} +add {policy1::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policy2::function} \ + {void (void)} \ + {operation_2::function} \ + {operation_2::function} +add {policy3::function} \ + {void (void)} \ + {operation_3::function} \ + {operation_3::function} +add {policy4::function} \ + {void (void)} \ + {operation_4::function} \ + {operation_4::function} +add {policyd >::policyd} \ + [ctor "policyd >" "int"] \ + - \ + {policyd::policyd} +add {policyd1::policyd} \ + [ctor "policyd >" "int"] \ + {policyd >::policyd} \ + {policyd::policyd} +add {policyd >::~policyd} \ + [dtor "policyd >"] \ + - \ + {policyd::~policyd} +add {policyd1::~policyd} \ + [dtor "policyd >"] \ + {policyd >::~policyd} \ + {policyd::~policyd} +add {policyd >::policyd} \ + [ctor "policyd >" "long"] \ + - \ + {policyd::policyd} +add {policyd2::policyd} \ + [ctor "policyd >" "long"] \ + {policyd >::policyd} \ + {policyd::policyd} +add {policyd >::~policyd} \ + [dtor "policyd >"] \ + - \ + {policyd::~policyd} +add {policyd2::~policyd} \ + [dtor "policyd >"] \ + {policyd >::~policyd} \ + {policyd::~policyd} +add {policyd >::policyd} \ + [ctor "policyd >" "char"] \ + - \ + {policyd::policyd} +add {policyd3::policyd} \ + [ctor "policyd >" "char"] \ + {policyd >::policyd} \ + {policyd::policyd} +add {policyd >::~policyd} \ + [dtor "policyd >"] \ + - \ + {policyd::~policyd} +add {policyd3::~policyd} \ + [dtor "policyd >"] \ + {policyd >::~policyd} \ + {policyd::~policyd} +add {policyd >::policyd} \ + [ctor "policyd >" "base"] \ + - \ + {policyd::policyd} +add {policyd4::policyd} \ + [ctor "policyd >" "base"] \ + {policyd >::policyd} \ + {policyd::policyd} +add {policyd >::~policyd} \ + [dtor "policyd >"] \ + - \ + {policyd::~policyd} +add {policyd4::~policyd} \ + [dtor "policyd >"] \ + {policyd >::~policyd} \ + {policyd::~policyd} +add {policyd, operation_1 > >::policyd} \ + [ctor "policyd, operation_1 > >" "tclass"] \ + - \ + {policyd::policyd} +add {policyd5::policyd} \ + [ctor "policyd, operation_1 > >" "tclass"] \ + {policyd, operation_1 > >::policyd} \ + {policyd::policyd} +add {policyd, operation_1 > >::~policyd} \ + [dtor "policyd, operation_1 > >"] \ + - \ + {policyd::~policyd} +add {policyd5::~policyd} \ + [dtor "policyd, operation_1 > >"] \ + {policyd, operation_1 > >::~policyd} \ + {policyd::~policyd} +add {policyd >::function} \ + {void (void)} \ + {operation_1::function}\ + {operation_1::function} +add {policyd1::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd2::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd >::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd3::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd >::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd4::function} \ + {void (void)} \ + {operation_1::function} \ + {operation_1::function} +add {policyd, operation_1 > >::function} \ + {void (void)} \ + {operation_1 >::function} \ + {operation_1::function} +add {policyd5::function} \ + {void (void)} \ + {operation_1 >::function} \ + {operation_1::function} + +# Start the test +if {$tracelevel} { + strace $tracelevel +} + +if {[skip_cplus_tests]} { continue } + +# On SPU this test fails because the executable exceeds local storage size. +if { [istarget "spu*-*-*"] } { + return 0 +} + +# +# test running programs +# + +set testfile "cpexprs" +set srcfile "${testfile}.cc" +set binfile [file join $objdir $subdir $testfile] + +if {[gdb_compile [file join $srcdir $subdir $srcfile] $binfile \ + executable {debug c++}] != "" } { + untested "$testfile.exp" + return -1 +} + +if {[get_compiler_info $binfile "c++"]} { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir [file join $srcdir $subdir] +gdb_load $binfile + +if {![runto_main]} { + perror "couldn't run to breakpoint" + continue +} + +# Set the listsize to one. This will help with testing "list". +gdb_test "set listsize 1" + +# "print METHOD" +foreach name [get_functions print] { + gdb_test "print $name" [get $name print] "print $name" +} + +# "list METHOD" +foreach name [get_functions list] { + gdb_test "list $name" [get $name list] "list $name" +} + +# Running to breakpoint -- use any function we can "list" +foreach name [get_functions list] { + # Skip "main", since test_breakpoint uses it + if {[string compare $name "main"] != 0} { + test_breakpoint $name + } +} + +gdb_exit +return 0 Index: misc.cc =================================================================== --- misc.cc (nonexistent) +++ misc.cc (revision 513) @@ -0,0 +1,606 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2007, 2008, + 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +// Test various -*- C++ -*- things. + +// ====================== basic C++ types ======================= +bool v_bool; +bool v_bool_array[2]; + +typedef struct fleep fleep; +struct fleep { int a; } s; + +// ====================== simple class structures ======================= + +struct default_public_struct { + // defaults to public: + int a; + int b; +}; + +struct explicit_public_struct { + public: + int a; + int b; +}; + +struct protected_struct { + protected: + int a; + int b; +}; + +struct private_struct { + private: + int a; + int b; +}; + +struct mixed_protection_struct { + public: + int a; + int b; + private: + int c; + int d; + protected: + int e; + int f; + public: + int g; + private: + int h; + protected: + int i; +}; + +class public_class { + public: + int a; + int b; +}; + +class protected_class { + protected: + int a; + int b; +}; + +class default_private_class { + // defaults to private: + int a; + int b; +}; + +class explicit_private_class { + private: + int a; + int b; +}; + +class mixed_protection_class { + public: + int a; + int b; + private: + int c; + int d; + protected: + int e; + int f; + public: + int g; + private: + int h; + protected: + int i; +}; + +class const_vol_method_class { +public: + int a; + int b; + int foo (int &) const; + int bar (int &) volatile; + int baz (int &) const volatile; +}; + +int const_vol_method_class::foo (int & ir) const +{ + return ir + 3; +} +int const_vol_method_class::bar (int & ir) volatile +{ + return ir + 4; +} +int const_vol_method_class::baz (int & ir) const volatile +{ + return ir + 5; +} + +// ========================= simple inheritance ========================== + +class A { + public: + int a; + int x; +}; + +A g_A; + +class B : public A { + public: + int b; + int x; +}; + +B g_B; + +class C : public A { + public: + int c; + int x; +}; + +C g_C; + +class D : public B, public C { + public: + int d; + int x; +}; + +D g_D; + +class E : public D { + public: + int e; + int x; +}; + +E g_E; + +class class_with_anon_union +{ + public: + int one; + union + { + int a; + long b; + }; +}; + +class_with_anon_union g_anon_union; + +void inheritance2 (void) +{ +} + +void inheritance1 (void) +{ + int ival; + int *intp; + + // {A::a, A::x} + + g_A.A::a = 1; + g_A.A::x = 2; + + // {{A::a,A::x},B::b,B::x} + + g_B.A::a = 3; + g_B.A::x = 4; + g_B.B::b = 5; + g_B.B::x = 6; + + // {{A::a,A::x},C::c,C::x} + + g_C.A::a = 7; + g_C.A::x = 8; + g_C.C::c = 9; + g_C.C::x = 10; + + // {{{A::a,A::x},B::b,B::x},{{A::a,A::x},C::c,C::x},D::d,D::x} + + // The following initialization code is non-portable, but allows us + // to initialize all members of g_D until we can fill in the missing + // initialization code with legal C++ code. + + for (intp = (int *) &g_D, ival = 11; + intp < ((int *) &g_D + sizeof (g_D) / sizeof (int)); + intp++, ival++) + { + *intp = ival; + } + + // Overlay the nonportable initialization with legal initialization. + + // ????? = 11; (g_D.A::a = 11; is ambiguous) + // ????? = 12; (g_D.A::x = 12; is ambiguous) +/* djb 6-3-2000 + + This should take care of it. Rather than try to initialize using an ambiguous + construct, use 2 unambiguous ones for each. Since the ambiguous a/x member is + coming from C, and B, initialize D's C::a, and B::a, and D's C::x and B::x. + */ + g_D.C::a = 15; + g_D.C::x = 12; + g_D.B::a = 11; + g_D.B::x = 12; + g_D.B::b = 13; + g_D.B::x = 14; + // ????? = 15; + // ????? = 16; + g_D.C::c = 17; + g_D.C::x = 18; + g_D.D::d = 19; + g_D.D::x = 20; + + + // {{{{A::a,A::x},B::b,B::x},{{A::a,A::x},C::c,C::x},D::d,D::x}},E::e,E::x} + + // The following initialization code is non-portable, but allows us + // to initialize all members of g_D until we can fill in the missing + // initialization code with legal C++ code. + + for (intp = (int *) &g_E, ival = 21; + intp < ((int *) &g_E + sizeof (g_E) / sizeof (int)); + intp++, ival++) + { + *intp = ival; + } + + // Overlay the nonportable initialization with legal initialization. + + // ????? = 21; (g_E.A::a = 21; is ambiguous) + // ????? = 22; (g_E.A::x = 22; is ambiguous) + g_E.B::b = 23; + g_E.B::x = 24; + // ????? = 25; + // ????? = 26; + g_E.C::c = 27; + g_E.C::x = 28; + g_E.D::d = 29; + g_E.D::x = 30; + g_E.E::e = 31; + g_E.E::x = 32; + + g_anon_union.one = 1; + g_anon_union.a = 2; + + inheritance2 (); +} + +// ======================== static member functions ===================== + +class Static { +public: + static void ii(int, int); +}; +void Static::ii (int, int) { } + +// ======================== virtual base classes========================= + +class vA { + public: + int va; + int vx; +}; + +vA g_vA; + +class vB : public virtual vA { + public: + int vb; + int vx; +}; + +vB g_vB; + +class vC : public virtual vA { + public: + int vc; + int vx; +}; + +vC g_vC; + +class vD : public virtual vB, public virtual vC { + public: + int vd; + int vx; +}; + +vD g_vD; + +class vE : public virtual vD { + public: + int ve; + int vx; +}; + +vE g_vE; + +void inheritance4 (void) +{ +} + +void inheritance3 (void) +{ + int ival; + int *intp; + + // {vA::va, vA::vx} + + g_vA.vA::va = 1; + g_vA.vA::vx = 2; + + // {{vA::va, vA::vx}, vB::vb, vB::vx} + + g_vB.vA::va = 3; + g_vB.vA::vx = 4; + g_vB.vB::vb = 5; + g_vB.vB::vx = 6; + + // {{vA::va, vA::vx}, vC::vc, vC::vx} + + g_vC.vA::va = 7; + g_vC.vA::vx = 8; + g_vC.vC::vc = 9; + g_vC.vC::vx = 10; + + // {{{{vA::va, vA::vx}, vB::vb, vB::vx}, vC::vc, vC::vx}, vD::vd,vD::vx} + + g_vD.vA::va = 11; + g_vD.vA::vx = 12; + g_vD.vB::vb = 13; + g_vD.vB::vx = 14; + g_vD.vC::vc = 15; + g_vD.vC::vx = 16; + g_vD.vD::vd = 17; + g_vD.vD::vx = 18; + + + // {{{{{vA::va,vA::vx},vB::vb,vB::vx},vC::vc,vC::vx},vD::vd,vD::vx},vE::ve,vE::vx} + + g_vD.vA::va = 19; + g_vD.vA::vx = 20; + g_vD.vB::vb = 21; + g_vD.vB::vx = 22; + g_vD.vC::vc = 23; + g_vD.vC::vx = 24; + g_vD.vD::vd = 25; + g_vD.vD::vx = 26; + g_vE.vE::ve = 27; + g_vE.vE::vx = 28; + + inheritance4 (); +} + +// ====================================================================== + +class Base1 { + public: + int x; + Base1(int i) { x = i; } +}; + +class Foo +{ + public: + int x; + int y; + static int st; + Foo (int i, int j) { x = i; y = j; } + int operator! (); + operator int (); + int times (int y); +}; + +class Bar : public Base1, public Foo { + public: + int z; + Bar (int i, int j, int k) : Base1 (10*k), Foo (i, j) { z = k; } +}; + +int Foo::operator! () { return !x; } + +int Foo::times (int y) { return x * y; } + +int Foo::st = 100; + +Foo::operator int() { return x; } + +Foo foo(10, 11); +Bar bar(20, 21, 22); + +class ClassWithEnum { +public: + enum PrivEnum { red, green, blue, yellow = 42 }; + PrivEnum priv_enum; + int x; +}; + +void enums2 (void) +{ +} + +/* classes.exp relies on statement order in this function for testing + enumeration fields. */ + +void enums1 () +{ + ClassWithEnum obj_with_enum; + obj_with_enum.priv_enum = ClassWithEnum::red; + obj_with_enum.x = 0; + enums2 (); + obj_with_enum.priv_enum = ClassWithEnum::green; +} + +class ClassParam { +public: + int Aptr_a (A *a) { return a->a; } + int Aptr_x (A *a) { return a->x; } + int Aref_a (A &a) { return a.a; } + int Aref_x (A &a) { return a.x; } + int Aval_a (A a) { return a.a; } + int Aval_x (A a) { return a.x; } +}; + +ClassParam class_param; + +class Contains_static_instance +{ + public: + int x; + int y; + Contains_static_instance (int i, int j) { x = i; y = j; } + static Contains_static_instance null; +}; + +Contains_static_instance Contains_static_instance::null(0,0); +Contains_static_instance csi(10,20); + +class Contains_nested_static_instance +{ + public: + class Nested + { + public: + Nested(int i) : z(i) {} + int z; + static Contains_nested_static_instance xx; + }; + + Contains_nested_static_instance(int i, int j) : x(i), y(j) {} + + int x; + int y; + + static Contains_nested_static_instance null; + static Nested yy; +}; + +Contains_nested_static_instance Contains_nested_static_instance::null(0, 0); +Contains_nested_static_instance::Nested Contains_nested_static_instance::yy(5); +Contains_nested_static_instance + Contains_nested_static_instance::Nested::xx(1,2); +Contains_nested_static_instance cnsi(30,40); + +typedef struct { + int one; + int two; +} tagless_struct; +tagless_struct v_tagless; + +/* Try to get the compiler to allocate a class in a register. */ +class small { + public: + int x; + int method (); +}; + +int +small::method () +{ + return x + 5; +} + +void marker_reg1 () {} + +int +register_class () +{ + /* We don't call any methods for v, so gcc version cygnus-2.3.3-930220 + might put this variable in a register. This is a lose, though, because + it means that GDB can't call any methods for that variable. */ + register small v; + + int i; + + /* Perform a computation sufficiently complicated that optimizing compilers + won't optimized out the variable. If some compiler constant-folds this + whole loop, maybe using a parameter to this function here would help. */ + v.x = 0; + for (i = 0; i < 13; ++i) + v.x += i; + --v.x; /* v.x is now 77 */ + marker_reg1 (); + return v.x + 5; +} + +void dummy() +{ + v_bool = true; + v_bool_array[0] = false; + v_bool_array[1] = v_bool; +} + +void use_methods () +{ + /* Refer to methods so that they don't get optimized away. */ + int i; + i = class_param.Aptr_a (&g_A); + i = class_param.Aptr_x (&g_A); + i = class_param.Aref_a (g_A); + i = class_param.Aref_x (g_A); + i = class_param.Aval_a (g_A); + i = class_param.Aval_x (g_A); +} + + +int +main() +{ +#ifdef usestubs + set_debug_traps(); + breakpoint(); +#endif + dummy(); + inheritance1 (); + inheritance3 (); + enums1 (); + register_class (); + + /* FIXME: pmi gets optimized out. Need to do some more computation with + it or something. (No one notices, because the test is xfail'd anyway, + but that probably won't always be true...). */ + int Foo::* pmi = &Foo::y; + + /* Make sure the AIX linker doesn't remove the variable. */ + v_tagless.one = 5; + + use_methods (); + + return foo.*pmi; +} + +/* Create an instance for some classes, otherwise they get optimized away. */ + +default_public_struct default_public_s; +explicit_public_struct explicit_public_s; +protected_struct protected_s; +private_struct private_s; +mixed_protection_struct mixed_protection_s; +public_class public_c; +protected_class protected_c; +default_private_class default_private_c; +explicit_private_class explicit_private_c; +mixed_protection_class mixed_protection_c; Index: cplusfuncs.exp =================================================================== --- cplusfuncs.exp (nonexistent) +++ cplusfuncs.exp (revision 513) @@ -0,0 +1,622 @@ +# Copyright 1992, 1997, 1999, 2001, 2002, 2003, 2004, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file was written by Fred Fish. (fnf@cygnus.com) +# Adapted for g++ 3.0 ABI by Michael Chastain. (chastain@redhat.com) + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +set testfile "cplusfuncs" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [get_compiler_info $binfile "c++"] } { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested cplusfuncs.exp + return -1 +} + +# +# g++ changed its ABI between 2.95 and 3.0. gdb has two demanglers +# for the two different styles. The two demanglers have some subtle +# discrepancies in their output. +# +# old demangler new demangler +# --- --------- --- --------- +# "operator, " "operator," +# "char *" "char*" +# "int *" "int*" +# "long *" "long*" +# "void *" "void*" +# "foo &" "foo&" +# "unsigned int" "unsigned" +# "void" "" +# +# I probe for the forms in use. +# The defaults are for the v3 demangler (as of 2001-02-13). +# + +set dm_operator_comma "," +set dm_type_char_star "char*" +set dm_type_char_star_quoted "char\\*" +set dm_type_foo_ref "foo&" +set dm_type_int_star "int*" +set dm_type_long_star "long*" +set dm_type_unsigned_int "unsigned" +set dm_type_void "void" +set dm_type_void_star "void*" + +# Some other vagaries of GDB's type printing machinery. The integer types +# may have unsigned before or after their length, and may have "int" +# appended. The char* conversion operator may have name "char*" even if +# the type is "char *", because the name comes from the debug information +# and the type from GDB. Function types may not see through typedefs. + +set dm_type_short "short" +set dm_type_long "long" +set dm_type_unsigned_short "unsigned short" +set dm_type_unsigned_long "unsigned long" +set dm_operator_char_star "char*" +set dm_operator_char_star_quoted "char\\*" +set dm_type_typedef 0 + +proc probe_demangler { } { + global gdb_prompt + global dm_operator_comma + global dm_operator_char_star + global dm_operator_char_star_quoted + global dm_type_char_star + global dm_type_char_star_quoted + global dm_type_foo_ref + global dm_type_int_star + global dm_type_long_star + global dm_type_unsigned_int + global dm_type_void + global dm_type_void_star + global dm_type_short + global dm_type_unsigned_short + global dm_type_long + global dm_type_unsigned_long + global dm_type_typedef + + gdb_test_multiple "print &foo::operator,(foo&)" \ + "detect dm_operator_comma" { + -re ".*foo::operator, \\(.*foo.*&.*\\).*\r\n$gdb_prompt $" { + # v2 demangler + set dm_operator_comma ", " + pass "detect dm_operator_comma" + } + -re ".*foo::operator,\\(.*foo.*&.*\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_operator_comma" + } + } + + gdb_test_multiple "print &foo::operator char*($dm_type_void)" \ + "detect dm_operator_char_star" { + -re ".*foo::operator char \\*\\(void\\).*\r\n$gdb_prompt $" { + # v2 demangler or GDB type printer + set dm_operator_char_star "char *" + set dm_operator_char_star_quoted "char \\*" + pass "detect dm_operator_char_star" + } + -re ".*foo::operator char\\*\\(\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_operator_char_star" + } + } + + gdb_test_multiple "print &dm_type_char_star" \ + "detect dm_type_char_star" { + -re ".*dm_type_char_star\\(char \\*\\).*\r\n$gdb_prompt $" { + # v2 demangler + set dm_type_char_star "char *" + set dm_type_char_star_quoted "char \\*" + pass "detect dm_type_char_star" + } + -re ".*dm_type_char_star\\(char\\*\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_type_char_star" + } + } + + gdb_test_multiple "print &dm_type_foo_ref" \ + "detect dm_type_foo_ref" { + -re ".*dm_type_foo_ref\\(foo &\\).*\r\n$gdb_prompt $" { + # v2 demangler + set dm_type_foo_ref "foo &" + pass "detect dm_type_foo_ref" + } + -re ".*dm_type_foo_ref\\(foo&\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_type_foo_ref" + } + } + + gdb_test_multiple "print &dm_type_int_star" \ + "detect dm_type_int_star" { + -re ".*dm_type_int_star\\(int \\*\\).*\r\n$gdb_prompt $" { + # v2 demangler + set dm_type_int_star "int *" + pass "detect dm_type_int_star" + } + -re ".*dm_type_int_star\\(int\\*\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_type_int_star" + } + } + + gdb_test_multiple "print &dm_type_long_star" \ + "detect dm_type_long_star" { + -re ".*dm_type_long_star\\(long \\*\\).*\r\n$gdb_prompt $" { + # v2 demangler + set dm_type_long_star "long *" + pass "detect dm_type_long_star" + } + -re ".*dm_type_long_star\\(long\\*\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_type_long_star" + } + -re ".*dm_type_long_star\\(long int \\*\\).*\r\n$gdb_prompt $" { + # GCC v3 and GDB's type printer + set dm_type_long_star "long int *" + pass "detect dm_type_long_star" + } + } + + gdb_test_multiple "print &dm_type_unsigned_int" \ + "detect dm_type_unsigned_int" { + -re ".*dm_type_unsigned_int\\(unsigned int\\).*\r\n$gdb_prompt $" { + # v2 demangler + set dm_type_unsigned_int "unsigned int" + pass "detect dm_type_unsigned_int" + } + -re ".*dm_type_unsigned_int\\(unsigned\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_type_unsigned_int" + } + } + + gdb_test_multiple "print &dm_type_void" \ + "detect dm_type_void" { + -re ".*dm_type_void\\(void\\).*\r\n$gdb_prompt $" { + # v2 demangler + set dm_type_void "void" + pass "detect dm_type_void" + } + -re ".*dm_type_void\\(\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_type_void" + } + } + + gdb_test_multiple "print &dm_type_void_star" \ + "detect dm_type_void_star" { + -re ".*dm_type_void_star\\(void \\*\\).*\r\n$gdb_prompt $" { + # v2 demangler + set dm_type_void_star "void *" + pass "detect dm_type_void_star" + } + -re ".*dm_type_void_star\\(void\\*\\).*\r\n$gdb_prompt $" { + # v3 demangler + pass "detect dm_type_void_star" + } + } + + gdb_test_multiple "print &dm_type_short" \ + "detect dm_type_short" { + -re ".*dm_type_short\\(short\\).*\r\n$gdb_prompt $" { + # v2 and v3 demanglers + pass "detect dm_type_short" + } + -re ".*dm_type_short\\(short int\\).*\r\n$gdb_prompt $" { + # GDB type printer + set dm_type_short "short int" + pass "detect dm_type_short" + } + } + + gdb_test_multiple "print &dm_type_unsigned_short" \ + "detect dm_type_unsigned_short" { + -re ".*dm_type_unsigned_short\\(unsigned short\\).*\r\n$gdb_prompt $" { + # v2 and v3 demanglers + pass "detect dm_type_unsigned_short" + } + -re ".*dm_type_unsigned_short\\(short unsigned int\\).*\r\n$gdb_prompt $" { + # GDB type printer + set dm_type_unsigned_short "short unsigned int" + pass "detect dm_type_unsigned_short" + } + } + + gdb_test_multiple "print &dm_type_long" \ + "detect dm_type_long" { + -re ".*dm_type_long\\(long\\).*\r\n$gdb_prompt $" { + # v2 and v3 demanglers + pass "detect dm_type_long" + } + -re ".*dm_type_long\\(long int\\).*\r\n$gdb_prompt $" { + # GDB type printer + set dm_type_long "long int" + pass "detect dm_type_long" + } + } + + gdb_test_multiple "print &dm_type_unsigned_long" \ + "detect dm_type_unsigned_long" { + -re ".*dm_type_unsigned_long\\(unsigned long\\).*\r\n$gdb_prompt $" { + # v2 and v3 demanglers + pass "detect dm_type_unsigned_long" + } + -re ".*dm_type_unsigned_long\\(long unsigned int\\).*\r\n$gdb_prompt $" { + # GDB type printer + set dm_type_unsigned_long "long unsigned int" + pass "detect dm_type_unsigned_long" + } + } + + gdb_test_multiple "print &dm_type_typedef" \ + "detect dm_type_typedef" { + -re ".*dm_type_typedef\\(int\\).*\r\n$gdb_prompt $" { + # v2 and v3 demanglers + pass "detect dm_type_typedef" + } + -re ".*dm_type_typedef\\(myint\\).*\r\n$gdb_prompt $" { + # GDB type printer + set dm_type_typedef 1 + pass "detect dm_type_typedef" + } + } +} + +# +# Lookup a specific C++ function and print the demangled type. +# This form accepts the demangled type as a regexp. +# + +proc info_func_regexp { name demangled } { + global gdb_prompt + + regsub {\\\(void\\\)} $demangled {\(\)} demangled + + gdb_test "info function $name" \ + "File .*:\r\n(class|)${demangled}.*" \ + "info function for \"$name\"" +} + +# +# Lookup a specific C++ function and print the demangled type. +# This form accepts the demangled type as a literal string. +# + +proc info_func { name demangled } { + info_func_regexp "$name" [string_to_regexp "$demangled"] +} + +# +# Print the address of a function. +# This checks that I can lookup a fully qualified C++ function. +# This also checks the argument types on the return string. + +# Note: carlton/2003-01-16: If you modify this, make a corresponding +# modification to print_addr_2_kfail. + +proc print_addr_2 { name good } { + global gdb_prompt + global hex + + set good_pattern [string_to_regexp $good] + + gdb_test "print &$name" \ + ".* = .* $hex <$good_pattern>" +} + +# NOTE: carlton/2003-01-16: hairyfunc5-6 fail on GCC 3.x (for at least +# x=1 and x=2.1). So I'm modifying print_addr_2 to accept a failure +# condition. FIXME: It would be nice if the failure condition were +# conditional on the compiler version, but I'm not sufficiently +# motivated. I did hardwire in the versions of char * and int *, +# which will give some compiler-specificity to the failure. + +proc print_addr_2_kfail { name good bad bugid } { + global gdb_prompt + global hex + + set good_pattern [string_to_regexp $good] + set bad_pattern [string_to_regexp $bad] + + gdb_test_multiple "print &$name" "print &$name" { + -re ".* = .* $hex <$good_pattern>\r\n$gdb_prompt $" { + pass "print &$name" + } + -re ".* = .* $hex <$bad_pattern>\r\n$gdb_prompt $" { + kfail $bugid "print &$name" + } + } +} + +# +# Simple interfaces to print_addr_2. +# + +proc print_addr { name } { + regsub {\(void\)} $name {()} expected + if {[string first "::" $name] == -1} { + # C function -- must be qutoed + set name "'$name'" + } + print_addr_2 "$name" $expected +} + +# +# Test name demangling for operators. +# +# The '(' at the end of each regex input pattern is so that we match only +# the one we are looking for. I.E. "operator&" would match both +# "operator&(foo &)" and "operator&&(foo &)". +# +# gdb-gnats bug gdb/18: +# "gdb can't parse "info func operator*" or "info func operator\*". +# The star in "operator*" is interpreted as a regexp, but the "\*" +# in "operator\*" is not a legal operator. +# + +proc test_lookup_operator_functions {} { + global dm_operator_comma + global dm_operator_char_star + global dm_type_char_star + global dm_operator_char_star_quoted + global dm_type_foo_ref + global dm_type_void + global dm_type_void_star + + # operator* requires quoting so that GDB does not treat it as a regexp. + info_func "operator\\*(" "void foo::operator*($dm_type_foo_ref);" + info_func "operator%(" "void foo::operator%($dm_type_foo_ref);" + info_func "operator-(" "void foo::operator-($dm_type_foo_ref);" + info_func "operator>>(" "void foo::operator>>($dm_type_foo_ref);" + info_func "operator!=(" "void foo::operator!=($dm_type_foo_ref);" + info_func "operator>(" "void foo::operator>($dm_type_foo_ref);" + info_func "operator>=(" "void foo::operator>=($dm_type_foo_ref);" + info_func "operator|(" "void foo::operator|($dm_type_foo_ref);" + info_func "operator&&(" "void foo::operator&&($dm_type_foo_ref);" + info_func "operator!(" "void foo::operator!($dm_type_void);" + info_func "operator++(" "void foo::operator++(int);" + info_func "operator=(" "void foo::operator=($dm_type_foo_ref);" + info_func "operator+=(" "void foo::operator+=($dm_type_foo_ref);" + # operator*= requires quoting so that GDB does not treat it as a regexp. + info_func "operator\\*=(" "void foo::operator*=($dm_type_foo_ref);" + info_func "operator%=(" "void foo::operator%=($dm_type_foo_ref);" + info_func "operator>>=(" "void foo::operator>>=($dm_type_foo_ref);" + info_func "operator|=(" "void foo::operator|=($dm_type_foo_ref);" + info_func "operator$dm_operator_comma\(" \ + "void foo::operator$dm_operator_comma\($dm_type_foo_ref);" + info_func "operator/(" "void foo::operator/($dm_type_foo_ref);" + info_func "operator+(" "void foo::operator+($dm_type_foo_ref);" + info_func "operator<<(" "void foo::operator<<($dm_type_foo_ref);" + info_func "operator==(" "void foo::operator==($dm_type_foo_ref);" + info_func "operator<(" "void foo::operator<($dm_type_foo_ref);" + info_func "operator<=(" "void foo::operator<=($dm_type_foo_ref);" + info_func "operator&(" "void foo::operator&($dm_type_foo_ref);" + info_func "operator^(" "void foo::operator^($dm_type_foo_ref);" + info_func "operator||(" "void foo::operator||($dm_type_foo_ref);" + info_func "operator~(" "void foo::operator~($dm_type_void);" + info_func "operator--(" "void foo::operator--(int);" + info_func "operator->(" "foo *foo::operator->($dm_type_void);" + info_func "operator-=(" "void foo::operator-=($dm_type_foo_ref);" + info_func "operator/=(" "void foo::operator/=($dm_type_foo_ref);" + info_func "operator<<=(" "void foo::operator<<=($dm_type_foo_ref);" + info_func "operator&=(" "void foo::operator&=($dm_type_foo_ref);" + info_func "operator^=(" "void foo::operator^=($dm_type_foo_ref);" + # operator->* requires quoting so that GDB does not treat it as a regexp. + info_func "operator->\\*(" "void foo::operator->*($dm_type_foo_ref);" + + # operator[] needs double backslashes, so that a single backslash + # will be sent to GDB, preventing the square brackets from being + # evaluated as a regular expression. + info_func "operator\\\[\\\](" "void foo::operator\[\]($dm_type_foo_ref);" + + # These are gnarly because they might end with 'static'. + set dm_type_void_star_regexp [string_to_regexp $dm_type_void_star] + info_func_regexp "operator new(" "void \\*foo::operator new\\(.*\\)(| static);" + info_func_regexp "operator delete(" "void foo::operator delete\\($dm_type_void_star_regexp\\)(| static);" + + info_func "operator int(" "int foo::operator int($dm_type_void);" + info_func "operator()(" "void foo::operator()($dm_type_foo_ref);" + info_func "operator $dm_operator_char_star_quoted\(" \ + "char *foo::operator $dm_operator_char_star\($dm_type_void);" + +} + + +proc test_paddr_operator_functions {} { + global hex + global hp_aCC_compiler + global dm_operator_comma + global dm_type_char_star + global dm_type_foo_ref + global dm_type_long_star + global dm_type_unsigned_int + global dm_type_void + global dm_type_void_star + global dm_operator_char_star + + print_addr "foo::operator*($dm_type_foo_ref)" + print_addr "foo::operator%($dm_type_foo_ref)" + print_addr "foo::operator-($dm_type_foo_ref)" + print_addr "foo::operator>>($dm_type_foo_ref)" + print_addr "foo::operator!=($dm_type_foo_ref)" + print_addr "foo::operator>($dm_type_foo_ref)" + print_addr "foo::operator>=($dm_type_foo_ref)" + print_addr "foo::operator|($dm_type_foo_ref)" + print_addr "foo::operator&&($dm_type_foo_ref)" + print_addr "foo::operator!($dm_type_void)" + print_addr "foo::operator++(int)" + print_addr "foo::operator=($dm_type_foo_ref)" + print_addr "foo::operator+=($dm_type_foo_ref)" + print_addr "foo::operator*=($dm_type_foo_ref)" + print_addr "foo::operator%=($dm_type_foo_ref)" + print_addr "foo::operator>>=($dm_type_foo_ref)" + print_addr "foo::operator|=($dm_type_foo_ref)" + print_addr "foo::operator$dm_operator_comma\($dm_type_foo_ref)" + print_addr "foo::operator/($dm_type_foo_ref)" + print_addr "foo::operator+($dm_type_foo_ref)" + print_addr "foo::operator<<($dm_type_foo_ref)" + print_addr "foo::operator==($dm_type_foo_ref)" + print_addr "foo::operator<($dm_type_foo_ref)" + print_addr "foo::operator<=($dm_type_foo_ref)" + print_addr "foo::operator&($dm_type_foo_ref)" + print_addr "foo::operator^($dm_type_foo_ref)" + print_addr "foo::operator||($dm_type_foo_ref)" + print_addr "foo::operator~($dm_type_void)" + print_addr "foo::operator--(int)" + print_addr "foo::operator->($dm_type_void)" + print_addr "foo::operator-=($dm_type_foo_ref)" + print_addr "foo::operator/=($dm_type_foo_ref)" + print_addr "foo::operator<<=($dm_type_foo_ref)" + print_addr "foo::operator&=($dm_type_foo_ref)" + print_addr "foo::operator^=($dm_type_foo_ref)" + print_addr "foo::operator->*($dm_type_foo_ref)" + print_addr "foo::operator\[\]($dm_type_foo_ref)" + print_addr "foo::operator()($dm_type_foo_ref)" + + gdb_test "print &foo::operator new" \ + " = .* $hex " + gdb_test "print &foo::operator new\[\]" \ + " = .* $hex " + if { !$hp_aCC_compiler } { + print_addr "foo::operator delete($dm_type_void_star)" + print_addr "foo::operator delete[]($dm_type_void_star)" + } else { + gdb_test "print &'foo::operator delete($dm_type_void_star) static'" \ + " = .*(0x\[0-9a-f\]+|) " + } + + print_addr "foo::operator int($dm_type_void)" + print_addr "foo::operator $dm_operator_char_star\($dm_type_void)" +} + +# +# Test overloaded functions (1 arg). +# + +proc test_paddr_overloaded_functions {} { + global dm_type_unsigned_int + global dm_type_void + global dm_type_short + global dm_type_unsigned_short + global dm_type_long + global dm_type_unsigned_long + + print_addr "overload1arg($dm_type_void)" + print_addr "overload1arg(char)" + print_addr "overload1arg(signed char)" + print_addr "overload1arg(unsigned char)" + print_addr "overload1arg($dm_type_short)" + print_addr "overload1arg($dm_type_unsigned_short)" + print_addr "overload1arg(int)" + print_addr "overload1arg($dm_type_unsigned_int)" + print_addr "overload1arg($dm_type_long)" + print_addr "overload1arg($dm_type_unsigned_long)" + print_addr "overload1arg(float)" + print_addr "overload1arg(double)" + + print_addr "overloadargs(int)" + print_addr "overloadargs(int, int)" + print_addr "overloadargs(int, int, int)" + print_addr "overloadargs(int, int, int, int)" + print_addr "overloadargs(int, int, int, int, int)" + print_addr "overloadargs(int, int, int, int, int, int)" + print_addr "overloadargs(int, int, int, int, int, int, int)" + print_addr "overloadargs(int, int, int, int, int, int, int, int)" + print_addr "overloadargs(int, int, int, int, int, int, int, int, int)" + print_addr "overloadargs(int, int, int, int, int, int, int, int, int, int)" + print_addr "overloadargs(int, int, int, int, int, int, int, int, int, int, int)" +} + +proc test_paddr_hairy_functions {} { + global gdb_prompt + global hex + global dm_type_char_star + global dm_type_int_star + global dm_type_long_star + global dm_type_typedef + + print_addr_2 "hairyfunc1" "hairyfunc1(int)" + + if {$dm_type_typedef == 0} { + print_addr_2 "hairyfunc2" "hairyfunc2(int (*)($dm_type_char_star))" + print_addr_2 "hairyfunc3" "hairyfunc3(int (*)(short (*)($dm_type_long_star)))" + print_addr_2 "hairyfunc4" "hairyfunc4(int (*)(short (*)($dm_type_char_star)))" + + # gdb-gnats bug gdb/19: + # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7" + print_addr_2_kfail "hairyfunc5" "hairyfunc5(int (*(*)($dm_type_char_star))(long))" "hairyfunc5(int (*)(long) (*)(char*))" "gdb/19" + print_addr_2_kfail "hairyfunc6" "hairyfunc6(int (*(*)($dm_type_int_star))(long))" "hairyfunc6(int (*)(long) (*)(int*))" "gdb/19" + print_addr_2_kfail "hairyfunc7" "hairyfunc7(int (*(*)(int (*)($dm_type_char_star)))(long))" "hairyfunc7(int (*)(long) (*)(int (*)(char*)))" "gdb/19" + } else { + print_addr_2 "hairyfunc2" "hairyfunc2(PFPc_i)" + print_addr_2 "hairyfunc3" "hairyfunc3(PFPFPl_s_i)" + print_addr_2 "hairyfunc4" "hairyfunc4(PFPFPc_s_i)" + + # gdb-gnats bug gdb/19: + # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7" + print_addr_2 "hairyfunc5" "hairyfunc5(PFPc_PFl_i)" + print_addr_2 "hairyfunc6" "hairyfunc6(PFPi_PFl_i)" + print_addr_2 "hairyfunc7" "hairyfunc7(PFPFPc_i_PFl_i)" + } +} + +proc do_tests {} { + global subdir + global objdir + global srcdir + global binfile + global gdb_prompt + global dm_type_int_star + + + # Start with a fresh gdb. + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load $binfile + + gdb_test_no_output "set language c++" + gdb_test_no_output "set width 0" + + runto_main + + probe_demangler + test_paddr_overloaded_functions + test_paddr_operator_functions + test_paddr_hairy_functions + test_lookup_operator_functions + + # A regression test on errors involving operators + gdb_test "list foo::operator $dm_type_int_star" \ + ".*the class foo does not have any method named operator $dm_type_int_star.*" +} + +do_tests Index: userdef.cc =================================================================== --- userdef.cc (nonexistent) +++ userdef.cc (revision 513) @@ -0,0 +1,413 @@ +/* This test script is part of GDB, the GNU debugger. + + Copyright 1999, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#include + +using namespace std; + +void marker1() +{ + return; +} + +class A1 { + int x; + int y; + +friend ostream& operator<<(ostream& outs, A1 one); + +public: + + A1(int a, int b) + { + x=a; + y=b; + } + +A1 operator+=(int value); +A1 operator+(const A1&); +A1 operator-(const A1&); +A1 operator%(const A1&); +int operator==(const A1&); +int operator!=(const A1&); +int operator&&(const A1&); +int operator||(const A1&); +A1 operator<<(int); +A1 operator>>(int); +A1 operator|(const A1&); +A1 operator^(const A1&); +A1 operator&(const A1&); +int operator<(const A1&); +int operator<=(const A1&); +int operator>=(const A1&); +int operator>(const A1&); +A1 operator*(const A1&); +A1 operator/(const A1&); +A1 operator=(const A1&); + +A1 operator~(); +A1 operator+(); +A1 operator-(); +int operator!(); +A1 operator++(); +A1 operator++(int); +A1 operator--(); +A1 operator--(int); + +}; + + +A1 A1::operator+(const A1& second) +{ + A1 sum(0,0); + sum.x = x + second.x; + sum.y = y + second.y; + + return (sum); +} + +A1 A1::operator*(const A1& second) +{ + A1 product(0,0); + product.x = this->x * second.x; + product.y = this->y * second.y; + + return product; +} + +A1 A1::operator-(const A1& second) +{ + A1 diff(0,0); + diff.x = x - second.x; + diff.y = y - second.y; + + return diff; +} + +A1 A1::operator/(const A1& second) +{ + A1 div(0,0); + div.x = x / second.x; + div.y = y / second.y; + + return div; +} + +A1 A1::operator%(const A1& second) +{ + A1 rem(0,0); + rem.x = x % second.x; + rem.y = y % second.y; + + return rem; +} + +int A1::operator==(const A1& second) +{ + int a = (x == second.x); + int b = (y == second.y); + + return (a && b); +} + +int A1::operator!=(const A1& second) +{ + int a = (x != second.x); + int b = (y != second.y); + + return (a || b); +} + +int A1::operator&&(const A1& second) +{ + return ( x && second.x); +} + +int A1::operator||(const A1& second) +{ + return ( x || second.x); +} + +A1 A1::operator<<(int value) +{ + A1 lshft(0,0); + lshft.x = x << value; + lshft.y = y << value; + + return lshft; +} + +A1 A1::operator>>(int value) +{ + A1 rshft(0,0); + rshft.x = x >> value; + rshft.y = y >> value; + + return rshft; +} + +A1 A1::operator|(const A1& second) +{ + A1 abitor(0,0); + abitor.x = x | second.x; + abitor.y = y | second.y; + + return abitor; +} + +A1 A1::operator^(const A1& second) +{ + A1 axor(0,0); + axor.x = x ^ second.x; + axor.y = y ^ second.y; + + return axor; +} + +A1 A1::operator&(const A1& second) +{ + A1 abitand(0,0); + abitand.x = x & second.x; + abitand.y = y & second.y; + + return abitand; +} + +int A1::operator<(const A1& second) +{ + A1 b(0,0); + b.x = 3; + return (x < second.x); +} + +int A1::operator<=(const A1& second) +{ + return (x <= second.x); +} + +int A1::operator>=(const A1& second) +{ + return (x >= second.x); +} + +int A1::operator>(const A1& second) +{ + return (x > second.x); +} + +int A1::operator!(void) +{ + return (!x); +} + +A1 A1::operator-(void) +{ + A1 neg(0,0); + neg.x = -x; + neg.y = -y; + + return (neg); +} + +A1 A1::operator+(void) +{ + A1 pos(0,0); + pos.x = +x; + pos.y = +y; + + return (pos); +} + +A1 A1::operator~(void) +{ + A1 acompl(0,0); + acompl.x = ~x; + acompl.y = ~y; + + return (acompl); +} + +A1 A1::operator++() // pre increment +{ + x = x +1; + + return (*this); +} + +A1 A1::operator++(int) // post increment +{ + y = y +1; + + return (*this); +} + +A1 A1::operator--() // pre decrement +{ + x = x -1; + + return (*this); +} + +A1 A1::operator--(int) // post decrement +{ + y = y -1; + + return (*this); +} + + +A1 A1::operator=(const A1& second) +{ + + x = second.x; + y = second.y; + + return (*this); +} + +A1 A1::operator+=(int value) +{ + + x += value; + y += value; + + return (*this); +} + +ostream& operator<<(ostream& outs, A1 one) +{ + return (outs << endl << "x = " << one.x << endl << "y = " << one.y << endl << "-------" << endl); +} + +class A2 { + public: +A2 operator+(); +}; + +A2 A2::operator+() +{ + return A2 (); +} + +class Member +{ +public: + int z; +}; + +bool operator== (const Member &m1, const Member &m2) +{ + return m1.z == m2.z; +} + +class Container +{ +public: + Member m; + + Member& operator* (); +}; + +Member& Container::operator* () +{ + return this->m; +} + +int main (void) +{ + A1 one(2,3); + A1 two(4,5); + A1 three(0,0); + Container c; + Member mem1, mem2; + int val; + + mem1.z = 5; + mem2.z = 7; + + marker1(); // marker1-returns-here + cout << one; // marker1-returns-here + cout << two; + three = one + two; + cout << "+ " << three; + three = one - two; + cout << "- " << three; + three = one * two; + cout <<"* " << three; + three = one / two; + cout << "/ " << three; + three = one % two; + cout << "% " << three; + three = one | two; + cout << "| " <= two; + cout << ">= " << val << endl << "-----"< two; + cout << "> " << val << endl << "-----"<> 2; + cout << "rsh " << three; + + three = one; + cout << " = "<< three; + three += 5; + cout << " += "<< three; + + val = (!one); + cout << "! " << val << endl << "-----"<. + +if $tracelevel then { + strace $tracelevel +} + + +set testfile nsusing +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \ + {debug c++}] != "" } { + untested "Couldn't compile test program" + return -1 +} + +if [get_compiler_info ${binfile}] { + return -1 +} + + +# Get things started. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +############################################ +# test printing of namespace imported within +# the function. + +if ![runto_main] then { + perror "couldn't run to breakpoint main" + continue +} + +gdb_test "print _a" "= 1" + +# Test that names are not printed when they +# are not imported + +gdb_breakpoint marker3 +gdb_continue_to_breakpoint "marker3" + +#send_gdb "break marker3\n" +#send_gdb "continue\n" + +gdb_test "print _a" "No symbol \"_a\" in current context." \ + "Print _a without import" + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +############################################ +# test printing of namespace imported into +# a scope containing the pc. + +if ![runto_main] then { + perror "couldn't run to breakpoint main" + continue +} + +gdb_breakpoint [gdb_get_line_number "marker1 stop"] +gdb_continue_to_breakpoint "marker1 stop" + +gdb_test "print _a" "= 1" "print _a in a nested scope" + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +############################################ +# test printing of namespace imported into +# file scope. + + +if ![runto marker5] then { + perror "couldn't run to breakpoint marker5" + continue +} + +gdb_test "print cc" "= 3" + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +############################################ +# Test printing of namespace aliases + +if ![runto marker2] then { + perror "couldn't run to breakpoint marker2" + continue +} + +gdb_test "print B::_a" "= 1" + +gdb_test "print _a" "No symbol \"_a\" in current context." \ + "print _a in namespace alias scope" + +gdb_test "print x" "No symbol \"x\" in current context." \ + "print x in namespace alias scope" + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +############################################ +# Test that names are not printed when they +# are not imported + +if {![runto marker3]} { + perror "couldn't run to breakpoint marker3" +} + +# gcc-4-3 puts import statements for aliases in +# the global scope instead of the corresponding +# function scope. These wrong import statements throw +# this test off. This is fixed in gcc-4-4. +if [test_compiler_info gcc-4-3-*] then { setup_xfail *-*-* } + +gdb_test "print _a" "No symbol \"_a\" in current context." \ + "Print _a without import" + +############################################ +# Test printing of individually imported elements + +if ![runto marker4] then { + perror "couldn't run to breakpoint marker4" + continue +} + +gdb_test "print dx" "= 4" + +############################################ +# Test printing of namespace aliases + +if ![runto marker5] then { + perror "couldn't run to marker5" + continue +} + +gdb_test "print efx" "= 5" + +############################################ +# Test printing of variables imported from +# nested namespaces + +if ![runto I::marker7] then { + perror "couldn't run to breakpoint I::marker7" + continue +} + +gdb_test "print ghx" "= 6" + +############################################ +# Test that variables are not printed in a namespace +# that is sibling to the namespace containing an import + +if ![runto L::marker8] then { + perror "couldn't run to breakpoint L::marker8" + continue +} + +gdb_test "print jx" "= 44" + +gdb_breakpoint "K::marker9" +gdb_continue_to_breakpoint "K::marker9" + +gdb_test "print jx" "No symbol \"jx\" in current context." + +############################################ +# Test that variables are only printed after the line +# containing the import + +if ![runto_main] then { + perror "couldn't run to breakpoint main" + continue +} + +gdb_breakpoint [gdb_get_line_number "marker10 stop"] +gdb_continue_to_breakpoint "marker10 stop" + +if { [test_compiler_info {gcc-[0-3]-*}] || + [test_compiler_info {gcc-4-[0-3]-*}]} { + setup_xfail *-*-* +} + +# Assert that M::x is printed and not N::x +gdb_test "print x" "= 911" "print x (from M::x)" Index: breakpoint.cc =================================================================== --- breakpoint.cc (nonexistent) +++ breakpoint.cc (revision 513) @@ -0,0 +1,66 @@ +/* Code to go along with tests in breakpoint.exp. + + Copyright 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +int g = 0; + +class C1 { +public: + C1(int i) : i_(i) {} + + int foo () + { + return 1; // conditional breakpoint in method + } + + int bar () + { + for (int i = 0; i < 1; ++i) + { + int t = i * 2; + g += t; // conditional breakpoint in method 2 + } + } + + class Nested { + public: + int + foo () + { + return 1; + } + }; + +private: + int i_; +}; + +int main () +{ + C1::Nested c1; + + c1.foo (); + + C1 c2 (2), c3 (3); + c2.foo (); + c2.bar (); + c3.foo (); + c3.bar (); + + return 0; +} Index: Makefile.in =================================================================== --- Makefile.in (nonexistent) +++ Makefile.in (revision 513) @@ -0,0 +1,18 @@ +VPATH = @srcdir@ +srcdir = @srcdir@ + +EXECUTABLES = ambiguous annota2 anon-union cplusfuncs cttiadd \ + derivation inherit local member-ptr method misc \ + overload ovldbreak ref-typ ref-typ2 templates userdef virtfunc namespace \ + ref-types ref-params method2 pr9594 gdb2495 virtfunc2 pr9067 \ + pr1072 pr10687 pr9167 + +all info install-info dvi install uninstall installcheck check: + @echo "Nothing to be done for $@..." + +clean mostlyclean: + -rm -f *~ *.o *.ci + -rm -f core ${EXECUTABLES} + +distclean maintainer-clean realclean: clean + -rm -f Makefile config.status config.log Index: pr-1210.cc =================================================================== --- pr-1210.cc (nonexistent) +++ pr-1210.cc (revision 513) @@ -0,0 +1,19 @@ +class A +{ +}; + +class B : virtual public A +{ +}; + +class C : public A +{ + protected: + B myB; +}; + +int main() +{ + C *obj = new C(); + return 0; +} Index: mb-ctor.cc =================================================================== --- mb-ctor.cc (nonexistent) +++ mb-ctor.cc (revision 513) @@ -0,0 +1,66 @@ + +#include + +class Base +{ +public: + Base(int k); + ~Base(); + virtual void foo() {} +private: + int k; +}; + +Base::Base(int k) +{ + this->k = k; +} + +Base::~Base() +{ + printf("~Base\n"); +} + +class Derived : public virtual Base +{ +public: + Derived(int i); + ~Derived(); +private: + int i; + int i2; +}; + +Derived::Derived(int i) : Base(i) +{ + this->i = i; + /* The next statement is spread over two lines on purpose to exercise + a bug where breakpoints set on all but the last line of a statement + would not get multiple breakpoints. + The second line's text for gdb_get_line_number is a subset of the + first line so that we don't care which line gdb prints when it stops. */ + this->i2 = // set breakpoint here + i; // breakpoint here +} + +Derived::~Derived() +{ + printf("~Derived\n"); +} + +class DeeplyDerived : public Derived +{ +public: + DeeplyDerived(int i) : Base(i), Derived(i) {} +}; + +int main() +{ + /* Invokes the Derived ctor that constructs both + Derived and Base. */ + Derived d(7); + /* Invokes the Derived ctor that constructs only + Derived. Base is constructed separately by + DeeplyDerived's ctor. */ + DeeplyDerived dd(15); +} Index: arg-reference.cc =================================================================== --- arg-reference.cc (nonexistent) +++ arg-reference.cc (revision 513) @@ -0,0 +1,49 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +class Obj +{ +public: + Obj (); + Obj (const Obj &); + ~Obj (); + int var; +}; + +int foo (Obj arg) +{ + arg.var++; + return arg.var; +} + +int main() +{ + Obj obj; + + return 0; /* initialized */ +} + +Obj::Obj () +{ + var = 1; +} + +Obj::~Obj () +{ +} Index: breakpoint.exp =================================================================== --- breakpoint.exp (nonexistent) +++ breakpoint.exp (revision 513) @@ -0,0 +1,73 @@ +# Copyright 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the gdb testsuite. + +# This contains tests for breakpoints in C++. + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + +# +# test running programs +# + +set testfile "breakpoint" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested breakpoint.exp + return -1 +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +proc test_breakpoint {name} { + # Restart the program every time, so that a single failure doesn't + # lead to a cascade. + if ![runto_main] then { + perror "couldn't run to main when testing ${name}" + continue + } else { + gdb_breakpoint "${name}" + gdb_test "continue" "Continuing.\r\n\r\nBreakpoint \[0-9\]*, ${name}.*" "continue to ${name}" + } +} + +test_breakpoint "C1::Nested::foo" + +set bp_location1 [gdb_get_line_number "conditional breakpoint in method"] +set bp_location2 [gdb_get_line_number "conditional breakpoint in method 2"] +gdb_test "break $bp_location1 if i_==3" ".*Breakpoint.*" "conditional breakpoint in method" +gdb_test "break $bp_location2 if i_==3" ".*Breakpoint.*" "conditional breakpoint in method 2" +gdb_test "continue" ".*Breakpoint.*C1::foo.*" "continue to breakpoint" +gdb_test "print i_" "\\\$1 = 3" "check the member variable" +gdb_test "continue" ".*Breakpoint.*C1::bar.*" "continue to breakpoint" +gdb_test "print i_" "\\\$2 = 3" "check the member variable" + + +gdb_exit +return 0 Index: formatted-ref.exp =================================================================== --- formatted-ref.exp (nonexistent) +++ formatted-ref.exp (revision 513) @@ -0,0 +1,143 @@ +# Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Author: P. N. Hilfinger, AdaCore, Inc. + +# This test checks the behavior of formatted print when applied to a +# reference value. The intended behavior is that a formatted print of +# such a value should display the same value as a plain print, +# modulo format, of course. Older versions of GDB would instead print +# the reference's address value itself when doing a formatted print, +# rather than printing both that and the dereferenced value. We also +# check that the (non-standard) expression &(&x), where x is of type T&, +# yields an appropriate value. +# This also tests that some other arithmetic operations on references +# work properly: condition expression using a reference object as one of its +# operand. + +if $tracelevel then { + strace $tracelevel +} + + +if { [skip_cplus_tests] } { continue } + +set testfile "formatted-ref" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested formatted-ref.exp + return -1 +} + +proc get_address { var } { + global expect_out + global gdb_prompt + + gdb_test_multiple "print &$var" "find address of $var" { + -re "\\$\[0-9\]+ = \\(.*\\) (0x\[0-9a-f\]+).*$gdb_prompt $" { + return $expect_out(1,string) + } + timeout { + perror "couldn't find address of $var" + return "" + } + } + return "" +} + +proc test_p_x { var type val addr } { + global gdb_prompt + + set test "print/x $var" + gdb_test_multiple $test $test { + -re "\\$\[0-9\]+ = \\([string_to_regexp $type]\\) @0x\[a-f0-9\]+: [string_to_regexp $val].*$gdb_prompt $" { + pass $test + } + -re "\\$\[0-9\]+ = $addr.*$gdb_prompt $" { + fail "$test (prints just address)" + } + -re "\\$\[0-9\]+ = 0x\[a-f0-9\]+.*$gdb_prompt $" { + fail "$test (prints unexpected address)" + } + } + return 0 +} + +proc test_p_x_addr { var addr } { + global gdb_prompt + + set test "print/x &$var" + gdb_test_multiple $test $test { + -re "\\$\[0-9\]+ = $addr.*$gdb_prompt $" { + pass $test + } + -re "\\$\[0-9\]+ = 0x\[a-f0-9+\]+.*$gdb_prompt $" { + fail "$test (prints unexpected address)" + } + } + return 0 +} + +proc test_p_x_ref_addr { var addr } { + global gdb_prompt + + set test "print/x *(&(&$var))" + gdb_test_multiple $test $test { + -re "\\$\[0-9\]+ = $addr.*$gdb_prompt $" { + pass $test + } + -re "Attempt to take address of value not located in memory.*$gdb_prompt $" { + # The reference might be in a register. At least we parsed + # correctly... + pass $test + } + -re "\\$\[0-9\]+ = 0x\[a-f0-9+\]+.*$gdb_prompt $" { + fail "$test (prints unexpected address)" + } + } + return 0 +} + +proc test_p_op1_equals_op2 {op1 op2} { + set test "print $op1 == $op2" + gdb_test $test "\\$\[0-9\]+ = true" +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +runto ${srcfile}:[gdb_get_line_number "marker here"] + +set s1_address [get_address "s1"] +set e1_address [get_address "e1"] +set i1_address [get_address "i1"] + +test_p_x "s" "Struct1 &" "{x = 0xd, y = 0x13}" $s1_address +test_p_x "e" "Enum1 &" "0xb" $e1_address +test_p_x "i" "int &" "0x17" $i1_address + +test_p_x_addr "s" $s1_address +test_p_x_addr "e" $e1_address +test_p_x_addr "i" $i1_address + +test_p_x_ref_addr "s" $s1_address +test_p_x_ref_addr "i" $i1_address +test_p_x_ref_addr "e" $e1_address + +test_p_op1_equals_op2 "s.x" "13" Index: static-print-quit.exp =================================================================== --- static-print-quit.exp (nonexistent) +++ static-print-quit.exp (revision 513) @@ -0,0 +1,50 @@ +# Copyright 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +if { [skip_cplus_tests] } { continue } + +set testfile static-print-quit +set srcfile ${testfile}.cc +set executable $testfile.o +set objfile ${objdir}/${subdir}/${executable} + +if { [gdb_compile $srcdir/$subdir/$srcfile $objfile object {debug c++}] != ""} { + untested ${testfile}.exp + return -1 +} + +clean_restart $executable + +gdb_test_no_output "set width 80" +gdb_test_no_output "set height 2" + +set test "print c" +gdb_test_multiple $test $test { + -re " = \{loooooooooooooooooooooooooooooooooooooooooooooong = 0, static field = \{\r\n---Type to continue, or q to quit---$" { + pass $test + } + -re " to quit---$" { + fail $test + return -1 + } +} + +gdb_test "q" ".*" + +# Now the obstack is uninitialized. Excercise it. + +gdb_test_no_output "set pagination off" +gdb_test "print c" ".*" "first print" +gdb_test "print c" ".*" "second print" Index: punctuator.exp =================================================================== --- punctuator.exp (nonexistent) +++ punctuator.exp (revision 513) @@ -0,0 +1,52 @@ +# Copyright 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Simple test for alternate punctuators. + +# This file is part of the gdb testsuite + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + +gdb_exit +gdb_start + +gdb_test_no_output "set lang c++" +gdb_test "print (0x5a5a bitand 0xaaaa) == (0x5a5a & 0xaaaa)" " = true" +gdb_test "print (0x5a5a bitor 0xaaaa) == (0x5a5a | 0xaaaa)" " = true" +gdb_test "print (0x5a5a xor 0xaaaa) == (0x5a5a ^ 0xaaaa)" " = true" +gdb_test "print (0x5a5a and 0xaaaa) == (0x5a5a && 0xaaaa)" " = true" +gdb_test "print (0x5a5a or 0xaaaa) == (0x5a5a || 0xaaaa)" " = true" +gdb_test "print (not not 0xaaaa) == (!!0xaaaa)" " = true" +gdb_test "print (compl 0xaaaa) == (~0xaaaa)" " = true" + +gdb_test_no_output "set \$u = 0x5a5a" "set \$u 1" +gdb_test_no_output "set \$v = 0x5a5a" "set \$v 1" +gdb_test "print (\$u not_eq 0xaaaa) == (\$v != 0xaaaa)" "= true" +gdb_test "print (\$u and_eq 0xaaaa) == (\$v &= 0xaaaa)" "= true" + +gdb_test_no_output "set \$u = 0x5a5a" "set \$u 2" +gdb_test_no_output "set \$v = 0x5a5a" "set \$v 2" +gdb_test "print (\$u or_eq 0xaaaa) == (\$v |= 0xaaaa)" "= true" + +gdb_test_no_output "set \$u = 0x5a5a" "set \$u 3" +gdb_test_no_output "set \$v = 0x5a5a" "set \$v 3" +gdb_test "print (\$u xor_eq 0xaaaa) == (\$v ^= 0xaaaa)" "= true" + +gdb_exit +return 0 Index: derivation.exp =================================================================== --- derivation.exp (nonexistent) +++ derivation.exp (revision 513) @@ -0,0 +1,191 @@ +# Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file was written by Elena Zannoni (ezannoni@cygnus.com) +# And rewritten by Michael Chastain + +# This file is part of the gdb testsuite + +# tests for inheritance, with several derivations types combinations +# (private, public, protected) +# classes have simple members and member functions. + +set ws "\[\r\n\t \]+" +set nl "\[\r\n\]+" + +if $tracelevel then { + strace $tracelevel +} + +# Start program. + + +if { [skip_cplus_tests] } { continue } + +load_lib "cp-support.exp" + +set testfile "derivation" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested derivation.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +# Set it up at a breakpoint so we can play with the variable values. + +if ![runto 'marker1'] then { + perror "couldn't run to marker1" + continue +} + +gdb_test "up" ".*main.*" "up from marker1" + +# Print class types and values. + +# class A + +gdb_test "print a_instance" "\\$\[0-9\]+ = \{a = 1, aa = 2\}" "print value of a_instance" + +cp_test_ptype_class \ + "ptype a_instance" "" "class" "A" \ + { + { field public "int a;" } + { field public "int aa;" } + { method public "A();" } + { method public "int afoo();" } + { method public "int foo();" } + } + +# class D + +gdb_test_multiple "print d_instance" "print value of d_instance" { + -re "\\$\[0-9\]+ = \{<(class A|A)> = \{a = 1, aa = 2\}, <(class B|B)> = \{b = 3, bb = 4\}, <(class C|C)> = \{c = 5, cc = 6\}, d = 7, dd = 8\}$nl$gdb_prompt $" { + pass "print value of d_instance" + } +} + +cp_test_ptype_class \ + "ptype d_instance" "" "class" "D" \ + { + { base "private A" } + { base "public B" } + { base "protected C" } + { field public "int d;" } + { field public "int dd;" } + { method public "D();" } + { method public "int dfoo();" } + { method public "int foo();" } + } \ + "" \ + { + { "protected C" "private C" { setup_xfail "*-*-*" "gcc/13539" } } + } + +# class E + +gdb_test_multiple "print e_instance" "print value of e_instance" { + -re "\\$\[0-9\]+ = \{<(class A|A)> = \{a = 1, aa = 2\}, <(class B|B)> = \{b = 3, bb = 4\}, <(class C|C)> = \{c = 5, cc = 6\}, e = 9, ee = 10\}$nl$gdb_prompt $" { + pass "print value of e_instance" + } +} + +cp_test_ptype_class \ + "ptype e_instance" "" "class" "E" \ + { + { base "public A" } + { base "private B" } + { base "protected C" } + { field public "int e;" } + { field public "int ee;" } + { method public "E();" } + { method public "int efoo();" } + { method public "int foo();" } + } \ + "" \ + { + { "protected C" "private C" { setup_xfail "*-*-*" "gcc/13539" } } + } + +# class F + +gdb_test_multiple "print f_instance" "print value of f_instance" { + -re "\\$\[0-9\]+ = \{<(class A|A)> = \{a = 1, aa = 2\}, <(class B|B)> = \{b = 3, bb = 4\}, <(class C|C)> = \{c = 5, cc = 6\}, f = 11, ff = 12\}$nl$gdb_prompt $" { + pass "print value of f_instance" + } +} + +cp_test_ptype_class \ + "ptype f_instance" "" "class" "F" \ + { + { base "private A" } + { base "public B" } + { base "private C" } + { field public "int f;" } + { field public "int ff;" } + { method public "F();" } + { method public "int ffoo();" } + { method public "int foo();" } + } + +# Print individual fields. + +gdb_test "print d_instance.a" "\\$\[0-9\]+ = 1" "print value of d_instance.a" +gdb_test "print d_instance.aa" "\\$\[0-9\]+ = 2" "print value of d_instance.aa" +gdb_test "print d_instance.b" "\\$\[0-9\]+ = 3" "print value of d_instance.b" +gdb_test "print d_instance.bb" "\\$\[0-9\]+ = 4" "print value of d_instance.bb" +gdb_test "print d_instance.c" "\\$\[0-9\]+ = 5" "print value of d_instance.c" +gdb_test "print d_instance.cc" "\\$\[0-9\]+ = 6" "print value of d_instance.cc" +gdb_test "print d_instance.d" "\\$\[0-9\]+ = 7" "print value of d_instance.d" +gdb_test "print d_instance.dd" "\\$\[0-9\]+ = 8" "print value of d_instance.dd" + +# Print some fields which are defined in the top of class G +# and in its base classes. This is not be ambiguous. + +gdb_test "print g_instance.a" "\\$\[0-9\]+ = 15" "print value of g_instance.a" +gdb_test "print g_instance.b" "\\$\[0-9\]+ = 16" "print value of g_instance.b" +gdb_test "print g_instance.c" "\\$\[0-9\]+ = 17" "print value of g_instance.c" + +# Print a function call. + +gdb_test "print g_instance.afoo()" "\\$\[0-9\]+ = 1" "print value of g_instance.afoo()" + +# If GDB fails to restore the selected frame properly after the +# inferior function call above (see GDB PR 1155 for an explanation of +# why this might happen), all the subsequent tests will fail. We +# should detect report that failure, but let the marker call finish so +# that the rest of the tests can run undisturbed. + +gdb_test_multiple "frame" "re-selected 'main' frame after inferior call" { + -re "#0 marker1.*$gdb_prompt $" { + setup_kfail "gdb/1155" s390-*-linux-gnu + fail "re-selected 'main' frame after inferior call" + gdb_test "finish" ".*main.*at .*derivation.cc:.*// marker1-returns-here.*" \ + "finish call to marker1" + } + -re "#1 ($hex in )?main.*$gdb_prompt $" { + pass "re-selected 'main' frame after inferior call" + } +} + +gdb_test "print g_instance.bfoo()" "\\$\[0-9\]+ = 2" "print value of g_instance.bfoo()" +gdb_test "print g_instance.cfoo()" "\\$\[0-9\]+ = 3" "print value of g_instance.cfoo()" Index: pr9167.exp =================================================================== --- pr9167.exp (nonexistent) +++ pr9167.exp (revision 513) @@ -0,0 +1,36 @@ +#Copyright 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# On SPU this test fails because the executable exceeds local storage size. +if { [istarget "spu*-*-*"] } { + return 0 +} + +set testfile pr9167 +set srcfile ${testfile}.cc +if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] { + return -1 +} + +if ![runto_main] then { + fail "Can't run to main" + return +} + +gdb_breakpoint [gdb_get_line_number "marker"] +gdb_continue_to_breakpoint "marker" + +gdb_test "p b" "{> = {> = {data = 0}, static DEFAULT_INSTANCE = }, }" + Index: ovldbreak.exp =================================================================== --- ovldbreak.exp (nonexistent) +++ ovldbreak.exp (revision 513) @@ -0,0 +1,382 @@ +# Copyright (C) 1998, 1999, 2001, 2004, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# written by Elena Zannoni (ezannoni@cygnus.com) +# modified by Michael Chastain (chastain@redhat.com) + +# This file is part of the gdb testsuite +# +# tests for overloaded member functions. Set breakpoints on +# overloaded member functions +# + +global timeout +set timeout 15 +if $tracelevel then { + strace $tracelevel + } + +# +# test running programs +# + +if { [skip_cplus_tests] } { continue } + +set testfile "ovldbreak" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested ovldbreak.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +# set it up at a breakpoint so we can play with the variable values +# +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + + + +# When I ask gdb to set a breakpoint on an overloaded function, +# gdb gives me a choice menu. I might get stuck in that choice menu +# (for example, if C++ name mangling is not working properly). +# +# This procedure issues a command that works at either the menu +# prompt or the command prompt to get back to the command prompt. +# +# Note that an empty line won't do it (it means 'repeat the previous command' +# at top level). A line with a single space in it works nicely. + +proc take_gdb_out_of_choice_menu {} { + global gdb_prompt + gdb_test_multiple " " " " { + -re ".*$gdb_prompt $" { + } + timeout { + perror "could not resynchronize to command prompt (timeout)" + continue + } + } +} + + + +# This procedure sets an overloaded breakpoint. +# When I ask for such a breakpoint, gdb gives me a menu of 'cancel' 'all' +# and a bunch of choices. I then choose from that menu by number. + +proc set_bp_overloaded {name expectedmenu mychoice bpnumber linenumber} { + global gdb_prompt hex srcfile + + # Get into the overload menu. + send_gdb "break $name\n" + gdb_expect { + -re "$expectedmenu" { + pass "bp menu for $name choice $mychoice" + + # Choose my choice. + send_gdb "$mychoice\n" + gdb_expect { + -re "Breakpoint $bpnumber at $hex: file.*$srcfile, line $linenumber.\r\n$gdb_prompt $" { + pass "set bp $bpnumber on $name $mychoice line $linenumber" + } + -re ".*$gdb_prompt $" { + fail "set bp $bpnumber on $name $mychoice line $linenumber (bad bp)" + } + timeout { + fail "set bp $bpnumber on $name $mychoice line $linenumber (timeout)" + take_gdb_out_of_choice_menu + } + } + } + -re ".*\r\n> " { + fail "bp menu for $name choice $mychoice (bad menu)" + take_gdb_out_of_choice_menu + } + -re ".*$gdb_prompt $" { + fail "bp menu for $name choice $mychoice (no menu)" + } + timeout { + fail "bp menu for $name choice $mychoice (timeout)" + take_gdb_out_of_choice_menu + } + } +} + +# This is the expected menu for overload1arg. +# Note the arg type variations for void and integer types. +# This accommodates different versions of g++. + +set menu_overload1arg "\\\[0\\\] cancel\r\n" +append menu_overload1arg "\\\[1\\\] all\r\n" +append menu_overload1arg "\\\[2\\\] foo::overload1arg\\(double\\) at.*$srcfile:121\r\n" +append menu_overload1arg "\\\[3\\\] foo::overload1arg\\(float\\) at.*$srcfile:120\r\n" +append menu_overload1arg "\\\[4\\\] foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r\n" +append menu_overload1arg "\\\[5\\\] foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r\n" +append menu_overload1arg "\\\[6\\\] foo::overload1arg\\((unsigned int|unsigned)\\) at.*$srcfile:117\r\n" +append menu_overload1arg "\\\[7\\\] foo::overload1arg\\(int\\) at.*$srcfile:116\r\n" +append menu_overload1arg "\\\[8\\\] foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r\n" +append menu_overload1arg "\\\[9\\\] foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r\n" +append menu_overload1arg "\\\[10\\\] foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r\n" +append menu_overload1arg "\\\[11\\\] foo::overload1arg\\(signed char\\) at.*$srcfile:112\r\n" +append menu_overload1arg "\\\[12\\\] foo::overload1arg\\(char\\) at.*$srcfile:111\r\n" +append menu_overload1arg "\\\[13\\\] foo::overload1arg\\((void|)\\) at.*$srcfile:110\r\n" +append menu_overload1arg "> $" + +# Set multiple-symbols to "ask", to allow us to test the use +# of the multiple-choice menu when breaking on an overloaded method. +gdb_test_no_output "set multiple-symbols ask" + +# Set breakpoints on foo::overload1arg, one by one. + +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 12 2 111 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 11 3 112 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 10 4 113 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 9 5 114 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 8 6 115 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 7 7 116 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 6 8 117 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 5 9 118 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 4 10 119 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 3 11 120 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 2 12 121 +set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 13 13 110 + + + +# Verify the breakpoints. + +gdb_test "info break" \ + "Num Type\[\t \]+Disp Enb Address\[\t \]+What.* +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main(\\((|void)\\))? at.*$srcfile:49\r +\[\t \]+breakpoint already hit 1 time\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \ + "breakpoint info (after setting one-by-one)" + + + +# Test choice "cancel". +# This is copy-and-paste from set_bp_overloaded. + +send_gdb "break foo::overload1arg\n" +gdb_expect { + -re "$menu_overload1arg" { + pass "bp menu for foo::overload1arg choice cancel" + # Choose cancel. + send_gdb "0\n" + gdb_expect { + -re "canceled\r\n$gdb_prompt $" { + pass "set bp on overload1arg canceled" + } + -re "cancelled\r\n$gdb_prompt $" { + pass "set bp on overload1arg canceled" + } + -re ".*$gdb_prompt $" { + fail "set bp on overload1arg canceled (bad message)" + } + timeout { + fail "set bp on overload1arg canceled (timeout)" + take_gdb_out_of_choice_menu + } + } + } + -re ".*\r\n> " { + fail "bp menu for foo::overload1arg choice cancel (bad menu)" + take_gdb_out_of_choice_menu + } + -re ".*$gdb_prompt $" { + fail "bp menu for foo::overload1arg choice cancel (no menu)" + } + timeout { + fail "bp menu for foo::overload1arg choice cancel (timeout)" + take_gdb_out_of_choice_menu + } +} + +gdb_test "info break" \ + "Num Type\[\t \]+Disp Enb Address\[\t \]+What.* +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main(\\((|void)\\))? at.*$srcfile:49\r +\[\t \]+breakpoint already hit 1 time\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \ + "breakpoint info (after cancel)" + + + +# Delete these breakpoints. + +send_gdb "delete breakpoints\n" +gdb_expect { + -re "Delete all breakpoints.* $" { + send_gdb "y\n" + gdb_expect { + -re ".*$gdb_prompt $" { + pass "delete all breakpoints" + } + timeout { + fail "delete all breakpoints (timeout)" + } + } + } + timeout { + fail "delete all breakpoints (timeout)" + } +} + +gdb_test "info breakpoints" "No breakpoints or watchpoints." "breakpoint info (after delete)" + + + +# Test choice "all". +# This is copy-and-paste from set_bp_overloaded. + +send_gdb "break foo::overload1arg\n" +gdb_expect { + -re "$menu_overload1arg" { + pass "bp menu for foo::overload1arg choice all" + # Choose all. + send_gdb "1\n" + gdb_expect { + -re "Breakpoint $decimal at $hex: file.*$srcfile, line 121.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 120.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 119.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 118.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 117.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 116.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 115.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 114.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 113.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 112.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 111.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 110.\r\nwarning: Multiple breakpoints were set.\r\nUse the .delete. command to delete unwanted breakpoints.\r\n$gdb_prompt $" { + pass "set bp on overload1arg all" + } + -re ".*$gdb_prompt $" { + fail "set bp on overload1arg all (bad message)" + } + timeout { + fail "set bp on overload1arg all (timeout)" + take_gdb_out_of_choice_menu + } + } + } + -re ".*\r\n> " { + fail "bp menu for foo::overload1arg choice all (bad menu)" + take_gdb_out_of_choice_menu + } + -re ".*$gdb_prompt $" { + fail "bp menu for foo::overload1arg choice all (no menu)" + } + timeout { + fail "bp menu for foo::overload1arg choice all (timeout)" + take_gdb_out_of_choice_menu + } +} + +gdb_test "info break" \ + "Num Type\[\t \]+Disp Enb Address\[\t \]+What.* +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \ + "breakpoint info (after setting on all)" + + + +# Run through each breakpoint. + +# NOTE: carlton/2003-02-03: I'm seeing failures on some of the tests, +# with the wrong arg being printed out. Michael Chastain sees +# failures at times, too, albeit fewer than I do. + +proc continue_to_bp_overloaded {might_kfail bpnumber argtype actuals} { + global gdb_prompt hex decimal srcfile + + send_gdb "continue\n" + gdb_expect { + -re "Continuing.\r\n\r\nBreakpoint ${bpnumber}, (${hex} in )?foo::overload1arg(\\(${argtype}\\))? \\(this=${hex}(, )?${actuals}\\) at.*${srcfile}:${decimal}\r\n${decimal}\[\t \]+int foo::overload1arg \\(${argtype}( arg)?\\).*\r\n.*$gdb_prompt $" { + pass "continue to bp overloaded : ${argtype}" + } + -re "Continuing.\r\n\r\nBreakpoint ${bpnumber}, (${hex} in )?foo::overload1arg(\\(${argtype}\\))? \\(this=${hex}, arg=.*\\) at.*${srcfile}:${decimal}\r\n${decimal}\[\t \]+int foo::overload1arg \\(${argtype}( arg)?\\).*\r\n.*$gdb_prompt $" { + if $might_kfail { + kfail "gdb/1025" "continue to bp overloaded : ${argtype}" + } else { + fail "continue to bp overloaded : ${argtype}" + } + } + -re ".*$gdb_prompt $" { + fail "continue to bp overloaded : ${argtype}" + } + timeout { + fail "continue to bp overloaded : ${argtype} (timeout)" + } + } +} + +continue_to_bp_overloaded 0 25 "(void|)" "" +continue_to_bp_overloaded 1 24 "char" "arg=2 \\'\\\\002\\'" +continue_to_bp_overloaded 1 23 "signed char" "arg=3 \\'\\\\003\\'" +continue_to_bp_overloaded 1 22 "unsigned char" "arg=4 \\'\\\\004\\'" +continue_to_bp_overloaded 1 21 "short" "arg=5" +continue_to_bp_overloaded 1 20 "unsigned short" "arg=6" +continue_to_bp_overloaded 0 19 "int" "arg=7" +continue_to_bp_overloaded 0 18 "(unsigned|unsigned int)" "arg=8" +continue_to_bp_overloaded 0 17 "long" "arg=9" +continue_to_bp_overloaded 0 16 "unsigned long" "arg=10" +continue_to_bp_overloaded 0 15 "float" "arg=100" +continue_to_bp_overloaded 1 14 "double" "arg=200" + +# Test breaking on an overloaded function when multiple-symbols +# is set to "cancel" +gdb_test_no_output "set multiple-symbols cancel" +gdb_test "break foo::foofunc" \ + "canceled.*" + +# Test breaking on an overloaded function when multiple-symbols +# is set to "all" +gdb_test_no_output "set multiple-symbols all" +gdb_test "break foo::foofunc" \ + "Breakpoint \[0-9\]+ at ${hex}: file .*ovldbreak\\.cc, line \[0-9\]+\\.\r\nBreakpoint \[0-9\]+ at ${hex}: file .*ovldbreak\\.cc, line \[0-9\]+\\.\r\nwarning: Multiple breakpoints were set\\.\r\nUse the \"delete\" command to delete unwanted breakpoints\\." + +# That's all, folks. + +gdb_continue_to_end "finish program" Index: mb-inline.exp =================================================================== --- mb-inline.exp (nonexistent) +++ mb-inline.exp (revision 513) @@ -0,0 +1,128 @@ +# Copyright 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the gdb testsuite. + +# This test verifies that setting breakpoint on line in inline +# function will fire in all instantiations of that function. + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + + +set testfile "mb-inline" +set hdrfile "${testfile}.h" +set srcfile1 "${testfile}1.cc" +set objfile1 "${testfile}1.o" +set srcfile2 "${testfile}2.cc" +set objfile2 "${testfile}2.o" +set binfile "${objdir}/${subdir}/${testfile}" + +if { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } { + untested mb-inline.exp + return -1 +} + +if { [gdb_compile "$srcdir/$subdir/$srcfile2" "$objdir/$subdir/$objfile2" object {debug c++}] != "" } { + untested mb-inline.exp + return -1 +} + +if { [gdb_compile "$objdir/$subdir/$objfile1 $objdir/$subdir/$objfile2" "${binfile}" executable {debug c++}] != "" } { + untested mb-inline.exp + return -1 +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +set bp_location [gdb_get_line_number "set breakpoint here" $hdrfile] + +# Set a breakpoint with multiple locations. + +gdb_test "break $hdrfile:$bp_location" \ + "Breakpoint.*at.* file .*$hdrfile, line.*\\(2 locations\\).*" \ + "set breakpoint" + +gdb_run_cmd +gdb_expect { + -re "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*$gdb_prompt $" { + pass "run to breakpoint" + } + -re "$gdb_prompt $" { + fail "run to breakpoint" + } + timeout { + fail "run to breakpoint (timeout)" + } +} + +gdb_test "continue" \ + ".*Breakpoint.*foo \\(i=1\\).*" \ + "run to breakpoint 2" + +# Try disabling a single location. We also test +# that at least in simple cases, the enable/disable +# state of locations survive "run". +# Early bug would disable 1.1 and enable 1.2 when program is run. +gdb_test_no_output "disable 1.2" "disabling location: disable" + +gdb_run_cmd +gdb_expect { + -re "Breakpoint \[0-9\]+,.*foo \\(i=0\\).*$gdb_prompt $" { + pass "disabling location: run to breakpoint" + } + -re "$gdb_prompt $" { + fail "disabling location: run to breakpoint" + } + timeout { + fail "disabling location: run to breakpoint (timeout)" + } +} + +gdb_test "continue" \ + ".*Program exited normally.*" \ + "continue with disabled breakpoint 1.2" + +# Make sure we can set a breakpoint on a source statement that spans +# multiple lines. + +delete_breakpoints + +set bp_location [gdb_get_line_number "set multi-line breakpoint here" $hdrfile] + +if { ![runto_main] } { + fail "Can't run to main for multi_line_foo tests." + return 0 +} + +gdb_test "break $hdrfile:$bp_location" \ + "Breakpoint.*at.* file .*$hdrfile, line.*\\(2 locations\\).*" \ + "set multi_line_foo breakpoint" +gdb_test "continue" \ + ".*Breakpoint.*multi_line_foo \\(i=0\\).*" \ + "run to multi_line_foo breakpoint 4 afn" +gdb_test "continue" \ + ".*Breakpoint.*multi_line_foo \\(i=1\\).*" \ + "run to multi_line_foo breakpoint 4 bfn" Index: hang.exp =================================================================== --- hang.exp (nonexistent) +++ hang.exp (revision 513) @@ -0,0 +1,125 @@ +# Copyright 2002, 2004, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +if $tracelevel then { + strace $tracelevel +} + + +if { [skip_cplus_tests] } { continue } + +set testfile hang +set binfile ${objdir}/${subdir}/${testfile} + +foreach file {hang1 hang2 hang3} { + if {[gdb_compile "${srcdir}/${subdir}/${file}.cc" "${file}.o" object {c++ debug}] != ""} { + untested hang.exp + return -1 + } +} + +if {[gdb_compile "hang1.o hang2.o hang3.o" ${binfile} executable {c++ debug}] != "" } { + untested hang.exp + return -1 +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +# As of May 1, 2002, GDB hangs trying to read the debug info for the +# `hang2.o' compilation unit from the executable `hang', when compiled +# by g++ 2.96 with STABS debugging info. Here's what's going on, as +# best as I can tell. +# +# The definition of `struct A' in `hang.H' refers to `struct B' as an +# incomplete type. The stabs declare type number (1,3) to be a cross- +# reference type, `xsB:'. +# +# The definition of `struct C' contains a nested definition for +# `struct B' --- or more properly, `struct C::B'. However, the stabs +# fail to qualify the structure tag: it just looks like a definition +# for `struct B'. I think this is a compiler bug, but perhaps GCC +# doesn't emit qualified names for a reason. +# +# `hang.H' gets #included by both `hang1.C' and `hang2.C'. So the +# stabs for `struct A', the incomplete `struct B', and `struct C' +# appear in both hang1.o's and hang2.o's stabs. +# +# When those two files are linked together, since hang2.o appears +# later in the command line, its #inclusion of `hang.H' gets replaced +# with an N_EXCL stab, referring back to hang1.o's stabs for the +# header file. +# +# When GDB builds psymtabs for the executable hang, it notes that +# hang2.o's stabs contain an N_EXCL referring to a header that appears +# in full in hang1.o's stabs. So hang2.o's psymtab lists a dependency +# on hang1.o's psymtab. +# +# When the user types the command `print var_in_b', GDB scans the +# psymtabs for a symbol by that name, and decides to read full symbols +# for `hang2.o'. +# +# Since `hang2.o''s psymtab lists `hang1.o' as a dependency, GDB first +# reads `hang1.o''s symbols. When GDB sees `(1,3)=xsB:', it creates a +# type object for `struct B', sets its TYPE_FLAG_STUB flag, and +# records it as type number `(1,3)'. +# +# When GDB finds the definition of `struct C::B', since the stabs +# don't indicate that the type is nested within C, it treats it as +# a definition of `struct B'. +# +# When GDB is finished reading `hang1.o''s symbols, it calls +# `cleanup_undefined_types'. This function mistakes the definition of +# `struct C::B' for a definition for `struct B', and overwrites the +# incomplete type object for the real `struct B', using `memcpy'. Now +# stabs type number `(1,3)' refers to this (incorrect) complete type. +# Furthermore, the `memcpy' simply copies the original's `cv_type' +# field to the target, giving the target a corrupt `cv_type' ring: the +# chain does not point back to the target type. +# +# Having satisfied `hang2.o''s psymtab's dependencies, GDB begins to +# read `hang2.o''s symbols. These contain the true definition for +# `struct B', which refers to type number `(1,3)' as the type it's +# defining. GDB looks up type `(1,3)', and finds the (incorrect) +# complete type established by the call to `cleanup_undefined_types' +# above. However, it doesn't notice that the type is already defined, +# and passes it to `read_struct_type', which then writes the new +# definition's size, field list, etc. into the type object which +# already has those fields initialized. Adding insult to injury, +# `read_struct_type' then calls `finish_cv_type'; since the `memcpy' +# in `cleanup_undefined_types' corrupted the target type's `cv_type' +# ring, `finish_cv_type' enters an infinite loop. + +# This checks that GDB recognizes when a structure is about to be +# overwritten, and refuses, with a complaint. +gdb_test "print var_in_b" " = 1729" "doesn't overwrite struct type" + +# This checks that cleanup_undefined_types doesn't create corrupt +# cv_type chains. Note that var_in_hang3 does need to be declared in +# a separate compilation unit, whose psymtab depends on hang1.o's +# psymtab. Otherwise, GDB won't call cleanup_undefined_types (as it +# finishes hang1.o's symbols) before it calls make_cv_type (while +# reading hang3.o's symbols). +# +# The bug only happens when you compile with -gstabs+; Otherwise, GCC +# won't include the `const' qualifier on `const_B_ptr' in `hang3.o''s +# STABS, so GDB won't try to create a const variant of the smashed +# struct type, and get caught by the corrupted cv_type chain. +gdb_test "print var_in_hang3" " = 42" "doesn't corrupt cv_type chain" Index: cplusfuncs.cc =================================================================== --- cplusfuncs.cc (nonexistent) +++ cplusfuncs.cc (revision 513) @@ -0,0 +1,206 @@ +#include + +class foo { +public: + foo (int); + foo (int, const char *); + foo (foo&); + ~foo (); + + void operator * (foo&); + void operator % (foo&); + void operator - (foo&); + void operator >> (foo&); + void operator != (foo&); + void operator > (foo&); + void operator >= (foo&); + void operator | (foo&); + void operator && (foo&); + void operator ! (void); + void operator ++ (int); + void operator = (foo&); + void operator += (foo&); + void operator *= (foo&); + void operator %= (foo&); + void operator >>= (foo&); + void operator |= (foo&); + void operator , (foo&); + void operator / (foo&); + void operator + (foo&); + void operator << (foo&); + void operator == (foo&); + void operator < (foo&); + void operator <= (foo&); + void operator & (foo&); + void operator ^ (foo&); + void operator || (foo&); + void operator ~ (void); + void operator -- (int); + foo* operator -> (void); + void operator -= (foo&); + void operator /= (foo&); + void operator <<= (foo&); + void operator &= (foo&); + void operator ^= (foo&); + void operator ->* (foo&); + void operator [] (foo&); + void operator () (foo&); + void* operator new (size_t) throw (); + void* operator new[] (size_t) throw (); + void operator delete (void *); + void operator delete[] (void *); + /**/ operator int (); + /**/ operator char* (); + + int foofunc (int); // forced to have int return type, which is required + int foofunc (int, signed char *); // forced to have int return type, which is required + int ifoo; + const char *ccpfoo; +}; + +#ifdef usestubs +extern "C" { + void set_debug_traps(); + void breakpoint(); +}; +#endif + +int main () { +#ifdef usestubs + set_debug_traps(); + breakpoint(); +#endif + int z=3; +} + +foo::foo (int i) { ifoo = i;} +foo::foo (int i, const char *ccp) { ifoo = i; ccpfoo = ccp; } +foo::foo (foo& afoo) { afoo.ifoo = 0; } +foo::~foo () {} + +void foo::operator * (foo& afoo) { afoo.ifoo = 0; } +void foo::operator % (foo& afoo) { afoo.ifoo = 0; } +void foo::operator - (foo& afoo) { afoo.ifoo = 0; } +void foo::operator >> (foo& afoo) { afoo.ifoo = 0; } +void foo::operator != (foo& afoo) { afoo.ifoo = 0; } +void foo::operator > (foo& afoo) { afoo.ifoo = 0; } +void foo::operator >= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator | (foo& afoo) { afoo.ifoo = 0; } +void foo::operator && (foo& afoo) { afoo.ifoo = 0; } +void foo::operator ! (void) {} +void foo::operator ++ (int ival) { ival = 0; } +void foo::operator = (foo& afoo) { afoo.ifoo = 0; } +void foo::operator += (foo& afoo) { afoo.ifoo = 0; } +void foo::operator *= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator %= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator >>= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator |= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator , (foo& afoo) { afoo.ifoo = 0; } +void foo::operator / (foo& afoo) { afoo.ifoo = 0; } +void foo::operator + (foo& afoo) { afoo.ifoo = 0; } +void foo::operator << (foo& afoo) { afoo.ifoo = 0; } +void foo::operator == (foo& afoo) { afoo.ifoo = 0; } +void foo::operator < (foo& afoo) { afoo.ifoo = 0; } +void foo::operator <= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator & (foo& afoo) { afoo.ifoo = 0; } +void foo::operator ^ (foo& afoo) { afoo.ifoo = 0; } +void foo::operator || (foo& afoo) { afoo.ifoo = 0; } +void foo::operator ~ (void) {} +void foo::operator -- (int ival) { ival = 0; } +foo* foo::operator -> (void) {return this;} +void foo::operator -= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator /= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator <<= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator &= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator ^= (foo& afoo) { afoo.ifoo = 0; } +void foo::operator ->* (foo& afoo) { afoo.ifoo = 0; } +void foo::operator [] (foo& afoo) { afoo.ifoo = 0; } +void foo::operator () (foo& afoo) { afoo.ifoo = 0; } +void* foo::operator new (size_t ival) throw () { ival = 0; return 0; } +void* foo::operator new[] (size_t ival) throw () { ival = 0; return 0; } +void foo::operator delete (void *ptr) { ptr = 0; } +void foo::operator delete[] (void *ptr) { ptr = 0; } +/**/ foo::operator int () { return 0; } +/**/ foo::operator char* () { return 0; } + +/* Some functions to test overloading by varying one argument type. */ + +void overload1arg (void) { } +void overload1arg (char arg) { arg = 0; } +void overload1arg (signed char arg) { arg = 0; } +void overload1arg (unsigned char arg) { arg = 0; } +void overload1arg (short arg) { arg = 0; } +void overload1arg (unsigned short arg) { arg = 0; } +void overload1arg (int arg) { arg = 0; } +void overload1arg (unsigned int arg) { arg = 0; } +void overload1arg (long arg) { arg = 0; } +void overload1arg (unsigned long arg) { arg = 0; } +void overload1arg (float arg) { arg = 0; } +void overload1arg (double arg) { arg = 0; } + +/* Some functions to test overloading by varying argument count. */ + +void overloadargs (int a1) { a1 = 0; } +void overloadargs (int a1, int a2) { a1 = a2 = 0; } +void overloadargs (int a1, int a2, int a3) { a1 = a2 = a3 = 0; } +void overloadargs (int a1, int a2, int a3, int a4) + { a1 = a2 = a3 = a4 = 0; } +void overloadargs (int a1, int a2, int a3, int a4, int a5) + { a1 = a2 = a3 = a4 = a5 = 0; } +void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6) + { a1 = a2 = a3 = a4 = a5 = a6 = 0; } +void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = 0; } +void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = 0; } +void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = 0; } +void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = + a10 = 0; } +void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10, int a11) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = + a10 = a11 == 0; } + +/* Some hairy function definitions. + Use typedefs to help maintain sanity. */ + +typedef int (*PFPc_i)(char *); +typedef short (*PFPl_s)(long *); +typedef short (*PFPc_s)(char *); +typedef int (*PFl_i)(long); +typedef PFl_i (*PFPc_PFl_i)(char *); +typedef PFl_i (*PFPi_PFl_i)(int *); +typedef PFl_i (*PFPFPc_i_PFl_i)(PFPc_i); +typedef PFl_i (*PFs_PFl_i)(short); +typedef int (*PFPFPl_s_i)(PFPl_s); +typedef int (*PFPFPc_s_i)(PFPc_s); + +PFs_PFl_i hairyfunc1 (int arg) { arg = 0; return 0; } +int hairyfunc2 (PFPc_i arg) { arg = 0; return 0; } +int hairyfunc3 (PFPFPl_s_i arg) { arg = 0; return 0; } +int hairyfunc4 (PFPFPc_s_i arg) { arg = 0; return 0; } +int hairyfunc5 (PFPc_PFl_i arg) { arg = 0; return 0; } +int hairyfunc6 (PFPi_PFl_i arg) { arg = 0; return 0; } +int hairyfunc7 (PFPFPc_i_PFl_i arg) { arg = 0; return 0; } + +/* gdb has two demanglers (one for g++ 2.95, one for g++ 3). + These marker functions help me figure out which demangler is in use. */ + +char * dm_type_char_star (char * p) { return p; } +int dm_type_foo_ref (foo & foo) { return foo.ifoo; } +int * dm_type_int_star (int * p) { return p; } +long * dm_type_long_star (long * p) { return p; } +int dm_type_short (short i) { return i; } +int dm_type_long (long i) { return i; } +int dm_type_unsigned_int (unsigned int i) { return i; } +int dm_type_unsigned_short (unsigned short i) { return i; } +int dm_type_unsigned_long (unsigned long i) { return i; } +int dm_type_void (void) { return 0; } +void * dm_type_void_star (void * p) { return p; } +typedef int myint; +int dm_type_typedef (myint i) { return i; } Index: re-set-overloaded.exp =================================================================== --- re-set-overloaded.exp (nonexistent) +++ re-set-overloaded.exp (revision 513) @@ -0,0 +1,61 @@ +# Copyright 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +if { [skip_cplus_tests] } { continue } +if { [skip_shlib_tests] } { continue } + +set testfile re-set-overloaded +set srcfile bool.cc +set executable $testfile +set binfile $objdir/$subdir/$executable + +set libsrcfile ${testfile}.cc +set sofile $objdir/$subdir/${testfile}.so + +# Create and source the file that provides information about the compiler +# used to compile the test case. +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +if { [gdb_compile_shlib $srcdir/$subdir/$libsrcfile $sofile {debug c++}] != "" + || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug "c++" shlib=${sofile}]] != ""} { + untested ${testfile}.exp + return -1 +} + +clean_restart $executable +gdb_load_shlibs ${sofile} + +gdb_test_no_output "set breakpoint pending yes" +gdb_test "break C::C" {Breakpoint [0-9]+ \(C::C\) pending\.} "break C::C" +gdb_test_no_output {set variable $brk = $bpnum} + +# runto or runto_main would call delete_breakpoints. +gdb_breakpoint "main" +gdb_run_cmd +setup_kfail breakpoints/11657 *-*-* +gdb_test "" ".*" "start" + +set test "breakpoint resolved" +gdb_test_multiple {info breakpoints $brk} $test { + -re "" { + kfail breakpoints/11657 $test + } + -re "\r\n$gdb_prompt $" { + # FIXME: Check more specific resolution state. + pass $test + } +} Index: m-static.exp =================================================================== --- m-static.exp (nonexistent) +++ m-static.exp (revision 513) @@ -0,0 +1,151 @@ +# Copyright 2002, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Tests for member static data +# 2002-05-13 Benjamin Kosnik +# 2002-08-22 David Carlton + +# This file is part of the gdb testsuite + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + +# +# test running programs +# + +set testfile "m-static" +set srcfile "${testfile}.cc" +set srcfile1 "${testfile}1.cc" +set objfile "${testfile}.o" +set objfile1 "${testfile}1.o" +set binfile "${objdir}/${subdir}/${testfile}" + +if { [gdb_compile "$srcdir/$subdir/$srcfile" "$objdir/$subdir/$objfile" object {debug c++}] != "" } { + untested m-static.exp + return -1 +} + +if { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } { + untested m-static.exp + return -1 +} + +if { [gdb_compile "$objdir/$subdir/$objfile $objdir/$subdir/$objfile1" "${binfile}" executable {debug c++}] != "" } { + untested m-static.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +get_debug_format +set non_dwarf [expr ! [test_debug_format "DWARF 2"]] + +# First, run to after we've constructed all the objects: + +gdb_breakpoint [gdb_get_line_number "constructs-done"] +gdb_continue_to_breakpoint "end of constructors" + + +# One. + +# simple object, static const bool +gdb_test "print test1.test" "\\$\[0-9\]* = true" "simple object, static const bool" + +# simple object, static const int +gdb_test "print test1.key1" "\\$\[0-9\]* = 5" "simple object, static const int" + +# simple object, static long +gdb_test "print test1.key2" "\\$\[0-9\]* = 77" "simple object, static long" + +# simple object, static enum +gdb_test "print test1.value" "\\$\[0-9\]* = oriental" "simple object, static enum" + +# Two. + +# derived template object, base static const bool +gdb_test "print test2.test" "\\$\[0-9\]* = true" "derived template object, base static const bool" + +# derived template object, base static const int +gdb_test "print test2.key1" "\\$\[0-9\]* = 5" "derived template object, base static const int" + +# derived template object, base static long +gdb_test "print test2.key2" "\\$\[0-9\]* = 77" "derived template object, base static long" + +# derived template object, base static enum +gdb_test "print test2.value" "\\$\[0-9\].* = oriental" "derived template object, base static enum" + +# derived template object, static enum +gdb_test "print test2.value_derived" "\\$\[0-9\].* = etruscan" "derived template object, static enum" + +# Three. + +# template object, static derived template data member's base static const bool +gdb_test "print test3.data.test" "\\$\[0-9\].* = true" "template object, static const bool" + +# template object, static derived template data member's base static const int +gdb_test "print test3.data.key1" "\\$\[0-9\].* = 5" "template object, static const int" + +# template object, static derived template data member's base static long +gdb_test "print test3.data.key2" "\\$\[0-9\].* = 77" "template object, static long" + +# template object, static derived template data member's base static enum +gdb_test "print test3.data.value" "\\$\[0-9\].* = oriental" "template object, static enum" + +# template object, static derived template data member's static enum +gdb_test "print test3.data.value_derived" "\\$\[0-9\].* = etruscan" "template object, static derived enum" + +# 2002-08-16 +# Four. + +# static const int initialized in another file. +gdb_test "print test4.elsewhere" "\\$\[0-9\].* = 221" "static const int initialized elsewhere" + +# static const int that nobody initializes. From PR gdb/635. +gdb_test "print test4.nowhere" "field nowhere is nonexistent or has been optimized out" "static const int initialized nowhere" + +# static const initialized in the class definition, PR gdb/11702. +if { $non_dwarf } { setup_xfail *-*-* } +gdb_test "print test4.everywhere" "\\$\[0-9\].* = 317" "static const int initialized in class definition" +if { $non_dwarf } { setup_xfail *-*-* } +gdb_test "print test4.somewhere" "\\$\[0-9\].* = 3.14\[0-9\]*" "static const float initialized in class definition" + +# Also make sure static const members can be found via "info var". +if { $non_dwarf } { setup_xfail *-*-* } +gdb_test "info variable everywhere" "File .*/m-static\[.\]h.*const int gnu_obj_4::everywhere;" "info variable everywhere" + +# Perhaps at some point test4 should also include a test for a static +# const int that was initialized in the header file. But I'm not sure +# that GDB's current behavior in such situations is either consistent +# across platforms or optimal, so I'm not including one now. + +# Step into test1.method and examine the method-scoped static. +# This is a regression test for PR 9708. +gdb_test "step" "gnu_obj_1::method.*" +gdb_test "print svar" " = true" + +gdb_exit +return 0 Index: pass-by-ref.cc =================================================================== --- pass-by-ref.cc (nonexistent) +++ pass-by-ref.cc (revision 513) @@ -0,0 +1,79 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +class Obj { +public: + Obj (); + Obj (const Obj &); + ~Obj (); + int var[2]; +}; + +int foo (Obj arg) +{ + return arg.var[0] + arg.var[1]; +} + +Obj::Obj () +{ + var[0] = 1; + var[1] = 2; +} + +Obj::Obj (const Obj &obj) +{ + var[0] = obj.var[0]; + var[1] = obj.var[1]; +} + +Obj::~Obj () +{ + +} + +struct Derived : public Obj +{ + int other; +}; + +int blap (Derived arg) +{ + return foo (arg); +} + +struct Container +{ + Obj obj; +}; + +int blip (Container arg) +{ + return foo (arg.obj); +} + +Obj global_obj; +Derived global_derived; +Container global_container; + +int +main () +{ + int bar = foo (global_obj); + blap (global_derived); + blip (global_container); + return bar; +} Index: pr10728.exp =================================================================== --- pr10728.exp (nonexistent) +++ pr10728.exp (revision 513) @@ -0,0 +1,66 @@ +# Copyright 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the gdb testsuite + +set nl "\[\r\n\]+" + +if { [skip_cplus_tests] } { continue } + +load_lib "cp-support.exp" + +set testfile "pr10728" +set srcfile ${testfile}-x.cc +set tfx ${testfile}-x +set tfy ${testfile}-y +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${tfy}.cc" "${tfy}.o" object {c++}] != "" } { + untested pr10728.exp + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${tfx}.cc" "${tfx}.o" object {debug c++}] != "" } { + untested pr10728.exp + return -1 +} + +if { [gdb_compile "${tfx}.o ${tfy}.o" ${binfile} executable {debug c++}] != "" } { + untested pr10728.exp + return -1 +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +# set a breakpoint at the return stmt + +gdb_breakpoint [gdb_get_line_number "marker 1"] +gdb_continue_to_breakpoint "marker 1" + +gdb_test "print x->y2 - x->y1" "warning: Type size unknown, assuming 1\. Try casting to a known type, or void \*\.\[^=\]*= 1" + +gdb_exit +return 0 + + Index: shadow.exp =================================================================== --- shadow.exp (nonexistent) +++ shadow.exp (revision 513) @@ -0,0 +1,95 @@ +# Copyright 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test that when multiple variables have the same +# name the one from the correct scope is printed. + +if $tracelevel then { + strace $tracelevel +} + + +set testfile shadow +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested "Couldn't compile test program" + return -1 +} + +if [get_compiler_info ${binfile}] { + return -1 +} + +# Get things started. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint main" + continue +} + +############################################ +# Test printing of class variable is not shadowed +# by global variable + +gdb_breakpoint [gdb_get_line_number "marker1"] +gdb_continue_to_breakpoint "marker1" + +gdb_test "print x" "= 33" "Print class x shadowing global x" + + +############################################ +# Test printing local variable is not shadowed +# by class variable + +gdb_breakpoint [gdb_get_line_number "marker2"] +gdb_continue_to_breakpoint "marker2" + +gdb_test "print x" "= 44" "Print local x shadowing class x" + +############################################ +# Test inner scope x is printed not outer scope + +gdb_breakpoint [gdb_get_line_number "marker3"] +gdb_continue_to_breakpoint "marker3" + +gdb_test "print x" "= 55" "Print inner scope x" + +############################################ +# Test printing local variable is not shadowed +# by namespace variable + +gdb_breakpoint [gdb_get_line_number "marker4"] +gdb_continue_to_breakpoint "marker4" + +gdb_test "print x" "= 55" "Print local x not namespace x" + +############################################ +# Test imported namespace element is printed + +gdb_breakpoint [gdb_get_line_number "marker5"] +gdb_continue_to_breakpoint "marker5" + +if { [test_compiler_info {gcc-[0-3]-*}] || + [test_compiler_info {gcc-4-[0-3]-*}]} { + setup_xfail *-*-* +} + +gdb_test "print x" "= 11" "Print imported namespace x" Index: cttiadd1.cc =================================================================== --- cttiadd1.cc (nonexistent) +++ cttiadd1.cc (revision 513) @@ -0,0 +1,35 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 1998, 1999, 2004, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +template T add(T v1, T v2); + +void add1() +{ + unsigned char c; + int i; + float f; + + c = 'b'; + i = 3; + f = 6.5; + + c = add(c, c); + i = add(i, i); + f = add(f, f); +} Index: class2.exp =================================================================== --- class2.exp (nonexistent) +++ class2.exp (revision 513) @@ -0,0 +1,124 @@ +# Copyright 2003, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + + +set testfile "class2" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +# Create and source the file that provides information about the compiler +# used to compile the test case. +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested class2.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +# Start with "set print object off". + +gdb_test_no_output "set print object off" + +if ![runto_main] then { + perror "couldn't run to main" + continue +} + +get_debug_format + +gdb_test "break [gdb_get_line_number "marker return 0"]" \ + "Breakpoint.*at.* file .*" "" + +gdb_test "continue" "Breakpoint .* at .*" "" + +# Access the "A" object. + +gdb_test "print alpha" \ + "= {.*a1 = 100.*}" \ + "print alpha at marker return 0" + +# Access the "B" object. + +gdb_test "print beta" \ + "= {.*a1 = 200.*b1 = 201.*b2 = 202}" \ + "print beta at marker return 0" + +# Access the "A" object through an "A *" pointer. + +gdb_test_multiple "print * aap" "print * aap at marker return 0" { + -re "= {.*a1 = 100.*}\r\n$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + # gcc 3.3.2 -gdwarf-2 + # gcc 3.3.2 -gstabs+ + pass "print * aap at marker return 0" + } + -re "= {.*a1 = .*}\r\n$gdb_prompt $" { + if { [test_compiler_info gcc-2-*] && [test_debug_format "DWARF 2"] } { + # gcc 2.95.3 -gdwarf-2 + setup_kfail "gdb/1465" "*-*-*" + } + fail "print * aap at marker return 0" + } +} + +# Access the "B" object through a "B *" pointer. + +gdb_test "print * bbp" \ + "= {.*a1 = 200.*b1 = 201.*b2 = 202}" \ + "print * bbp at marker return 0" + +# Access the "B" object through an "A *" pointer. +# This should print using the "A" type. + +gdb_test_multiple "print * abp" "print * abp at marker return 0, s-p-o off" { + -re "= {.*a1 = 200.*b1 = .*b2 = .*}\r\n$gdb_prompt $" { + # This would violate the documentation for "set print object off". + fail "print * abp at marker return 0, s-p-o off" + } + -re "= {.*a1 = 200.*}\r\n$gdb_prompt $" { + pass "print * abp at marker return 0, s-p-o off" + } +} + +# Access the "B" object through a "B *" pointer expression. +# This should print using the "B" type. + +gdb_test "print * (B *) abp" \ + "= {.*a1 = 200.*b1 = 201.*b2 = 202}" \ + "print * (B *) abp at marker return 0" + +# Printing the value of an object containing no data fields: + +gdb_test "p e" "= \{\}" "print object with no data fields" + +# Printing NULL pointers with "set print object on" + +gdb_test_no_output "set print object on" +gdb_test "p acp" "= \\(C \\*\\) ${hex}" +gdb_test "p acp->c1" "\\(A \\*\\) 0x0" +gdb_test "p acp->c2" "\\(A \\*\\) ${hex}f" Index: call-c.exp =================================================================== --- call-c.exp (nonexistent) +++ call-c.exp (revision 513) @@ -0,0 +1,52 @@ +# Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +if $tracelevel then { + strace $tracelevel +} + + +if { [skip_cplus_tests] } { continue } + +set testfile call-c +set binfile ${objdir}/${subdir}/${testfile} +set srcfilec ${srcdir}/${subdir}/${testfile}-1.c +set srcfilecpp ${srcdir}/${subdir}/${testfile}.cc +set objfilec ${objdir}/${subdir}/${testfile}-1.o +set objfilecpp ${objdir}/${subdir}/${testfile}.o + +if {[gdb_compile "${srcfilec}" "${objfilec}" object {debug}] != "" + || [gdb_compile "${srcfilecpp}" "${objfilecpp}" object {c++ debug}] != "" + || [gdb_compile "${objfilecpp} ${objfilec}" "${binfile}" executable {c++ debug}] != ""} { + untested hang.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +runto_main + +gdb_test "b [gdb_get_line_number {breakpoint here} ${testfile}.cc ]" \ + ".*Breakpoint .*call-c.*" + +gdb_test "print foo(1)" "\\\$$decimal = 1" +gdb_test "continue" ".*breakpoint here.*" "continue to bp" +gdb_test "print rf->func()" "\\\$$decimal = 1" + +# Regression test for method call via a typedef. +gdb_test "print handle->func()" "\\\$$decimal = 1" Index: pr9631.cc =================================================================== --- pr9631.cc (nonexistent) +++ pr9631.cc (revision 513) @@ -0,0 +1,42 @@ +/* This test script is part of GDB, the GNU debugger. + + Copyright 2009, + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +namespace foo +{ + class vbase + { + public: + virtual ~vbase() {} + }; +}; + +class empty_base +{ +}; + +class bar : public foo::vbase, public virtual empty_base +{ +}; + +int +main(int argc, char *argv[]) +{ + bar tender; + return 0; /* set breakpoint here */ +} Index: classes.exp =================================================================== --- classes.exp (nonexistent) +++ classes.exp (revision 513) @@ -0,0 +1,639 @@ +# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, +# 2004, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file was written by Fred Fish. (fnf@cygnus.com) +# And rewritten by Michael Chastain . + +set nl "\[\r\n\]+" + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +load_lib "cp-support.exp" + +set testfile "classes" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested classes.exp + return -1 +} + +# Test ptype of class objects. + +proc test_ptype_class_objects {} { + + # Simple type. + + cp_test_ptype_class \ + "ptype struct default_public_struct" "" "struct" "default_public_struct" \ + { + { field public "int a;" } + { field public "int b;" } + } + + # Another simple type. + + cp_test_ptype_class \ + "ptype struct explicit_public_struct" "" "struct" "explicit_public_struct" \ + { + { field public "int a;" } + { field public "int b;" } + } + + # Another simple type. + + cp_test_ptype_class \ + "ptype struct protected_struct" "" "struct" "protected_struct" \ + { + { field protected "int a;" } + { field protected "int b;" } + } + + # Another simple type. + + cp_test_ptype_class \ + "ptype struct private_struct" "" "struct" "private_struct" \ + { + { field private "int a;" } + { field private "int b;" } + } + + # A bigger type. + + cp_test_ptype_class \ + "ptype struct mixed_protection_struct" "" "struct" "mixed_protection_struct" \ + { + { field public "int a;" } + { field public "int b;" } + { field private "int c;" } + { field private "int d;" } + { field protected "int e;" } + { field protected "int f;" } + { field public "int g;" } + { field private "int h;" } + { field protected "int i;" } + } + + # All that again with "class" instead of "struct". + # gdb does not care about the difference anyways. + + cp_test_ptype_class \ + "ptype class public_class" "" "class" "public_class" \ + { + { field public "int a;" } + { field public "int b;" } + } + + # Another simple type. + + cp_test_ptype_class \ + "ptype class protected_class" "" "class" "protected_class" \ + { + { field protected "int a;" } + { field protected "int b;" } + } + + # Another simple type. + + cp_test_ptype_class \ + "ptype class default_private_class" "" "class" "default_private_class" \ + { + { field private "int a;" } + { field private "int b;" } + } + + # Another simple type. + + cp_test_ptype_class \ + "ptype class explicit_private_class" "" "class" "explicit_private_class" \ + { + { field private "int a;" } + { field private "int b;" } + } + + # A bigger type. + + cp_test_ptype_class \ + "ptype class mixed_protection_class" "" "class" "mixed_protection_class" \ + { + + { field public "int a;" } + { field public "int b;" } + { field private "int c;" } + { field private "int d;" } + { field protected "int e;" } + { field protected "int f;" } + { field public "int g;" } + { field private "int h;" } + { field protected "int i;" } + } + + # Here are some classes with inheritance. + + # Base class. + + cp_test_ptype_class \ + "ptype class A" "" "class" "A" \ + { + { field public "int a;" } + { field public "int x;" } + } + + # Derived class. + + cp_test_ptype_class \ + "ptype class B" "" "class" "B" \ + { + { base "public A" } + { field public "int b;" } + { field public "int x;" } + } + + # Derived class. + + cp_test_ptype_class \ + "ptype class C" "" "class" "C" \ + { + { base "public A" } + { field public "int c;" } + { field public "int x;" } + } + + # Derived class, multiple inheritance. + + cp_test_ptype_class \ + "ptype class D" "" "class" "D" \ + { + { base "public B" } + { base "public C" } + { field public "int d;" } + { field public "int x;" } + } + + # Derived class. + + cp_test_ptype_class \ + "ptype class E" "" "class" "E" \ + { + { base "public D" } + { field public "int e;" } + { field public "int x;" } + } + + # This is a break from inheritance tests. + # + # gcc 2.X with stabs (stabs or stabs+?) used to have a problem with + # static methods whose name is the same as their argument mangling. + + cp_test_ptype_class \ + "ptype class Static" "" "class" "Static" \ + { + { method public "static void ii(int, int);" } + } + + # Here are some virtual inheritance tests. + + # A virtual base class. + + cp_test_ptype_class \ + "ptype class vA" "" "class" "vA" \ + { + { field public "int va;" } + { field public "int vx;" } + } + + # A derived class with a virtual base. + + cp_test_ptype_class \ + "ptype class vB" "" "class" "vB" \ + { + { base "public virtual vA" } + { vbase "vA" } + { field public "int vb;" } + { field public "int vx;" } + } + + # Another derived class with a virtual base. + + cp_test_ptype_class \ + "ptype class vC" "" "class" "vC" \ + { + { base "public virtual vA" } + { vbase "vA" } + { field public "int vc;" } + { field public "int vx;" } + } + + # A classic diamond class. + + cp_test_ptype_class \ + "ptype class vD" "" "class" "vD" \ + { + { base "public virtual vB" } + { base "public virtual vC" } + { vbase "vC" } + { vbase "vB" } + { field public "int vd;" } + { field public "int vx;" } + } + + # A class derived from a diamond class. + + cp_test_ptype_class \ + "ptype class vE" "" "class" "vE" \ + { + { base "public virtual vD" } + { vbase "vD" } + { field public "int ve;" } + { field public "int vx;" } + } + + # Another inheritance series. + + # A base class. + + cp_test_ptype_class \ + "ptype class Base1" "" "class" "Base1" \ + { + { field public "int x;" } + { method public "Base1(int);" } + } + + # Another base class. + + cp_test_ptype_class \ + "ptype class Foo" "" "class" "Foo" \ + { + { field public "int x;" } + { field public "int y;" } + { field public "static int st;" } + { method public "Foo(int, int);" } + { method public "int operator!();" } + { method public "operator int();" } + { method public "int times(int);" } + } \ + "" \ + { + { + "operator int();" + "int operator int();" + { setup_kfail "gdb/1497" "*-*-*" } + } + { + "operator int();" + "int operator int(void);" + { setup_kfail "gdb/1497" "*-*-*" } + } + } + + # A multiple inheritance derived class. + + cp_test_ptype_class \ + "ptype class Bar" "" "class" "Bar" \ + { + { base "public Base1" } + { base "public Foo" } + { field public "int z;" } + { method public "Bar(int, int, int);" } + } + +} + +# Test simple access to class members. + +proc test_non_inherited_member_access {} { + + # Print non-inherited members of g_A. + gdb_test "print g_A.a" ".* = 1" + gdb_test "print g_A.x" ".* = 2" + + # Print non-inherited members of g_B. + gdb_test "print g_B.b" ".* = 5" + gdb_test "print g_B.x" ".* = 6" + + # Print non-inherited members of g_C. + gdb_test "print g_C.c" ".* = 9" + gdb_test "print g_C.x" ".* = 10" + + # Print non-inherited members of g_D. + gdb_test "print g_D.d" ".* = 19" + gdb_test "print g_D.x" ".* = 20" + + # Print non-inherited members of g_E. + gdb_test "print g_E.e" ".* = 31" + gdb_test "print g_E.x" ".* = 32" +} + +# Test access to members of other classes. +# gdb should refuse to print them. +# (I feel old -- I remember when this was legal in C -- chastain). + +proc test_wrong_class_members {} { + gdb_test "print g_A.b" "There is no member( or method|) named b." + gdb_test "print g_B.c" "There is no member( or method|) named c." + gdb_test "print g_B.d" "There is no member( or method|) named d." + gdb_test "print g_C.b" "There is no member( or method|) named b." + gdb_test "print g_C.d" "There is no member( or method|) named d." + gdb_test "print g_D.e" "There is no member( or method|) named e." +} + +# Test access to names that are not members of any class. + +proc test_nonexistent_members {} { + gdb_test "print g_A.y" "There is no member( or method|) named y." + gdb_test "print g_B.z" "There is no member( or method|) named z." + gdb_test "print g_C.q" "There is no member( or method|) named q." + gdb_test "print g_D.p" "There is no member( or method|) named p." +} + +# Call a method that expects a base class parameter with base, inherited, +# and unrelated class arguments. + +proc test_method_param_class {} { + gdb_test "call class_param.Aptr_a (&g_A)" ".* = 1" + gdb_test "call class_param.Aptr_x (&g_A)" ".* = 2" + gdb_test "call class_param.Aptr_a (&g_B)" ".* = 3" + gdb_test "call class_param.Aptr_x (&g_B)" ".* = 4" + gdb_test "call class_param.Aref_a (g_A)" ".* = 1" + gdb_test "call class_param.Aref_x (g_A)" ".* = 2" + gdb_test "call class_param.Aref_a (g_B)" ".* = 3" + gdb_test "call class_param.Aref_x (g_B)" ".* = 4" + gdb_test "call class_param.Aval_a (g_A)" ".* = 1" + gdb_test "call class_param.Aval_x (g_A)" ".* = 2" + gdb_test "call class_param.Aval_a (g_B)" ".* = 3" + gdb_test "call class_param.Aval_x (g_B)" ".* = 4" + + gdb_test "call class_param.Aptr_a (&foo)" "Cannot resolve .*" "unrelated class *param" + gdb_test "call class_param.Aref_a (foo)" "Cannot resolve .*" "unrelated class ¶m" + gdb_test "call class_param.Aval_a (foo)" "Cannot resolve .*" "unrelated class param" +} + +# Examine a class with an enum field. + +proc test_enums {} { + global gdb_prompt + global nl + + # print the object + + # We match the enum values with and without qualifiers. As of + # 2008-08-21 we can output the qualifiers for DWARF-2. + + gdb_test "print obj_with_enum" \ + "\\$\[0-9\]+ = \{priv_enum = (ClassWithEnum::)?red, x = 0\}" \ + "print obj_with_enum (1)" + + # advance one line + + gdb_test "next" ".*" + + # print the object again + + gdb_test "print obj_with_enum" \ + "\\$\[0-9\]+ = \{priv_enum = (ClassWithEnum::)?green, x = 0\}" \ + "print obj_with_enum (2)" + + # print the enum member + + gdb_test "print obj_with_enum.priv_enum" "\\$\[0-9\]+ = (ClassWithEnum::)?green" + + # ptype on the enum member + + gdb_test_multiple "ptype obj_with_enum.priv_enum" "ptype obj_with_enum.priv_enum" { + -re "type = enum ClassWithEnum::PrivEnum \{ ?(ClassWithEnum::)?red, (ClassWithEnum::)?green, (ClassWithEnum::)?blue, (ClassWithEnum::)?yellow = 42 ?\}$nl$gdb_prompt $" { + pass "ptype obj_with_enum.priv_enum" + } + -re "type = enum PrivEnum \{ ?(ClassWithEnum::)?red, (ClassWithEnum::)?green, (ClassWithEnum::)?blue, (ClassWithEnum::)?yellow = 42 ?\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 3.3.2 -gdwarf-2 + pass "ptype obj_with_enum.priv_enum" + } + -re "type = enum \{ ?red, green, blue, yellow = 42 ?\}$nl$gdb_prompt $" { + # This case case is a little dubious, but it's not clear what + # ought to be required of a ptype on a private enum... + # -sts 19990324 + # + # It bugs me that this happens with gcc 3. + # -- chastain 2003-12-30 + # + # gcc 2.95.3 -gstabs+ + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ + pass "ptype obj_with_enum.priv_enum" + } + } + + # ptype on the object + + # NOTE: carlton/2003-02-28: One could certainly argue that plain + # "PrivEnum" + # is acceptable: PrivEnum is a member of ClassWithEnum, so + # there's no need to explicitly qualify its name with + # "ClassWithEnum::". The truth, though, is that GDB is simply + # forgetting that PrivEnum is a member of ClassWithEnum, so we do + # that output for a bad reason instead of a good reason. Under + # stabs, we probably can't get this right; under DWARF-2, we can. + + cp_test_ptype_class \ + "ptype obj_with_enum" "" "class" "ClassWithEnum" \ + { + { field public "ClassWithEnum::PrivEnum priv_enum;" } + { field public "int x;" } + } \ + "" \ + { + { + "ClassWithEnum::PrivEnum priv_enum;" + "PrivEnum priv_enum;" + { setup_kfail "gdb/57" "*-*-*" } + } + } + + # I'll do this test two different ways, because of a parser bug. + # See PR gdb/1588. + + gdb_test_multiple "print (ClassWithEnum::PrivEnum) 42" "print (ClassWithEnum::PrivEnum) 42" { + -re "\\$\[0-9\]+ = (ClassWithEnum::)?yellow$nl$gdb_prompt $" { + pass "print (ClassWithEnum::PrivEnum) 42" + } + -re "A (parse|syntax) error in expression, near `42'.$nl$gdb_prompt $" { + # "parse error" is bison 1.35. + # "syntax error" is bison 1.875. + kfail "gdb/1588" "print (ClassWithEnum::PrivEnum) 42" + } + } + + gdb_test_multiple "print ('ClassWithEnum::PrivEnum') 42" "print ('ClassWithEnum::PrivEnum') 42" { + -re "\\$\[0-9\]+ = (ClassWithEnum::)?yellow$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ + pass "print ('ClassWithEnum::PrivEnum') 42" + } + -re "No symbol \"ClassWithEnum::PrivEnum\" in current context.$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 + # gcc 2.95.3 -gstabs+ + kfail "gdb/57" "print ('ClassWithEnum::PrivEnum') 42" + } + } +} + +# Pointers to class members + +proc test_pointers_to_class_members {} { + gdb_test "print Bar::z" "Cannot reference non-static field \"z\"" + gdb_test "print &Foo::x" "\\$\[0-9\]+ = &Foo::x" + gdb_test "print (int)&Foo::x" "\\$\[0-9\]+ = 0" + gdb_test "print (int)&Bar::y == 2*sizeof(int)" "\\$\[0-9\]+ = true" + + gdb_test "ptype Bar::z" "type = int" + gdb_test "ptype &Bar::z" "type = int Bar::\\*" + + # TODO: this is a bogus test. It's looking at a variable that + # has not even been declared yet, so it's accessing random junk + # on the stack and comparing that it's NOT equal to a specific + # value. It's been like this since gdb 4.10 in 1993! + # -- chastain 2004-01-01 + gdb_test "print (int)pmi == sizeof(int)" ".* = false" +} + +# Test static members. + +proc test_static_members {} { + global hex + + gdb_test "print Foo::st" "\\$\[0-9\]+ = 100" + gdb_test_no_output "set foo.st = 200" "" + gdb_test "print bar.st" "\\$\[0-9\]+ = 200" + gdb_test "print &foo.st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex" + gdb_test "print &Bar::st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex" + gdb_test "print *\$" "\\$\[0-9\]+ = 200" + + gdb_test_no_output "set print static-members off" + gdb_test "print csi" \ + "{x = 10, y = 20}" \ + "print csi without static members" + gdb_test "print cnsi" \ + "{x = 30, y = 40}" \ + "print cnsi without static members" + + gdb_test_no_output "set print static-members on" + gdb_test "print csi" \ + "{x = 10, y = 20, static null = {x = 0, y = 0, static null = }}" \ + "print csi with static members" + gdb_test "print cnsi" \ + "{x = 30, y = 40, static null = {x = 0, y = 0, static null = , static yy = {z = 5, static xx = {x = 1, y = 2, static null = , static yy = }}}, static yy = }" \ + "print cnsi with static members" +} + +proc do_tests {} { + global subdir + global objdir + global srcdir + global binfile + global gdb_prompt + global nl + + + # Start with a fresh gdb. + + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load $binfile + + gdb_test_no_output "set language c++" "" + gdb_test_no_output "set width 0" "" + + if ![runto_main ] then { + perror "couldn't run to breakpoint" + return + } + + gdb_breakpoint inheritance2 + gdb_test "continue" ".*Breakpoint .* inheritance2.*" "" + + test_ptype_class_objects + test_non_inherited_member_access + test_wrong_class_members + test_nonexistent_members + test_method_param_class + + gdb_breakpoint enums2 + gdb_test "continue" ".*Breakpoint .* enums2.*" "continue to enums2(\\(\\)|)" + # Leave enums2. Make sure we reach the next line, in case there + # are any more instructions to finish the function call. + gdb_test_multiple "finish" "" { + -re "enums2 \\(\\);.*$gdb_prompt $" { + gdb_test "next" ".*" "" + } + -re "$gdb_prompt $" { } + } + test_enums + + gdb_test "finish" ".*" "" + test_pointers_to_class_members + test_static_members + + # Now some random tests that were just thrown in here. + + gdb_breakpoint marker_reg1 + gdb_test "continue" ".*Breakpoint .* marker_reg1.*" "" + gdb_test "finish" "Run till exit from.*" "finish from marker_reg1" + + # This class is so small that an instance of it can fit in a register. + # When gdb tries to call a method, it gets embarrassed about taking + # the address of a register. + # + # TODO: I think that message should be a PASS, not an XFAIL. + # gdb prints an informative message and declines to do something + # impossible. + # + # The method call actually succeeds if the compiler allocates very + # small classes in memory instead of registers. So this test does + # not tell us anything interesting if the call succeeds. + # + # -- chastain 2003-12-31 + gdb_test_multiple "print v.method ()" "calling method for small class" { + -re "\\$\[0-9\]+ = 82$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2 + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+ + pass "calling method for small class" + } + -re "Address requested for identifier \"v\" which is in register .*$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + setup_xfail "*-*-*" 2972 + fail "calling method for small class" + } + } + + gdb_test "print base1::Base1" "<.*Base1.*>" "print ctor of typedef class" + gdb_test "print base1::~Base1" "<.*~Base1(\\(\\))?>" \ + "print dtor of typedef class" + + gdb_test "list ByAnyOtherName::times" ".*int Foo::times.*" +} + +do_tests Index: psmang2.cc =================================================================== --- psmang2.cc (nonexistent) +++ psmang2.cc (revision 513) @@ -0,0 +1,171 @@ +/* This test script is part of GDB, the GNU debugger. + + Copyright 2002, 2004, + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#include + +/* Do not move this definition into a header file! See the comments + in psmang.exp. */ +struct s +{ + int value; + void method1 (void); + void method2 (void); +}; + +void +s::method2 (void) +{ + printf ("%d\n", value); +} + + +/* The presence of these variables ensures there will be so many + symbols in psmang2.cc's symtab's global block that it will have a + non-trivial hash table. When there are only a very few symbols, + the block only has one hash bucket, so even if we compute the hash + value for the wrong symbol name, we'll still find a symbol that + matches. */ +int a; +int b; +int a1; +int b1; +int a2; +int b2; +int a12; +int b12; +int a3; +int b3; +int a13; +int b13; +int a23; +int b23; +int a123; +int b123; +int a4; +int b4; +int a14; +int b14; +int a24; +int b24; +int a124; +int b124; +int a34; +int b34; +int a134; +int b134; +int a234; +int b234; +int a1234; +int b1234; +int a5; +int b5; +int a15; +int b15; +int a25; +int b25; +int a125; +int b125; +int a35; +int b35; +int a135; +int b135; +int a235; +int b235; +int a1235; +int b1235; +int a45; +int b45; +int a145; +int b145; +int a245; +int b245; +int a1245; +int b1245; +int a345; +int b345; +int a1345; +int b1345; +int a2345; +int b2345; +int a12345; +int b12345; +int a6; +int b6; +int a16; +int b16; +int a26; +int b26; +int a126; +int b126; +int a36; +int b36; +int a136; +int b136; +int a236; +int b236; +int a1236; +int b1236; +int a46; +int b46; +int a146; +int b146; +int a246; +int b246; +int a1246; +int b1246; +int a346; +int b346; +int a1346; +int b1346; +int a2346; +int b2346; +int a12346; +int b12346; +int a56; +int b56; +int a156; +int b156; +int a256; +int b256; +int a1256; +int b1256; +int a356; +int b356; +int a1356; +int b1356; +int a2356; +int b2356; +int a12356; +int b12356; +int a456; +int b456; +int a1456; +int b1456; +int a2456; +int b2456; +int a12456; +int b12456; +int a3456; +int b3456; +int a13456; +int b13456; +int a23456; +int b23456; +int a123456; +int b123456; Index: pr9067.cc =================================================================== --- pr9067.cc (nonexistent) +++ pr9067.cc (revision 513) @@ -0,0 +1,17 @@ +struct B; + +struct A { + static B b; +}; + +struct B { + A a; +}; + +B A::b; +B b; + +int main(int,char **) +{ + return 0; +} Index: pr-1023.exp =================================================================== --- pr-1023.exp (nonexistent) +++ pr-1023.exp (revision 513) @@ -0,0 +1,70 @@ +# Copyright 2003, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Tests for PR gdb/1023. +# 2003-02-03 Michael Chastain + +# This file is part of the gdb testsuite. + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + +# +# test running programs +# + +set testfile "pr-1023" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested pr-1023.exp + return -1 +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +gdb_test_multiple "break myClass::performBlocking" "break myClass::performBlocking" { + -re "Breakpoint $decimal at $hex: file .*$srcfile, line 12.*$gdb_prompt $" { + pass "break myClass::performBlocking" + } + -re "the class myClass does not have any method named performBlocking.*$gdb_prompt $" { + # fails with gcc 2.95.3 -gstabs+, native i686-pc-linux-gnu + # -- chastain 2003-02-03 + kfail "gdb/1023" "break myClass::performBlocking" + } +} + +gdb_test \ + "break myClass::performUnblocking" \ + "Breakpoint $decimal at $hex: file .*$srcfile, line 10.*" + +gdb_exit +return 0 Index: expand-sals.cc =================================================================== --- expand-sals.cc (nonexistent) +++ expand-sals.cc (revision 513) @@ -0,0 +1,53 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright (C) 2009, 2010 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +int +func () +{ + return 42; /* func-line */ +} + +volatile int global_x; + +class A +{ +public: + A () + { + global_x = func (); /* caller-line */ + } +}; + +/* class B is here just to make the `func' calling line above having multiple + instances - multiple locations. Template cannot be used as its instances + would have different function names which get discarded by GDB + expand_line_sal_maybe. */ + +class B : public A +{ +}; + +int +main (void) +{ + A a; + B b; + + return 0; +} Index: method.cc =================================================================== --- method.cc (nonexistent) +++ method.cc (revision 513) @@ -0,0 +1,80 @@ +// Class funk has a constructor and an ordinary method +// Test for CHFts23426 + +class funk +{ +public: + funk(); + void getFunky(int a, int b); + int data_; +}; + +funk::funk() + : data_(33) +{ +} + +void funk::getFunky(int a, int b) +{ + int res; + res = a + b - data_; + data_ = res; +} + +// Class A has const and volatile methods + +class A { +public: + int x; + int y; + int foo (int arg); + int bar (int arg) const; + int baz (int arg, char c) volatile; + int qux (int arg, float f) const volatile; +}; + +int A::foo (int arg) +{ + x += arg; + return arg *2; +} + +int A::bar (int arg) const +{ + return arg + 2 * x; +} + +int A::baz (int arg, char c) volatile +{ + return arg - 2 * x + c; +} + +int A::qux (int arg, float f) const volatile +{ + if (f > 0) + return 2 * arg - x; + else + return 2 * arg + x; +} + + +int main() +{ + A a; + int k; + + k = 10; + a.x = k * 2; + + k = a.foo(13); + + k += a.bar(15); + + // Test for CHFts23426 follows + funk f; + f.getFunky(1, 2); + return 0; +} + + + Index: cpexprs.cc =================================================================== --- cpexprs.cc (nonexistent) +++ cpexprs.cc (revision 513) @@ -0,0 +1,431 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2008, 2009, 2010 Free Software Foundation, Inc. + + Contributed by Red Hat, originally written by Keith Seitz. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@gnu.org */ + +#include +#include + +// Forward decls +class base; +class derived; + +// A simple template with specializations +template +class tclass +{ +public: + void do_something () { } // tclass::do_something +}; + +template <> +void tclass::do_something () { } // tclass::do_something + +template <> +void tclass::do_something () { } // tclass::do_something + +template<> +void tclass::do_something () { } // tclass::do_something + +template<> +void tclass::do_something () { } // tclass::do_something + +// A simple template with multiple template parameters +template +void flubber (void) // flubber +{ + A a; + B b; + C c; + D d; + E e; + + ++a; + ++b; + ++c; + ++d; + ++e; +} + +// Some contrived policies +template +struct operation_1 +{ + static void function (void) { } // operation_1::function +}; + +template +struct operation_2 +{ + static void function (void) { } // operation_2::function +}; + +template +struct operation_3 +{ + static void function (void) { } // operation_3::function +}; + +template +struct operation_4 +{ + static void function (void) { } // operation_4::function +}; + +// A policy-based class w/ and w/o default policy +template +class policy : public Policy +{ +public: + policy (T obj) : obj_ (obj) { } // policy::policy + +private: + T obj_; +}; + +template > +class policyd : public Policy +{ +public: + policyd (T obj) : obj_ (obj) { } // policyd::policyd + ~policyd (void) { } // policyd::~policyd + +private: + T obj_; +}; + +typedef policy > policy1; +typedef policy > policy2; +typedef policy > policy3; +typedef policy > policy4; + +typedef policyd policyd1; +typedef policyd policyd2; +typedef policyd policyd3; +typedef policyd policyd4; +typedef policyd > policyd5; + +class fluff { }; +static fluff *g_fluff = new fluff (); + +class base +{ +protected: + int foo_; + +public: + base (void) : foo_ (42) { } // base::base(void) + base (int foo) : foo_ (foo) { } // base::base(int) + ~base (void) { } // base::~base + + // Some overloaded methods + int overload (void) const { return 0; } // base::overload(void) const + int overload (int i) const { return 1; } // base::overload(int) const + int overload (short s) const { return 2; } // base::overload(short) const + int overload (long l) const { return 3; } // base::overload(long) const + int overload (char* a) const { return 4; } // base::overload(char*) const + int overload (base& b) const { return 5; } // base::overload(base&) const + + // Operators + int operator+ (base const& o) const // base::operator+ + { return foo_ + o.foo_; } + + base operator++ (void) // base::operator++ + { ++foo_; return *this; } + + base operator+=(base const& o) // base::operator+= + { foo_ += o.foo_; return *this; } + + int operator- (base const& o) const // base::operator- + { return foo_ - o.foo_; } + + base operator-- (void) // base::operator-- + { --foo_; return *this; } + + base operator-= (base const& o) // base::operator-= + { foo_ -= o.foo_; return *this; } + + int operator* (base const& o) const // base::operator* + { return foo_ * o.foo_; } + + base operator*= (base const& o) // base::operator*= + { foo_ *= o.foo_; return *this; } + + int operator/ (base const& o) const // base::operator/ + { return foo_ / o.foo_; } + + base operator/= (base const& o) // base::operator/= + { foo_ /= o.foo_; return *this; } + + int operator% (base const& o) const // base::operator% + { return foo_ % o.foo_; } + + base operator%= (base const& o) // base::operator%= + { foo_ %= o.foo_; return *this; } + + bool operator< (base const& o) const // base::operator< + { return foo_ < o.foo_; } + + bool operator<= (base const& o) const // base::operator<= + { return foo_ <= o.foo_; } + + bool operator> (base const& o) const // base::operator> + { return foo_ > o.foo_; } + + bool operator>= (base const& o) const // base::operator>= + { return foo_ >= o.foo_; } + + bool operator!= (base const& o) const // base::operator!= + { return foo_ != o.foo_; } + + bool operator== (base const& o) const // base::operator== + { return foo_ == o.foo_; } + + bool operator! (void) const // base::operator! + { return !foo_; } + + bool operator&& (base const& o) const // base::operator&& + { return foo_ && o.foo_; } + + bool operator|| (base const& o) const // base::operator|| + { return foo_ || o.foo_; } + + int operator<< (int value) const // base::operator<< + { return foo_ << value; } + + base operator<<= (int value) // base::operator<<= + { foo_ <<= value; return *this; } + + int operator>> (int value) const // base::operator>> + { return foo_ >> value; } + + base operator>>= (int value) // base::operator>>= + { foo_ >>= value; return *this; } + + int operator~ (void) const // base::operator~ + { return ~foo_; } + + int operator& (base const& o) const // base::operator& + { return foo_ & o.foo_; } + + base operator&= (base const& o) // base::operator&= + { foo_ &= o.foo_; return *this; } + + int operator| (base const& o) const // base::operator| + { return foo_ | o.foo_; } + + base operator|= (base const& o) // base::operator|= + { foo_ |= o.foo_; return *this; } + + int operator^ (base const& o) const // base::operator^ + { return foo_ ^ o.foo_; } + + base operator^= (base const& o) // base::operator^= + { foo_ ^= o.foo_; return *this; } + + base operator= (base const& o) // base::operator= + { foo_ = o.foo_; return *this; } + + void operator() (void) const // base::operator() + { return; } + + int operator[] (int idx) const // base::operator[] + { return idx; } + + void* operator new (size_t size) throw () // base::operator new + { return malloc (size); } + + void operator delete (void* ptr) // base::operator delete + { free (ptr); } + + void* operator new[] (size_t size) throw () // base::operator new[] + { return malloc (size); } + + void operator delete[] (void* ptr) // base::operator delete[] + { free (ptr); } + + base const* operator-> (void) const // base::opeartor-> + { return this; } + + int operator->* (base const& b) const // base::operator->* + { return foo_ * b.foo_; } + + operator char* () const { return const_cast ("hello"); } // base::operator char* + operator int () const { return 21; } // base::operator int + operator fluff* () const { return new fluff (); } // base::operator fluff* + operator fluff** () const { return &g_fluff; } // base::operator fluff** +}; + +class base1 : public virtual base +{ +public: + base1 (void) : foo_ (21) { } // base1::base1(void) + base1 (int a) : foo_(a) { } // base1::base1(int) + void a_function (void) const { } // base1::a_function + +protected: + int foo_; +}; + +class base2 : public virtual base +{ +public: + base2 () : foo_ (3) { } // base2::base2 + +protected: + void a_function (void) const { } // base2::a_function + int foo_; +}; + +class derived : public base1, public base2 +{ + public: + derived(void) : foo_ (4) { } // derived::derived + void a_function (void) const // derived::a_function + { + this->base1::a_function (); + this->base2::a_function (); + } + + protected: + int foo_; +}; + +int +main (int argc, char* argv[]) // main +{ // main + derived d; + void (derived::*pfunc) (void) const = &derived::a_function; + (d.*pfunc) (); + + base a (1), b (3), c (8); + (void) a.overload (); + (void) a.overload (static_cast (0)); + (void) a.overload (static_cast (0)); + (void) a.overload (static_cast (0)); + (void) a.overload (static_cast (0)); + (void) a.overload (a); + + int r; + r = b + c; + ++a; + a += b; + r = b - c; + --a; + a -= b; + r = b * c; + a *= b; + r = b / c; + a /= b; + r = b % c; + a %= b; + bool x = (b < c); + x = (b <= c); + x = (b > c); + x = (b >= c); + x = (b != c); + x = (b == c); + x = (!b); + x = (b && c); + x = (b || c); + r = b << 2; + a <<= 1; + r = b >> 2; + a >>= 1; + r = ~b; + r = b & c; + a &= c; + r = b | c; + a |= c; + r = b ^ c; + a ^= c; + a = c; + a (); + int i = a[3]; + derived* f = new derived (); + derived* g = new derived[3]; + delete f; + delete[] g; + a->overload (); + r = a->*b; + + tclass char_tclass; + tclass int_tclass; + tclass short_tclass; + tclass long_tclass; + tclass base_tclass; + char_tclass.do_something (); + int_tclass.do_something (); + short_tclass.do_something (); + long_tclass.do_something (); + base_tclass.do_something (); + + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + flubber (); + + policy1 p1 (1); + p1.function (); + policy2 p2 (2); + p2.function (); + policy3 p3 (3); + p3.function (); + policy4 p4 (4); + p4.function (); + + policyd1 pd1 (5); + pd1.function (); + policyd2 pd2 (6); + pd2.function (); + policyd3 pd3 (7); + pd3.function (); + policyd4 pd4 (d); + pd4.function (); + policyd5 pd5 (int_tclass); + pd5.function (); + + base1 b1 (3); + + r = a; + char* str = a; + fluff* flp = a; + fluff** flpp = a; +} + Index: gdb2384-base.cc =================================================================== --- gdb2384-base.cc (nonexistent) +++ gdb2384-base.cc (revision 513) @@ -0,0 +1,37 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2008, 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#include "gdb2384-base.h" + +base::base (int _x) + : x (_x) +{ +} + +using namespace B; + +int +base::meth () +{ + return x; +} + +derived::derived (int _x) + : base (_x) +{ +} Index: shadow.cc =================================================================== --- shadow.cc (nonexistent) +++ shadow.cc (revision 513) @@ -0,0 +1,47 @@ +namespace A +{ + int x = 11; +} + +int x = 22; +int y = 0; + +class B +{ +public: + int x; + + int + func() + { + x = 33; + y++; // marker1 + + { + int x = 44; + y++; // marker2 + + { + int x = 55; + y++; // marker3 + + { + using namespace A; + y++; // marker4 + + { + using A::x; + y++; // marker5 + } + } + } + } + } +}; + +int +main() +{ + B theB; + return theB.func(); +} Index: abstract-origin.cc =================================================================== --- abstract-origin.cc (nonexistent) +++ abstract-origin.cc (revision 513) @@ -0,0 +1,42 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +extern void f (int *); + +class A +{ +public: + A(int i); +}; + +A::A(int i) +{ + static int *problem = new int(i); + f (problem); /* break-here */ +} + +void f (int *) +{ +} + +int +main (void) +{ + A a(42); + return 0; +} Index: anon-union.exp =================================================================== --- anon-union.exp (nonexistent) +++ anon-union.exp (revision 513) @@ -0,0 +1,176 @@ +# Tests for anonymous union support. +# Copyright 1998, 1999, 2003, 2004, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Written by Satish Pai 1997-08-19 + +# This file is part of the gdb testsuite + +if $tracelevel then { + strace $tracelevel + } + +# +# test running programs +# + + +if { [skip_cplus_tests] } { continue } + +set testfile "anon-union" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + perror "Testcase compile failed" 0 + continue +} + +# Start with a fresh gdb +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +gdb_test_no_output "set width 0" + +#send_gdb "ptype foo\n" +#gdb_expect { +# -re "\r\n$gdb_prompt $" { +# pass "ptype foo" +# } +# -re ".*$gdb_prompt $" { fail "ptype foo" } +# timeout { fail "(timeout) ptype foo" } +#} + +#send_gdb "ptype bar\n" +#gdb_expect { +# -re "\r\n$gdb_prompt $" { +# pass "ptype foo" +# } +# -re ".*$gdb_prompt $" { fail "ptype foo" } +# timeout { fail "(timeout) ptype foo" } +#} + +# NOTE: Add -- ptype foo.x, etc. when things are working + +#Initialize foo +gdb_test "next" "40\[ \t\]*foo.paper = 33;" "next 1" + +# Print out the big anon union. +gdb_test "print foo" \ + "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 0, x = \{rock = 0, rock2 = 0\}, \{qux = 0, mux = 0\}, boulder = 0\}, \{paper = 0, cloth = 0\}, num2 = \{two = 0, three = 0\}\}" \ + "print foo 1" + +# Step over assignment to member + +gdb_test "next" "41\[ \t\]*foo.pebble = 44;" "next 2" + +# Now print out anon union again +gdb_test "print foo" \ + "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 0, x = \{rock = 0, rock2 = 0\}, \{qux = 0, mux = 0\}, boulder = 0\}, \{paper = 33, cloth = 33\}, num2 = \{two = 0, three = 0\}\}" \ + "print foo 2" + +# Modify the member just set +gdb_test_no_output "set var foo.cloth = 35" "set var foo.cloth" + +# Now print out anon union again to see if the right member was set +gdb_test "print foo" \ + "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 0, x = \{rock = 0, rock2 = 0\}, \{qux = 0, mux = 0\}, boulder = 0\}, \{paper = 35, cloth = 35\}, num2 = \{two = 0, three = 0\}\}" \ + "print foo 3" + +# Step over next assignment to member + +gdb_test "next" "42\[ \t\]*foo.mux = 55;" "next 3" + +# Now print out anon union again +gdb_test "print foo" \ + "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 44, x = \{rock = 44, rock2 = 0\}, \{qux = 44, mux = 44\}, boulder = 44\}, \{paper = 35, cloth = 35\}, num2 = \{two = 0, three = 0\}\}" \ + "print foo 4" + +# Modify the member just set +gdb_test_no_output "set var foo.pebble = 45" "set var foo.pebble" + +# Now print out anon union again to see if the right member was set +gdb_test "print foo" \ + "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 45, x = \{rock = 45, rock2 = 0\}, \{qux = 45, mux = 45\}, boulder = 45\}, \{paper = 35, cloth = 35\}, num2 = \{two = 0, three = 0\}\}" \ + "print foo 5" + +# Modify another member at a different level +gdb_test_no_output "set var foo.qux = 46" "set var foo.qux" + +# Now print out anon union again to see if the right member was set +gdb_test "print foo" \ + "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 46, x = \{rock = 46, rock2 = 0\}, \{qux = 46, mux = 46\}, boulder = 46\}, \{paper = 35, cloth = 35\}, num2 = \{two = 0, three = 0\}\}" \ + "print foo 6" + +# Modify the member at another level, but not the first one in the union +gdb_test_no_output "set var foo.mux = 47" "set var foo.mux" + +# Now print out anon union again to see if things worked +gdb_test "print foo" \ + "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 47, x = \{rock = 47, rock2 = 0\}, \{qux = 47, mux = 47\}, boulder = 47\}, \{paper = 35, cloth = 35\}, num2 = \{two = 0, three = 0\}\}" \ + "print foo 7" + +# Modify a member of a struct in an anon union +gdb_test_no_output "set var foo.x.rock = 48" "set var foo.x.rock" + +# Now print out anon union again to see if things worked +gdb_test "print foo" \ + "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 48, x = \{rock = 48, rock2 = 0\}, \{qux = 48, mux = 48\}, boulder = 48\}, \{paper = 35, cloth = 35\}, num2 = \{two = 0, three = 0\}\}" \ + "print foo 8" + +# Modify a member of a struct in an anon union, but something +# that doesn't alias to some other union member +gdb_test_no_output "set var foo.x.rock2 = 49" "set var foo.x.rock2" + +# Now print out anon union again to see if things worked +gdb_test "print foo" \ + "\\$\[0-9\]* = \{num1 = \{zero = 0, one = 0\}, \{pebble = 48, x = \{rock = 48, rock2 = 49\}, \{qux = 48, mux = 48\}, boulder = 48\}, \{paper = 35, cloth = 35\}, num2 = \{two = 0, three = 0\}\}" \ + "print foo 9" + +# Step over next four assignments +gdb_test "next 4" "53\[ \t\]*w = 45;" "next 4" + +# Tests for anon unions that are not members of a class or struct + +gdb_test "print w" "\\$\[0-9\]* = 0" "print w 1" + +gdb_test "print z" "\\$\[0-9\]* = 0" "print z 1" + +# Step over next assignment to w +gdb_test "next" "55\[ \t\]*int j = 0;" "next 5" + +# See if the change in value is noticed +gdb_test "print w" "\\$\[0-9\]* = 45" "print w 2" + +# See if z shows the same value +gdb_test "print z" "\\$\[0-9\]* = 45" "print z 2" + +# Set the anon union member +gdb_test_no_output "set var z = 27" "set var z" + +# See if the change in value is noticed +gdb_test "print w" "\\$\[0-9\]* = 27" "print w 3" + +# See if z shows the same value +gdb_test "print z" "\\$\[0-9\]* = 27" "print z 3" Index: virtfunc2.exp =================================================================== --- virtfunc2.exp (nonexistent) +++ virtfunc2.exp (revision 513) @@ -0,0 +1,59 @@ +# Copyright 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file was written by Chris Moller based on +# virtfunc.exp + +set nl "\[\r\n\]+" + +if { [skip_cplus_tests] } { continue } + +load_lib "cp-support.exp" + +set testfile "virtfunc2" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {c++ debug}] != "" } { + untested virtfunc2.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +# set a breakpoint at the return stmt + +gdb_breakpoint [gdb_get_line_number "marker 1"] +gdb_continue_to_breakpoint "marker 1" + +gdb_test "print o.do_print()" "\\$\[0-9\]+ = 123456" +gdb_test "print o.do_print3()" "\\$\[0-9\]+ = 111111" + +gdb_test "print o2.do_print()" "\\$\[0-9\]+ = 123456" +gdb_test "print o2.do_print2()" "\\$\[0-9\]+ = 654321" +gdb_test "print o2.do_print3()" "\\$\[0-9\]+ = 111111" + + +gdb_exit +return 0 + Index: nsstress.exp =================================================================== --- nsstress.exp (nonexistent) +++ nsstress.exp (revision 513) @@ -0,0 +1,50 @@ +# Copyright 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Stress test namespace lookup + +if $tracelevel then { + strace $tracelevel +} + + +set testfile nsstress +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested "Couldn't compile test program" + return -1 +} + +if [get_compiler_info ${binfile}] { + return -1 +} + +# Get things started. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint main" + continue +} + +############################################ +# Test that the search can fail efficiently + +gdb_test "print y" "No symbol \"y\" in current context." Index: classes.cc =================================================================== --- classes.cc (nonexistent) +++ classes.cc (revision 513) @@ -0,0 +1,614 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2004, 2007, + 2008, 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +// Test various -*- C++ -*- things. + +// ====================== basic C++ types ======================= +bool v_bool; +bool v_bool_array[2]; + +typedef struct fleep fleep; +struct fleep { int a; } s; + +// ====================== simple class structures ======================= + +struct default_public_struct { + // defaults to public: + int a; + int b; +}; + +struct explicit_public_struct { + public: + int a; + int b; +}; + +struct protected_struct { + protected: + int a; + int b; +}; + +struct private_struct { + private: + int a; + int b; +}; + +struct mixed_protection_struct { + public: + int a; + int b; + private: + int c; + int d; + protected: + int e; + int f; + public: + int g; + private: + int h; + protected: + int i; +}; + +class public_class { + public: + int a; + int b; +}; + +class protected_class { + protected: + int a; + int b; +}; + +class default_private_class { + // defaults to private: + int a; + int b; +}; + +class explicit_private_class { + private: + int a; + int b; +}; + +class mixed_protection_class { + public: + int a; + int b; + private: + int c; + int d; + protected: + int e; + int f; + public: + int g; + private: + int h; + protected: + int i; +}; + +class const_vol_method_class { +public: + int a; + int b; + int foo (int &) const; + int bar (int &) volatile; + int baz (int &) const volatile; +}; + +int const_vol_method_class::foo (int & ir) const +{ + return ir + 3; +} +int const_vol_method_class::bar (int & ir) volatile +{ + return ir + 4; +} +int const_vol_method_class::baz (int & ir) const volatile +{ + return ir + 5; +} + +// ========================= simple inheritance ========================== + +class A { + public: + int a; + int x; +}; + +A g_A; + +class B : public A { + public: + int b; + int x; +}; + +B g_B; + +class C : public A { + public: + int c; + int x; +}; + +C g_C; + +class D : public B, public C { + public: + int d; + int x; +}; + +D g_D; + +class E : public D { + public: + int e; + int x; +}; + +E g_E; + +class class_with_anon_union +{ + public: + int one; + union + { + int a; + long b; + }; +}; + +class_with_anon_union g_anon_union; + +void inheritance2 (void) +{ +} + +void inheritance1 (void) +{ + int ival; + int *intp; + + // {A::a, A::x} + + g_A.A::a = 1; + g_A.A::x = 2; + + // {{A::a,A::x},B::b,B::x} + + g_B.A::a = 3; + g_B.A::x = 4; + g_B.B::b = 5; + g_B.B::x = 6; + + // {{A::a,A::x},C::c,C::x} + + g_C.A::a = 7; + g_C.A::x = 8; + g_C.C::c = 9; + g_C.C::x = 10; + + // {{{A::a,A::x},B::b,B::x},{{A::a,A::x},C::c,C::x},D::d,D::x} + + // The following initialization code is non-portable, but allows us + // to initialize all members of g_D until we can fill in the missing + // initialization code with legal C++ code. + + for (intp = (int *) &g_D, ival = 11; + intp < ((int *) &g_D + sizeof (g_D) / sizeof (int)); + intp++, ival++) + { + *intp = ival; + } + + // Overlay the nonportable initialization with legal initialization. + + // ????? = 11; (g_D.A::a = 11; is ambiguous) + // ????? = 12; (g_D.A::x = 12; is ambiguous) +/* djb 6-3-2000 + + This should take care of it. Rather than try to initialize using an ambiguous + construct, use 2 unambiguous ones for each. Since the ambiguous a/x member is + coming from C, and B, initialize D's C::a, and B::a, and D's C::x and B::x. + */ + g_D.C::a = 15; + g_D.C::x = 12; + g_D.B::a = 11; + g_D.B::x = 12; + g_D.B::b = 13; + g_D.B::x = 14; + // ????? = 15; + // ????? = 16; + g_D.C::c = 17; + g_D.C::x = 18; + g_D.D::d = 19; + g_D.D::x = 20; + + + // {{{{A::a,A::x},B::b,B::x},{{A::a,A::x},C::c,C::x},D::d,D::x}},E::e,E::x} + + // The following initialization code is non-portable, but allows us + // to initialize all members of g_D until we can fill in the missing + // initialization code with legal C++ code. + + for (intp = (int *) &g_E, ival = 21; + intp < ((int *) &g_E + sizeof (g_E) / sizeof (int)); + intp++, ival++) + { + *intp = ival; + } + + // Overlay the nonportable initialization with legal initialization. + + // ????? = 21; (g_E.A::a = 21; is ambiguous) + // ????? = 22; (g_E.A::x = 22; is ambiguous) + g_E.B::b = 23; + g_E.B::x = 24; + // ????? = 25; + // ????? = 26; + g_E.C::c = 27; + g_E.C::x = 28; + g_E.D::d = 29; + g_E.D::x = 30; + g_E.E::e = 31; + g_E.E::x = 32; + + g_anon_union.one = 1; + g_anon_union.a = 2; + + inheritance2 (); +} + +// ======================== static member functions ===================== + +class Static { +public: + static void ii(int, int); +}; +void Static::ii (int, int) { } + +// ======================== virtual base classes========================= + +class vA { + public: + int va; + int vx; +}; + +vA g_vA; + +class vB : public virtual vA { + public: + int vb; + int vx; +}; + +vB g_vB; + +class vC : public virtual vA { + public: + int vc; + int vx; +}; + +vC g_vC; + +class vD : public virtual vB, public virtual vC { + public: + int vd; + int vx; +}; + +vD g_vD; + +class vE : public virtual vD { + public: + int ve; + int vx; +}; + +vE g_vE; + +void inheritance4 (void) +{ +} + +void inheritance3 (void) +{ + int ival; + int *intp; + + // {vA::va, vA::vx} + + g_vA.vA::va = 1; + g_vA.vA::vx = 2; + + // {{vA::va, vA::vx}, vB::vb, vB::vx} + + g_vB.vA::va = 3; + g_vB.vA::vx = 4; + g_vB.vB::vb = 5; + g_vB.vB::vx = 6; + + // {{vA::va, vA::vx}, vC::vc, vC::vx} + + g_vC.vA::va = 7; + g_vC.vA::vx = 8; + g_vC.vC::vc = 9; + g_vC.vC::vx = 10; + + // {{{{vA::va, vA::vx}, vB::vb, vB::vx}, vC::vc, vC::vx}, vD::vd,vD::vx} + + g_vD.vA::va = 11; + g_vD.vA::vx = 12; + g_vD.vB::vb = 13; + g_vD.vB::vx = 14; + g_vD.vC::vc = 15; + g_vD.vC::vx = 16; + g_vD.vD::vd = 17; + g_vD.vD::vx = 18; + + + // {{{{{vA::va,vA::vx},vB::vb,vB::vx},vC::vc,vC::vx},vD::vd,vD::vx},vE::ve,vE::vx} + + g_vD.vA::va = 19; + g_vD.vA::vx = 20; + g_vD.vB::vb = 21; + g_vD.vB::vx = 22; + g_vD.vC::vc = 23; + g_vD.vC::vx = 24; + g_vD.vD::vd = 25; + g_vD.vD::vx = 26; + g_vE.vE::ve = 27; + g_vE.vE::vx = 28; + + inheritance4 (); +} + +// ====================================================================== + +class Base1 { + public: + int x; + Base1(int i) { x = i; } + ~Base1 () { } +}; + +typedef Base1 base1; + +class Foo +{ + public: + int x; + int y; + static int st; + Foo (int i, int j) { x = i; y = j; } + int operator! (); + operator int (); + int times (int y); +}; + +typedef Foo ByAnyOtherName; + +class Bar : public Base1, public Foo { + public: + int z; + Bar (int i, int j, int k) : Base1 (10*k), Foo (i, j) { z = k; } +}; + +int Foo::operator! () { return !x; } + +int Foo::times (int y) { return x * y; } + +int Foo::st = 100; + +Foo::operator int() { return x; } + +ByAnyOtherName foo(10, 11); +Bar bar(20, 21, 22); + +class ClassWithEnum { +public: + enum PrivEnum { red, green, blue, yellow = 42 }; + PrivEnum priv_enum; + int x; +}; + +void enums2 (void) +{ +} + +/* classes.exp relies on statement order in this function for testing + enumeration fields. */ + +void enums1 () +{ + ClassWithEnum obj_with_enum; + obj_with_enum.priv_enum = ClassWithEnum::red; + obj_with_enum.x = 0; + enums2 (); + obj_with_enum.priv_enum = ClassWithEnum::green; + obj_with_enum.x = 1; +} + +class ClassParam { +public: + int Aptr_a (A *a) { return a->a; } + int Aptr_x (A *a) { return a->x; } + int Aref_a (A &a) { return a.a; } + int Aref_x (A &a) { return a.x; } + int Aval_a (A a) { return a.a; } + int Aval_x (A a) { return a.x; } +}; + +ClassParam class_param; + +class Contains_static_instance +{ + public: + int x; + int y; + Contains_static_instance (int i, int j) { x = i; y = j; } + static Contains_static_instance null; +}; + +Contains_static_instance Contains_static_instance::null(0,0); +Contains_static_instance csi(10,20); + +class Contains_nested_static_instance +{ + public: + class Nested + { + public: + Nested(int i) : z(i) {} + int z; + static Contains_nested_static_instance xx; + }; + + Contains_nested_static_instance(int i, int j) : x(i), y(j) {} + + int x; + int y; + + static Contains_nested_static_instance null; + static Nested yy; +}; + +Contains_nested_static_instance Contains_nested_static_instance::null(0, 0); +Contains_nested_static_instance::Nested Contains_nested_static_instance::yy(5); +Contains_nested_static_instance + Contains_nested_static_instance::Nested::xx(1,2); +Contains_nested_static_instance cnsi(30,40); + +typedef struct { + int one; + int two; +} tagless_struct; +tagless_struct v_tagless; + +/* Try to get the compiler to allocate a class in a register. */ +class small { + public: + int x; + int method (); +}; + +int +small::method () +{ + return x + 5; +} + +void marker_reg1 () {} + +int +register_class () +{ + /* We don't call any methods for v, so gcc version cygnus-2.3.3-930220 + might put this variable in a register. This is a lose, though, because + it means that GDB can't call any methods for that variable. */ + register small v; + + int i; + + /* Perform a computation sufficiently complicated that optimizing compilers + won't optimized out the variable. If some compiler constant-folds this + whole loop, maybe using a parameter to this function here would help. */ + v.x = 0; + for (i = 0; i < 13; ++i) + v.x += i; + --v.x; /* v.x is now 77 */ + marker_reg1 (); + return v.x + 5; +} + +void dummy() +{ + v_bool = true; + v_bool_array[0] = false; + v_bool_array[1] = v_bool; +} + +void use_methods () +{ + /* Refer to methods so that they don't get optimized away. */ + int i; + i = class_param.Aptr_a (&g_A); + i = class_param.Aptr_x (&g_A); + i = class_param.Aref_a (g_A); + i = class_param.Aref_x (g_A); + i = class_param.Aval_a (g_A); + i = class_param.Aval_x (g_A); + + base1 b (3); +} + + +int +main() +{ +#ifdef usestubs + set_debug_traps(); + breakpoint(); +#endif + dummy(); + inheritance1 (); + inheritance3 (); + enums1 (); + register_class (); + + /* FIXME: pmi gets optimized out. Need to do some more computation with + it or something. (No one notices, because the test is xfail'd anyway, + but that probably won't always be true...). */ + int Foo::* pmi = &Foo::y; + + /* Make sure the AIX linker doesn't remove the variable. */ + v_tagless.one = 5; + + use_methods (); + + return foo.*pmi; +} + +/* Create an instance for some classes, otherwise they get optimized away. */ + +default_public_struct default_public_s; +explicit_public_struct explicit_public_s; +protected_struct protected_s; +private_struct private_s; +mixed_protection_struct mixed_protection_s; +public_class public_c; +protected_class protected_c; +default_private_class default_private_c; +explicit_private_class explicit_private_c; +mixed_protection_class mixed_protection_c; Index: hang3.cc =================================================================== --- hang3.cc (nonexistent) +++ hang3.cc (revision 513) @@ -0,0 +1,9 @@ +#include "hang.H" + +const struct B *const_B_ptr; +int var_in_hang3 = 42; + +int dummy3 (void) +{ + return var_in_hang3; +} Index: method2.cc =================================================================== --- method2.cc (nonexistent) +++ method2.cc (revision 513) @@ -0,0 +1,27 @@ +struct A +{ + void method (); + void method (int a); + void method (A* a); +}; + +void +A::method () +{ +} + +void +A::method (int a) +{ +} + +void +A::method (A* a) +{ +} + +int +main (int argc, char** argv) +{ + return 0; +} Index: bs15503.cc =================================================================== --- bs15503.cc (nonexistent) +++ bs15503.cc (revision 513) @@ -0,0 +1,71 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 1992, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#include +#include +using namespace std; + +template +class StringTest { +public: + virtual void runTest(); + void testFunction(); +}; + +template +void StringTest:: runTest() { + testFunction (); +} + +template +void StringTest ::testFunction() { + // initialize s with string literal + cout << "in StringTest" << endl; + string s("I am a shot string"); + cout << s << endl; + + // insert 'r' to fix "shot" + s.insert(s.begin()+10,'r' ); + cout << s << endl; + + // concatenate another string + s += "and now a longer string"; + cout << s << endl; + + // find position where blank needs to be inserted + string::size_type spos = s.find("and"); + s.insert(spos, " "); + cout << s << endl; + + // erase the concatenated part + s.erase(spos); + cout << s << endl; +} + +int main() { + StringTest ts; + ts.runTest(); +} + +/* output: +I am a shot string +I am a short string +I am a short stringand now a longer string +I am a short string and now a longer string +I am a short string +*/ Index: derivation.cc =================================================================== --- derivation.cc (nonexistent) +++ derivation.cc (revision 513) @@ -0,0 +1,240 @@ +class A { +public: + int a; + int aa; + + A() + { + a=1; + aa=2; + } + int afoo(); + int foo(); + +}; + + + +class B { +public: + int b; + int bb; + + B() + { + b=3; + bb=4; + } + int bfoo(); + int foo(); + +}; + + + +class C { +public: + int c; + int cc; + + C() + { + c=5; + cc=6; + } + int cfoo(); + int foo(); + +}; + + + +class D : private A, public B, protected C { +public: + int d; + int dd; + + D() + { + d =7; + dd=8; + } + int dfoo(); + int foo(); + +}; + + +class E : public A, B, protected C { +public: + int e; + int ee; + + E() + { + e =9; + ee=10; + } + int efoo(); + int foo(); + +}; + + +class F : A, public B, C { +public: + int f; + int ff; + + F() + { + f =11; + ff=12; + } + int ffoo(); + int foo(); + +}; + +class G : private A, public B, protected C { +public: + int g; + int gg; + int a; + int b; + int c; + + G() + { + g =13; + gg =14; + a=15; + b=16; + c=17; + + } + int gfoo(); + int foo(); + +}; + + + + +int A::afoo() { + return 1; +} + +int B::bfoo() { + return 2; +} + +int C::cfoo() { + return 3; +} + +int D::dfoo() { + return 4; +} + +int E::efoo() { + return 5; +} + +int F::ffoo() { + return 6; +} + +int G::gfoo() { + return 77; +} + +int A::foo() +{ + return 7; + +} + +int B::foo() +{ + return 8; + +} + +int C::foo() +{ + return 9; + +} + +int D::foo() +{ + return 10; + +} + +int E::foo() +{ + return 11; + +} + +int F::foo() +{ + return 12; + +} + +int G::foo() +{ + return 13; + +} + + +void marker1() +{ +} + + +int main(void) +{ + + A a_instance; + B b_instance; + C c_instance; + D d_instance; + E e_instance; + F f_instance; + G g_instance; + + #ifdef usestubs + set_debug_traps(); + breakpoint(); + #endif + + + marker1(); // marker1-returns-here + + a_instance.a = 20; // marker1-returns-here + a_instance.aa = 21; + b_instance.b = 22; + b_instance.bb = 23; + c_instance.c = 24; + c_instance.cc = 25; + d_instance.d = 26; + d_instance.dd = 27; + e_instance.e = 28; + e_instance.ee =29; + f_instance.f =30; + f_instance.ff =31; + + + + + return 0; + +} + + + Index: overload.cc =================================================================== --- overload.cc (nonexistent) +++ overload.cc (revision 513) @@ -0,0 +1,217 @@ +#include + +class foo { +public: + foo (int); + foo (int, const char *); + foo (foo&); + ~foo (); + void foofunc (int); + void foofunc (int, signed char *); + int ifoo; + const char *ccpfoo; + +int overload1arg (void); +int overload1arg (char); +int overload1arg (signed char); +int overload1arg (unsigned char); +int overload1arg (short); +int overload1arg (unsigned short); +int overload1arg (int); +int overload1arg (unsigned int); +int overload1arg (long); +int overload1arg (unsigned long); +int overload1arg (float); +int overload1arg (double); + +int overloadfnarg (void); +int overloadfnarg (int); +int overloadfnarg (int, int (*) (int)); + +int overloadargs (int a1); +int overloadargs (int a1, int a2); +int overloadargs (int a1, int a2, int a3); +int overloadargs (int a1, int a2, int a3, int a4); +int overloadargs (int a1, int a2, int a3, int a4, int a5); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10); +int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10, int a11); + +}; + +struct K { + static int staticoverload (); + static int staticoverload (int); + static int staticoverload (int, int); +}; + +namespace N { + int nsoverload () { return 1; } + int nsoverload (int x) { return x; } + int nsoverload (int x, int y) { return x + y; } +}; + +int intToChar (char c) { return 297; } + +void marker1() +{} + +// Now test how overloading and namespaces interact. + +class dummyClass {}; + +dummyClass dummyInstance; + +int overloadNamespace(int i) +{ + return 1; +} + +int overloadNamespace(dummyClass d) +{ + return 2; +} + +namespace XXX { + int overloadNamespace (char c) + { + return 3; + } + + void marker2() {} +} + +int main () +{ + char arg2 = 2; + signed char arg3 =3; + unsigned char arg4 =4; + short arg5 =5; + unsigned short arg6 =6; + int arg7 =7; + unsigned int arg8 =8; + long arg9 =9; + unsigned long arg10 =10; + float arg11 =100.0; + double arg12 = 200.0; + + char *str = (char *) "A"; + foo foo_instance1(111); + foo foo_instance2(222, str); + foo foo_instance3(foo_instance2); + + // Some calls to ensure all the functions are emitted. + K::staticoverload(); + K::staticoverload(2); + K::staticoverload(2, 3); + N::nsoverload(); + N::nsoverload(2); + N::nsoverload(2, 3); + + #ifdef usestubs + set_debug_traps(); + breakpoint(); + #endif + + overloadNamespace (1); + overloadNamespace (dummyInstance); + XXX::overloadNamespace ('a'); + + // Verify that intToChar should work: + intToChar(1); + + marker1(); // marker1-returns-here + XXX::marker2(); // marker1-returns-here + return 0; +} + +foo::foo (int i) { ifoo = i; ccpfoo = NULL; } +foo::foo (int i, const char *ccp) { ifoo = i; ccpfoo = ccp; } +foo::foo (foo& afoo) { ifoo = afoo.ifoo; ccpfoo = afoo.ccpfoo;} +foo::~foo () {} + + +/* Some functions to test overloading by varying one argument type. */ + +int foo::overload1arg (void) { return 1; } +int foo::overload1arg (char arg) { arg = 0; return 2;} +int foo::overload1arg (signed char arg) { arg = 0; return 3;} +int foo::overload1arg (unsigned char arg) { arg = 0; return 4;} +int foo::overload1arg (short arg) { arg = 0; return 5;} +int foo::overload1arg (unsigned short arg) { arg = 0; return 6;} +int foo::overload1arg (int arg) { arg = 0; return 7;} +int foo::overload1arg (unsigned int arg) { arg = 0; return 8;} +int foo::overload1arg (long arg) { arg = 0; return 9;} +int foo::overload1arg (unsigned long arg) { arg = 0; return 10;} +int foo::overload1arg (float arg) { arg = 0; return 11;} +int foo::overload1arg (double arg) { arg = 0; return 12;} + +/* Test to see that we can explicitly request overloaded functions + with function pointers in the prototype. */ + +int foo::overloadfnarg (void) { return ifoo * 20; } +int foo::overloadfnarg (int arg) { arg = 0; return 13;} +int foo::overloadfnarg (int arg, int (*foo) (int)) { return foo(arg); } + +/* Some functions to test overloading by varying argument count. */ + +int foo::overloadargs (int a1) +{ a1 = 0; +return 1;} + +int foo::overloadargs (int a1, int a2) +{ a1 = a2 = 0; +return 2;} + +int foo::overloadargs (int a1, int a2, int a3) +{ a1 = a2 = a3 = 0; +return 3;} + +int foo::overloadargs (int a1, int a2, int a3, int a4) +{ a1 = a2 = a3 = a4 = 0; +return 4;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5) +{ a1 = a2 = a3 = a4 = a5 = 0; +return 5;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6) +{ a1 = a2 = a3 = a4 = a5 = a6 = 0; +return 6;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7) +{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = 0; +return 7;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8) +{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = 0; +return 8;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9) +{ + a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = 0; + return 9; +} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = + a10 = 0; return 10;} + +int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10, int a11) + { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = + a10 = a11 = 0; return 11;} + + + +int K::staticoverload () { return 1; } +int K::staticoverload (int x) { return x; } +int K::staticoverload (int x, int y) { return x + y; } Index: nsrecurs.exp =================================================================== --- nsrecurs.exp (nonexistent) +++ nsrecurs.exp (revision 513) @@ -0,0 +1,74 @@ +# Copyright 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +if $tracelevel then { + strace $tracelevel +} + + +set testfile nsrecurs +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" \ + "${binfile}" executable {debug c++}] != "" } { + untested "Couldn't compile test program" + return -1 +} + +if [get_compiler_info ${binfile}] { + return -1 +} + + +# Get things started. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint main" + continue +} + +############################################ +# test printing from namespace imported into +# imported namespace + +gdb_test "print ax" "= 9" + +############################################ +# test that gdb can print without falling +# into search loop + +gdb_test "print dx" "= 99" + +############################################ +# test printing from namespace imported into +# imported namespace where imports are implicit +# anonymous namespace imports. + +gdb_test "print xx" "= 999" + +############################################ +# Test printing using recursive namespace +# aliases. + +setup_kfail "gdb/10541" "*-*-*" +gdb_test "ptype G::GF" "= namespace F" + +setup_kfail "gdb/10541" "*-*-*" +gdb_test "print G::GF::FE::ex" "= 9999" Index: pr9067.exp =================================================================== --- pr9067.exp (nonexistent) +++ pr9067.exp (revision 513) @@ -0,0 +1,46 @@ +# Copyright 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set nl "\[\r\n\]+" + +if { [skip_cplus_tests] } { continue } + +load_lib "cp-support.exp" + +set testfile "pr9067" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {c++ debug}] != "" } { + untested pr9067.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +gdb_test "print b" ".*same as static member.*" + + +gdb_exit +return 0 + Index: virtbase.cc =================================================================== --- virtbase.cc (nonexistent) +++ virtbase.cc (revision 513) @@ -0,0 +1,101 @@ +// This first batch of classes are for PR 11226. +namespace mc { + class Base { + protected: + int x; + + public: + Base(void) { x = 2; }; + }; +} + +namespace ph { + class Middle: public virtual mc::Base { + protected: + int y; + + public: + Middle(void): mc::Base() { y = 3; }; + + int get_y(void) + { + return y; // breakpoint 1 + }; + }; + + class Derived: public virtual Middle { + protected: + int z; + + public: + Derived(void): Middle() { z = 4; }; + + int get_z(void) + { + return z; // breakpoint 2 + }; + }; +} + +// These classes are for PR 9629. +struct A {}; +struct B : virtual A {}; + +struct C {int v; C() {v=11;};}; +struct D:virtual C{}; + +class E:B,D{}; + +// These classes are for another regression test, from +// https://bugzilla.redhat.com/show_bug.cgi?id=560741 + +class RHA +{ +public: + RHA() : mA(0xaaaaaaaa) {} + virtual void a() = 0; + int mA; +}; + +class RHB +{ +public: + RHB() : mB(0xbbbbbbbb) {} + virtual void b() = 0; + int mB; +}; + +class RHC : public RHA, + public RHB +{ +public: + RHC() : RHA(), RHB() {} + virtual void a() {} + virtual void b() {} +}; + +class RTTI_base +{ +public: + virtual ~RTTI_base() {} +}; + +class RTTI_data +{ +public: + RTTI_base base; + int data; + RTTI_data() : data(1) {} +}; + +int main() { + ph::Derived tst; + tst.get_y(); + tst.get_z(); + + E *e = new E; + RHB *b = new RHC(); + RTTI_data rtti_data; + + return 0; // breakpoint 3 +} Index: gdb2495.cc =================================================================== --- gdb2495.cc (nonexistent) +++ gdb2495.cc (revision 513) @@ -0,0 +1,89 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#include +#include + +using namespace std; + +class SimpleException +{ + +public: + + void raise_signal (int dummy) + { + if (dummy > 0) + raise(SIGABRT); + } + + int no_throw_function () + { + return 1; + } + + void throw_function () + { + throw 1; + } + + int throw_function_with_handler () + { + try + { + throw 1; + } + catch (...) + { + cout << "Handled" << endl; + } + + return 2; + } + + void call_throw_function_no_handler () + { + throw_function (); + } + + void call_throw_function_handler () + { + throw_function_with_handler (); + } +}; +SimpleException exceptions; + +int +main() +{ + /* Have to call these functions so GCC does not optimize them + away. */ + exceptions.raise_signal (-1); + exceptions.no_throw_function (); + exceptions.throw_function_with_handler (); + exceptions.call_throw_function_handler (); + try + { + exceptions.throw_function (); + exceptions.call_throw_function_no_handler (); + } + catch (...) + { + } + return 0; +} Index: koenig.exp =================================================================== --- koenig.exp (nonexistent) +++ koenig.exp (revision 513) @@ -0,0 +1,117 @@ +# Copyright 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set testfile koenig +set srcfile ${testfile}.cc +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } { + return -1 +} + +############################################ + +if ![runto_main] then { + perror "couldn't run to breakpoint main" + continue +} + +# Test that koenig lookup finds correct function +gdb_test "p first(c)" "= 11" + +# Change the number of parameters and position of +# the qualifying parameter +gdb_test "p second(0,0,c,0,0)" "= 33" + +# Test that koenig lookup finds correct function +# even if it is overloaded +gdb_test "p first(0,c)" "= 22" + +# Test that koenig lookup finds correct function +# when the argument is an expression +gdb_test "p first(b.c)" "= 11" + +# test that resolutions can be made across namespaces +gdb_test "p foo(eo)" "= 1" +gdb_test "p foo(eo, eo)" "= 2" +gdb_test "p foo(eo, eo, 1)" "= 3" +gdb_test "p foo(fo, eo)" "= 4" +gdb_test "p foo(1 ,fo, eo)" "= 5" +gdb_test "p foo(go, fo, eo)" "= 6" + +#test that gdb fails gracefully +gdb_test "p fake(eo)" "No symbol \"fake\" in current context." +gdb_test "p foo (fake)" "No symbol \"fake\" in current context." + +#test that namespaces of base classes are searched +gdb_test "p foo(io)" "= 7" +gdb_test "p foo(ix)" "Cannot resolve function foo to any overloaded instance" + +#test for other types +gdb_test "p foo(ju)" "= 8" +gdb_test "p foo(js)" "= 9" +gdb_test "p foo(je)" "= 10" + +#test for class members +setup_xfail "*-*-*" +gdb_test "p foo(jab)" "= 11" + +gdb_test "p foo(jap)" "= 12" +gdb_test "p foo(japp)" "= 13" +gdb_test "p foo(jca)" "= 14" + +#test overload resolution +gdb_test "p foo(ko,1)" "= 15" +gdb_test "p foo(ko,1.0f)" "= 16" +setup_xfail "*-*-*" +gdb_test "p bar(ko,1)" "= -1" + +#test lookup of objects belonging to nested namespaces +gdb_test "p foo(labo)" "= 17" + +#test koenig found function do not compete with qualified +#names +gdb_test "p ma.foo('a')" "= 18" +gdb_test "p foo(ma,'a')" "= 19" +gdb_test "p M::N::foo(ma,'a')" "= 20" +gdb_test "p M::FAKE::foo(ma,'a')" "No type \"FAKE\" within class or namespace \"M\"." +gdb_test "p M::N::fake(ma,'a')" "No symbol \"fake\" in namespace \"M::N\"." + +gdb_test "p M::bar('a')" "= 21" +gdb_test "p M::N::bar('a')" "= 22" + +#test that lookup supports typedef +gdb_test "p foo(ttoa, 'a')" "= 23" + +#test that lookup is not thwarted by anonymous types +gdb_test "p foo (p_union)" \ + "Cannot resolve function foo to any overloaded instance" + +# test lookup of namespace user-defined operators +# and overload resolution: + +# within class +gdb_test "p q == 5" "= 24" +gdb_test "p q == 5.0f" "= 25" + +# within namespace +gdb_test "p q != 5" "= 27" +gdb_test "p q != 5.0f" "= 28" + +# across namespace and class +gdb_test "p q + 5.0f" "= 26" +gdb_test "p q + 5" "= 29" + +# some unary operators for good measure +# Cannot resolve function operator++ to any overloaded instance +gdb_test "p ++q" "= 30" Index: expand-sals.exp =================================================================== --- expand-sals.exp (nonexistent) +++ expand-sals.exp (revision 513) @@ -0,0 +1,52 @@ +# Copyright 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +if { [skip_cplus_tests] } { continue } + +set srcfile expand-sals.cc +if { [prepare_for_testing expand-sals.exp expand-sals $srcfile {debug c++}] } { + return -1 +} +if ![runto_main] { + return -1 +} + +gdb_breakpoint [gdb_get_line_number "func-line"] +gdb_continue_to_breakpoint "func" ".*func-line.*" + +gdb_test "up" "caller-line.*" + +# PC should not be now at the boundary of source lines to make the original bug +# exploitable. The GLOBAL_X variable exists in the source for this purpose. + +# Original problem was an internal error here. +set test "break" +gdb_test_multiple $test $test { + -re "Breakpoint \[0-9\]+ at .*, line \[0-9\]+\\. \\(\[2-9\] locations\\)\r\n$gdb_prompt $" { + fail $test + } + -re "Breakpoint \[0-9\]+ at .*, line \[0-9\]+\\.\r\n$gdb_prompt $" { + pass $test + } +} + +gdb_continue_to_breakpoint "caller" ".*caller-line.*" + +# Test GDB caught this return call and not the next one through B::B() +gdb_test "bt" \ + "#0 \[^\r\n\]* (A::)?A \[^\r\n\]*\r\n#1 \[^\r\n\]* main \[^\r\n\]*" \ + "bt from A" + +gdb_continue_to_breakpoint "next caller func" ".*func-line.*" Index: mb-templates.cc =================================================================== --- mb-templates.cc (nonexistent) +++ mb-templates.cc (revision 513) @@ -0,0 +1,31 @@ + +#include +using namespace std; + +template +void foo(T i) +{ + std::cout << "hi\n"; // set breakpoint here +} + +template +void multi_line_foo(T i) +{ + std::cout // set multi-line breakpoint here + << "hi\n"; +} + +int main() +{ + foo(0); + foo(0); + foo(1); + foo(1); + foo(2); + foo(2); + + multi_line_foo(0); + multi_line_foo(0); + + return 0; +} Index: namespace-nested-import.exp =================================================================== --- namespace-nested-import.exp (nonexistent) +++ namespace-nested-import.exp (revision 513) @@ -0,0 +1,46 @@ +# Copyright 2008, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +if $tracelevel then { + strace $tracelevel +} + + +set testfile namespace-nested-import +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested "Couldn't compile test program" + return -1 +} + +# Get things started. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +############################################ +# Test printing of a variable from a nested +# in a namespace inner to the one which has +# been imported. + +if ![runto_main] then { + perror "couldn't run to breakpoint main" + continue +} + +gdb_test "print C::x" "= 5" Index: psmang.exp =================================================================== --- psmang.exp (nonexistent) +++ psmang.exp (revision 513) @@ -0,0 +1,223 @@ +# Copyright 2002, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the gdb testsuite + +# Looking up methods by name, in programs with multiple compilation units. + +# ====== PLEASE BE VERY CAREFUL WHEN CHANGING THIS TEST. ===== +# +# The bug we're testing for (circa October 2002) is very sensitive to +# various conditions that are hard to control directly in the test +# suite. If you change the test, please revert this change, and make +# sure the test still fails: +# +# 2002-08-29 Jim Blandy +# +# * symtab.c (lookup_symbol_aux): In the cases where we find a +# minimal symbol of an appropriate name and use its address to +# select a symtab to read and search, use `name' (as passed to us) +# as the demangled name when searching the symtab's global and +# static blocks, not the minsym's name. +# +# The original bug was that you'd try to set a breakpoint on a method +# (e.g., `break s::method1'), and you'd get an error, but if you +# repeated the command, it would work the second time: +# +# (gdb) break s::method1 +# the class s does not have any method named method1 +# Hint: try 's::method1 or 's::method1 +# (Note leading single quote.) +# (gdb) break s::method1 +# Breakpoint 1 at 0x804841b: file psmang1.cc, line 13. +# (gdb) +# +# We observed this bug first using Stabs, and then using Dwarf 2. +# +# The problem was in lookup_symbol_aux: when looking up s::method1, it +# would fail to find it in any symtabs, find the minsym with the +# corresponding mangled name (say, `_ZN1S7method1Ev'), pass the +# minsym's address to find_pc_sect_symtab to look up the symtab +# (causing the compilation unit's full symbols to be read in), and +# then look up the symbol in that symtab's global block. All that is +# correct. However, it would pass the minsym's name as the NAME +# argument to lookup_block_symbol; a minsym's name is mangled, whereas +# lookup_block_symbol's NAME argument should be demangled. +# +# This is a pretty simple bug, but it turns out to be a bear to +# construct a test for. That's why this test case is so delicate. If +# you can see how to make it less so, please contribute a patch. +# +# Here are the twists: +# +# The bug only manifests itself when we call lookup_symbol to look up +# a method name (like "s::method1" or "s::method2"), and that method's +# definition is in a compilation unit for which we have read partial +# symbols, but not full symbols. The partial->full conversion must be +# caused by that specific lookup. (If we already have full symbols +# for the method's compilation unit, we won't need to look up the +# minsym, find the symtab for the minsym's address, and then call +# lookup_block_symbol; it's that last call where things go awry.) +# +# Now, when asked to set a breakpoint at `s::method1', GDB will first +# look up `s' to see if that is, in fact, the name of a class, and +# then look up 's::method1'. So we have to make sure that looking up +# `s' doesn't cause full symbols to be read for the compilation unit +# containing the definition of `s::method1'. +# +# The partial symbol tables for `psmang1.cc' and `psmang2.cc' will +# both have entries for `s'; GDB will read full symbols for whichever +# compilation unit's partial symbol table appears first in the +# objfile's list. The order in which compilation units appear in the +# partial symbol table list depends on how the program is linked, and +# how the debug info reader does the partial symbol scan. Ideally, +# the test shouldn't rely on them appearing in any particular order. +# +# So, since we don't know which compilation unit's full symbols are +# going to get read, we simply try looking up one method from each of +# the two compilation units. One of them has to come after the other +# in the partial symbol table list, so whichever comes later will +# still need its partial symbols read by the time we go to look up +# 's::methodX'. +# +# Second twist: don't move the common definition of `struct s' into a +# header file. If the compiler emits identical stabs for the +# #inclusion of that header file into psmang1.cc and into psmang2.cc, +# then the linker will do stabs compression, and replace one of the +# BINCL/EINCL regions with an EXCL stab, pointing to the other +# BINCL/EINCL region. GDB will read this, and record that the +# compilation unit that got the EXCL depends on the compilation unit +# that kept the BINCL/EINCL. Then, when it decides it needs to read +# full symbols for the former, it'll also read full symbols for the +# latter. Now, if it just so happens that the compilation unit that +# got the EXCL is also the first one with a definition of `s' in the +# partial symbol table list, then that first probe for `s' will cause +# both compilation units' full symbols to be read --- again defeating +# the test. +# +# We could work around this by having three compilation units, or by +# ensuring that the header file produces different stabs each time +# it's #included, but it seems simplest just to avoid compilation unit +# dependencies altogether, drop the header file, and duplicate the +# (pretty trivial) struct definition. +# +# Note that #including any header file at all into both compilation +# units --- say, --- could create this sort of dependency. +# +# This is the aspect of the test which the debug format is most likely +# to affect, I think. The different formats create different kinds of +# inter-CU dependencies, which could mask the bug. It might be +# possible for the test to check that at least one of the partial +# symtabs remains unread, and fail otherwise --- the failure +# indicating that the test itself isn't going to catch the bug it was +# meant to, not that GDB is misbehaving. +# +# Third twist: given the way lookup_block_symbol is written, it's +# possible to find the symbol even when it gets passed a mangled name +# for its NAME parameter. There are three ways lookup_block_symbol +# might search a block, depending on how it was constructed: +# +# linear search. In this case, this bug will never manifest itself, +# since we check every symbol against NAME using SYMBOL_MATCHES_NAME. +# Since that macro checks its second argument (NAME) against both the +# mangled and demangled names of the symbol, this will always find the +# symbol successfully, so, no bug. +# +# hash table. If both the mangled and demangled names hash to the +# same bucket, then you'll again find the symbol "by accident", since +# we search the entire bucket using SYMBOL_SOURCE_NAME. Since GDB +# chooses the number of buckets based on the number of symbols, small +# compilation units may have only one hash bucket; in this case, the +# search always succeeds, even though we hashed on the wrong name. +# This test works around that by having a lot of dummy variables, +# making it less likely that the mangled and demangled names fall in +# the same bucket. +# +# binary search. (GDB 5.2 produced these sorts of blocks, and this +# test tries to detect the bug there, but subsequent versions of GDB +# almost never build them, and they may soon be removed entirely.) In +# this case, the symbols in the block are sorted by their +# SYMBOL_SOURCE_NAME (whose behavior depends on the current demangling +# setting, so that's wrong, but let's try to stay focussed). +# lookup_block_symbol does a binary search comparing NAME with +# SYMBOL_SOURCE_NAME until the range has been narrowed down to only a +# few symbols; then it starts a linear search forward from the lower +# end of that range, until it reaches a symbol whose +# SYMBOL_SOURCE_NAME follows NAME in lexicographic order. This means +# that, if you're doing a binary search for a mangled name in a block +# sorted by SYMBOL_SOURCE_NAME, you might find the symbol `by +# accident' if the mangled and demangled names happen to fall near +# each other in the ordering. The initial version of this patch used +# a class called `S'; all the other symbols in the compilation unit +# started with lower-case letters, so the demangled name `S::method1' +# sorted at the same place as the mangled name `_ZN1S7method1Ev': at +# the very beginning. Using a lower-case 's' as the name ensures that +# the demangled name falls after all the dummy symbols introduced for +# the hash table, as described above. +# +# This is all so tortured, someone will probably come up with still +# other ways this test could fail to do its job. If you need to make +# revisions, please be very careful. + +if $tracelevel then { + strace $tracelevel +} + +# +# test running programs +# + + +if { [skip_cplus_tests] } { continue } + +set testfile "psmang" +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile} "c++"] { + return -1; +} + +if { [gdb_compile "${srcdir}/${subdir}/${testfile}1.cc" "${testfile}1.o" object {debug c++}] != "" } { + untested psmang.exp + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${testfile}2.cc" "${testfile}2.o" object {debug c++}] != "" } { + untested psmang.exp + return -1 +} + +if { [gdb_compile "${testfile}1.o ${testfile}2.o" ${binfile} executable {debug c++}] != "" } { + untested psmang.exp + return -1 +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +gdb_test "break s::method1" "Breakpoint .* at .*: file .*psmang1.cc.*" + +# We have to exit and restart GDB here, to make sure that all the +# compilation units are psymtabs again. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +gdb_test "break s::method2" "Breakpoint .* at .*: file .*psmang2.cc.*" Index: cp-relocate.cc =================================================================== --- cp-relocate.cc (nonexistent) +++ cp-relocate.cc (revision 513) @@ -0,0 +1,26 @@ +/* This test file is part of GDB, the GNU debugger. + + Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +template int func(int) +{ + return X; +} + +int caller() +{ + return func<1>(1) + func<2>(2); +} Index: pass-by-ref.exp =================================================================== --- pass-by-ref.exp (nonexistent) +++ pass-by-ref.exp (revision 513) @@ -0,0 +1,41 @@ +# Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Check that GDB can call C++ functions whose parameters have +# object type, but are passed by reference. + +if { [skip_cplus_tests] } { continue } + +set testfile "pass-by-ref" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ + executable {debug c++}] != "" } { + untested pass-by-ref.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + return -1 +} + +gdb_test "print foo (global_obj)" " = 3" "call function in obj" +gdb_test "print blap (global_derived)" " = 3" "call function in derived" +gdb_test "print blip (global_container)" " = 3" "call function in container" Index: operator.exp =================================================================== --- operator.exp (nonexistent) +++ operator.exp (revision 513) @@ -0,0 +1,61 @@ +# Copyright 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set testfile operator +set srcfile ${testfile}.cc +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } { + return -1 +} + +############################################ + +if ![runto_main] then { + perror "couldn't run to breakpoint main" + continue +} + +# Test global operator +gdb_test "p a == 1" "= 11" "global operator" +gdb_test "p a == 'a'" "= 12" "global operator overload" + +# Test ADL operator +gdb_test "p bc == 1" "= 22" "ADL operator" +gdb_test "p bc == 'a'" "= 23" "ADL operator overload" +gdb_test "p B::BD::operator== (bc,'a')" "= 24" "Fully qualified explicit operator call" + +# Test operator imported from anonymous namespace +gdb_test "p d == 1" "= 33" "anonymous namespace operator" +gdb_test "p d == 'a'" "= 34" "anonymous namespace operator overload" +gdb_test "p d == 1.0f" "= 35" "anonymous namespace operator overload float" + +# Test operator imported by using directive +gdb_test "p e == 1" "= 44" "imported operator" +gdb_test "p e == 'a'" "= 45" "imported operator overload" +gdb_test "p e == 1.0f" "= 46" "imported operator overload float" + +# Test member operator +gdb_test "p g == 1" "= 55" "member operator" +gdb_test "p g == 'a'" "= 56" "member operator overload" + +# Test that operators are not wrongly imported +# by import declarations and namespace aliases +gdb_test "p h == 1" "Cannot resolve function operator== to any overloaded instance" "namespace alias" +gdb_test "p j == 1" "Cannot resolve function operator== to any overloaded instance" "imported declaration" + +# Test that indirectly imported operators work +gdb_test "p l == 1" "= 88" + +# Test that we don't fall into an import loop +gdb_test {p x[0]} {No symbol "operator\[\]" in current context.} Index: annota2.cc =================================================================== --- annota2.cc (nonexistent) +++ annota2.cc (revision 513) @@ -0,0 +1,28 @@ +#include + +class A { +public: + int x; + int y; + int foo (int arg); +}; + + +int A::foo (int arg) +{ + x += arg; + return arg *2; +} + +int main() +{ + A a; + + a.x = 0; + a.x = 1; + a.y = 2; + + printf ("a.x is %d\n", a.x); + return 0; +} + Index: rtti1.cc =================================================================== --- rtti1.cc (nonexistent) +++ rtti1.cc (revision 513) @@ -0,0 +1,105 @@ +/* Code to go along with tests in rtti.exp. + + Copyright 2003, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + Contributed by David Carlton and by Kealia, + Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "rtti.h" + +namespace n1 { + + class C1; + + class Base1 { + public: + virtual ~Base1() { } + }; + + + class C1: public Base1 { + public: + }; + + class D1 : public C1{ + public: + D1(C1 *, C1 *); + + C1* expr_1_; + C1* expr_2_; + }; + + D1::D1(C1 *expr_1, C1 *expr_2) + : expr_1_(expr_1), expr_2_(expr_2) { } + + C1 *create1() { + return new D1(0, 0); + } + +} // n1 + +// NOTE: carlton/2004-01-23: This call exists only to convince GCC to +// keep around a reference to 'obj' in n2::func - GCC 3.4 had been +// optimizing it away. +void refer_to (n2::C2 *obj) +{ + // Do nothing. +} + +void refer_to (n2::n3::C3 *obj) +{ + // Do nothing. +} + +namespace n2 +{ + void func () + { + C2 *obj = create2 (); + + refer_to (obj); // func-constructs-done + + return; + } + + namespace n3 + { + void func3 () + { + C3 *obj3 = create3 (); + + refer_to (obj3); // func3-constructs-done + + return; + } + } +} + +int main() +{ + using namespace n1; + using namespace n2; + + C1 *e1 = create1(); + C2 *e2 = create2(); + + n2::func(); // main-constructs-done + n2::n3::func3(); + + return 0; +} Index: pr-1023.cc =================================================================== --- pr-1023.cc (nonexistent) +++ pr-1023.cc (revision 513) @@ -0,0 +1,20 @@ +class myClass +{ + public: + myClass() {}; + ~myClass() {}; + void performUnblocking( short int cell_index ); + void performBlocking( int cell_index ); +}; + +void myClass::performUnblocking( short int cell_index ) {} + +void myClass::performBlocking( int cell_index ) {} + +int main () +{ + myClass mc; + mc.performBlocking (0); + mc.performUnblocking (0); +} + Index: cp-relocate.exp =================================================================== --- cp-relocate.exp (nonexistent) +++ cp-relocate.exp (revision 513) @@ -0,0 +1,136 @@ +# Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . */ + +# Test loading symbols from unrelocated C++ object files. + +set testfile cp-relocate +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile}.o + +if { [skip_cplus_tests] } { continue } + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {c++ debug}] != "" } { + untested cp-relocate.exp + return -1 +} + +proc get_func_address { func } { + global gdb_prompt hex + + set rfunc [string_to_regexp $func] + gdb_test_multiple "print ${func}" "get address of ${func}" { + -re "\\\$\[0-9\]+ = \\{.*\\} (0|($hex) <${rfunc}>)\[\r\n\]+${gdb_prompt} $" { + # $1 = {int ()} 0x24 + # But if the function is at zero, the name may be omitted. + pass "get address of ${func}" + if { $expect_out(1,string) == "0" } { + return "0x0" + } else { + return $expect_out(2,string) + } + } + } + return "" +} + +# Load the file as an executable; GDB should assign non-overlapping +# section offsets. +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_file_cmd ${binfile} + +# Find the interesting functions. We go to a little effort to find +# the right function names here, to work around PR c++/40. +set func1_name "" +set func2_name "" +gdb_test_multiple "info functions func<.>" "info functions" { + -re "\r\nint (\[^\r\]*func<1>\[^\r]*);" { + set func1_name $expect_out(1,string) + exp_continue + } + -re "\r\nint (\[^\r\]*func<2>\[^\r]*);" { + set func2_name $expect_out(1,string) + exp_continue + } + -re "$gdb_prompt $" { + if { ${func1_name} != "" && ${func2_name} != "" } { + pass "info functions" + } else { + fail "info functions" + return -1 + } + } +} + +# Check that all the functions have different addresses. +set func1_addr [get_func_address "$func1_name"] +set func2_addr [get_func_address "$func2_name"] +set caller_addr [get_func_address "caller"] + +if { "${func1_addr}" == "${func2_addr}" + || "${func1_addr}" == "${func2_addr}" + || "${func2_addr}" == "${caller_addr}" } { + fail "C++ functions have different addresses" +} else { + pass "C++ functions have different addresses" +} + +# Figure out the names of the sections containing the template +# functions. +set func1_sec "" +set func2_sec "" +gdb_test_multiple "info file" "info file" { + -re "($hex) - ($hex) is (\[^\r\]*)\r" { + if { $expect_out(1,string) <= $func1_addr + && $expect_out(2,string) > $func1_addr } { + set func1_sec $expect_out(3,string) + } elseif { $expect_out(1,string) <= $func2_addr + && $expect_out(2,string) > $func2_addr } { + set func2_sec $expect_out(3,string) + } + exp_continue + } + -re "$gdb_prompt $" { + if { ${func1_sec} != "" && ${func2_sec} != "" } { + pass "info file" + } else { + fail "info file" + return -1 + } + } +} + +if { $func1_sec == $func2_sec } { + untested "cp-relocate.exp - template functions in same sections" + return -1 +} + +# Now start a clean GDB, for add-symbol-file tests. +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir + +gdb_test "add-symbol-file ${binfile} 0 -s ${func1_sec} 0x10000 -s ${func2_sec} 0x20000" \ + "Reading symbols from .*${testfile}\\.o\\.\\.\\.done\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \ + "add-symbol-file ${testfile}.o" \ + "add symbol table from file \".*${testfile}\\.o\" at.*\\(y or n\\) " \ + "y" + +# Make sure the function addresses were updated. +gdb_test "break *$func1_name" \ + "Breakpoint $decimal at 0x1....: file .*" +gdb_test "break *$func2_name" \ + "Breakpoint $decimal at 0x2....: file .*" Index: member-ptr.cc =================================================================== --- member-ptr.cc (nonexistent) +++ member-ptr.cc (revision 513) @@ -0,0 +1,222 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 1998, 1999, 2004, 2006, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + + + +extern "C" { +#include +} + + +class A { +public: + A(); + int foo (int x); + int bar (int y); + virtual int baz (int z); + char c; + int j; + int jj; + static int s; +}; + +class B { +public: + static int s; +}; + +int A::s = 10; +int B::s = 20; + +A::A() +{ + c = 'x'; + j = 5; +} + +int A::foo (int dummy) +{ + j += 3; + return j + dummy; +} + +int A::bar (int dummy) +{ + int r; + j += 13; + r = this->foo(15); + return r + j + 2 * dummy; +} + +int A::baz (int dummy) +{ + int r; + j += 15; + r = this->foo(15); + return r + j + 12 * dummy; +} + +int fum (int dummy) +{ + return 2 + 13 * dummy; +} + +typedef int (A::*PMF)(int); + +typedef int A::*PMI; + +/* This class is in front of the other base classes of Diamond, so + that we can detect if the offset for Left or the first Base is + added twice - otherwise it would be 2 * 0 == 0. */ +class Padding +{ +public: + int spacer; + virtual int vspacer(); +}; + +int Padding::vspacer() +{ + return this->spacer; +} + +class Base +{ +public: + int x; + int get_x(); + virtual int vget_base (); +}; + +int Base::get_x () +{ + return this->x; +} + +int Base::vget_base () +{ + return this->x + 1000; +} + +class Left : public Base { +public: + virtual int vget (); +}; + +int Left::vget () +{ + return this->x + 100; +} + +class Right : public Base { +public: + virtual int vget (); +}; + +int Right::vget () +{ + return this->x + 200; +} + +class Diamond : public Padding, public Left, public Right +{ +public: + virtual int vget_base (); +}; + +int Diamond::vget_base () +{ + return this->Left::x + 2000; +} + +int main () +{ + A a; + A * a_p; + PMF pmf; + + PMF * pmf_p; + PMI pmi; + + Diamond diamond; + int (Diamond::*left_pmf) (); + int (Diamond::*right_pmf) (); + int (Diamond::*left_vpmf) (); + int (Diamond::*left_base_vpmf) (); + int (Diamond::*right_vpmf) (); + int (Base::*base_vpmf) (); + int Diamond::*diamond_pmi; + + PMI null_pmi; + PMF null_pmf; + + a.j = 121; + a.jj = 1331; + + int k; + + a_p = &a; + + pmi = &A::j; + pmf = &A::bar; + pmf_p = &pmf; + + diamond.Left::x = 77; + diamond.Right::x = 88; + + /* Some valid pointer to members from a base class. */ + left_pmf = (int (Diamond::*) ()) (int (Left::*) ()) (&Base::get_x); + right_pmf = (int (Diamond::*) ()) (int (Right::*) ()) (&Base::get_x); + left_vpmf = &Left::vget; + left_base_vpmf = (int (Diamond::*) ()) (int (Left::*) ()) (&Base::vget_base); + right_vpmf = &Right::vget; + + /* An unspecified, value preserving pointer to member cast. */ + base_vpmf = (int (Base::*) ()) (int (Left::*) ()) &Diamond::vget_base; + + /* A pointer to data member from a base class. */ + diamond_pmi = (int Diamond::*) (int Left::*) &Base::x; + + null_pmi = NULL; + null_pmf = NULL; + + pmi = NULL; /* Breakpoint 1 here. */ + + k = (a.*pmf)(3); + + pmi = &A::jj; + pmf = &A::foo; + pmf_p = &pmf; + + k = (a.*pmf)(4); + + k = (a.**pmf_p)(5); + + k = a.*pmi; + + + k = a.bar(2); + + k += fum (4); + + B b; + + k += b.s; + +} Index: annota3.exp =================================================================== --- annota3.exp (nonexistent) +++ annota3.exp (revision 513) @@ -0,0 +1,218 @@ +# Copyright 2003, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file was written by Elena Zannoni (ezannoni@cygnus.com) + +if $tracelevel then { + strace $tracelevel +} + + +# +# test running programs +# + +if { [skip_cplus_tests] } { continue } + +set testfile "annota3" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ nowarnings}] != "" } { + untested annota3.exp + return -1 +} + +# are we on a target board? If so, don't run these tests. +# note: this is necessary because we cannot use runto_main (which would +# work for remote targets too) because of the different prompt we get +# when using annotation level 2. +# +if [is_remote target] then { + return 0 +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if [target_info exists gdb_stub] { + gdb_step_for_stub; +} + +# +# line number where we need to stop in main +# +set main_line 25 + +# The commands we test here produce many lines of output; disable "press +# to continue" prompts. +gdb_test_no_output "set height 0" + +# +# break at main +# +gdb_test "break 25" \ + "Breakpoint.*at.* file .*$srcfile, line.*" \ + "breakpoint main" + + +# +# NOTE: this prompt is OK only when the annotation level is > 1 +# NOTE: When this prompt is in use the gdb_test procedure cannot be used because +# it assumes that the last char of the gdb_prompt is a white space. This is not +# true with this annotated prompt. So we must use send_gdb and gdb_expect. +# + +set old_gdb_prompt $gdb_prompt +set gdb_prompt "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n" + +send_gdb "set annotate 3\n" +gdb_expect_list "annotation set at level 3" "\r\n$gdb_prompt$" { + "set annotate 3" +} + +send_gdb "run\n" +gdb_expect_list "first run until main breakpoint" "$gdb_prompt$" { + "\r\n\032\032post-prompt\r\n" + "Starting program: .*annota3 \r\n" + "\r\n\032\032starting\r\n" + "\r\n\032\032breakpoint 1\r\n" + "\r\n" + "Breakpoint 1, " + "\r\n\032\032frame-begin 0 0x\[0-9a-z\]+\r\n" + "main \\(\\) at .*annota3.cc:25\r\n" + "\r\n\032\032source.*annota3.cc:25:.*:beg:0x\[0-9a-z\]+\r\n" + "\r\n\032\032stopped\r\n" +} + +# +# print class 'a' with public fields. +# +send_gdb "print a\n" +gdb_expect_list "print class" "$gdb_prompt$" { + "\r\n\032\032post-prompt\r\n" + ".*= \\{x = 1, y = 2\\}\r\n" +} + +# +# continue until exit +# this will test: +# annotate-exited +# +send_gdb "continue\n" +gdb_expect_list "continue to exit" "$gdb_prompt$" { + "\r\n\032\032post-prompt\r\n" + "Continuing.\r\n" + "\r\n\032\032starting\r\n" + "a.x is 1\r\n" + "\r\n\032\032exited 0\r\n" + "\r\n" + "Program exited normally.\r\n" + "\r\n\032\032stopped\r\n" +} + +# +# delete all breakpoints +# +send_gdb "delete\n" +gdb_expect { + -re ".*Delete all breakpoints. \\(y or n\\) \r\n\032\032query.*$" { + send_gdb "y\n" + gdb_expect { + -re "\r\n\032\032post-query\r\n$gdb_prompt$" { pass "delete bps" } + -re ".*$gdb_prompt$" { fail "delete bps" } + timeout { fail "delete bps (timeout)" } + } + } + -re ".*$gdb_prompt$" { fail "delete bps" } + timeout { fail "delete bps (timeout)" } +} + +# +# break at first line of main. +# +send_gdb "break 22\n" +gdb_expect_list "break at main" "$gdb_prompt$" { + "\r\n\032\032post-prompt\r\n" + "Breakpoint.*at 0x\[a-z0-9\]+: file.*annota3.cc, line 22.\r\n" +} + +# +# run program up to breakpoint. +# + + +send_gdb "run\n" +gdb_expect_list "second run until main breakpoint" "$gdb_prompt$" { + "\r\n\032\032post-prompt\r\n" + "\r\n\032\032starting\r\n" + "\r\n\032\032breakpoint 2\r\n" + "\r\n" + "Breakpoint 2, " + "\r\n\032\032frame-begin 0 0x\[0-9a-z\]+\r\n" + "main \\(\\) at .*annota3.cc:22\r\n" + "\r\n\032\032source.*annota3.cc:22:.*:beg:0x\[0-9a-z\]+\r\n" + "\r\n\032\032stopped\r\n" +} + +# +# set up a watch point on a.x +# +send_gdb "watch a.x\n" +gdb_expect_list "set watch on a.x" "$gdb_prompt$" { + "\r\n\032\032post-prompt\r\n" + ".*atchpoint 3: a.x\r\n" \ +} + +# +# do a next, so that the watchpoint triggers. This will test: +# annotate-watchpoint +# +gdb_test_multiple "next" "watch triggered on a.x" { + -re "\r\n\032\032post-prompt\r\n\r\n\032\032starting\r\n\r\n\032\032watchpoint 3\r\n.*atchpoint 3: a.x\r\n\r\nOld value = 0\r\nNew value = 1\r\n\r\n(\032\032frame-begin 0 0x\[0-9a-z\]+\r\n|)main \\(\\) at .*$srcfile:$decimal\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032stopped\r\n.*$gdb_prompt$" { + pass "watch triggered on a.x" + } + -re "\r\n\032\032post-prompt\r\n\r\n\032\032starting\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032stopped\r\n$gdb_prompt$" { + kfail "gdb/38" "watch triggered on a.x" + } +} + +# +# send ^C to gdb, so that the quit() function gets called +# and annotate-quit is tested +# test: +# annotate-quit +# +send_gdb "\003" +gdb_expect_list "annotate-quit" "$gdb_prompt$" { + "\r\n\032\032error-begin\r\n" + "Quit\r\n" + "\r\n\032\032quit\r\n" +} + +# +# FIXME: the testsuite does not currently have tests for +# annotate_catchpoints and annotate_function_call +# and a few variants of the annotations that are +# tested (marked by FIXME on the annot?.exp files) +# + +# reinstall the old prompt for the rest of the testsuite. + +set gdb_prompt $old_gdb_prompt + Index: gdb1355.exp =================================================================== --- gdb1355.exp (nonexistent) +++ gdb1355.exp (revision 513) @@ -0,0 +1,117 @@ +# Copyright 2003, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Tests for PR gdb/1355, which is a reference to PR gcc/12066. +# 2003-08-26 Michael Chastain + +# This file is part of the gdb testsuite. + +set ws "\[\r\n\t \]*" +set nl "\[\r\n\]+" + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + +# +# test running programs +# + +set testfile "gdb1355" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested gdb1355.exp + return -1 +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to main" + continue +} + +# See http://sources.redhat.com/gdb/bugs/1355 +# See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12066 +# +# g++ -gstabs+ does not emit stabs for fundamental types. +# They get emitted later inside other types, so they have no names +# and gdb cannot handle them. + +set s_head "${ws}(struct|class) mystruct \{(${ws}public:|)" +set s_tail ".*" + +set f_i "${ws}int m_int;" +set f_c "${ws}char m_char;" +set f_li "${ws}long( int)? m_long_int;" +set f_ui "${ws}unsigned int m_unsigned_int;" +set f_lui "${ws}(long unsigned int|unsigned long) m_long_unsigned_int;" +set f_si "${ws}short( int)? m_short_int;" +set f_sui "${ws}(short unsigned int|unsigned short) m_short_unsigned_int;" +set f_uc "${ws}unsigned char m_unsigned_char;" +set f_f "${ws}float m_float;" +set f_d "${ws}double m_double;" +set f_ld "${ws}long double m_long_double;" +set f_b "${ws}bool m_bool;" + +set itc "" +set bad_i "${ws}(${itc}|int) m_int;"; +set bad_c "${ws}(${itc}|char) m_char;" +set bad_li "${ws}(${itc}|long int) m_long_int;" +set bad_ui "${ws}(${itc}|unsigned int) m_unsigned_int;" +set bad_lui "${ws}(${itc}|long unsigned int) m_long_unsigned_int;" +set bad_si "${ws}(${itc}|short int) m_short_int;" +set bad_sui "${ws}(${itc}|short unsigned int) m_short_unsigned_int;" +set bad_uc "${ws}(${itc}|unsigned char) m_unsigned_char;" +set bad_f "${ws}(${itc}|float) m_float;" +set bad_d "${ws}(${itc}|double) m_double;" +set bad_ld "${ws}(${itc}|long double) m_long_double;" +set bad_b "${ws}(${itc}|bool) m_bool;" + +gdb_test_multiple "ptype s1" "ptype s1" { + -re "type = ${s_head}${f_i}${f_c}${f_li}${f_ui}${f_lui}${f_si}${f_sui}${f_uc}${f_f}${f_d}${f_ld}${f_b}${s_tail}\}$nl$gdb_prompt $" { + pass "ptype s1" + } + -re "type = ${s_head}${bad_i}${bad_c}${bad_li}${bad_ui}${bad_lui}${bad_si}${bad_sui}${bad_uc}${bad_f}${bad_d}${bad_ld}${bad_b}${s_tail}\}$nl$gdb_prompt $" { + # This happened with gcc HEAD 2003-08-20 08:00:00 UTC, -gstabs+. + kfail "gdb/1355" "ptype s1" + } +} + +gdb_test_multiple "print s1" "print s1" { + -re "$decimal = \{m_int = 117, m_char = 97 'a', m_long_int = 118, m_unsigned_int = 119, m_long_unsigned_int = 120, m_short_int = 123, m_short_unsigned_int = 124, m_unsigned_char = 98 'b', m_float = 125, m_double = 126, m_long_double = 127, m_bool = true\}$nl$gdb_prompt $" { + pass "print s1" + } + -re "$decimal = \{m_int = 117, m_char = 97 'a', m_long_int = 118, m_unsigned_int = 119, m_long_unsigned_int = 120, m_short_int = 123, m_short_unsigned_int = 124, m_unsigned_char = 98 'b', m_float = 125, m_double = 126, m_long_double = 127, m_bool = 117\}$nl$gdb_prompt $" { + # This pattern is very picky, but if more different output + # shows up, I can just add more arms. -- chastain 2003-08-26 + # + # This happened with gcc HEAD 2003-08-20 08:00:00 UTC, -gstabs+. + # Look at the value of m_bool. It looks like gdb latched onto + # random int type and then used the data at structure offset 0. + kfail "gdb/1355" "print s1" + } +} Index: nsstress.cc =================================================================== --- nsstress.cc (nonexistent) +++ nsstress.cc (revision 513) @@ -0,0 +1,60 @@ + +namespace A{ int x; } +namespace B{ int x; } +namespace C{ int x; } +namespace D{ int x; } +namespace E{ int x; } +namespace F{ int x; } +namespace G{ int x; } +namespace H{ int x; } +namespace I{ int x; } +namespace J{ int x; } +namespace K{ int x; } +namespace L{ int x; } +namespace M{ int x; } +namespace N{ int x; } +namespace O{ int x; } +namespace P{ int x; } +namespace Q{ int x; } +namespace R{ int x; } +namespace S{ int x; } +namespace T{ int x; } +namespace U{ int x; } +namespace V{ int x; } +namespace W{ int x; } +namespace X{ int x; } +namespace Y{ int x; } +namespace Z{ int x; } + + +int main(){ + + using namespace A; + using namespace B; + using namespace C; + using namespace D; + using namespace E; + using namespace F; + using namespace G; + using namespace H; + using namespace I; + using namespace J; + using namespace K; + using namespace L; + using namespace M; + using namespace N; + using namespace O; + using namespace P; + using namespace Q; + using namespace R; + using namespace S; + using namespace T; + using namespace U; + using namespace V; + using namespace W; + using namespace X; + using namespace Y; + using namespace Z; + + return 0; +} Index: virtbase.exp =================================================================== --- virtbase.exp (nonexistent) +++ virtbase.exp (revision 513) @@ -0,0 +1,67 @@ +# Copyright 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file is part of the gdb testsuite. + +if { [skip_cplus_tests] } { continue } + +set testfile "virtbase" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested virtbase.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if {![runto_main]} then { + perror "couldn't run to breakpoint" + continue +} + +gdb_breakpoint [gdb_get_line_number "breakpoint 1"] +gdb_continue_to_breakpoint "first breakpoint" + +# In PR 11226, we failed to print x correctly in the "print *this" +# case. +gdb_test "print *this" " = { = {x = 2}, _vptr.Middle = $hex, y = 3}" +gdb_test "print x" " = 2" "print x in get_y" + +gdb_breakpoint [gdb_get_line_number "breakpoint 2"] +gdb_continue_to_breakpoint "second breakpoint" + +# In PR 11226, we could not find x here. +gdb_test "print x" " = 2" "print x in get_z" + +gdb_breakpoint [gdb_get_line_number "breakpoint 3"] +gdb_continue_to_breakpoint "third breakpoint" + +# In PR 9629, we failed to print v correctly here. +gdb_test "print *(D *) e" " = { = {v = 11}, _vptr.D = $hex}" + +# A regression test reported to Red Hat bugzilla, see: +# https://bugzilla.redhat.com/show_bug.cgi?id=560741 +gdb_test_no_output "set print object on" +gdb_test "print/x b->mA" " = 0xaaaaaaaa" + +# A regression test reported to Red Hat bugzilla, see: +# https://bugzilla.redhat.com/show_bug.cgi?id=606660 +# `set print object on' is expected. +gdb_test "print rtti_data" " = .*, data = 1\}" Index: pr10687.cc =================================================================== --- pr10687.cc (nonexistent) +++ pr10687.cc (revision 513) @@ -0,0 +1,24 @@ +class vec2 +{ + public: + vec2() { _v[0] = _v[1] = 0; } + vec2(int x, int y) { _v[0] = x; _v[1] = y; } + static vec2 axis[2]; + static vec2 axis6[6]; + private: + int _v[2]; +}; + +vec2 vec2::axis[2] = { vec2(1,0), vec2(0,1) }; +vec2 vec2::axis6[6] = { + vec2(1,0), vec2(0,1), + vec2(2,0), vec2(0,2), + vec2(3,0), vec2(0,3) +}; + +int main(int argc, char*argv[]) +{ + vec2 a; + + return 0; // marker +} Index: method.exp =================================================================== --- method.exp (nonexistent) +++ method.exp (revision 513) @@ -0,0 +1,185 @@ +# Copyright 1998, 1999, 2001, 2002, 2003, 2004, 2007, 2008, 2009, 2010 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# tests for misc. C++ method stuff +# Written by Satish Pai 1997-07-08 + +# This file is part of the gdb testsuite + +# This tests: +# 0. method arguments are correct +# 1. access to class data members inside method scopes +# 2. correct param types for methods in ptype. +# 3. const and volatile methods + +# (#0 and #1 above relate to an HP specific problem -- GDB must correctly +# integrate FPARAM symbols in HP debug info into the local var list +# for the function or method's block.) + +if $tracelevel then { + strace $tracelevel + } + +# +# test running programs +# + +if { [skip_cplus_tests] } { continue } + +set testfile "method" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested method.exp + return -1 +} + +if [get_compiler_info $binfile "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + + +# +# set it up at a breakpoint so we can play with the variable values +# +if ![runto_main] then { + perror "couldn't run to breakpoint" + continue +} + +gdb_test "break A::foo" \ + "Breakpoint \[0-9\]* at $hex.*file .*method.cc, line 38\\." + +gdb_test "continue" \ + "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, A::foo(\\(int\\)|) \\(this=$hex, arg=13\\) at .*method\\.cc:38\r\n38\[\t \]*x \\+= arg;" \ + "continue to A::foo" + +# Check ability to access this-relative stuff. + +gdb_test "print x" \ + "\\$\[0-9\]* = 20" \ + "print x in A::foo" + +# Check access to this pointer + +gdb_test "print this" \ + "\\$\[0-9\]* = \\((class |)A *\\* *(const|)\\) $hex" \ + "print this in A::foo" + +# Now do everything over again for A::bar, because sometimes processing one method +# (the first one) is fine, but the second one's debug info gets munged beyond recognition. + +gdb_test "break A::bar" \ + "Breakpoint \[0-9\]* at $hex.*file .*method.cc, line 44\\." + +gdb_test "continue" \ + "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, A::bar(|\\(int\\) const| const) \\(this=$hex, arg=15\\) at .*method\\.cc:44\r\n44\[\t \]*return arg \\+ 2 \\* x;" \ + "continue to A::bar" + +# Check ability to access this-relative stuff. + +gdb_test "print x" \ + "\\$\[0-9\]* = 33" \ + "print x in A::bar" + +# Check access to this pointer + +get_debug_format + +gdb_test_multiple "print this" "print this in A::bar" { + -re "\\$\[0-9\]* = \\(const (class |)A *\\* *(const|)\\) $hex\r\n$gdb_prompt $" { + pass "print this in A::bar" + } + -re "\\$\[0-9\]* = \\((class |)A *\\* *(const|)\\) $hex\r\n$gdb_prompt $" { + # gcc versions up to 3.0.4 with -gstabs+ do not emit "const" + # indicators, so the output is "A *". It should be "const A + # *" or "const A * const". + setup_xfail_format "stabs" + fail "print this in A::bar (missing const)" + } + -re "\\$\[0-9\]* = \\(const (class |)\{\\.\\.\\.\} *\\* *(const|)\\) $hex\r\n$gdb_prompt $" { + # gcc versions gcc-3_1-branch%20020404 and HEAD%20020404 with -gstabs+ + # produce good stabs, but gdb prints "const class {...} *" const. + # This is PR gdb/277. + # setup_kfail "gdb/277" + fail "print this in A::bar (gdb/277)" + } +} + +# Check again with funk::getFunky (this is the original test case +# for CHFts23426); sometimes having a constructor with no arguments +# will nuke the debug info read in for other methods in the class. + +gdb_test "break 21" \ + "Breakpoint \[0-9\]* at $hex.*file .*method.cc, line 21\\." + +gdb_test "continue" \ + "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, funk::getFunky(\\(int, int\\)|) \\(this=$hex, a=1, b=2\\) at .*method\\.cc:21\r\n21\[\t \]*data_ = res;" \ + "continue to 21" + +# Check ability to access this-relative stuff. + +gdb_test "print data_" \ + "\\$\[0-9\]* = 33" \ + "print data_ in funk::getFunky" + +# Check access to this pointer + +gdb_test "print this" \ + "\\$\[0-9\]* = \\((class |)funk *\\* *(const|)\\) $hex" \ + "print this in funk::getFunky" + +# Check access to local variable + +gdb_test "print res" \ + "\\$\[0-9\]* = -30" \ + "print res in funk::getFunky" + +# Check ptype of class -- should show const/volatile methods + +gdb_test_multiple "ptype A" "ptype A" { + -re "type = class A \{\r\n\[ \]*public:\r\n\[ \]*int x;\r\n\[ \]*int y;\r\n\r\n\[ \]*int foo\\(int\\);\r\n\[ \]*int bar\\(int\\) const;\r\n\[ \]*int baz\\(int, char\\) volatile;\r\n\[ \]*int qux\\(int, float\\) (const volatile|volatile const);\r\n\}\r\n$gdb_prompt $" { + pass "ptype A" + } + -re "type = class A \{\r\n\[ \]*public:\r\n\[ \]*int x;\r\n\[ \]*int y;\r\n\r\n\[ \]*A & operator=\\(A const ?&\\);\r\n\[ \]*A\\(A const ?&\\);\r\n\[ \]*A\\((void|)\\);\r\n\[ \]*int foo\\(int\\);\r\n\[ \]*int bar\\(int\\) const;\r\n\[ \]*int baz\\(int, char\\) volatile;\r\n\[ \]*int qux\\(int, float\\) (const volatile|volatile const);\r\n\}\r\n$gdb_prompt $" { + pass "ptype A" + } + -re "type = class A \{\r\n\[ \]*public:\r\n\[ \]*int x;\r\n\[ \]*int y;\r\n\r\n\[ \]*int foo\\(int\\);\r\n\[ \]*int bar\\(int\\) const;\r\n\[ \]*int baz\\(int, char\\) volatile;\r\n\[ \]*int qux\\(int, float\\) (const volatile|volatile const);\r\n\[ \]*A & operator=\\(A const ?&\\);\r\n\[ \]*A\\(A const ?&\\);\r\n\[ \]*A\\((void|)\\);\r\n\}\r\n$gdb_prompt $" { + pass "ptype A" + } + -re "type = class A \{\r\n\[ \]*public:\r\n\[ \]*int x;\r\n\[ \]*int y;\r\n\r\n\[ \]*int foo\\(int\\);\r\n\[ \]*int bar\\(int\\) const;\r\n\[ \]*int baz\\(int, char\\);\r\n\[ \]*int qux\\(int, float\\) const;\r\n\}\r\n$gdb_prompt $" { + pass "ptype A (HP aCC bug -- volatile not indicated)" + } + -re "type = class A \{\r\n\[ \]*public:\r\n\[ \]*int x;\r\n\[ \]*int y;\r\n\r\n\[ \]*int foo\\(int\\);\r\n\[ \]*int bar\\(int\\) const;\r\n\[ \]*int baz\\(int, char\\) volatile;\r\n\[ \]*int qux\\(int, float\\) const volatile;\r\n\}\r\n$gdb_prompt $" { + pass "ptype A" + } +} + +gdb_test_multiple "cont" "finish program" { + -re "Continuing.\r\n\r\nProgram exited normally.*$gdb_prompt $" { + pass "finish program" + } + -re "Continuing.* EXIT code 0.*Program exited normally.*$gdb_prompt $" { + pass "finish program (exit wrapper)" + } +} +

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.