Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let compiletest recognize gdb 10.x #71428

Merged
merged 2 commits into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/tools/compiletest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,12 +831,28 @@ fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
// GDB versions look like this: "major.minor.patch?.yyyymmdd?", with both
// of the ? sections being optional

// We will parse up to 3 digits for minor and patch, ignoring the date
// We limit major to 1 digit, otherwise, on openSUSE, we parse the openSUSE version
// We will parse up to 3 digits for each component, ignoring the date

// We skip text in parentheses. This avoids accidentally parsing
// the openSUSE version, which looks like:
// GNU gdb (GDB; openSUSE Leap 15.0) 8.1
// This particular form is documented in the GNU coding standards:
// https://www.gnu.org/prep/standards/html_node/_002d_002dversion.html#g_t_002d_002dversion

// don't start parsing in the middle of a number
let mut prev_was_digit = false;
let mut in_parens = false;
for (pos, c) in full_version_line.char_indices() {
if in_parens {
if c == ')' {
in_parens = false;
}
continue;
} else if c == '(' {
in_parens = true;
continue;
}

if prev_was_digit || !c.is_digit(10) {
prev_was_digit = c.is_digit(10);
continue;
Expand Down Expand Up @@ -876,7 +892,7 @@ fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
None => (line, None),
};

if major.len() != 1 || minor.is_empty() {
if minor.is_empty() {
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ fn test_extract_gdb_version() {
)*}}}

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

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

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