[gdb/testsuite] Fix buffer full errors in gdb.mi/mi-sym-info.exp
authorTom de Vries <tdevries@suse.de>
Fri, 13 Mar 2020 14:38:19 +0000 (15:38 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 13 Mar 2020 14:38:19 +0000 (15:38 +0100)
With debug info packages for system libs installed, I run into buffer full
errors with test-case gdb.mi/mi-sym-info.exp.  Fix these using exp_continue.

This exposes timeouts due to gdb taking a long time before starting to print
output.  Fix these using with_timeout_factor.

Tested on x86_64-linux, with make targets check and check-read1.

gdb/testsuite/ChangeLog:

2020-03-13  Tom de Vries  <tdevries@suse.de>

* gdb.mi/mi-sym-info.exp: Fix buffer full errors, and timeouts.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.mi/mi-sym-info.exp

index 3c09acd043bdd7872923f6ed66397683fd148254..48d3c946855026f158bb5dabd277851823191a95 100644 (file)
@@ -1,3 +1,7 @@
+2020-03-13  Tom de Vries  <tdevries@suse.de>
+
+       * gdb.mi/mi-sym-info.exp: Fix buffer full errors, and timeouts.
+
 2020-03-13  Tom de Vries  <tdevries@suse.de>
 
        * gdb.mi/mi-sym-info.exp: Make matching more precise.
index 0537eb193593d89ba9b97bae7b27bb7cedc8b2ac..290fb46c412d2f7a4e3d3c3330516d3a9e9ed1f2 100644 (file)
 
 # Test -symbol-info-functions, -symbol-info-variables, and
 # -symbol-info-types.
+#
+# These tests can generate large amounts of output, which can cause gdb to be
+# slow in two different ways:
+# - it takes long before the command starts producing output
+# - it takes long to print all the output
+# We can prevent timeouts due to the latter using exp_continue, but for
+# the former that doesn't work.  There we use with_timeout_factor instead.
 
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
@@ -51,17 +58,65 @@ set type_syms \
 
 # Fetch all functions, variables and types without any non-debug
 # symbols.
-mi_gdb_test "111-symbol-info-functions" \
-    "111\\^done,${debug_only_syms}" \
-    "List all functions from debug information only"
+set testname "List all functions from debug information only"
+set cmd "111-symbol-info-functions"
+set state 0
+gdb_test_multiple $cmd $testname -prompt "${mi_gdb_prompt}$" {
+    -re "111\\^done,symbols=\{debug=\\\[${symtab_re}" {
+       if { $state == 0 } { incr state }
+       exp_continue
+    }
+    -re ",${symtab_re}" {
+       exp_continue
+    }
+    -re "\\\]\}\r\n${mi_gdb_prompt}$" {
+       if { $state == 1 } {
+           pass $gdb_test_name
+       } else {
+           fail $gdb_test_name
+       }
+    }
+}
 
-mi_gdb_test "112-symbol-info-variables" \
-    "112\\^done,${debug_only_syms}" \
-    "List all variables from debug information only"
+set testname "List all variables from debug information only"
+set cmd "112-symbol-info-variables"
+set state 0
+gdb_test_multiple $cmd $testname -prompt "${mi_gdb_prompt}$" {
+    -re "112\\^done,symbols=\{debug=\\\[${symtab_re}" {
+       if { $state == 0 } { incr state }
+       exp_continue
+    }
+    -re ",${symtab_re}" {
+       exp_continue
+    }
+    -re "\\\]\}\r\n${mi_gdb_prompt}$" {
+       if { $state == 1 } {
+           pass $gdb_test_name
+       } else {
+           fail $gdb_test_name
+       }
+    }
+}
 
-mi_gdb_test "113-symbol-info-types" \
-    "113\\^done,${type_syms}" \
-    "List all types"
+set testname "List all types"
+set cmd "113-symbol-info-types"
+set state 0
+gdb_test_multiple $cmd $testname -prompt "${mi_gdb_prompt}$" {
+    -re "113\\^done,symbols=\{debug=\\\[${symtab_type_re}" {
+       if { $state == 0 } { incr state }
+       exp_continue
+    }
+    -re ",${symtab_type_re}" {
+       exp_continue
+    }
+    -re "\\\]\}\r\n${mi_gdb_prompt}$" {
+       if { $state == 1 } {
+           pass $gdb_test_name
+       } else {
+           fail $gdb_test_name
+       }
+    }
+}
 
 # Fetch functions and variables but also grab the non-debug symbols
 # (from the symbol table).  There's often so much output output from
@@ -69,34 +124,98 @@ mi_gdb_test "113-symbol-info-types" \
 # fetching the output piece by piece.
 set testname "List all functions"
 set cmd "114-symbol-info-functions --include-nondebug"
+set state 0
 gdb_test_multiple $cmd ${testname} -prompt "${mi_gdb_prompt}$" {
-    -re "114\\^done,symbols=\{debug=\\\[${symtab_re}(?:,${symtab_re})*\\\],nondebug=\\\[" {
+    -re "114\\^done,symbols=\{" {
+       if { $state == 0 } { set state 1 }
        exp_continue
     }
-
-    -re "\{address=${qstr},name=${qstr}\}," {
+    -re "debug=\\\[${symtab_re}" {
+       if { $state == 1 } { set state 2 }
        exp_continue
     }
-
-    -re "\{address=${qstr},name=${qstr}\}\\\]\}\r\n${mi_gdb_prompt}$" {
-       pass ${testname}
+    -re ",${symtab_re}" {
+       exp_continue
     }
-}
-
-set testname "List all variables"
-set cmd "115-symbol-info-variables --include-nondebug"
-gdb_test_multiple $cmd ${testname} -prompt "${mi_gdb_prompt}$" {
-    -re "115\\^done,symbols=\{debug=\\\[${symtab_re}(?:,${symtab_re})*\\\],nondebug=\\\[" {
-       verbose -log "Got the first part of the input"
+    -re "\\\],nondebug=\\\[" {
+       if { $state == 2 } { set state 3 }
        exp_continue
     }
-
     -re "\{address=${qstr},name=${qstr}\}," {
        exp_continue
     }
-
     -re "\{address=${qstr},name=${qstr}\}\\\]\}\r\n${mi_gdb_prompt}$" {
-       pass ${testname}
+       if { $state == 3 } {
+           pass $gdb_test_name
+       } else {
+           fail $gdb_test_name
+       }
+    }
+}
+
+with_timeout_factor 2 {
+    set testname "List all variables"
+    set cmd "115-symbol-info-variables --include-nondebug"
+    set state 0
+    gdb_test_multiple $cmd ${testname} -prompt "${mi_gdb_prompt}$" {
+       -re "115\\^done,symbols=\{" {
+           if { $state == 0 } { set state 1 }
+           exp_continue
+       }
+       -re "debug=\\\[${symtab_re}" {
+           if { $state == 1 } { set state 2 }
+           exp_continue
+       }
+       -re ",${symtab_re}" {
+           exp_continue
+       }
+       -re "\\\],nondebug=\\\[" {
+           if { $state == 2 } { set state 3 }
+           exp_continue
+       }
+       -re "\{address=${qstr},name=${qstr}\}," {
+           exp_continue
+       }
+       -re "\{address=${qstr},name=${qstr}\}\\\]\}\r\n${mi_gdb_prompt}$" {
+           if { $state == 3 } {
+               pass $gdb_test_name
+           } else {
+               fail $gdb_test_name
+           }
+       }
+    }
+}
+
+with_timeout_factor 2 {
+    set testname "List all variables"
+    set cmd "115-symbol-info-variables --include-nondebug"
+    set state 0
+    gdb_test_multiple $cmd ${testname} -prompt "${mi_gdb_prompt}$" {
+       -re "115\\^done,symbols=\{" {
+           if { $state == 0 } { incr state }
+           exp_continue
+       }
+       -re "debug=\\\[${symtab_re}" {
+           if { $state == 1 } { incr state }
+           exp_continue
+       }
+       -re ",${symtab_re}" {
+           exp_continue
+       }
+       -re "\\\],nondebug=\\\[" {
+           if { $state == 2 } { incr state }
+           exp_continue
+       }
+       -re "\{address=${qstr},name=${qstr}\}," {
+           exp_continue
+       }
+       -re "\{address=${qstr},name=${qstr}\}\\\]\}\r\n${mi_gdb_prompt}$" {
+           if { $state == 3 } {
+               pass $gdb_test_name
+           } else {
+               fail $gdb_test_name
+           }
+       }
     }
 }