diff --git a/gdb/python/py-minsymbol.c b/gdb/python/py-minsymbol.c index fc600cca67d..a5515caf0d9 100644 --- a/gdb/python/py-minsymbol.c +++ b/gdb/python/py-minsymbol.c @@ -88,7 +88,6 @@ static const struct objfile_data *msympy_objfile_data_key; static PyObject * msympy_str (PyObject *self) { - PyObject *result; struct minimal_symbol *minsym = NULL; MSYMPY_REQUIRE_VALID (self, minsym); @@ -334,7 +333,6 @@ gdb_PyUnicode_AsUTF8(PyObject *obj) PyObject * gdbpy_lookup_minimal_symbol (PyObject *self, PyObject *args, PyObject *kw) { - int domain = VAR_DOMAIN; const char *name, *sfile = NULL; struct objfile *objfile = NULL; static const char *keywords[] = { "name", "sfile", "objfile", NULL }; @@ -402,7 +400,7 @@ del_objfile_msymbols (struct objfile *objfile, void *datum) obj->next = NULL; obj->prev = NULL; - obj = obj->next; + obj = next; } } diff --git a/gdb/testsuite/gdb.python/Makefile.in b/gdb/testsuite/gdb.python/Makefile.in deleted file mode 100644 index b9d76d7769c..00000000000 --- a/gdb/testsuite/gdb.python/Makefile.in +++ /dev/null @@ -1,22 +0,0 @@ -VPATH = @srcdir@ -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-mi py-pp-maint py-progspace py-section-script py-objfile \ - py-finish-breakpoint py-finish-breakpoint2 py-value-cc py-explore \ - py-explore-cc py-arch py-minsymbol - -MISCELLANEOUS = py-shared-sl.sl py-events-shlib.so py-events-shlib-nodebug.so - -all info install-info dvi install uninstall installcheck check: - @echo "Nothing to be done for $@..." - -clean mostlyclean: - -rm -f *~ *.o *.ci - -rm -f *.dwo *.dwp - -rm -f core $(EXECUTABLES) $(MISCELLANEOUS) - -distclean maintainer-clean realclean: clean - -rm -f Makefile config.status config.log gdb.log gdb.sum diff --git a/gdb/testsuite/gdb.python/py-minsymbol.c b/gdb/testsuite/gdb.python/py-minsymbol.c new file mode 100644 index 00000000000..e33ee2041fb --- /dev/null +++ b/gdb/testsuite/gdb.python/py-minsymbol.c @@ -0,0 +1,38 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2018 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 . */ + +/* So we have a data section */ +const char foo[] = "somestring"; + +asm("\ +.section .text\n\ +.global text_msym\n\ +text_msym:\n\ + .byte 0\n\ +.section .data\n\ +.globl data_msym\n\ +data_msym:\n\ + .asciz \"minsym text\"\n\ +data_msym2:\n\ + .asciz \"minsym2 text\"\n\ +"); + +int +main (void) +{ + return 0; +} diff --git a/gdb/testsuite/gdb.python/py-minsymbol.exp b/gdb/testsuite/gdb.python/py-minsymbol.exp index 877e17fc130..c2ee9d208ce 100644 --- a/gdb/testsuite/gdb.python/py-minsymbol.exp +++ b/gdb/testsuite/gdb.python/py-minsymbol.exp @@ -28,31 +28,34 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} { if { [skip_python_tests] } { continue } # Test looking up missing value -gdb_test "python print gdb.lookup_minimal_symbol('xyz')" "None" "lookup missing symbol" +gdb_test "python print (gdb.lookup_minimal_symbol('xyz'))" "None" "lookup missing symbol" # Test looking up a minimal symbol of text type gdb_test "print text_msym" " = \{\} 0x\[0-9a-f\]* " "locate text_msym with print" gdb_py_test_silent_cmd "python x = gdb.lookup_minimal_symbol('text_msym')" "Lookup text_msym" 1 -gdb_test "python print x" "text_msym" "lookup text min sym" -gdb_test "python print x.name" "text_msym" "get text minsym name" -gdb_test "python print x.linkage_name" "text_msym" "get text minsym linkage_name" +gdb_test "python print (x)" "text_msym" "lookup text min sym" +gdb_test "python print (x.name)" "text_msym" "get text minsym name" +gdb_test "python print (x.linkage_name)" "text_msym" "get text minsym linkage_name" # Using asm() ends up inventing a compiler-dependent filename -gdb_test "python print x.filename" ".*" "get text minsym filename" -gdb_test "python print x.print_name" "text_msym" "get text minsym print_name" -gdb_test "python print x.section" ".text" "get text minsym section" -gdb_test "python print x.value()" "0x\[0-9a-f\]*.*" "get text minsym value" -gdb_test "python print x.value().type" "void \\(\\*\\)\\(\\)" "get text minsym value type" +gdb_test "python print (x.filename)" ".*" "get text minsym filename" +gdb_test "python print (x.print_name)" "text_msym" "get text minsym print_name" +gdb_test "python print (x.section)" ".text" "get text minsym section" +gdb_test "python print (x.value())" "0x\[0-9a-f\]*.*" "get text minsym value" +gdb_test "python print (x.value().type)" "void \\(\\*\\)\\(\\)" "get text minsym value type" # Test looking up a minimal symbol of data type -gdb_test "print data_msym" " = \[0-9\]*" "locate data_msym with print" +gdb_test "print (void *)data_msym" "0x\[0-9a-f\]*.*" "locate data_msym with print" gdb_py_test_silent_cmd "python x = gdb.lookup_minimal_symbol('data_msym')" "Lookup data_msym" 1 -gdb_test "python print x.name" "data_msym" "get data minsym name" -gdb_test "python print x.linkage_name" "data_msym" "get data minsym linkage_name" +gdb_test "python print (x.name)" "data_msym" "get data minsym name" +gdb_test "python print (x.linkage_name)" "data_msym" "get data minsym linkage_name" # Using asm() ends up inventing a compiler-dependent filename -gdb_test "python print x.filename" ".*" "get data minsym filename" -gdb_test "python print x.print_name" "data_msym" "get data minsym print_name" -gdb_test "python print x.section" ".data" "get data minsym section" -gdb_test "python print x.value()" "0x\[0-9a-f\]*.*" "get data minsym value" +gdb_test "python print (x.filename)" ".*" "get data minsym filename" +gdb_test "python print (x.print_name)" "data_msym" "get data minsym print_name" +gdb_test "python print (x.section)" ".data" "get data minsym section" +gdb_test "python print (x.value())" "0x\[0-9a-f\]*.*" "get data minsym value" + +gdb_test "python print(gdb.lookup_minimal_symbol('data_msym2', 'foobar.c'))" "None" "Lookup data_msym2 in foobar.c src" +gdb_test "python print(gdb.lookup_minimal_symbol('data_msym2', 'py-minsymbol.c'))" "data_msym2" "Lookup data_msym2 in py-minsymbol.c src" gdb_unload gdb_test "python print (x.is_valid())" "False" "Test symbol non-validity" diff --git a/gdb/testsuite/gdb.python/py-register.exp b/gdb/testsuite/gdb.python/py-register.exp index b18de66ee5c..b52a3390714 100644 --- a/gdb/testsuite/gdb.python/py-register.exp +++ b/gdb/testsuite/gdb.python/py-register.exp @@ -39,7 +39,7 @@ gdb_py_test_silent_cmd "python regs = gdb.selected_thread().registers" "Keep a # Hopefully an architecture-independent way of finding a GPR to test; Reg #0 gdb_py_test_silent_cmd "python gpr0 = sorted(regs.values(), key=lambda x: x.regnum)\[0\]" "saving the name of GPR#0" 1 -gdb_test "python print gpr0" "