gdb: Introduce 'print max-depth' feature
[deliverable/binutils-gdb.git] / gdb / testsuite / lib / gdb.exp
index 6800c741874b06dcb2f4cee6b5716cd845aed94c..25d370ebb52832af97287a3b9e1d807d35960bd4 100644 (file)
@@ -906,10 +906,13 @@ proc gdb_test_multiple { command message user_code } {
        }
     }
     append code $processed_code
+
+    # Reset the spawn id, in case the processed code used -i.
     append code {
-       # Reset the spawn id, in case the processed code used -i.
        -i "$gdb_spawn_id"
+    }
 
+    append code {
        -re "Ending remote debugging.*$gdb_prompt $" {
            if ![isnative] then {
                warning "Can`t communicate to remote target."
@@ -990,8 +993,10 @@ proc gdb_test_multiple { command message user_code } {
            }
            return -1
        }
+    }
 
-       # Patterns below apply to any spawn id specified.
+    # Now patterns that apply to any spawn id specified.
+    append code {
        -i $any_spawn_id
        eof {
            perror "Process no longer exists"
@@ -1013,6 +1018,20 @@ proc gdb_test_multiple { command message user_code } {
        }
     }
 
+    # remote_expect calls the eof section if there is an error on the
+    # expect call.  We already have eof sections above, and we don't
+    # want them to get called in that situation.  Since the last eof
+    # section becomes the error section, here we define another eof
+    # section, but with an empty spawn_id list, so that it won't ever
+    # match.
+    append code {
+       -i "" eof {
+           # This comment is here because the eof section must not be
+           # the empty string, otherwise remote_expect won't realize
+           # it exists.
+       }
+    }
+
     set result 0
     set code [catch {gdb_expect $code} string]
     if {$code == 1} {
@@ -1371,6 +1390,36 @@ proc gdb_test_stdio {command inferior_pattern {gdb_pattern ""} {message ""}} {
     return $res
 }
 
+# get_print_expr_at_depths EXP OUTPUTS
+#
+# Used for testing 'set print max-depth'.  Prints the expression EXP
+# with 'set print max-depth' set to various depths.  OUTPUTS is a list
+# of `n` different patterns to match at each of the depths from 0 to
+# (`n` - 1).
+#
+# This proc does one final check with the max-depth set to 'unlimited'
+# which is tested against the last pattern in the OUTPUTS list.  The
+# OUTPUTS list is therefore required to match every depth from 0 to a
+# depth where the whole of EXP is printed with no ellipsis.
+#
+# This proc leaves the 'set print max-depth' set to 'unlimited'.
+proc gdb_print_expr_at_depths {exp outputs} {
+    for { set depth 0 } { $depth <= [llength $outputs] } { incr depth } {
+       if { $depth == [llength $outputs] } {
+           set expected_result [lindex $outputs [expr [llength $outputs] - 1]]
+           set depth_string "unlimited"
+       } else {
+           set expected_result [lindex $outputs $depth]
+           set depth_string $depth
+       }
+
+       with_test_prefix "exp='$exp': depth=${depth_string}" {
+           gdb_test_no_output "set print max-depth ${depth_string}"
+           gdb_test "p $exp" "$expected_result"
+       }
+    }
+}
+
 \f
 
 # Issue a PASS and return true if evaluating CONDITION in the caller's
@@ -3545,7 +3594,8 @@ proc gdb_compile {source dest type options} {
     if { $getting_compiler_info == 0
         && [test_compiler_info {gcc-*-*}]
         && !([test_compiler_info {gcc-[0-3]-*}]
-             || [test_compiler_info {gcc-4-0-*}]) } {
+             || [test_compiler_info {gcc-4-0-*}])
+        && [lsearch -exact $options rust] == -1} {
         # Put it at the front to not override any user-provided value.
         lappend new_options "early_flags=-fno-stack-protector"
     }
@@ -6334,5 +6384,20 @@ proc cd { dir } {
     builtin_cd $dir
 }
 
+# Return a list of all languages supported by GDB, suitable for use in
+# 'set language NAME'.  This doesn't include either the 'local' or
+# 'auto' keywords.
+proc gdb_supported_languages {} {
+    return [list c objective-c c++ d go fortran modula-2 asm pascal \
+               opencl rust minimal ada]
+}
+
+# Check if debugging is enabled for gdbserver.
+
+proc gdbserver_debug_enabled { } {
+    # Always disabled for GDB only setups.
+    return 0
+}
+
 # Always load compatibility stuff.
 load_lib future.exp
This page took 0.025707 seconds and 4 git commands to generate.