diff options
author | Phil Muldoon <pmuldoon@redhat.com> | 2011-03-17 09:36:17 +0000 |
---|---|---|
committer | Phil Muldoon <pmuldoon@redhat.com> | 2011-03-17 09:36:17 +0000 |
commit | 29703da4b1a5b80034c3f33b0c8f34ce6e1f08d5 (patch) | |
tree | c0999d1a168f21196c3c8ba5b1401f05b00236d3 /gdb/testsuite | |
parent | a6363bfc3832f13436cb744783aa96eaec972006 (diff) | |
download | gdb-29703da4b1a5b80034c3f33b0c8f34ce6e1f08d5.zip gdb-29703da4b1a5b80034c3f33b0c8f34ce6e1f08d5.tar.gz gdb-29703da4b1a5b80034c3f33b0c8f34ce6e1f08d5.tar.bz2 |
2011-03-17 Phil Muldoon <pmuldoon@redhat.com>
* python/py-symtab.c: Populate symtab_object_methods,
sal_object_methods.
(stpy_is_valid): New function.
(salpy_is_valid): Ditto.
* python/py-symbol.c: Declare symbol_object_methods.
Populate.
(sympy_is_valid): New function.
* python/py-objfile.c: Declare objfile_object_methods.
Populate.
(objfpy_is_valid): New function.
* python/py-inferior.c: Populate inferior_object_methods.
(infpy_is_valid): New function.
* python/py-infthread.c: Populate thread_object_methods.
(thpy_is_valid): New function.
* python/py-block.c: Declare block_object_methods.
Populate. Declare
block_iterator_object_methods. Populate.
(blpy_is_valid): New function.
(blpy_iter_is_valid): Ditto.
2010-03-17 Phil Muldoon <pmuldoon@redhat.com>
* gdb.python/Makefile.in: Add py-objfile.
* gdb.python/py-objfile.exp: New file.
* gdb.python/py-objfile.c: New file.
* gdb.python/py-block.exp: Add is_valid tests.
* gdb.python/py-inferior.exp: Ditto.
* gdb.python/py-infthread.exp: Ditto.
* gdb.python/py-symbol.exp: Ditto.
* gdb.python/py-symtab.exp: Ditto.
2011-03-17 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Blocks In Python): Add is_valid method
description.
(Inferiors In Python): Likewise.
(Threads In Python): Likewise.
(Symbols In Python): Likewise.
(Objfiles In Python): Likewise.
(Symbol Tables In Python): Likewise.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 11 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/Makefile.in | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-block.exp | 17 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-inferior.exp | 20 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-infthread.exp | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-objfile.c | 23 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-objfile.exp | 51 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-symbol.exp | 16 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-symtab.exp | 8 |
9 files changed, 154 insertions, 1 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 5d72c34..ded9d94 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2010-03-17 Phil Muldoon <pmuldoon@redhat.com> + + * gdb.python/Makefile.in: Add py-objfile. + * gdb.python/py-objfile.exp: New file. + * gdb.python/py-objfile.c: New file. + * gdb.python/py-block.exp: Add is_valid tests. + * gdb.python/py-inferior.exp: Ditto. + * gdb.python/py-infthread.exp: Ditto. + * gdb.python/py-symbol.exp: Ditto. + * gdb.python/py-symtab.exp: Ditto. + 2011-03-16 Keith Seitz <keiths@redhat.com> PR c++/12273 diff --git a/gdb/testsuite/gdb.python/Makefile.in b/gdb/testsuite/gdb.python/Makefile.in index 2b26fc8..5b2b7b0 100644 --- a/gdb/testsuite/gdb.python/Makefile.in +++ b/gdb/testsuite/gdb.python/Makefile.in @@ -4,7 +4,7 @@ srcdir = @srcdir@ EXECUTABLES = py-type py-value py-prettyprint py-template py-block \ py-symbol py-mi py-breakpoint py-inferior py-infthread \ py-shared python lib-types py-events py-evthreads py-frame \ - py-pp-maint py-progspace py-section-script + py-pp-maint py-progspace py-section-script py-objfile MISCELLANEOUS = py-shared-sl.sl diff --git a/gdb/testsuite/gdb.python/py-block.exp b/gdb/testsuite/gdb.python/py-block.exp index c400df7..98b89d9 100644 --- a/gdb/testsuite/gdb.python/py-block.exp +++ b/gdb/testsuite/gdb.python/py-block.exp @@ -62,3 +62,20 @@ gdb_py_test_silent_cmd "python block = frame.block()" "Get Frame 2's block" 0 gdb_test "python print block" "<gdb.Block object at $hex>" \ "Check Frame 2's block not None" gdb_test "python print block.function" "main" "main block" + + +# Test Block is_valid. This must always be the last test in this +# testcase as it unloads the object file. +delete_breakpoints +gdb_py_test_silent_cmd "python frame = gdb.selected_frame()" "Get Frame" 0 +gdb_py_test_silent_cmd "python block = frame.block()" "Get Frame block" 0 +gdb_py_test_silent_cmd "python block_iter = iter (block)" "Get Frame block" 0 +gdb_test "python print block.is_valid()" "True" \ + "Check block validity" +gdb_test "python print block_iter.is_valid()" "True" \ + "Check block validity" +gdb_unload +gdb_test "python print block.is_valid()" "False" \ + "Check block validity" +gdb_test "python print block_iter.is_valid()" "False" \ + "Check block validity" diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp index 138c0fb..42ca920 100644 --- a/gdb/testsuite/gdb.python/py-inferior.exp +++ b/gdb/testsuite/gdb.python/py-inferior.exp @@ -191,3 +191,23 @@ if [isnative] { gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, end_addr - start_addr, pattern)" \ "${one_pattern_found}" "find pattern straddling chunk boundary" } + +# Test Inferior is_valid. This must always be the last test in +# this testcase as it kills the inferior. + +gdb_py_test_silent_cmd "python inf_list = gdb.inferiors()" "get initial list" 1 +gdb_test "python print len(inf_list)" "1" "Get inferior list length" +gdb_test "python print inf_list\[0\].is_valid()" "True" \ + "Check inferior validity" +gdb_test "add-inferior" "Added inferior 2.*" "add empty inferior 2" +gdb_py_test_silent_cmd "python inf_list = gdb.inferiors()" "get new list" 1 +gdb_test "python print len(inf_list)" "2" "Get inferior list length" +gdb_test "python print inf_list\[0\].is_valid()" "True" \ + "Check inferior validity" +gdb_test "python print inf_list\[1\].is_valid()" "True" \ + "Check inferior validity" +gdb_test_no_output "remove-inferiors 2" "remove-inferiors 2" +gdb_test "python print inf_list\[0\].is_valid()" "False" \ + "Check inferior validity" +gdb_test "python print inf_list\[1\].is_valid()" "True" \ + "Check inferior validity" diff --git a/gdb/testsuite/gdb.python/py-infthread.exp b/gdb/testsuite/gdb.python/py-infthread.exp index bbec4ec..05539ae 100644 --- a/gdb/testsuite/gdb.python/py-infthread.exp +++ b/gdb/testsuite/gdb.python/py-infthread.exp @@ -64,3 +64,10 @@ gdb_test "python print gdb.selected_thread().name == name" "True" \ gdb_test "python print 'result =', t0.is_stopped ()" " = True" "test InferiorThread.is_stopped" gdb_test "python print 'result =', t0.is_running ()" " = False" "test InferiorThread.is_running" gdb_test "python print 'result =', t0.is_exited ()" " = False" "test InferiorThread.is_exited" + +# Test InferiorThread is_valid. This must always be the last test in +# this testcase as it kills the inferior. + +gdb_test "python print 'result =', t0.is_valid ()" " = True" "test InferiorThread.is_valid" +gdb_test_no_output "kill inferior 1" "kill inferior 1" +gdb_test "python print 'result =', t0.is_valid ()" " = False" "test InferiorThread.is_valid" diff --git a/gdb/testsuite/gdb.python/py-objfile.c b/gdb/testsuite/gdb.python/py-objfile.c new file mode 100644 index 0000000..8add52c --- /dev/null +++ b/gdb/testsuite/gdb.python/py-objfile.c @@ -0,0 +1,23 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2011 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/>. */ + +int +main () +{ + int some_var = 0; + return 0; +} diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp new file mode 100644 index 0000000..f86efb5 --- /dev/null +++ b/gdb/testsuite/gdb.python/py-objfile.exp @@ -0,0 +1,51 @@ +# Copyright (C) 2011 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 program space +# support in Python. + +if $tracelevel then { + strace $tracelevel +} + +load_lib gdb-python.exp + +set testfile "py-objfile" +set srcfile ${testfile}.c + +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } { + return -1 +} + +# Skip all tests if Python scripting is not enabled. +if { [skip_python_tests] } { continue } + +if ![runto_main] then { + fail "Can't run to main" + return 0 +} + +gdb_py_test_silent_cmd "python sym = gdb.lookup_symbol(\"some_var\")" \ + "Find a symbol in objfile" 1 +gdb_py_test_silent_cmd "python objfile = sym\[0\].symtab.objfile" \ + "Get backing object file" 1 + +gdb_test "python print objfile.filename" ".*py-objfile.*" \ + "Get objfile validity" +gdb_test "python print objfile.is_valid()" "True" \ + "Get objfile validity" +gdb_unload +gdb_test "python print objfile.is_valid()" "False" \ + "Get objfile validity after unload" diff --git a/gdb/testsuite/gdb.python/py-symbol.exp b/gdb/testsuite/gdb.python/py-symbol.exp index b30c639..bb22485 100644 --- a/gdb/testsuite/gdb.python/py-symbol.exp +++ b/gdb/testsuite/gdb.python/py-symbol.exp @@ -128,3 +128,19 @@ gdb_test "python print cplusfunc.name" "SimpleClass::valueofi().*" "Test func.na gdb_test "python print cplusfunc.print_name" "SimpleClass::valueofi().*" "Test func.print_name" gdb_test "python print cplusfunc.linkage_name" "SimpleClass::valueofi().*" "Test func.linkage_name" gdb_test "python print cplusfunc.addr_class == gdb.SYMBOL_LOC_BLOCK" "True" "Test func.addr_class" + +# Test is_valid when the objfile is unloaded. This must be the last +# test as it unloads the object file in GDB. +# Start with a fresh gdb. +clean_restart ${testfile} +if ![runto_main] then { + fail "Cannot run to main." + return 0 +} +gdb_breakpoint [gdb_get_line_number "Break at end."] +gdb_continue_to_breakpoint "Break at end." +gdb_py_test_silent_cmd "python a = gdb.lookup_symbol(\'a\')" "Get variable a" 0 +gdb_test "python print a\[0\].is_valid()" "True" "Test symbol validity" +delete_breakpoints +gdb_unload +gdb_test "python print a\[0\].is_valid()" "False" "Test symbol validity" diff --git a/gdb/testsuite/gdb.python/py-symtab.exp b/gdb/testsuite/gdb.python/py-symtab.exp index d22811d..c52f5ef 100644 --- a/gdb/testsuite/gdb.python/py-symtab.exp +++ b/gdb/testsuite/gdb.python/py-symtab.exp @@ -57,8 +57,16 @@ gdb_py_test_silent_cmd "python symtab = sal.symtab" "Get block" 0 gdb_test "python print sal.symtab" "gdb/testsuite/gdb.python/py-symbol.c.*" "Test symtab" gdb_test "python print sal.pc" "${decimal}" "Test sal.pc" gdb_test "python print sal.line" "42" "Test sal.line" +gdb_test "python print sal.is_valid()" "True" "Test sal.is_valid" # Test symbol table. gdb_test "python print symtab.filename" "testsuite/gdb.python/py-symbol.c.*" "Test symtab.filename" gdb_test "python print symtab.objfile" "<gdb.Objfile object at ${hex}>" "Test symtab.objfile" gdb_test "python print symtab.fullname()" "testsuite/gdb.python/py-symbol.c.*" "Test symtab.fullname" +gdb_test "python print symtab.is_valid()" "True" "Test symtab.is_valid()" + +# Test is_valid when the objfile is unloaded. This must be the last +# test as it unloads the object file in GDB. +gdb_unload +gdb_test "python print sal.is_valid()" "False" "Test sal.is_valid" +gdb_test "python print symtab.is_valid()" "False" "Test symtab.is_valid()" |