Re: [PATCH v2 3/3] gdb: introduce scoped debug prints

Tom de Vries
2021-01-05T09:23:39Z

[-- Attachment #1: Type: text/plain, Size: 428 bytes --]

On 1/5/21 10:01 AM, Tom de Vries wrote:
> [ I first tried to override $gdb_prompt for the duration of
> gdb_test_sequence using save_vars, but there's the invariant that the
> gdb_prompt variable has an implicit " " after it, which
> gdb_test_sequence adds, so that didn't work. ]

So, if we introduce a variable gdb_prompt_full which does contain the
space, and use it in gdb_test_sequence, we can override it.

Thanks,
- Tom

[-- Attachment #2: tmp.patch --]
[-- Type: text/x-patch, Size: 2105 bytes --]

diff --git a/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp b/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp
index fe842531977..03f9c135361 100644
--- a/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp
+++ b/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp
@@ -102,12 +102,16 @@ gdb_test "set scheduler-locking off"
gdb_test "set debug infrun 1"

set test "step"
-gdb_test_sequence $test $test {
- "need to step-over"
- "resume_1: step=1,"
- "signal arrived while stepping over breakpoint"
- "stepped to a different line"
- "callme"
+save_vars { gdb_prompt_full } {
+ set gdb_prompt_full \
+ "$gdb_prompt_full\\\[infrun\\\] fetch_inferior_event: exit\r\n"
+ gdb_test_sequence $test $test {
+ "need to step-over"
+ "resume_1: step=1,"
+ "signal arrived while stepping over breakpoint"
+ "stepped to a different line"
+ "callme"
+ }
}

set cnt_after [get_value "args\[$my_number\]" "get count after step"]
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 3f61da8adf1..cf64bd21305 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -142,6 +142,9 @@ if ![info exists gdb_prompt] then {
set gdb_prompt "\\(gdb\\)"
}

+global gdb_prompt_full
+set gdb_prompt_full "$gdb_prompt "
+
# A regexp that matches the pagination prompt.
set pagination_prompt \
"--Type <RET> for more, q to quit, c to continue without paging--"
@@ -1414,7 +1417,7 @@ proc gdb_test_no_output { args } {
# -1 if there was an internal error.

proc gdb_test_sequence { command test_name expected_output_list } {
- global gdb_prompt
+ global gdb_prompt_full
if { $test_name == "" } {
set test_name $command
}
@@ -1422,7 +1425,7 @@ proc gdb_test_sequence { command test_name expected_output_list } {
if { $command != "" } {
send_gdb "$command\n"
}
- return [gdb_expect_list $test_name "$gdb_prompt $" $expected_output_list]
+ return [gdb_expect_list $test_name "$gdb_prompt_full$" $expected_output_list]
}

\f