From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25822 invoked by alias); 17 Oct 2008 22:54:32 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 25779 invoked by uid 9079); 17 Oct 2008 22:54:32 -0000 Date: Fri, 17 Oct 2008 22:54:00 -0000 Message-ID: <20081017225432.25764.qmail@sourceware.org> From: kseitz@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-keiths-realcpp-test: * testsuite/gdb.cp/realcpp.exp: New file. X-Git-Refname: refs/heads/archer-keiths-realcpp-test X-Git-Reftype: branch X-Git-Oldrev: 4eaa6f1cc84b9df0beda560f90a901ed36d70acf X-Git-Newrev: cdd182b43afd450b239be881b2d9c29a151eac8e X-SW-Source: 2008-q4/txt/msg00018.txt.bz2 List-Id: The branch, archer-keiths-realcpp-test has been updated via cdd182b43afd450b239be881b2d9c29a151eac8e (commit) from 4eaa6f1cc84b9df0beda560f90a901ed36d70acf (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit cdd182b43afd450b239be881b2d9c29a151eac8e Author: keiths Date: Fri Oct 17 15:54:17 2008 -0700 * testsuite/gdb.cp/realcpp.exp: New file. * testsuite/gdb.cp/realcpp.cc: New file. ----------------------------------------------------------------------- Summary of changes: gdb/ChangeLog | 5 + gdb/testsuite/gdb.cp/realcpp.cc | 382 +++++++++++++++++ gdb/testsuite/gdb.cp/realcpp.exp | 872 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 1259 insertions(+), 0 deletions(-) create mode 100644 gdb/testsuite/gdb.cp/realcpp.cc create mode 100644 gdb/testsuite/gdb.cp/realcpp.exp First 500 lines of diff: diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 848e00e..2ac27c4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2008-10-17 Keith Seitz + + * testsuite/gdb.cp/realcpp.exp: New file. + * testsuite/gdb.cp/realcpp.cc: New file. + 2008-09-09 Pedro Alves * infrun.c (normal_stop): Run hook-stop last. diff --git a/gdb/testsuite/gdb.cp/realcpp.cc b/gdb/testsuite/gdb.cp/realcpp.cc new file mode 100644 index 0000000..3562670 --- /dev/null +++ b/gdb/testsuite/gdb.cp/realcpp.cc @@ -0,0 +1,382 @@ +#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) +{ + 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 + +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 base +{ +protected: + int foo_; + +public: + base (void) : foo_ (1) { } // base::base + ~base (void) { } // base::~base + + // Some overloaded methods + int overload (void) const { return 0; } // base::overload(void) + int overload (int i) const { return 1; } // base::overload(int) + int overload (short s) const { return 2; } // base::overload(short) + int overload (long l) const { return 3; } // base::overload(long) + int overload (char* a) const { return 4; } // base::overload(char*) + int overload (base& b) const { return 5; } // base::overload(base&) + + // Operators + base operator+ (base const& o) const // base::operator+ + { base b; b.foo_ = foo_ + o.foo_; return b; } + + base operator++ (void) // base::operator++ + { ++foo_; return *this; } + + base operator+=(base const& o) // base::operator+= + { foo_ += o.foo_; return *this; } + + base operator- (base const& o) const // base::operator- + { base b; b.foo_ = foo_ - o.foo_; return b; } + + base operator-- (void) // base::operator-- + { --foo_; return *this; } + + base operator-= (base const& o) // base::operator-= + { foo_ -= o.foo_; return *this; } + + base operator* (base const& o) const // base::operator* + { base b; b.foo_ = foo_ * o.foo_; return *this;} + + base operator*= (base const& o) // base::operator*= + { foo_ *= o.foo_; return *this; } + + base operator/ (base const& o) const // base::operator/ + { base b; b.foo_ = foo_ / o.foo_; return b; } + + base operator/= (base const& o) // base::operator/= + { foo_ /= o.foo_; return *this; } + + base operator% (base const& o) const // base::operator% + { base b; b.foo_ = foo_ % o.foo_; return b; } + + 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_; } + + base operator<< (int value) const // base::operator<< + { base b; b.foo_ = foo_ << value; return b; } + + base operator<<= (int value) // base::operator<<= + { foo_ <<= value; return *this; } + + base operator>> (int value) const // base::operator>> + { base b; b.foo_ = foo_ >> value; return b; } + + base operator>>= (int value) // base::operator>>= + { foo_ >>= value; return *this; } + + base operator~ (void) const // base::operator~ + { base b; b.foo_ = ~foo_; return b; } + + base operator& (base const& o) const // base::operator& + { base b; b.foo_ = foo_ & o.foo_; return b; } + + base operator&= (base const& o) // base::operator&= + { foo_ &= o.foo_; return *this; } + + base operator| (base const& o) const // base::operator| + { base b; b.foo_ = foo_ | o.foo_; return b; } + + base operator|= (base const& o) // base::operator|= + { foo_ |= o.foo_; return *this; } + + base operator^ (base const& o) const // base::operator^ + { base b; b.foo_ = foo_ ^ o.foo_; return b; } + + 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 (unsigned int size) throw () // base::operator new + { return NULL; } + + void operator delete (void* ptr) // base::operator delete + { return; } + + void* operator new[] (unsigned int size) throw () // base::operator new[] + { return NULL; } + + void operator delete[] (void* ptr) // base::operator delete[] + { return; } +}; + +class base1 : public virtual base +{ +public: + base1 (void) : foo_ (2) { } // base1::base1 + 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 +{ + derived d; + void (derived::*pfunc) (void) const = &derived::a_function; + (d.*pfunc) (); + + base a, b, c; + (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); + + a = b + c; + ++a; + a += b; + a = b - c; + --a; + a -= b; + a = b * c; + a *= b; + a = b / c; + a /= b; + a = 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); + a = b << 2; + a <<= 1; + a = b >> 2; + a >>= 1; + a = ~b; + a = b & c; + a &= c; + a = b | c; + a |= c; + a = b ^ c; + a ^= c; + a = c; + a (); + int i = a[3]; + derived* f = new derived (); + derived* g = new derived[3]; + delete f; + delete[] g; + + 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 (); +} + diff --git a/gdb/testsuite/gdb.cp/realcpp.exp b/gdb/testsuite/gdb.cp/realcpp.exp new file mode 100644 index 0000000..dc56690 --- /dev/null +++ b/gdb/testsuite/gdb.cp/realcpp.exp @@ -0,0 +1,872 @@ +# 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 . + +# This file is part of the gdb testsuite. + +### +# +# SOME IMPORTANT NOTES +# +### + +# The "info func" tests here aren't comlete. I've commented them +# out for now. + +# Gdb is *very* inconsistent with spaces in typenames. +# For example, while "print" may print "void *", +# "info func" will use "void*". + +# Gdb is also very inconsistent with the const keyword. Sometimes it +# puts "const" before the '*'/'&' (with or without a space), sometimes after. +# For example, "print 'base::operator*'" will return +# "{base (const base * const, const base &)} 0x8049444 " +# Note that the parameter to the method is "const base &" in the type, +# declaration, but "base const&" in the parameter list. + +# The types "long" and "short" are sometimes converted to "long int" or +# "short int". For example, look at the output of "info func long": +# it defies logic. + +# Tyepdefs of template names do not work at all. If you attempt to +# do just about anything with a template's tyepdef'd name, gdb will fail. +# For example, "break policyd1::policyd" will cause an error. + +# Template functions do not seem to work very well, either. It is +# currently impossible to do anything with this test cases function +# "flubber". "info func flubber" is the only thing that seems to work. +# Note: this is apparently because gcc doesn't output sufficient debug info, +# so gdb groks the minsym name, so one has to use "void flubber()" +# to do anything. How extraordinarily user-friendly. + +# Still cannot do much with destructors. "print base::~base" will error. +# [But "print 'base::~bsae' will work, but "break" does not work at all.] + +# This brings up the quoting issue. Some C++ methods can have spaces in them. +# Most notably, operators and multiple-argument templates. Sometimes +# these need to be surrounded by single quotes. Other times they don't. +# Sometimes method names with no spaces requires single quotes. +# All of this really needs documenting. In this test case, quoting has +# been intentionally ommitted: IMO gdb should be able to manage. + +# Completion for namespaces and C++ classes is broken. The user +# may be tempted to type "break base::" -- indeed, gdb +# even instructs him to do so occasionally -- but the parsing stops +# at the namespace operator. So gdb returns a list of every global +# symbol instead of those just in "base". There is currently no +# test for this. [See notes of unimplemented tests at the end of +# this file.]. +# +# Ugh. This is related to the scope operator parsing problems. +# Workaround is to use "break 'base::" (note the single +# single quote). Lame. + +# Overloaded methods are just horrible to work with. From this +# test case, "print base::overload" should work (or at least +# "print base::overload()" or "print base::overload(void)"). Alas, +# gdb requires you to put "const" on the end, even though there are +# no other plausible alternatives! We need to find out exactly how +# upstream expects gdb to behave. +# +# IMO, "print base::overload" is unambiguous. It should output +# information about "base::overload(void)". We should NOT need +# "const" -- since that method is not overloaded on the keyword const +# at all. The tests below reflect this philosophy. + +# "info func flubber" returns "void void flubber...". + + + + +# A helper proc which sets a breakpoint at FUNC and attempts to +# run to the breakpoint. hooks/post-receive -- Repository for Project Archer.