From ffb6ba773e0a5ad9884afdc3b8279671c61d5add Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 6 Jul 2021 13:31:12 -0400 Subject: [PATCH] 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 --- gdb/testsuite/gdb.base/setshow.exp | 33 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/gdb/testsuite/gdb.base/setshow.exp b/gdb/testsuite/gdb.base/setshow.exp index 5404b523967..7b273b3902a 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)" -- 2.30.2