Skip to content

Commit 00b2a9c

Browse files
committed
[cross-project-tests] Make GDB version string parsing more robust
Follow up to D118468 (5257efd). When built from source, gdb's version string looks like this: GNU gdb (GDB) 9.2 ... But for installed versions it looks different. E.g. GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2 ... Use a regex rather than str.parition in the version string parsing in order to handle this case too.
1 parent 29caa85 commit 00b2a9c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cross-project-tests/lit.cfg.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ def get_gdb_version_string():
216216
if len(gdb_vers_lines) < 1:
217217
print("Unkown GDB version format (too few lines)", file=sys.stderr)
218218
return None
219-
string = gdb_vers_lines[0].strip().partition('GNU gdb (GDB) ')[2]
220-
if len(string) == 0:
221-
print("Unkown GDB version format", file=sys.stderr)
219+
match = re.search('GNU gdb \(.*?\) ((\d|\.)+)', gdb_vers_lines[0].strip())
220+
if match is None:
221+
print(f"Unkown GDB version format: {gdb_vers_lines[0]}", file=sys.stderr)
222222
return None
223-
return string
223+
return match.group(1)
224224

225225
def get_clang_default_dwarf_version_string(triple):
226226
"""Return the default dwarf version string for clang on this (host) platform

0 commit comments

Comments
 (0)