aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-07-06 13:31:12 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-07-23 15:38:53 -0400
commitffb6ba773e0a5ad9884afdc3b8279671c61d5add (patch)
tree615de6bf849fe15c0735eefdbece6e9a5b87ff60 /gdb
parenta52b41bf2f08f6c106983f1acca2c8a2f69279b0 (diff)
downloadgdb-ffb6ba773e0a5ad9884afdc3b8279671c61d5add.zip
gdb-ffb6ba773e0a5ad9884afdc3b8279671c61d5add.tar.gz
gdb-ffb6ba773e0a5ad9884afdc3b8279671c61d5add.tar.bz2
gdb.base/setshow.exp: use save_vars to save/restore gdb_prompt
Using save_vars is a bit better than what we have now, as it ensures the variable gets restored if the code within it throws an error. Change-Id: I3bd6836e5b7efb61b078acadff1a1c8182c19a27
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/gdb.base/setshow.exp33
1 files changed, 16 insertions, 17 deletions
diff --git a/gdb/testsuite/gdb.base/setshow.exp b/gdb/testsuite/gdb.base/setshow.exp
index 5404b52..7b273b3 100644
--- a/gdb/testsuite/gdb.base/setshow.exp
+++ b/gdb/testsuite/gdb.base/setshow.exp
@@ -48,31 +48,30 @@ gdb_test "show annotate" "Annotation_level is 0..*" "default annotation_level i
#test set annotate 2
# Here we need to fiddle with prompts.
-set old_gdb_prompt $gdb_prompt
-set gdb_prompt "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n"
+save_vars { gdb_prompt } {
+ set old_gdb_prompt $gdb_prompt
+ set gdb_prompt "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n"
-gdb_test_multiple "set annotate 2" "set annotate 2" {
- -re "\r\n$gdb_prompt$" {
- pass "set annotate 2"
+ gdb_test_multiple "set annotate 2" "set annotate 2" {
+ -re "\r\n$gdb_prompt$" {
+ pass "set annotate 2"
+ }
}
-}
-gdb_test_multiple "show annotate" "show annotate 2" {
- -re ".*\032\032post-prompt.*Annotation_level is 2..*\032\032pre-prompt.*$old_gdb_prompt .*\032\032prompt.*$" {
- pass "show annotate 2"
+ gdb_test_multiple "show annotate" "show annotate 2" {
+ -re ".*\032\032post-prompt.*Annotation_level is 2..*\032\032pre-prompt.*$old_gdb_prompt .*\032\032prompt.*$" {
+ pass "show annotate 2"
+ }
}
-}
-#test annotation_level 2
-gdb_test_multiple "info line 1" "annotation_level 2" {
- -re ".*\032\032post-prompt.*Line 1 of .* is at address .* but contains no code.*:1:0:beg:0x.*\032\032pre-prompt.*$old_gdb_prompt .*\032\032prompt.*$" {
- pass "annotation_level 2"
+ #test annotation_level 2
+ gdb_test_multiple "info line 1" "annotation_level 2" {
+ -re ".*\032\032post-prompt.*Line 1 of .* is at address .* but contains no code.*:1:0:beg:0x.*\032\032pre-prompt.*$old_gdb_prompt .*\032\032prompt.*$" {
+ pass "annotation_level 2"
+ }
}
}
-# Restore the original prompt for the rest of the testsuite.
-set gdb_prompt $old_gdb_prompt
-
#test set annotate 1
gdb_test "set annotate 1" ".*post-prompt.*"
gdb_test "show annotate" "Annotation_level is 1..*" "show annotate (1)"