This is the mail archive of the archer@sourceware.org mailing list for the Archer project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix for gdb.template_argument() brokenness WRT const, volatile.


On Thu, Nov 6, 2008 at 4:29 PM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:

> Working on a test case now ...

Test attached.
OK to commit?

Thanks,
-- 
Paul Pluzhnikov

2008-11-06  Paul Pluzhnikov  <ppluzhnikov@google.com>

	* gdb.python/python-template.exp,
	gdb.python/python-template.cc: New test for const, volatile
	qualified pointer and reference template args.
	
diff --git a/gdb/testsuite/gdb.python/python-template.cc
b/gdb/testsuite/gdb.python/python-template.cc
new file mode 100644
index 0000000..bd6a212
--- /dev/null
+++ b/gdb/testsuite/gdb.python/python-template.cc
@@ -0,0 +1,30 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   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/>.  */
+
+template <typename T>
+struct Foo {
+};
+
+#ifndef TYPE
+#define TYPE int
+#endif
+
+int main()
+{
+  Foo<TYPE> foo;
+  return 0; // break here
+}
diff --git a/gdb/testsuite/gdb.python/python-template.exp
b/gdb/testsuite/gdb.python/python-template.exp
new file mode 100644
index 0000000..919a5d0
--- /dev/null
+++ b/gdb/testsuite/gdb.python/python-template.exp
@@ -0,0 +1,73 @@
+# Copyright (C) 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.  It tests the mechanism
+# exposing values to Python.
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set testfile "python-template"
+set srcfile ${testfile}.cc
+set binfile ${objdir}/${subdir}/${testfile}
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}"
executable {debug c++}] != "" } {
+    untested "Couldn't compile ${srcfile}"
+    return -1
+}
+
+# Start with a fresh gdb.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+gdb_test_multiple "python print 23" "verify python support" {
+    -re "not supported.*$gdb_prompt $"	{
+      unsupported "python support is disabled"
+      return -1
+    }
+    -re "$gdb_prompt $"	{}
+}
+
+proc test_template_arg {type} {
+    global testfile srcdir subdir srcfile binfile
+    if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}"
executable \
+	  [list debug c++ additional_flags="-DTYPE=$type"]] != "" } {
+	untested $type
+	return -1
+    }
+    gdb_load ${binfile}
+    if ![runto_main ] then {
+	perror "couldn't run to breakpoint"
+	return
+    }
+    # There is no executable code in main(), so we are where we want to be
+    gdb_test "print foo" ""
+    gdb_test "python foo = gdb.get_value_from_history(0)" ""
+
+    # Replace '*' with '\*' in regex.
+    regsub -all {\*} $type {\*} t
+    gdb_test "python print foo.type().template_argument(0)" $t
+}
+
+test_template_arg "const int"
+test_template_arg "volatile int"
+test_template_arg "const int &"
+test_template_arg "volatile int &"
+test_template_arg "volatile int * const"
+test_template_arg "volatile int * const *"
+test_template_arg "const int * volatile"
+test_template_arg "const int * volatile * const * volatile *"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]