Files
binutils-gdb/gdb/testsuite/gdb.base/default.exp
Guinevere Larsen 96662aacaa gdb/solib: rename convenience variable to _linker_namespace
Based on feedback from IRC and PR solib/32959, this commit renames the
recently introduced convenience variable $_current_linker_namespace to
the shorter name $_linker_namespace. This makes it more in line with
existing convenience variables such as $_thread and $_inferior, and
faster to type.

It should be ok to simply change the name because the variable was never
released to the public, so there should be no existing scripts depending
on the name.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32959
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
2025-06-05 08:54:06 -03:00

1027 lines
39 KiB
Plaintext

# Copyright 1988-2025 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 <http://www.gnu.org/licenses/>.
# Start with a fresh gdb
with_ansi_styling_terminal {
setenv TERM dumb
gdb_exit
gdb_start
}
set prev_timeout $timeout
set timeout 60
#
# test default actions of gdb commands
#
gdb_test "add-symbol-file" "add-symbol-file takes a file name and an address"
# test append
gdb_test "append" "List of \"append\" subcommands:.*"
gdb_test "append binary" "List of \"append binary\" subcommands:.*"
gdb_test "append memory" "Missing filename\."
gdb_test "append value" "Missing filename\."
gdb_test "append binary memory" "Missing filename\."
gdb_test "append binary value" "Missing filename\."
if !$use_gdb_stub {
gdb_test_multiple "attach" "attach" {
-re "Argument required .(process-id|program) to attach.*$gdb_prompt $"\
{ pass "attach" }
-re "You can't do that when your target is `None'.*$gdb_prompt $"\
{ pass "attach" }
-re "You can't do that without a process to debug.*$gdb_prompt $"\
{ pass "attach" }
-re "Don't know how to attach. Try \"help target\"..*$gdb_prompt $"\
{ pass "attach" }
-re "Kill it. .y or n." {
send_gdb "y\n"
exp_continue
}
}
gdb_test "break" "No default breakpoint address now."
foreach i "b br bre brea" {
gdb_test $i "No default breakpoint address now." "break \"$i\" abbreviation"
}
gdb_test "backtrace" "No stack."
# ba and bac are no longer unique command prefixes. So these tests
# elict an error from GDB.
# GDB needs to be fixed to map unique alias here for ba bac.
#
foreach i "bt ba bac" {
gdb_test $i "No stack." "backtrace \"$i\" abbreviation"
}
}
gdb_test "continue" "The program is not being run."
gdb_test "c" "The program is not being run." "continue \"c\" abbreviation"
#test call
gdb_test "call" "The history is empty..*"
#test catch
gdb_test "catch" "List of \"catch\" subcommands:(\[^\r\n\]*\[\r\n\])+Type \"help catch\" followed by subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous."
#test cd
gdb_test "cd" "Working directory \[^\r\n\]*\(\r\n \\(canonically \[^\r\n\]*\\)\)?\\."
#test clear
gdb_test "clear" "No source file specified..*"
#test commands
gdb_test "commands" "Argument required .one or more breakpoint numbers...*"
#test condition
gdb_test "condition" "Argument required .breakpoint number.*"
#test core-file
gdb_test "core-file" "No core file now."
#test delete "d" abbreviation
gdb_test_no_output "d" "delete \"d\" abbreviation"
#test delete
gdb_test_no_output "delete" "delete"
#test define
gdb_test "define" "Argument required \[(\]name of command to define\[)\]."
#test delete breakpoints
gdb_test_no_output "delete breakpoints" "delete breakpoints"
#test delete display
# FIXME -- need to dump full output to detailed log
gdb_test "delete display" \
"" \
"delete display prompt" \
"Delete all auto-display expressions.*y or n. $" \
"y"
#test detach
gdb_test "detach" ".*"
#test directory
# FIXME -- need to dump full output to detailed log
gdb_test "directory" \
"Source directories searched: .cdir\[:;\].cwd.*" \
"directory prompt" \
"Reinitialize source path to empty.*y or n. $" \
"y"
#test disable "dis" abbreviation
gdb_test_no_output "dis" "disable \"dis\" abbreviation"
#test disable "disa" abbreviation
gdb_test_no_output "disa" "disable \"disa\" abbreviation"
#test disable
gdb_test_no_output "disable" "disable"
#test disable breakpoints
gdb_test_no_output "disable breakpoints" "disable breakpoints"
#test disable display
gdb_test_no_output "disable display" "disable display"
#test disassemble
gdb_test "disassemble" "No frame selected."
#test display
gdb_test_no_output "display" "display"
#test do
gdb_test "do" "No stack."
#test document
gdb_test "document" "Argument required .name of command to define.*"
#test down
gdb_test "down" "No stack.*"
#test down-silently
gdb_test "down-silently" "No stack."
# test dump
gdb_test "dump" "List of \"dump\" subcommands:.*"
gdb_test "dump binary" "List of \"dump binary\" subcommands:.*"
gdb_test "dump ihex" "List of \"dump ihex\" subcommands:.*"
gdb_test "dump memory" "Missing filename\."
gdb_test "dump srec" "List of \"dump srec\" subcommands:.*"
gdb_test "dump tekhex" "List of \"dump tekhex\" subcommands:.*"
gdb_test "dump value" "Missing filename\."
gdb_test "dump binary memory" "Missing filename\."
gdb_test "dump binary value" "Missing filename\."
gdb_test "dump ihex memory" "Missing filename\."
gdb_test "dump ihex value" "Missing filename\."
gdb_test "dump srec memory" "Missing filename\."
gdb_test "dump srec value" "Missing filename\."
gdb_test "dump tekhex memory" "Missing filename\."
gdb_test "dump tekhex value" "Missing filename\."
#test echo
gdb_test_no_output "echo" "echo"
#test enable breakpoints delete
gdb_test "enable breakpoints delete" "Argument required .one or more breakpoint numbers.*"
#test enable breakpoints once
gdb_test "enable breakpoints once" "Argument required .one or more breakpoint numbers.*"
#test enable breakpoints
gdb_test_no_output "enable breakpoints" "enable breakpoints"
#test enable delete
gdb_test "enable delete" "Argument required .one or more breakpoint numbers.*"
#test enable display
gdb_test_no_output "enable display" "enable display"
#test enable once
gdb_test "enable once" "Argument required .one or more breakpoint numbers.*"
#test enable
gdb_test_no_output "enable" "enable"
#test exec-file
send_gdb "exec-file\n"
gdb_expect {
-re "No executable file now..*$gdb_prompt $" {
pass "exec-file"
}
-re "exec-file.*A program is being debugged already. Kill it. .y or n.*$" {
send_gdb "n\n"
if {$verbose > 1} {
send_user "\tDidn't kill program being debugged\n"
}
gdb_expect -re "$gdb_prompt $" { }
pass "exec-file"
}
-re "$gdb_prompt $" { fail "exec-file" }
timeout { fail "(timeout) exec-file" }
}
#test frame "f" abbreviation
gdb_test "f" "No stack." "frame \"f\" abbreviation"
#test frame
gdb_test "frame" "No stack."
#test fg
gdb_test "fg" "The program is not being run."
#test file
send_gdb "file\n"
gdb_expect {
-re "No executable file now..*$gdb_prompt $"\
{ pass "file" }
-re ".*A program is being debugged already. Kill it. .y or n.*$" {
send_gdb "n\n"
if {$verbose > 1} {
send_user "\t\tDidn't kill program being debugged\n"
}
gdb_expect -re "$gdb_prompt $" { }
pass "file"
}
-re ".*$gdb_prompt $" { fail "file" }
timeout { fail "(timeout) file" }
}
#test finish
gdb_test "finish" "The program is not being run."
#test forward-search
# The message here comes from the regexp library, not gdb, and so can
# vary on different systems.
gdb_test "forward-search" "No previous regular expression.*|There is no previous regular expression.*"
#test gcore
gdb_test_multiple "gcore" "gcore" {
-re "You can\'t do that without a process to debug.*$gdb_prompt $" {
pass "gcore"
}
-re "Undefined command: .*$gdb_prompt $" {
pass "gcore"
}
}
gdb_test_multiple "generate-core-file" "generate-core-file" {
-re "You can\'t do that without a process to debug.*$gdb_prompt $" {
pass "generate-core-file"
}
-re "Undefined command: .*$gdb_prompt $" {
pass "generate-core-file"
}
}
#test help "h" abbreviation
gdb_test "h" "List of classes of commands:(\[^\r\n\]*\[\r\n\])+aliases -- User-defined aliases of other commands(\[^\r\n\]*\[\r\n\])+breakpoints -- Making program stop at certain points(\[^\r\n\]*\[\r\n\])+data -- Examining data(\[^\r\n\]*\[\r\n\])+files -- Specifying and examining files(\[^\r\n\]*\[\r\n\])+obscure -- Obscure features(\[^\r\n\]*\[\r\n\])+running -- Running the program(\[^\r\n\]*\[\r\n\])+stack -- Examining the stack(\[^\r\n\]*\[\r\n\])+status -- Status inquiries(\[^\r\n\]*\[\r\n\])+support -- Support facilities(\[^\r\n\]*\[\r\n\])+user-defined -- User-defined commands(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by a class name for a list of commands in that class.(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by command name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "help \"h\" abbreviation"
#test help
gdb_test "help" "List of classes of commands:(\[^\r\n\]*\[\r\n\])+aliases -- User-defined aliases of other commands(\[^\r\n\]*\[\r\n\])+breakpoints -- Making program stop at certain points(\[^\r\n\]*\[\r\n\])+data -- Examining data(\[^\r\n\]*\[\r\n\])+files -- Specifying and examining files(\[^\r\n\]*\[\r\n\])+obscure -- Obscure features(\[^\r\n\]*\[\r\n\])+running -- Running the program(\[^\r\n\]*\[\r\n\])+stack -- Examining the stack(\[^\r\n\]*\[\r\n\])+status -- Status inquiries(\[^\r\n\]*\[\r\n\])+support -- Support facilities(\[^\r\n\]*\[\r\n\])+user-defined -- User-defined commands(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by a class name for a list of commands in that class.(\[^\r\n\]*\[\r\n\])+Type \"help\" followed by command name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous."
#test handle
gdb_test "handle" "Argument required .signal to handle.*"
proc test_info_command { command message } {
set saw_info_header 0
set saw_help_info 0
set saw_command_abbrev 0
gdb_test_multiple $command $message -lbl {
-re "\r\nList of \"info\" subcommands:" {
verbose "Info header displayed"
set saw_info_header 1
exp_continue
}
-re "Type \"help info\" followed by subcommand name for full documentation\\." {
verbose "Help info displayed"
set saw_help_info 1
exp_continue
}
-re "\r\nCommand name abbreviations are allowed if unambiguous\\." {
verbose "Command name abbreviations displayed"
set saw_command_abbrev 1
exp_continue
}
-re -wrap "" {
gdb_assert { $saw_info_header && $saw_help_info
&& $saw_command_abbrev } $gdb_test_name
}
}
}
#test info "i" abbreviation
test_info_command "i" "info \"i\" abbreviation"
#test info
test_info_command "info" "info"
#test ignore
gdb_test "ignore" "Argument required .a breakpoint number.*"
#test info address
gdb_test "info address" "Argument required."
#test info all-registers
gdb_test "info all-registers" "The program has no registers now."
#test info args
gdb_test "info args" "No frame selected."
#test info bogus-gdb-command
gdb_test "info bogus-gdb-command" "Undefined info command: \"bogus-gdb-command\". Try \"help info\".*"
#test info breakpoints
gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchpoints."
#test info copying
# The license text is very big, so it may overwhelm Expect's output buffer
# and cause the test to fail occasionally. To avoid this problem, verify
# the command's output in small chunks.
set saw_header 0
set saw_terms 0
set saw_section5 0
set saw_section7 0
set saw_section10 0
set saw_section14 0
set saw_last_para 0
# These excerpts were chosen for no particular reason, except that they
# occur at the beginning, middle and end of the license text.
set re_header [multi_line \
"\\s+GNU GENERAL PUBLIC LICENSE" \
"\\s+Version 3, 29 June 2007" \
"" \
" Copyright \\(C\\) 2007 Free Software Foundation, Inc. <http://fsf.org/>" \
" Everyone is permitted to copy and distribute verbatim copies" \
" of this license document, but changing it is not allowed." \
"" \
"\\s+Preamble" \
"" \
" The GNU General Public License is a free, copyleft license for" \
"software and other kinds of works.\r\n"]
set re_terms [multi_line \
"\\s+TERMS AND CONDITIONS" \
"" \
" 0. Definitions." \
"" \
" \"This License\" refers to version 3 of the GNU General Public License.\r\n"]
set re_section5 [multi_line \
" 5. Conveying Modified Source Versions." \
"" \
" You may convey a work based on the Program, or the modifications to\r\n"]
set re_section7 [multi_line \
" 7. Additional Terms." \
"" \
" \"Additional permissions\" are terms that supplement the terms of this\r\n"]
set re_section10 [multi_line \
" 10. Automatic Licensing of Downstream Recipients." \
"" \
" Each time you convey a covered work, the recipient automatically\r\n"]
set re_section14 [multi_line \
" 14. Revised Versions of this License." \
"" \
" The Free Software Foundation may publish revised and/or new versions of\r\n"]
set re_last_para [multi_line \
" Later license versions may give you additional or different" \
"permissions. However, no additional obligations are imposed on any" \
"author or copyright holder as a result of your choosing to follow a" \
"later version.\r\n"]
set test "info copying"
gdb_test_multiple $test $test {
-re $re_header {
set saw_header 1
exp_continue
}
-re $re_terms {
set saw_terms 1
exp_continue
}
-re $re_section5 {
set saw_section5 1
exp_continue
}
-re $re_section7 {
set saw_section7 1
exp_continue
}
-re $re_section10 {
set saw_section10 1
exp_continue
}
-re $re_section14 {
set saw_section14 1
exp_continue
}
-re $re_last_para {
set saw_last_para 1
exp_continue
}
-re "$gdb_prompt \$" {
gdb_assert { $saw_header && $saw_terms && $saw_section5 \
&& $saw_section7 && $saw_section10 \
&& $saw_section14 && $saw_last_para } $test
}
}
#test info display
gdb_test "info display" "There are no auto-display expressions now."
#test info frame "f" abbreviation
gdb_test "info f" "No stack.*|No selected frame.*" "info frame \"f\" abbreviation"
#test info frame
gdb_test "info frame" "No stack.|No selected frame."
#test info files
gdb_test_no_output "info files" "info files"
#test info float
gdb_test "info float" "The program has no registers now."
#test info functions
gdb_test "info functions" "All defined functions:"
#test info locals
gdb_test "info locals" "No frame selected."
#test info program
gdb_test "info program" "The program being debugged is not being run."
#test info registers
gdb_test "info registers" "The program has no registers now."
#test info stack "s" abbreviation
gdb_test "info s" "No stack." "info stack \"s\" abbreviation"
#test info stack
gdb_test "info stack" "No stack."
#test "info set" and "show" commands
# The test needs to match the "prompt: ..." part to fix an old problem on native
# Solaris 2.8, where this test fails due to this line:
# prompt: Gdb's prompt is "(gdb) ".^M
proc test_info_set_show { command } {
set set_confirm_seen 0
set set_history_filename_seen 0
set set_listsize_seen 0
set set_prompt_seen 0
set set_write_seen 0
gdb_test_multiple $command $command -lbl {
-re "\r\nconfirm: Whether to confirm potentially dangerous operations is o\[a-z\]+\\." {
verbose "Confirm displayed"
set set_confirm_seen 1
exp_continue
}
-re "\r\nhistory filename: The filename in which to record the command history is \[^\r\n\]+\\." {
verbose "History filename displayed"
set set_history_filename_seen 1
exp_continue
}
-re "\r\nlistsize: Number of source lines gdb will list by default is 10\\." {
verbose "Listsize displayed"
set set_listsize_seen 1
exp_continue
}
-re "\r\nprompt: Gdb's prompt is \"$::gdb_prompt \"" {
verbose "GDB prompt displayed"
set set_prompt_seen 1
exp_continue
}
-re "write: Writing into executable and core files is o\[a-z\]+\\." {
verbose "Write displayed"
set set_write_seen 1
exp_continue
}
-re -wrap "" {
gdb_assert { $set_confirm_seen && $set_history_filename_seen
&& $set_listsize_seen && $set_prompt_seen
&& $set_write_seen } $gdb_test_name
}
}
}
test_info_set_show "info set"
gdb_test "info symbol" "Argument required .address.."
#test info source
gdb_test "info source" "No current source file..*"
#test info sources
gdb_test "info sources" "No symbol table is loaded. Use the \"file\" command.*"
#test info target
gdb_test_no_output "info target" "info target"
#test info terminal
gdb_test "info terminal" "No saved terminal information."
# test info threads
gdb_test "info threads" "No threads."
#test info types
gdb_test "info types" "All defined types:"
#test info variables
gdb_test "info variables" "All defined variables:"
#test info vector
gdb_test "info vector" "The program has no registers now."
#test info warranty
gdb_test "info warranty" "15. *Disclaimer of Warranty.*"
#test info watchpoints
gdb_test "info watchpoints" "No watchpoints."
#test inspect
gdb_test "inspect" "The history is empty."
#test jump
gdb_test "jump" "The program is not being run."
#test kill
gdb_test "kill" "The program is not being run."
#test list "l" abbreviation
gdb_test "l" "No symbol table is loaded. Use the \"file\" command.*" "list \"l\" abbreviation"
#test list
gdb_test "list" "No symbol table is loaded. Use the \"file\" command.*"
#test load
# The ``takes a file name'' case is for vxgdb.
# The ``Use the "file" command'' case is for newer GDB versions which try
# to deduce the filename from the exec file.
gdb_test "load" "You can't do that when your target is `None'.*|The load command takes a file name.*|Must specify at least a file name with the load command.*|.*Use the .file. or .exec-file. command.*"
#test next "n" abbreviation
gdb_test "n" "The program is not being run." "next \"n\" abbreviation"
#test next
gdb_test "next" "The program is not being run."
#test nexti "ni" abbreviation
gdb_test "ni" "The program is not being run." "nexti \"ni\" abbreviation"
#test nexti
gdb_test "nexti" "The program is not being run."
#test output
gdb_test "output" "Argument required .expression to compute.*"
#test overlay
gdb_test "overlay" "List of \"overlay\" subcommands:.*"
#test a non-existant overlay subcommand
gdb_test "overlay on" "Undefined overlay command.* Try \"help overlay\"."
gdb_test_no_output "overlay manual" "overlay manual #1"
gdb_test_no_output "overlay auto"
gdb_test_no_output "overlay off"
gdb_test "overlay list" "No sections are mapped."
gdb_test "overlay map" "Overlay debugging not enabled.*" "overlay map #1"
gdb_test "overlay unmap" "Overlay debugging not enabled.*" "overlay unmap #1"
gdb_test_no_output "overlay manual" "overlay manual #2"
gdb_test "overlay map" "Argument required: name of an overlay section" "overlay map #2"
gdb_test "overlay unmap" "Argument required: name of an overlay section" "overlay unmap #2"
#test print "p" abbreviation
gdb_test "p" "The history is empty." "print \"p\" abbreviation"
#test print
gdb_test "print" "The history is empty."
#test printf
gdb_test "printf" "Argument required .format-control string and values to print.*"
#test ptype
gdb_test "ptype" "The history is empty."
#test pwd
gdb_test "pwd" "Working directory .*"
#test run "r" abbreviation
if $use_gdb_stub {
# Only extended-remote supports "run".
} else {
gdb_test_multiple "r" "run \"r\" abbreviation" {
-re "Starting program: .*You can't do that when your target is `None'.*$gdb_prompt $"\
{ pass "run \"r\" abbreviation" }
-re "Starting program: .*No executable file specified.*Use the \"file\" or \"exec-file\" command.*$gdb_prompt $"\
{ pass "run \"r\" abbreviation" }
-re "Starting program: .*No executable specified, use .target exec.\\..*$gdb_prompt $"\
{ pass "run \"r\" abbreviation" }
-re "Starting program: .*No image loaded into target.*$gdb_prompt $"\
{ pass "run \"r\" abbreviation" }
-re "Starting program: .*No program loaded.*$gdb_prompt $"\
{ pass "run \"r\" abbreviation" }
-re "Don't know how to run. Try \"help target\"..*$gdb_prompt $"\
{ pass "run \"r\" abbreviation" }
-re "Starting program: .*Running the default executable on the remote target failed; try \"set remote exec-file\"?.*$gdb_prompt $"\
{ pass "run \"r\" abbreviation" }
}
}
#test run
if $use_gdb_stub {
# Only extended-remote supports "run".
} else {
gdb_test_multiple "run" "run" {
-re "Starting program:.*You can't do that when your target is `None'.*$gdb_prompt $"\
{ pass "run" }
-re "Starting program: .*No executable file specified.*Use the \"file\" or \"exec-file\" command.*$gdb_prompt $"\
{ pass "run" }
-re "Starting program: .*No executable specified, use .target exec.\\..*$gdb_prompt $"\
{ pass "run" }
-re "Starting program: .*No image loaded into target.*$gdb_prompt $"\
{ pass "run" }
-re "Starting program: .*No program loaded.*$gdb_prompt $"\
{ pass "run" }
-re "Don't know how to run. Try \"help target\"..*$gdb_prompt $"\
{ pass "run" }
-re "Starting program: .*Running the default executable on the remote target failed; try \"set remote exec-file\"?.*$gdb_prompt $"\
{ pass "run" }
}
}
#test rbreak
gdb_test "rbreak" "No breakpoints made."
# test restore
gdb_test "restore" "You can't do that without a process to debug\."
#test return
# The middle case accommodated the obsolete a29k, where doing the "ni"
# above causes an initial stack to be created.
gdb_test "return" "No selected frame..*"
#test reverse-search
gdb_test "reverse-search" "No previous regular expression.*|There is no previous regular expression.*"
#test step "s" abbreviation
gdb_test "s" "The program is not being run." "step \"s\" abbreviation #1"
#test step
gdb_test "step" "The program is not being run." "step #1"
#test search
gdb_test "search" "No previous regular expression.*|There is no previous regular expression.*"
#test section
gdb_test "section" "Must specify section name and its virtual address.*"
#test set annotate
gdb_test "set annotate" "Argument required .integer to set it to.*"
#test set args
gdb_test_no_output "set args" "set args"
# Test set check abbreviations
foreach x {"c" "ch" "check"} {
gdb_test "set $x" "List of \"set check\" subcommands:(\[^\r\n\]*\[\r\n\])+set check range -- Set range checking(\[^\r\n\]*\[\r\n\])+set check type -- Set strict type checking(\[^\r\n\]*\[\r\n\])+Type \"help set check\" followed by subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." \
"set check \"$x\" abbreviation"
}
#test set check range
gdb_test "set check range" ".*"
#test set check type
gdb_test "set check type" ".*"
#test set complaints
gdb_test "set complaints" "Argument required .integer to set it to.*"
#test set confirm
gdb_test_no_output "set confirm" "set confirm"
# Don't test set editing. What if we're talking to a gdb that
# won't do editing correctly while we're talking to it?
# gdb_test "set editing" "" "set editing"
#test set environment
gdb_test "set environment" "Argument required .environment variable and value.*"
#test set height
gdb_test "set height" "Argument required .integer to set it to.*"
#test set history expansion
gdb_test_no_output "set history expansion" "set history expansion"
# Make sure the history ends up in the right place.
gdb_test_no_output "set history filename [standard_output_file .gdb_history]" \
"set the history filename"
#test set history save
gdb_test_no_output "set history save" "set history save"
#test set history size
gdb_test "set history size" "Argument required .integer to set it to.*"
#test set history
gdb_test "set history" "List of \"set history\" subcommands:(\[^\r\n\]*\[\r\n\])+set history expansion -- Set history expansion on command input(\[^\r\n\]*\[\r\n\])+set history filename -- Set the filename in which to record the command history(\[^\r\n\]*\[\r\n\])+set history save -- Set saving of the history record on exit(\[^\r\n\]*\[\r\n\])+set history size -- Set the size of the command history(\[^\r\n\]*\[\r\n\])+Type \"help set history\" followed by subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous."
#test set language
gdb_test "set language" "Requires an argument. Valid arguments are auto, local, unknown, ada, asm, c, c.., d, fortran, go, minimal, modula-2, objective-c, opencl, pascal, rust."
#test set listsize
gdb_test "set listsize" "Argument required .integer to set it to.*"
proc test_set_print { command message } {
set saw_info_header 0
set saw_help_info 0
set saw_command_abbrev 0
gdb_test_multiple $command $message -lbl {
-re "\r\nList of \"set print\" subcommands:" {
verbose "Info header displayed"
set saw_info_header 1
exp_continue
}
-re "Type \"help set print\" followed by subcommand name for full documentation\\." {
verbose "Help info displayed"
set saw_help_info 1
exp_continue
}
-re "\r\nCommand name abbreviations are allowed if unambiguous\\." {
verbose "Command name abbreviations displayed"
set saw_command_abbrev 1
exp_continue
}
-re -wrap "" {
gdb_assert { $saw_info_header && $saw_help_info
&& $saw_command_abbrev } $gdb_test_name
}
}
}
#test set print "p" abbreviation
test_set_print "set p" "set print \"p\" abbreviation"
#test set print "pr" abbreviation
test_set_print "set pr" "set print \"pr\" abbreviation"
#test set print
test_set_print "set print" "set print"
#test set print address
gdb_test_no_output "set print address" "set print address"
#test set print array
gdb_test_no_output "set print array" "set print array"
#test set print asm-demangle
gdb_test_no_output "set print asm-demangle" "set print asm-demangle"
#test set print characters
gdb_test "set print characters" \
"Argument required \\(integer to set it to, or one of:\
\"elements\", \"unlimited\"\\)\\."
#test set print demangle
gdb_test_no_output "set print demangle" "set print demangle"
#test set print elements
gdb_test "set print elements" \
"Argument required \\(integer to set it to, or \"unlimited\"\\)\\."
#test set print object
gdb_test_no_output "set print object" "set print object"
#test set print pretty
gdb_test_no_output "set print pretty" "set print pretty"
#test set print sevenbit-strings
gdb_test_no_output "set print sevenbit-strings" "set print sevenbit-strings"
#test set print union
gdb_test_no_output "set print union" "set print union"
#test set print vtbl
gdb_test_no_output "set print vtbl" "set print vtbl"
# FIXME -- need a test for "set prompt"
#test set radix
gdb_test "set radix" "Input and output radices now set to decimal 10, hex a, octal 12.*"
#test set variable
gdb_test "set variable" "Argument required .expression to compute.*"
#test set verbose
gdb_test_no_output "set verbose" "set verbose"
#test set width
gdb_test "set width" "Argument required .integer to set it to.*"
#test set write
# This is only supported on targets which use exec.o.
gdb_test_no_output "set write" "set write"
#test set
gdb_test "set" "Argument required .expression to compute.*"
#test shell echo Hi dad!
gdb_test "shell echo Hi dad!" "Hi dad!"
#test show annotate
gdb_test "show annotate" "Annotation_level is 0."
#test show args
gdb_test "show args" "Argument list to give program being debugged when it is started is \"\"."
# test show check abbreviations
foreach x {"c" "ch" "check"} {
gdb_test "show $x" "check range: *Range checking is \"auto; currently off\".(\[^\r\n\]*\[\r\n\])+check type: *Strict type checking is on\..*" \
"show check \"$x\" abbreviation"
}
#test show check range
gdb_test "show check range" "Range checking is \"auto; currently off\"."
#test show check type
gdb_test "show check type" "Strict type checking is on\."
#test show commands
gdb_test "show commands" ".*"
#test show complaints
gdb_test "show complaints" "Max number of complaints about incorrect symbols is 0."
#test show confirm
gdb_test "show confirm" "Whether to confirm potentially dangerous operations is o\[a-z\]*."
#test show convenience
# This is trickier as there are multiple internal convenience vars and
# functions and we can't assume any particular order.
# And we have to handle the extra convenience funs provided by Python.
set show_conv_list \
{ \
{$_sdata = void} \
{$_siginfo = void} \
{$_thread = 0} \
{$_gthread = 0} \
{$_inferior = 1} \
{$_inferior_thread_count = 0} \
{$_exception = <error: No frame selected>} \
{$_probe_argc = <error: No frame selected>} \
{$_probe_arg0 = <error: No frame selected>} \
{$_probe_arg1 = <error: No frame selected>} \
{$_probe_arg2 = <error: No frame selected>} \
{$_probe_arg3 = <error: No frame selected>} \
{$_probe_arg4 = <error: No frame selected>} \
{$_probe_arg5 = <error: No frame selected>} \
{$_probe_arg6 = <error: No frame selected>} \
{$_probe_arg7 = <error: No frame selected>} \
{$_probe_arg8 = <error: No frame selected>} \
{$_probe_arg9 = <error: No frame selected>} \
{$_probe_arg10 = <error: No frame selected>} \
{$_probe_arg11 = <error: No frame selected>} \
{$_cimag = <internal function _cimag>} \
{$_colorsupport = "monochrome"} \
{$_creal = <internal function _creal>} \
{$_isvoid = <internal function _isvoid>} \
{$_shell = <internal function _shell>} \
{$_gdb_maint_setting_str = <internal function _gdb_maint_setting_str>} \
{$_gdb_maint_setting = <internal function _gdb_maint_setting>} \
{$_gdb_setting_str = <internal function _gdb_setting_str>} \
{$_gdb_setting = <internal function _gdb_setting>} \
{$_gdb_major = 17} \
{$_gdb_minor = 1} \
{$_shell_exitsignal = void} \
{$_shell_exitcode = 0} \
{$_active_linker_namespaces = 1} \
{$_linker_namespace = <error: No registers.>}\
}
if [allow_python_tests] {
append show_conv_list \
{
{$_memeq = <internal function _memeq>} \
{$_regex = <internal function _regex>} \
{$_streq = <internal function _streq>} \
{$_strlen = <internal function _strlen>} \
{$_as_string = <internal function _as_string>} \
{$_caller_is = <internal function _caller_is>} \
{$_caller_matches = <internal function _caller_matches>} \
{$_any_caller_is = <internal function _any_caller_is>} \
{$_any_caller_matches = <internal function _any_caller_matches>} \
}
}
gdb_test_list_exact "show convenience" "show convenience" \
"\[^\r\n\]+\[\r\n\]+" \
"\[^\r\n\]+" \
$show_conv_list
#test show directories
gdb_test "show directories" "Source directories searched: .cdir\[:;\].cwd"
#test show editing
gdb_test "show editing" "Editing of command lines as they are typed is o\[a-z\]*."
#test show height
gdb_test "show height" "Number of lines gdb thinks are in a page is.*"
#test show history expansion
gdb_test "show history expansion" "History expansion on command input is o\[a-z\]*.*"
#test show history filename
gdb_test "show history filename" "The filename in which to record the command history is.*.gdb_history.*"
#test show history save
gdb_test "show history save" "Saving of the history record on exit is on."
#test show history size
gdb_test "show history size" "The size of the command history is.*"
#test show history
gdb_test "show history" "history expansion: *History expansion on command input is o(\[^\r\n\]*\[\r\n\])+history filename: *The filename in which to record the command history is.*.gdb_history(\[^\r\n\]*\[\r\n\])+history save: *Saving of the history record on exit is o(\[^\r\n\]*\[\r\n\])+history size: * The size of the command history is.*"
#test show language
gdb_test "show language" "The current source language is \"auto; currently c\"."
#test show listsize
gdb_test "show listsize" "Number of source lines gdb will list by default is 10."
proc test_show_print { command } {
set saw_print_address 0
set saw_print_frame_args 0
set saw_print_symbol 0
set saw_print_vtbl 0
gdb_test_multiple $command $command -lbl {
-re "\r\nprint address: Printing of addresses is o\[a-z\]+\\." {
verbose "Print address displayed"
set saw_print_address 1
exp_continue
}
-re "\r\nprint frame-arguments: Printing of non-scalar frame arguments is \[^\r\n\]+\\." {
verbose "Print frame-arguments displayed"
set saw_print_frame_args 1
exp_continue
}
-re "\r\nprint symbol: Printing of symbols when printing pointers is o\[a-z\]+\\." {
verbose "Print symbol displayed"
set saw_print_symbol 1
exp_continue
}
-re "\r\nprint vtbl: Printing of C\\+\\+ virtual function tables is o\[a-z\]+\\." {
verbose "Print vtbl displayed"
set saw_print_vtbl 1
exp_continue
}
-re -wrap "" {
gdb_assert { $saw_print_address && $saw_print_frame_args
&& $saw_print_symbol && $saw_print_vtbl } $gdb_test_name
}
}
}
#test show print "p" abbreviation
test_show_print "show p"
#test show print "pr" abbreviation
test_show_print "show pr"
#test show print
test_show_print "show print"
#test show paths
gdb_test "show paths" "Executable and object file path:.*"
#test show print address
gdb_test "show print address" "Printing of addresses is on."
#test show print array
gdb_test "show print array" "Pretty formatting of arrays is on."
#test show print asm-demangle
gdb_test "show print asm-demangle" "Demangling of C\[+\]+/ObjC names in disassembly listings is on."
#test show print characters
gdb_test "show print characters" \
"Limit on string characters to print is elements\\."
#test show print demangle
gdb_test "show print demangle" "Demangling of encoded C\[+\]+/ObjC names when displaying symbols is on."
#test show print elements
gdb_test "show print elements" "Limit on string chars or array elements to print is 200."
#test show print object
gdb_test "show print object" "Printing of object's derived type based on vtable info is on."
#test show print pretty
gdb_test "show print pretty" "Pretty formatting of structures is on."
#test show print sevenbit-strings
gdb_test "show print sevenbit-strings" "Printing of 8-bit characters in strings as .nnn is on."
#test show print union
gdb_test "show print union" "Printing of unions interior to structures is on."
#test show print vtbl
gdb_test "show print vtbl" "Printing of C\[+\]+ virtual function tables is on."
#test show prompt
# In the FAIL case, can't just look for $gdb_prompt because that will match
# the output, rather than the prompt. So look for $gdb_prompt at the start
# of a line.
gdb_test "show prompt" "Gdb's prompt is \"$gdb_prompt \".*"
#test show radix
gdb_test "show radix" "Input and output radices set to decimal 10, hex a, octal 12."
#test show user
gdb_test_no_output "show user" "show user"
#test show values
gdb_test_no_output "show values" "show values"
#test show verbose
gdb_test "show verbose" "Verbose printing of informational messages is o.*|Verbosity is off.*"
#test show version
gdb_test "show version" "GNU gdb \[0-9\.\]*(\[^\r\n\]*\[\r\n\])+Copyright \\(C\\) \[0-9\]* Free Software Foundation, Inc(\[^\r\n\]*\[\r\n\])+License GPLv3\\+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>(\[^\r\n\]*\[\r\n\])+This is free software: you are free to change and redistribute it.(\[^\r\n\]*\[\r\n\])+There is NO WARRANTY, to the extent permitted by law.(\[^\r\n\]*\[\r\n\])+Type \"show copying\" and \"show warranty\" for details..*"
#test show width
gdb_test "show width" "Number of characters gdb thinks are in a line is.*"
#test show write
# This is only supported on targets which use exec.o.
gdb_test "show write" "Writing into executable and core files is o.*"
#test show
test_info_set_show "show"
#history saving should stay disabled
gdb_test_no_output "set history save off" "set history save off"
#test stepi "si" abbreviation
gdb_test "si" "The program is not being run." "stepi \"si\" abbreviation"
#test stepi
gdb_test "stepi" "The program is not being run."
#test signal
gdb_test "signal" "The program is not being run."
#test source
gdb_test "source" "source command requires file name of file to source..*|No such file or directory.*"
#test step "s" abbreviation
gdb_test "s" "The program is not being run." "step \"s\" abbreviation #2"
#test step
gdb_test "step" "The program is not being run." "step #2"
#test symbol-file
gdb_test "symbol-file" ".*"
#test target native
gdb_test "target native" "Use the \"run\" command to start a process.*|Undefined target command: \"native\". *Try \"help target\".*"
#test target core
send_gdb "target core\n"
gdb_expect {
-re "No core file specified..*$gdb_prompt $" { pass "target core" }
-re ".*A program is being debugged already. Kill it. .y or n.*$" {
send_gdb "n\n"
if {$verbose > 1} {
send_user "\t\tDidn't kill program being debugged\n"
}
gdb_expect -re "$gdb_prompt $" { }
pass "target core"
}
-re "Undefined target command: \"core\". Try \"help target\"..*$gdb_prompt $" { pass "target core" }
-re ".*$gdb_prompt $" { fail "target core" }
timeout { fail "(timeout) target core" }
}
#test target exec
send_gdb "target exec\n"
gdb_expect {
-re "No executable file now..*$gdb_prompt $"\
{ pass "target exec" }
-re ".*A program is being debugged already. Kill it. .y or n.*$" {
send_gdb "n\n"
if {$verbose > 1} {
send_user "\t\tDidn't kill program being debugged\n"
}
gdb_expect -re "$gdb_prompt $" { }
pass "target exec"
}
-re ".*$gdb_prompt $" { fail "target exec" }
timeout { fail "(timeout) target exec" }
}
#test target remote
send_gdb "target remote\n"
gdb_expect {
-re "To open a remote debug connection, you need to specify what.*serial.*device is attached to the remote system.*.e.g. .*$gdb_prompt $"\
{ pass "target remote" }
-re ".*A program is being debugged already. Kill it. .y or n.*$" {
send_gdb "n\n"
if {$verbose > 1} {
send_user "\t\tDidn't kill program being debugged\n"
}
gdb_expect -re "$gdb_prompt $" { }
pass "target remote"
}
-re ".*$gdb_prompt $" { fail "target remote" }
timeout { fail "(timeout) target remote" }
}
#test target
gdb_test "target" "List of \"target\" subcommands:(\[^\r\n\]*\[\r\n\])+Type \"help target\" followed by subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous."
#test tbreak
gdb_test "tbreak" "No default breakpoint address now."
#test thread
gdb_test "thread" "No thread selected"
#test thread apply
gdb_test "thread apply" "Please specify a thread ID list"
#test thread find
gdb_test "thread find" "Command requires an argument."
#test thread name
gdb_test "thread name" "No thread selected"
#test until "u" abbreviation
gdb_test "u" "The program is not being run." "until \"u\" abbreviation"
#test until
gdb_test "until" "The program is not being run."
#test undisplay
# FIXME -- need to dump full output to detailed log
gdb_test "undisplay" \
"" \
"undisplay prompt" \
"Delete all auto-display expressions.*y or n. $" \
"y"
#test unset environment
gdb_test "unset environment" \
"" \
"unset environment prompt" \
"Delete all environment variables?.*y or n. $" \
"y"
#test unset
gdb_test "unset" "List of \"unset\" subcommands:(\[^\r\n\]*\[\r\n\])+unset environment -- Cancel environment variable VAR for the program(\[^\r\n\]*\[\r\n\])+Type \"help unset\" followed by subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous."
#test up
#test up-silently
gdb_test "up-silently" "No stack."
#test watch
gdb_test "watch" "Argument required .expression to compute.*"
#test whatis
gdb_test "whatis" "The history is empty."
#test where
gdb_test "where" "No stack."
#test x
gdb_test "x" "Argument required .starting display address.*"
gdb_exit
set timeout $prev_timeout