[PATCH 5/57][Arm][GAS] Add support for MVE instructions: vmull{b,t}
[binutils-gdb.git] / gdb / testsuite / gdb.base / gdbinit-history.exp
blobf4f0686ccc12d26ce28e0bcf09f897a5f2917990
1 # Copyright 2015-2019 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 # This file is part of the gdb testsuite.
18 # Test the setting of "history size" via $HOME/.gdbinit
20 # This test depends on being able to set $HOME and $GDBHISTSIZE.
21 # We cannot expect remote hosts to see environment variables set on the
22 # local machine.
24 if { [is_remote host] } {
25     unsupported "can't set environment variables on remote host"
26     return -1
29 # Check that the history size is properly set to SIZE when reading the .gdbinit
30 # file located in HOME with the environment variable GDBHISTSIZE optionally
31 # set to GDBHISTSIZE_VAL.
33 proc test_gdbinit_history_setting { home size { gdbhistsize_val "-" } } {
34     global env
35     global INTERNAL_GDBFLAGS
36     global srcdir
37     global subdir
39     save_vars { INTERNAL_GDBFLAGS env(GDBHISTFILE) env(GDBHISTSIZE) env(HOME) } {
40         set env(HOME) "$srcdir/$subdir/$home"
42         # These environment variables take precedence over whatever
43         # history size is set in .gdbinit.  Make sure the former is not
44         # set.
45         unset -nocomplain env(GDBHISTFILE)
46         unset -nocomplain env(GDBHISTSIZE)
48         if { $gdbhistsize_val != "-" } {
49             set env(GDBHISTSIZE) $gdbhistsize_val
50         }
52         set INTERNAL_GDBFLAGS [string map {"-nx" ""} $INTERNAL_GDBFLAGS]
54         set prefix "home=$home"
55         if { $gdbhistsize_val != "-" } {
56             append prefix " gdbhistsize=$gdbhistsize_val"
57         }
59         with_test_prefix $prefix {
60             gdb_exit
61             gdb_start
63             gdb_test "show history size" "The size of the command history is $size."
65             if { $size == "0" } {
66                 gdb_test_no_output "show commands"
67             } elseif { $size != "1" } {
68                 gdb_test "show commands" "    .  show history size\r\n    .  show commands"
69             }
70         }
71     }
74 # Check that the history file does not get truncated to zero when a gdbinit
75 # file sets the history size to unlimited.
77 proc test_no_truncation_of_unlimited_history_file { } {
78     global env
79     global INTERNAL_GDBFLAGS
81     save_vars { INTERNAL_GDBFLAGS env(GDBHISTFILE) env(GDBHISTSIZE) } {
82         # These environment variables take precedence over whatever
83         # history size is set in .gdbinit.  Make sure the former is not
84         # set.
85         unset -nocomplain env(GDBHISTFILE)
86         unset -nocomplain env(GDBHISTSIZE)
88         set temp_gdbinit [standard_output_file "gdbinit-history.gdbinit"]
89         set temp_histfile [standard_output_file "gdbinit-history.gdb_history"]
90         file delete $temp_gdbinit
91         file delete $temp_histfile
93         set fd [open $temp_gdbinit "w"]
94         puts $fd "set history size unlimited\n"
95         puts $fd "set history filename $temp_histfile\n"
96         puts $fd "set history save\n"
97         close $fd
99         append INTERNAL_GDBFLAGS " -x $temp_gdbinit"
101         # We have to start then exit GDB twice: the first time to test the creation
102         # of the initial history file, and the second time to test appending to it.
103         # In either case the initial "print 1" command should persist through the
104         # history file.
105         with_test_prefix "truncation" {
106             gdb_exit
107             gdb_start
108             gdb_test "print 1"
110             with_test_prefix "creating" {
111                 gdb_exit
112                 gdb_start
113                 gdb_test "server show commands" "    .  print 1.*"
114             }
116             with_test_prefix "appending" {
117                 gdb_exit
118                 gdb_start
119                 gdb_test "server show commands" "    .  print 1.*"
120             }
121         }
122     }
125 test_gdbinit_history_setting "gdbinit-history/unlimited" "unlimited"
126 test_gdbinit_history_setting "gdbinit-history/zero" "0"
128 test_no_truncation_of_unlimited_history_file
130 # A valid GDBHISTSIZE value overrides the setting inside the .gdbinit file; an
131 # invalid GDBHISTSIZE value is ignored, falling back on the setting inside the
132 # .gdbinit file.
133 test_gdbinit_history_setting "gdbinit-history/unlimited" "1000" "1000"
134 test_gdbinit_history_setting "gdbinit-history/unlimited" "unlimited" "foo"