diff options
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/completion.exp | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-typeprint.cc | 37 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-typeprint.exp | 53 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-typeprint.py | 35 |
5 files changed, 135 insertions, 3 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 9e04326..5293c88 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,12 @@ 2012-11-12 Tom Tromey <tromey@redhat.com> + * gdb.base/completion.exp: Update for "info type-printers". + * gdb.python/py-typeprint.cc: New file. + * gdb.python/py-typeprint.exp: New file. + * gdb.python/py-typeprint.py: New file. + +2012-11-12 Tom Tromey <tromey@redhat.com> + * gdb.base/call-sc.exp: Use "ptype/r". * gdb.base/volatile.exp: Don't expect "int". * gdb.cp/ptype-flags.cc: New file. diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp index ccdc199..8b1facb 100644 --- a/gdb/testsuite/gdb.base/completion.exp +++ b/gdb/testsuite/gdb.base/completion.exp @@ -161,7 +161,7 @@ gdb_test_multiple "" "$test" { -re "^info t foo\\\x07$" { send_gdb "\n" gdb_test_multiple "" "$test" { - -re "Ambiguous info command \"t foo\": target, tasks, terminal, threads, tp, tracepoints, tvariables, types\\..*$gdb_prompt $" { + -re "Ambiguous info command \"t foo\": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" { pass "$test" } } @@ -174,7 +174,7 @@ gdb_test_multiple "" "$test" { -re "^info t\\\x07$" { send_gdb "\n" gdb_test_multiple "" "$test" { - -re "Ambiguous info command \"t\": target, tasks, terminal, threads, tp, tracepoints, tvariables, types\\..*$gdb_prompt $" { + -re "Ambiguous info command \"t\": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" { pass "$test" } } @@ -187,7 +187,7 @@ gdb_test_multiple "" "$test" { -re "^info t \\\x07$" { send_gdb "\n" gdb_test_multiple "" "$test" { - -re "Ambiguous info command \"t \": target, tasks, terminal, threads, tp, tracepoints, tvariables, types\\..*$gdb_prompt $" { + -re "Ambiguous info command \"t \": target, tasks, terminal, threads, tp, tracepoints, tvariables, (type-printers, )?types\\..*$gdb_prompt $" { pass "$test" } } diff --git a/gdb/testsuite/gdb.python/py-typeprint.cc b/gdb/testsuite/gdb.python/py-typeprint.cc new file mode 100644 index 0000000..65c06f0 --- /dev/null +++ b/gdb/testsuite/gdb.python/py-typeprint.cc @@ -0,0 +1,37 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2008-2012 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/>. */ + +class basic_string +{ +}; + +template<typename T> +class templ +{ +public: + T x; + templ<T> *value; +}; + +templ<basic_string> s; + +basic_string bs; + +int main() +{ + return 0; +} diff --git a/gdb/testsuite/gdb.python/py-typeprint.exp b/gdb/testsuite/gdb.python/py-typeprint.exp new file mode 100644 index 0000000..ef07055 --- /dev/null +++ b/gdb/testsuite/gdb.python/py-typeprint.exp @@ -0,0 +1,53 @@ +# Copyright (C) 2012 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/>. + +if { [skip_cplus_tests] } { continue } + +load_lib gdb-python.exp +load_lib cp-support.exp + +standard_testfile .cc + +if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} { + return -1 +} + +if { [skip_python_tests] } { continue } + +set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py] + +gdb_test_no_output "python execfile ('${remote_python_file}')" + +cp_test_ptype_class s "basic test" "class" "templ<string>" { + { field public "T x;" } + { field public "templ<T> *value;" } +} "" {} "" + +cp_test_ptype_class s "raw test" "class" "templ<basic_string>" { + { field public "basic_string x;" } + { field public "templ<basic_string> *value;" } +} "" {} "/r" + +gdb_test_no_output "disable type-printer string" +gdb_test "whatis bs" "basic_string" "whatis with disabled printer" + +gdb_test "info type-printers" "Global type printers:.*string.*disabled.*" + +gdb_test_no_output "enable type-printer string" +gdb_test "whatis bs" "string" "whatis with enabled printer" + +gdb_test "whatis s" "templ<string>" + +remote_file host delete ${remote_python_file} diff --git a/gdb/testsuite/gdb.python/py-typeprint.py b/gdb/testsuite/gdb.python/py-typeprint.py new file mode 100644 index 0000000..a4351cd --- /dev/null +++ b/gdb/testsuite/gdb.python/py-typeprint.py @@ -0,0 +1,35 @@ +# Copyright (C) 2012 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/>. + +import gdb + +class Recognizer(object): + def __init__(self): + self.enabled = True + + def recognize(self, type_obj): + if type_obj.tag == 'basic_string': + return 'string' + return None + +class StringTypePrinter(object): + def __init__(self): + self.name = 'string' + self.enabled = True + + def instantiate(self): + return Recognizer() + +gdb.type_printers.append(StringTypePrinter()) |