fix gdb.python to be parallel-safe
authorTom Tromey <tromey@redhat.com>
Thu, 22 Aug 2013 13:51:08 +0000 (13:51 +0000)
committerTom Tromey <tromey@redhat.com>
Thu, 22 Aug 2013 13:51:08 +0000 (13:51 +0000)
This fixes gdb.python to be parallel-safe, mostly by changing it to
use gdb_remote_download.

Tested on x86-64 Fedora 18.

* gdb.python/py-error.exp: Use gdb_remote_download.
* gdb.python/py-mi.exp: Use gdb_remote_download.
* gdb.python/py-objfile-script.exp: Use standard_output_file.
* gdb.python/py-prettyprint.exp: Use gdb_remote_download.
(run_lang_tests): Likewise.
* gdb.python/py-section-script.c: Use SCRIPT_FILE rather than
filename.
* gdb.python/py-section-script.exp: Set SCRIPT_FILE when
compiling.  Use gdb_remote_download.  Update some tests.
* gdb.python/py-strfns.exp (test_strfns_core_file): Use
standard_output_file.
* gdb.python/py-typeprint.exp: Use gdb_remote_download.
* gdb.python/py-frame-args.exp: Use gdb_remote_download.
* gdb.python/py-framefilter-mi.exp: Use gdb_remote_download.
* gdb.python/py-framefilter.exp: Use gdb_remote_download,
standard_output_file.

12 files changed:
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-error.exp
gdb/testsuite/gdb.python/py-frame-args.exp
gdb/testsuite/gdb.python/py-framefilter-mi.exp
gdb/testsuite/gdb.python/py-framefilter.exp
gdb/testsuite/gdb.python/py-mi.exp
gdb/testsuite/gdb.python/py-objfile-script.exp
gdb/testsuite/gdb.python/py-prettyprint.exp
gdb/testsuite/gdb.python/py-section-script.c
gdb/testsuite/gdb.python/py-section-script.exp
gdb/testsuite/gdb.python/py-strfns.exp
gdb/testsuite/gdb.python/py-typeprint.exp

index b53ec2d..59fcf90 100644 (file)
@@ -1,5 +1,24 @@
 2013-08-22  Tom Tromey  <tromey@redhat.com>
 
+       * gdb.python/py-error.exp: Use gdb_remote_download.
+       * gdb.python/py-mi.exp: Use gdb_remote_download.
+       * gdb.python/py-objfile-script.exp: Use standard_output_file.
+       * gdb.python/py-prettyprint.exp: Use gdb_remote_download.
+       (run_lang_tests): Likewise.
+       * gdb.python/py-section-script.c: Use SCRIPT_FILE rather than
+       filename.
+       * gdb.python/py-section-script.exp: Set SCRIPT_FILE when
+       compiling.  Use gdb_remote_download.  Update some tests.
+       * gdb.python/py-strfns.exp (test_strfns_core_file): Use
+       standard_output_file.
+       * gdb.python/py-typeprint.exp: Use gdb_remote_download.
+       * gdb.python/py-frame-args.exp: Use gdb_remote_download.
+       * gdb.python/py-framefilter-mi.exp: Use gdb_remote_download.
+       * gdb.python/py-framefilter.exp: Use gdb_remote_download,
+       standard_output_file.
+
+2013-08-22  Tom Tromey  <tromey@redhat.com>
+
        * lib/cell.exp (skip_cell_tests): Use standard_temp_file.
 
 2013-08-22  Tom Tromey  <tromey@redhat.com>
index a204302..922798d 100644 (file)
@@ -48,7 +48,8 @@ if {$test2 == ""} {
     return 0
 }
 
-set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
+set remote_python_file [gdb_remote_download host \
+                           ${srcdir}/${subdir}/${testfile}.py]
 
 # argc=LookupError: unknown encoding: IBM1047
 gdb_test "source $remote_python_file" "Traceback.*ClassName.*\r\nLookupError: unknown encoding: $charset" $test2
index ff082dd..be6defd 100644 (file)
@@ -26,9 +26,11 @@ if ![runto_main] {
     return -1
 }
 
-set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
+set remote_python_file [gdb_remote_download host \
+                           ${srcdir}/${subdir}/${testfile}.py]
 
-gdb_test_no_output "python exec (open ('${remote_python_file}').read ())"
+gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \
+    "python exec (open ('[file tail ${remote_python_file}]').read ())"
 
 gdb_breakpoint [gdb_get_line_number "break-here"]
 gdb_continue_to_breakpoint "break-here" ".* break-here .*"
index 54fedf8..8228a91 100644 (file)
@@ -44,7 +44,7 @@ if {[lsearch -exact [mi_get_features] python] < 0} {
 
 mi_runto main
 
-set remote_python_file [remote_download host ${srcdir}/${subdir}/${pyfile}]
+set remote_python_file [gdb_remote_download host ${srcdir}/${subdir}/${pyfile}]
 
 mi_gdb_test "python execfile ('${remote_python_file}')" ".*\\^done." \
     "Load python file"
index 6c9946b..be5a479 100644 (file)
@@ -39,7 +39,7 @@ if { [skip_python_tests] } { continue }
 set remote_obj_python_file \
     [remote_download \
         host ${srcdir}/${subdir}/${testfile}-gdb.py.in \
-        ${subdir}/${testfile}-gdb.py]
+        [standard_output_file ${testfile}-gdb.py]]
 
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_test_no_output "set auto-load safe-path ${remote_obj_python_file}" \
@@ -57,7 +57,8 @@ gdb_test_no_output "set python print-stack full" \
     "Set python print-stack to full"
 
 # Load global frame-filters
-set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
+set remote_python_file [gdb_remote_download host \
+                           ${srcdir}/${subdir}/${testfile}.py]
 gdb_test_no_output "python execfile ('${remote_python_file}')" \
     "Load python file"
 
@@ -199,7 +200,7 @@ if { [skip_python_tests] } { continue }
 set remote_obj_python_file \
     [remote_download \
         host ${srcdir}/${subdir}/${testfile}-gdb.py.in \
-        ${subdir}/${testfile}-gdb.py]
+        [standard_output_file ${testfile}-gdb.py]]
 
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_test_no_output "set auto-load safe-path ${remote_obj_python_file}" \
@@ -218,7 +219,8 @@ gdb_test_no_output "set python print-stack full" \
     "set python print-stack full for no debuginfo tests"
 
 # Load global frame-filters
-set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
+set remote_python_file [gdb_remote_download host \
+                           ${srcdir}/${subdir}/${testfile}.py]
 gdb_test_no_output "python execfile ('${remote_python_file}')" \
     "Load python file for no debuginfo tests"
 
index ae8bfe5..28aa2c8 100644 (file)
@@ -42,7 +42,7 @@ if {[lsearch -exact [mi_get_features] python] < 0} {
 
 mi_runto main
 
-set remote_python_file [remote_download host ${srcdir}/${subdir}/${pyfile}]
+set remote_python_file [gdb_remote_download host ${srcdir}/${subdir}/${pyfile}]
 
 mi_gdb_test "python exec (open ('${remote_python_file}').read ())" ""
 
index 097de49..f75b9ba 100644 (file)
@@ -32,7 +32,9 @@ if { [skip_python_tests] } { continue }
 # Make the -gdb.py script available to gdb, it is automagically loaded by gdb.
 # Care is taken to put it in the same directory as the binary so that
 # gdb will find it.
-set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}-gdb.py.in ${subdir}/${testfile}-gdb.py]
+set remote_python_file [remote_download host \
+                           ${srcdir}/${subdir}/${testfile}-gdb.py.in \
+                           [standard_output_file ${testfile}-gdb.py]]
 
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_test_no_output "set auto-load safe-path ${remote_python_file}" "set auto-load safe-path"
index b7dd5b7..d124a72 100644 (file)
@@ -53,9 +53,11 @@ proc run_lang_tests {exefile lang} {
        ".*Breakpoint.*"
     gdb_test "continue" ".*Breakpoint.*"
 
-    set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
+    set remote_python_file [gdb_remote_download host \
+                               ${srcdir}/${subdir}/${testfile}.py]
 
-    gdb_test_no_output "python exec (open ('${remote_python_file}').read ())"
+    gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \
+       "python exec (open ('[file tail ${remote_python_file}]').read ())"
     
     gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>"
     gdb_test "print ssa\[1\]" " = a=< a=<5> b=<$hex>> b=< a=<6> b=<$hex>>"
@@ -123,9 +125,11 @@ if ![runto_main ] then {
     return
 }
 
-set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
+set remote_python_file [gdb_remote_download host \
+                           ${srcdir}/${subdir}/${testfile}.py]
 
-gdb_test_no_output "python exec (open ('${remote_python_file}').read ())"
+gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \
+    "python exec (open ('[file tail ${remote_python_file}]').read ())"
 
 gdb_breakpoint [gdb_get_line_number "eval-break"]
 gdb_continue_to_breakpoint "eval-break" ".* eval-break .*"
index ebe7b9b..db1daea 100644 (file)
@@ -26,7 +26,7 @@
 .popsection \n\
 ");
 
-DEFINE_GDB_SCRIPT ("py-section-script.py")
+DEFINE_GDB_SCRIPT (SCRIPT_FILE)
 
 struct ss
 {
index 7f710d3..66f1117 100644 (file)
@@ -31,7 +31,15 @@ if {![istarget *-*-linux*]
 
 standard_testfile
 
-if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
+# Make this available to gdb before the program starts, it is
+# automagically loaded by gdb.
+set remote_python_file [gdb_remote_download host \
+                           ${srcdir}/${subdir}/${testfile}.py]
+
+set quoted_name "\"$remote_python_file\""
+
+if {[build_executable $testfile.exp $testfile $srcfile \
+        [list debug additional_flags=-DSCRIPT_FILE=$quoted_name]] == -1} {
     return -1
 }
 
@@ -42,18 +50,14 @@ gdb_start
 # Skip all tests if Python scripting is not enabled.
 if { [skip_python_tests] } { continue }
 
-# Make this available to gdb before the program starts, it is
-# automagically loaded by gdb.
-set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
-
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_test_no_output "set auto-load safe-path ${remote_python_file}" "set auto-load safe-path"
 gdb_load ${binfile}
 
 # Verify gdb loaded the script.
-gdb_test "info auto-load python-scripts" "Yes.*${testfile}.py.*full name: .*/${testfile}.py.*"
+gdb_test "info auto-load python-scripts" "Yes.*${testfile}.py.*"
 # Again, with a regexp this time.
-gdb_test "info auto-load python-scripts ${testfile}" "Yes.*${testfile}.py.*full name: .*/${testfile}.py.*"
+gdb_test "info auto-load python-scripts ${testfile}" "Yes.*${testfile}.py.*"
 # Again, with a regexp that matches no scripts.
 gdb_test "info auto-load python-scripts no-script-matches-this" \
   "No auto-load scripts matching no-script-matches-this."
index 9d78518..daeb852 100644 (file)
@@ -64,9 +64,9 @@ gdb_test "p /d {char\[4\]} arg" "= \\{0, 1, 2, 4\\}"
 # Verify use on a core file.
 
 proc test_strfns_core_file { } {
-    global objdir subdir gdb_prompt testfile
+    global gdb_prompt testfile
 
-    set filename "${objdir}/${subdir}/py-strfns.core"
+    set filename [standard_output_file py-strfns.core]
 
     if {![gdb_gcore_cmd "$filename" "save a corefile"]} {
        # No use proceeding from here.
index 5e2a238..8e1b379 100644 (file)
@@ -26,9 +26,11 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
 
 if { [skip_python_tests] } { continue }
 
-set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
+set remote_python_file [gdb_remote_download host \
+                           ${srcdir}/${subdir}/${testfile}.py]
 
-gdb_test_no_output "python exec (open ('${remote_python_file}').read ())"
+gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \
+    "python exec (open ('[file tail ${remote_python_file}]').read ())"
 
 cp_test_ptype_class s "basic test" "class" "templ<string>" {
     { field public "T x;" }