Skip to content

Commit 37097fb

Browse files
committed
Let compiletest recognize gdb 10.x
git gdb has moved to version 10. My build prints this as its --version: GNU gdb (GDB) 10.0.50.20200420-git Unfortunately this conflicts with this comment in compiletest: // We limit major to 1 digit, otherwise, on openSUSE, we parse the openSUSE version This patch changes the version parsing to follow the GNU coding standard, which accounts for both the openSUSE case as well as handling gdb 10. My debuginfo test run now says: NOTE: compiletest thinks it is using GDB with native rust support NOTE: compiletest thinks it is using GDB version 10000050 ... where previously it failed to find that gdb 10 had rust support.
1 parent 45d050c commit 37097fb

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/tools/compiletest/src/main.rs

+19-3
Original file line numberDiff line numberDiff line change
@@ -831,12 +831,28 @@ fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
831831
// GDB versions look like this: "major.minor.patch?.yyyymmdd?", with both
832832
// of the ? sections being optional
833833

834-
// We will parse up to 3 digits for minor and patch, ignoring the date
835-
// We limit major to 1 digit, otherwise, on openSUSE, we parse the openSUSE version
834+
// We will parse up to 3 digits for each component, ignoring the date
835+
836+
// We skip text in parentheses. This avoids accidentally parsing
837+
// the openSUSE version, which looks like:
838+
// GNU gdb (GDB; openSUSE Leap 15.0) 8.1
839+
// This particular form is documented in the GNU coding standards:
840+
// https://www.gnu.org/prep/standards/html_node/_002d_002dversion.html#g_t_002d_002dversion
836841

837842
// don't start parsing in the middle of a number
838843
let mut prev_was_digit = false;
844+
let mut in_parens = false;
839845
for (pos, c) in full_version_line.char_indices() {
846+
if in_parens {
847+
if c == ')' {
848+
in_parens = false;
849+
}
850+
continue;
851+
} else if c == '(' {
852+
in_parens = true;
853+
continue;
854+
}
855+
840856
if prev_was_digit || !c.is_digit(10) {
841857
prev_was_digit = c.is_digit(10);
842858
continue;
@@ -876,7 +892,7 @@ fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
876892
None => (line, None),
877893
};
878894

879-
if major.len() != 1 || minor.is_empty() {
895+
if minor.is_empty() {
880896
continue;
881897
}
882898

0 commit comments

Comments
 (0)