+2019-08-13 Sandra Loosemore <sandra@codesourcery.com>
+
+ * gdb.python/py-completion.exp: Download the .py file to the host
+ and use its host pathname. Conditionalize tests that use
+ tab completion and manipulate files on the build machine.
+ * gdb.python/py-events.exp: Download the .py file to the host
+ and use its host pathname.
+ * gdb.python/py-evsignal.exp: Likewise.
+ * gdb.python/py-evthreads.exp: Likewise.
+ * gdb.python/py-framefilter-invalidarg.exp: Match Windows
+ pathname syntax.
+ * gdb.python/py-framefilter.exp: Download the .py file to the right
+ place on the host. Match Windows pathname syntax.
+ * gdb.python/py-mi-var-info-path-expression.exp: Download the
+ .py file to the host and use its host pathname.
+ * gdb.python/py-objfile-script.exp: Match Windows pathname syntax.
+ * gdb.python/py-objfile.exp: Expect a host pathname, not a
+ build pathname. Skip symlink test on Windows host. Add missing
+ newline at end of file.
+ * gdb.python/py-pp-maint.exp: Download the .py file to the host
+ and use its host pathname.
+ * gdb.python/py-pp-registration.exp: Match Windows pathname syntax.
+ * gdb.python/py-section-script.exp: Use host location of binfile
+ on safe-path. Use correct path separator on Windows host.
+ Reorder alternatives in gdb_test_multiple to prevent matching
+ the wrong alternative on success.
+ * gdb.python/py-symtab.exp: Match Windows pathname syntax.
+
2019-08-12 Patrick Palka <patrick@parcs.ath.cx>
* gdb.gdb/selftest.exp (test_with_self): Update test to now
load_lib gdb-python.exp
+set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
+set discard 0
gdb_exit
gdb_start
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
-gdb_test_no_output "source ${srcdir}/${subdir}/${testfile}.py" \
- "load python file"
-
-# Create a temporary directory
-set testdir "[standard_output_file "py-completion-testdir"]/"
-set testdir_regex [string_to_regexp $testdir]
-set testdir_complete [standard_output_file "py-completion-test"]
-file mkdir $testdir
-
-# This one should always pass.
-send_gdb "completefileinit ${testdir_complete}\t"
-gdb_test_multiple "" "completefileinit completion" {
- -re "^completefileinit ${testdir_regex}$" {
- pass "completefileinit completion"
+# Tab completion tests require readline support, and this set of tests
+# doesn't work on a remote host either.
+if { [readline_is_used] && ![is_remote host] } {
+ gdb_test_no_output "source ${pyfile}" "load python file"
+
+ # Create a temporary directory
+ set testdir "[standard_output_file "py-completion-testdir"]/"
+ set testdir_regex [string_to_regexp $testdir]
+ set testdir_complete [standard_output_file "py-completion-test"]
+ file mkdir $testdir
+
+ # This one should always pass.
+ send_gdb "completefileinit ${testdir_complete}\t"
+ gdb_test_multiple "" "completefileinit completion" {
+ -re "^completefileinit ${testdir_regex}$" {
+ pass "completefileinit completion"
+ }
}
-}
-# Just discarding whatever we typed.
-set discard 0
-gdb_test " " ".*" "discard #[incr discard]"
+ # Just discarding whatever we typed.
+ gdb_test " " ".*" "discard #[incr discard]"
-# This is the problematic one.
-send_gdb "completefilemethod ${testdir_complete}\t"
-gdb_test_multiple "" "completefilemethod completion" {
- -re "^completefilemethod ${testdir_regex} $" {
- fail "completefilemethod completion (completed filename as wrong command arg)"
- }
- -re "^completefilemethod ${testdir_regex}$" {
- pass "completefilemethod completion"
+ # This is the problematic one.
+ send_gdb "completefilemethod ${testdir_complete}\t"
+ gdb_test_multiple "" "completefilemethod completion" {
+ -re "^completefilemethod ${testdir_regex} $" {
+ fail "completefilemethod completion (completed filename as wrong command arg)"
+ }
+ -re "^completefilemethod ${testdir_regex}$" {
+ pass "completefilemethod completion"
+ }
}
-}
-# Discarding again
-gdb_test " " ".*" "discard #[incr discard]"
+ # Discarding again
+ gdb_test " " ".*" "discard #[incr discard]"
-# Another problematic
-set completion_regex "[string_to_regexp [standard_output_file "py-completion-t"]]"
-send_gdb "completefilecommandcond [standard_output_file "py-completion-t\t"]"
-gdb_test_multiple "" "completefilecommandcond completion" {
- -re "^completefilecommandcond ${testdir}$" {
- fail "completefilecommandcond completion (completed filename instead of command)"
- }
- -re "^completefilecommandcond ${completion_regex}\007$" {
- pass "completefilecommandcond completion"
+ # Another problematic
+ set completion_regex "[string_to_regexp [standard_output_file "py-completion-t"]]"
+ send_gdb "completefilecommandcond [standard_output_file "py-completion-t\t"]"
+ gdb_test_multiple "" "completefilecommandcond completion" {
+ -re "^completefilecommandcond ${testdir}$" {
+ fail "completefilecommandcond completion (completed filename instead of command)"
+ }
+ -re "^completefilecommandcond ${completion_regex}\007$" {
+ pass "completefilecommandcond completion"
+ }
}
+
}
# Start gdb over again to clear out current state. This can interfere
# with the expected output of the below tests in a buggy gdb.
gdb_exit
gdb_start
-gdb_test_no_output "source ${srcdir}/${subdir}/${testfile}.py" \
- "load python file again"
+gdb_test_no_output "source ${pyfile}" "load python file again"
gdb_test_sequence "complete completel" \
"list all completions of 'complete completel'" {
standard_testfile
set exec_opts [list debug shlib=$lib_sl]
-set pyfile ${srcdir}/${subdir}/${testfile}.py
if [get_compiler_info] {
return -1
if { [skip_python_tests] } { continue }
+set pyfile [gdb_remote_download host ${srcdir}/${subdir}/py-events.py]
gdb_test_no_output "source ${pyfile}" "load python file"
gdb_test "test-objfile-events" "Object file events registered."
load_lib gdb-python.exp
standard_testfile py-evthreads.c
-set pyfile ${srcdir}/${subdir}/py-events.py
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
return -1
if { [skip_python_tests] } { continue }
+set pyfile [gdb_remote_download host ${srcdir}/${subdir}/py-events.py]
gdb_test_no_output "source ${pyfile}" "load python file"
gdb_test "test-events" "Event testers registered."
load_lib gdb-python.exp
standard_testfile
-set pyfile ${srcdir}/${subdir}/py-events.py
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
return -1
if { [skip_python_tests] } { continue }
+set pyfile [gdb_remote_download host ${srcdir}/${subdir}/py-events.py]
gdb_test_no_output "source ${pyfile}" "load python file"
gdb_test "test-events" "Event testers registered."
"set auto-load safe-path"
gdb_load ${binfile}
# Verify gdb loaded the script.
-gdb_test "info auto-load python-scripts" "Yes.*/${testfile}-gdb.py.*" \
+gdb_test "info auto-load python-scripts" "Yes.*${testfile}-gdb.py.*" \
"Test auto-load had loaded python scripts"
if ![runto_main] then {
# Care is taken to put it in the same directory as the binary so that
# gdb will find it.
set remote_obj_python_file \
- [remote_download \
- host ${srcdir}/${subdir}/${testfile}-gdb.py.in \
- [standard_output_file ${testfile}-gdb.py]]
+ [gdb_remote_download host ${srcdir}/${subdir}/${testfile}-gdb.py.in \
+ ${testfile}-gdb.py]
gdb_reinitialize_dir $srcdir/$subdir
gdb_test_no_output "set auto-load safe-path ${remote_obj_python_file}" \
"set auto-load safe-path"
gdb_load ${binfile}
# Verify gdb loaded the script.
-gdb_test "info auto-load python-scripts" "Yes.*/${testfile}-gdb.py.*" \
+gdb_test "info auto-load python-scripts" "Yes.*${testfile}-gdb.py.*" \
"Test auto-load had loaded python scripts"
if ![runto_main] then {
# Care is taken to put it in the same directory as the binary so that
# gdb will find it.
set remote_obj_python_file \
- [remote_download \
- host ${srcdir}/${subdir}/${testfile}-gdb.py.in \
- [standard_output_file ${testfile}-gdb.py]]
+ [gdb_remote_download host ${srcdir}/${subdir}/${testfile}-gdb.py.in \
+ ${testfile}-gdb.py]
gdb_reinitialize_dir $srcdir/$subdir
gdb_test_no_output "set auto-load safe-path ${remote_obj_python_file}" \
gdb_load ${binfile}
# Verify gdb loaded the script.
-gdb_test "info auto-load python-scripts" "Yes.*/${testfile}-gdb.py.*" \
+gdb_test "info auto-load python-scripts" "Yes.*${testfile}-gdb.py.*" \
"Set autoload path for no debug info tests"
if ![runto_main] then {
perror "couldn't run to breakpoint"
# Skip all tests if Python scripting is not enabled.
if { [mi_skip_python_tests] } { continue }
-mi_gdb_test "source ${srcdir}/${subdir}/${testfile}.py" \
+set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
+mi_gdb_test "source ${pyfile}" \
".*\\^done" \
"load python file"
gdb_load ${binfile}
# Verify gdb loaded the script.
-gdb_test "info auto-load python-scripts" "Yes.*/${testfile}-gdb.py.*"
+gdb_test "info auto-load python-scripts" "Yes.*${testfile}-gdb.py.*"
if ![runto_main] {
perror "couldn't run to main"
"Get objfile user name"
gdb_test "python print (objfile)" \
- "<gdb.Objfile filename=[string_to_regexp ${binfile}]>"
+ "<gdb.Objfile filename=.*${testfile}.*>"
gdb_test_no_output "python dir(objfile)"
# An objfile that was a symlink to a differently named file is still
# findable with its original name.
-set symlink_binary [standard_output_file "symlink-binary"]
-remote_exec host "rm -f ${symlink_binary}"
-remote_exec host "ln -sf ${testfile} ${symlink_binary}"
-if [remote_file host exists "${symlink_binary}"] {
- clean_restart "${symlink_binary}"
- gdb_test "python print (gdb.lookup_objfile (\"${symlink_binary}\").filename)" \
- "${testfile}" "gdb.lookup_objfile of symlinked binary"
+# On Windows we don't have proper symlinks, so skip this.
+if ![ishost *-*-mingw*] {
+ set symlink_binary [standard_output_file "symlink-binary"]
+ remote_exec host "rm -f ${symlink_binary}"
+ remote_exec host "ln -sf ${testfile} ${symlink_binary}"
+ if [remote_file host exists "${symlink_binary}"] {
+ clean_restart "${symlink_binary}"
+ gdb_test "python print (gdb.lookup_objfile (\"${symlink_binary}\").filename)" \
+ "${testfile}" "gdb.lookup_objfile of symlinked binary"
+ }
}
# Test printing an Objfile object that is no longer valid.
gdb_py_test_silent_cmd "python objfile = gdb.objfiles()\[0\]" \
"get first objfile" 1
gdb_file_cmd ${binfile}
-gdb_test "python print(objfile)" "<gdb.Objfile \\\(invalid\\\)>"
\ No newline at end of file
+gdb_test "python print(objfile)" "<gdb.Objfile \\\(invalid\\\)>"
".*Breakpoint.*"
gdb_test "continue" ".*Breakpoint.*"
-set python_file ${srcdir}/${subdir}/${testfile}.py
+set python_file [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
gdb_test_no_output "source ${python_file}" "load python file"
gdb_test "py gdb.printing.register_pretty_printer(gdb, lookup_function_lookup_test)" \
"Registering global lookup_function_lookup_test pretty-printer ..."
gdb_test "py gdb.printing.register_pretty_printer(progspace, my_pretty_printer1)" \
- "Registering pp-test pretty-printer for .*/py-pp-registration ..."
+ "Registering pp-test pretty-printer for .*py-pp-registration ..."
test_printers "s1"
}
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
-gdb_test_no_output "set auto-load safe-path ${remote_python_file}:${binfile}" \
+# Get the name of the binfile on the host; on a remote host this means
+# stripping off any directory prefix.
+if [is_remote host] {
+ set remote_binfile [file tail ${binfile}]
+} else {
+ set remote_binfile ${binfile}
+}
+
+if [ishost *-*-mingw*] {
+ set remote_pathsep ";"
+} else {
+ set remote_pathsep ":"
+}
+gdb_test_no_output "set auto-load safe-path ${remote_python_file}${remote_pathsep}${remote_binfile}" \
"set auto-load safe-path"
gdb_load ${binfile}
# Verify gdb loaded each script and they appear once in the list.
set test_name "verify scripts loaded"
gdb_test_multiple "info auto-load python-scripts" "$test_name" {
+ -re "Yes.*${testfile}.py.*Yes.*inlined-script.*$gdb_prompt $" {
+ pass "$test_name"
+ }
-re "${testfile}.py.*${testfile}.py.*$gdb_prompt $" {
fail "$test_name"
}
-re "inlined-script.*inlined-script.*$gdb_prompt $" {
fail "$test_name"
}
- -re "Yes.*${testfile}.py.*Yes.*inlined-script.*$gdb_prompt $" {
- pass "$test_name"
- }
}
# Again, with a regexp this time.
# Test symbol table.
gdb_test "python print (symtab.filename)" ".*${py_symbol_c}" "test symtab.filename"
-gdb_test "python print (symtab.objfile)" "<gdb.Objfile filename=${binfile}>" \
- "test symtab.objfile"
+gdb_test "python print (symtab.objfile)" \
+ "<gdb.Objfile filename=.*${testfile}.*>" "test symtab.objfile"
gdb_test "python print (symtab.fullname())" ".*${full_py_symbol_c}" "test symtab.fullname"
gdb_test "python print (symtab.is_valid())" "True" "test symtab.is_valid()"
gdb_test "python print (\"qq\" in global_symbols)" "True" "test qq in global symbols"