diff options
author | Tom de Vries <tdevries@suse.de> | 2022-10-11 10:14:38 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2022-10-11 10:14:38 +0200 |
commit | 86b4a00fa329a4df7ec2cb404c2b52152560aa0f (patch) | |
tree | 66c60bb532c43c954933e5e3fc7d676a21d341e0 /gdb/testsuite/gdb.python/pretty-print-call-by-hand.py | |
parent | 3f2ef5ba4278e7a436208b4aa48e7cb599392a92 (diff) | |
download | gdb-86b4a00fa329a4df7ec2cb404c2b52152560aa0f.zip gdb-86b4a00fa329a4df7ec2cb404c2b52152560aa0f.tar.gz gdb-86b4a00fa329a4df7ec2cb404c2b52152560aa0f.tar.bz2 |
[gdb/testsuite] Fix prompt parsing in capture_command_output
I noticed in capture_command_output that the output of a single command is
matched using two gdb_test_multiples:
- the first one matching the echoed command and skipping an optional prefix,
- the second one matching the output and the prompt.
This is error-prone, because the first gdb_test_multiple has implicit
clauses which may consume the prompt.
The problem is easy to spot with an example. First consider:
...
set output [capture_command_output "print 1" "\\\$1 = "]
gdb_assert { [string equal $output "1"] }
...
for which we get:
...
PASS: [string equal $output "1"]
...
If we change the prefix string to a no-match, say "1 = ", and update the
output string match accordingly, we get instead:
...
FAIL: capture_command_output for print 1
FAIL: [string equal $output "\$1 = 1"]
...
The first FAIL is produced by the first gdb_test_multiple, consuming the prompt.
The second gdb_test_multiple then silently times out waiting for another prompt,
after which the second FAIL is produced. Note that the timeout is silent
because the gdb_test_multiple is called with an empty message argument.
The second FAIL is because capture_command_output returns "", given that all
the command output was consumed by the first gdb_test_multiple.
Fix this by rewriting capture_command_output to use only a single
gdb_test_multiple.
Tested on x86_64-linux.
Diffstat (limited to 'gdb/testsuite/gdb.python/pretty-print-call-by-hand.py')
0 files changed, 0 insertions, 0 deletions