This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
Re: Fix for gdb.template_argument() brokenness WRT const, volatile.
- From: Paul Pluzhnikov <ppluzhnikov at google dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: archer at sourceware dot org
- Date: Thu, 6 Nov 2008 17:37:29 -0800
- Subject: Re: Fix for gdb.template_argument() brokenness WRT const, volatile.
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta;t=1226021851; bh=WXY/3juv4q0YrHkevh+xSxnetwY=;h=DomainKey-Signature:MIME-Version:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type: Content-Transfer-Encoding; b=ZOh+pR15/JItxFVS0xI94B4tRDkKHbiQf4TLYLlaElPXdiw5PKnZ2ku1ydkRes7QdiGg+Lx2vy/qSsnjteg4QQ==
- Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns;h=mime-version:in-reply-to:references:date:message-id:subject:from:to:cc:content-type:content-transfer-encoding;b=bM5oHPW+MWQjcqHV8xDHbBr79tMWnfZzC0E/AZ6B1BTUdkIck/o9hIsVbIUrb8xdoeEgy3G/Gbb4S3HGWyW7uA==
- References: <20081106235909.146BF3A6B0D@localhost> <8ac60eac0811061607g2fef4c78q545597ecf258a76d@mail.gmail.com> <m34p2kcrqs.fsf@fleche.redhat.com> <8ac60eac0811061629q70fd77b8y1d005348a117e7c5@mail.gmail.com>
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 *"