about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-04-24 13:14:22 +0200
committerGitHub <noreply@github.com>2020-04-24 13:14:22 +0200
commit715948eb51920d5e4a791e4757652daf9fa925ed (patch)
treefb9681a1a7bccb6f137488b4d56b3508ecc48800
parent2846aa2f2f7adf764aaae1ed8221fc8084973db7 (diff)
parent90b4a97efe2af42bd4e124ede1e802f47f1fbc08 (diff)
downloadrust-715948eb51920d5e4a791e4757652daf9fa925ed.tar.gz
rust-715948eb51920d5e4a791e4757652daf9fa925ed.zip
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.
-rw-r--r--src/tools/compiletest/src/main.rs22
-rw-r--r--src/tools/compiletest/src/tests.rs4
2 files changed, 21 insertions, 5 deletions
diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs
index 028483b7d95..3a8a5491255 100644
--- a/src/tools/compiletest/src/main.rs
+++ b/src/tools/compiletest/src/main.rs
@@ -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;
@@ -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;
         }
 
diff --git a/src/tools/compiletest/src/tests.rs b/src/tools/compiletest/src/tests.rs
index 388ad75757f..31c151d29e9 100644
--- a/src/tools/compiletest/src/tests.rs
+++ b/src/tools/compiletest/src/tests.rs
@@ -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",