public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-keiths-realcpp-test:         * testsuite/gdb.cp/realcpp.exp: New file.
@ 2008-10-17 22:54 kseitz
  0 siblings, 0 replies; only message in thread
From: kseitz @ 2008-10-17 22:54 UTC (permalink / raw)
  To: archer-commits

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 <keiths@redhat.com>
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  <keiths@redhat.com>
+
+        * testsuite/gdb.cp/realcpp.exp: New file.
+        * testsuite/gdb.cp/realcpp.cc: New file.
+
 2008-09-09  Pedro Alves  <pedro@codesourcery.com>
 
 	* 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 <stdlib.h>
+#include <iostream>
+
+// Forward decls
+class base;
+class derived;
+
+// A simple template with specializations
+template <typename T>
+class tclass
+{
+public:
+  void do_something () { } // tclass<T>::do_something
+};
+
+template <>
+void tclass<char>::do_something () { } // tclass<char>::do_something
+
+template <>
+void tclass<int>::do_something () { } // tclass<int>::do_something
+
+template<>
+void tclass<long>::do_something () { } // tclass<long>::do_something
+
+template<>
+void tclass<short>::do_something () { } // tclass<short>::do_something
+
+// A simple template with multiple template parameters
+template <class A, class B, class C, class D, class E>
+void flubber (void)
+{
+  A a;
+  B b;
+  C c;
+  D d;
+  E e;
+
+  ++a;
+  ++b;
+  ++c;
+  ++d;
+  ++e;
+}
+
+// Some contrived policies
+template <class T>
+struct operation_1
+{
+  static void function (void) { } // operation_1<T>::function
+};
+
+template <class T>
+struct operation_2
+{
+  static void function (void) { } // operation_2<T>::function
+};
+
+template <class T>
+struct operation_3
+{
+  static void function (void) { } // operation_3<T>::function
+};
+
+template <class T>
+struct operation_4
+{
+  static void function (void) { } // operation_4<T>::function
+};
+
+// A policy-based class w/ and w/o default policy
+template <class T, class Policy>
+class policy : public Policy
+{
+public:
+  policy (T obj) : obj_ (obj) { } // policy<T, Policy>::policy
+
+private:
+  T obj_;
+};
+
+template <class T, class Policy = operation_1<T> >
+class policyd : public Policy
+{
+public:
+  policyd (T obj) : obj_ (obj) { } // policyd<T, Policy>::policyd
+
+private:
+  T obj_;
+};
+
+typedef policy<int, operation_1<void*> > policy1;
+typedef policy<int, operation_2<void*> > policy2;
+typedef policy<int, operation_3<void*> > policy3;
+typedef policy<int, operation_4<void*> > policy4;
+
+typedef policyd<int> policyd1;
+typedef policyd<long> policyd2;
+typedef policyd<char> policyd3;
+typedef policyd<base> policyd4;
+typedef policyd<tclass<int> > 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<int> (0));
+  (void) a.overload (static_cast<short> (0));
+  (void) a.overload (static_cast<long> (0));
+  (void) a.overload (static_cast<char*> (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> char_tclass;
+  tclass<int> int_tclass;
+  tclass<short> short_tclass;
+  tclass<long> long_tclass;
+  tclass<base> base_tclass;
+  char_tclass.do_something ();
+  int_tclass.do_something ();
+  short_tclass.do_something ();
+  long_tclass.do_something ();
+  base_tclass.do_something ();
+
+  flubber<int, int, int, int, int> ();
+  flubber<int, int, int, int, short> ();
+  flubber<int, int, int, int, long> ();
+  flubber<int, int, int, int, char> ();
+  flubber<int, int, int, short, int> ();
+  flubber<int, int, int, short, short> ();
+  flubber<int, int, int, short, long> ();
+  flubber<int, int, int, short, char> ();
+  flubber<int, int, int, long, int> ();
+  flubber<int, int, int, long, short> ();
+  flubber<int, int, int, long, long> ();
+  flubber<int, int, int, long, char> ();
+  flubber<int, int, int, char, int> ();
+  flubber<int, int, int, char, short> ();
+  flubber<int, int, int, char, long> ();
+  flubber<int, int, int, char, char> ();
+  flubber<int, int, short, int, int> ();
+  flubber<int, int, short, int, short> ();
+  flubber<int, int, short, int, long> ();
+  flubber<int, int, short, int, char> ();
+  flubber<int, int, short, short, int> ();
+  flubber<short, int, short, int, short> ();
+  flubber<long, short, long, short, long> ();
+
+  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 <http://www.gnu.org/licenses/>.
+
+# 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 <base::operator*(base const&) const>"
+# 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<int,int,int,int,int>()"
+# 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::<TAB><TAB>" -- 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::<TAB><TAB>" (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.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-10-17 22:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-17 22:54 [SCM] archer-keiths-realcpp-test: * testsuite/gdb.cp/realcpp.exp: New file kseitz

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