Skip to content

Commit 715948e

Browse files
authored
Rollup merge of #71428 - tromey:gdb-10-parsing, r=tromey
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.
2 parents 2846aa2 + 90b4a97 commit 715948e

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
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

src/tools/compiletest/src/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ fn test_extract_gdb_version() {
77
)*}}}
88

99
test! {
10-
7000001: "GNU gdb (GDB) CentOS (7.0.1-45.el5.centos)",
10+
7000001: "GNU gdb (GDB) CentOS 7.0.1-45.el5.centos",
1111

12-
7002000: "GNU gdb (GDB) Red Hat Enterprise Linux (7.2-90.el6)",
12+
7002000: "GNU gdb (GDB) Red Hat Enterprise Linux 7.2-90.el6",
1313

1414
7004000: "GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04",
1515
7004001: "GNU gdb (GDB) 7.4.1-debian",

0 commit comments

Comments
 (0)