diff options
author | Andrew Burgess <aburgess@redhat.com> | 2024-05-31 22:03:06 +0100 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2024-06-05 10:19:35 +0100 |
commit | f95540d91f4c3df373c0f9e212030154658d7f6f (patch) | |
tree | 4ecc2246f5bee64e23fbb147a0e227adbff99e5a /gdb | |
parent | 5260dcf0c6c4bd403fe5f82bb6109e89858ea974 (diff) | |
download | gdb-f95540d91f4c3df373c0f9e212030154658d7f6f.zip gdb-f95540d91f4c3df373c0f9e212030154658d7f6f.tar.gz gdb-f95540d91f4c3df373c0f9e212030154658d7f6f.tar.bz2 |
gdb/testsuite: remove trailing \r from rust_llvm_version result
I noticed that the value returned by rust_llvm_version had a trailing
carriage return. I don't think this is causing any problems right
now, but looking at the code I don't think this was the desired
behaviour.
The current code runs 'rustc --version --verbose', splits the output
at each '\n' and then loops over every line looking for the line that
contains the LLVM version.
There are two problems here. First, at the end of each captured line
we have '\r\n', so when we split the lines on '\n', each of the lines
will still end with a '\r' character.
Second, though we loop over the lines, when we try to compare the line
contents we actually compare the unsplit full output. Luckily this
still finds the match, but this renders the loop over lines redundant.
This commit makes two fixes:
1. I use regsub to convert all '\r\n' sequences to '\n'; now when we
split on '\n' the lines will not end in '\r'.
2. Within the loop over lines block I now check the line contents
rather than the unsplit full output; now we capture a value
without a trailing '\r'.
There's only one test (gdb.rust/simple.exp) that uses
rust_llvm_version, and it doesn't care if there's a trailing '\r' or
not, so this change should make no difference there.
Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/testsuite/lib/rust-support.exp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gdb/testsuite/lib/rust-support.exp b/gdb/testsuite/lib/rust-support.exp index 6b3da2a..971a4a6 100644 --- a/gdb/testsuite/lib/rust-support.exp +++ b/gdb/testsuite/lib/rust-support.exp @@ -86,8 +86,9 @@ gdb_caching_proc rust_llvm_version {} { verbose "could not find rustc" } else { set output [lindex [remote_exec host "$rustc --version --verbose"] 1] + set output [regsub -all "\r\n" $output "\n"] foreach line [split $output \n] { - if {[regexp "LLVM version: (.+)\$" $output ignore version]} { + if {[regexp "LLVM version: (.+)\$" $line ignore version]} { return $version } } |