From 59ed52f4026dee199201bc6dc80f5a5e5ad378c7 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 26 Sep 2019 16:54:13 +0200 Subject: [PATCH] bpo-38239: Fix test_gdb for Link Time Optimization (LTO) (GH-16422) (cherry picked from commit 64b4a3a2deabcd4103fac2759a311fe94159b4d1) Co-authored-by: Victor Stinner --- Lib/test/test_gdb.py | 11 +++++++++-- .../Tests/2019-09-26-15-48-36.bpo-38239.MfoVzY.rst | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Tests/2019-09-26-15-48-36.bpo-38239.MfoVzY.rst diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py index e07d3273a4552d..e1060330550e34 100644 --- a/Lib/test/test_gdb.py +++ b/Lib/test/test_gdb.py @@ -255,8 +255,15 @@ def get_gdb_repr(self, source, # gdb can insert additional '\n' and space characters in various places # in its output, depending on the width of the terminal it's connected # to (using its "wrap_here" function) - m = re.match(r'.*#0\s+builtin_id\s+\(self\=.*,\s+v=\s*(.*?)?\)\s+at\s+\S*Python/bltinmodule.c.*', - gdb_output, re.DOTALL) + m = re.search( + # Match '#0 builtin_id(self=..., v=...)' + r'#0\s+builtin_id\s+\(self\=.*,\s+v=\s*(.*?)?\)' + # Match ' at Python/bltinmodule.c'. + # bpo-38239: builtin_id() is defined in Python/bltinmodule.c, + # but accept any "Directory\file.c" to support Link Time + # Optimization (LTO). + r'\s+at\s+\S*[A-Za-z]+/[A-Za-z0-9_-]+\.c', + gdb_output, re.DOTALL) if not m: self.fail('Unexpected gdb output: %r\n%s' % (gdb_output, gdb_output)) return m.group(1), gdb_output diff --git a/Misc/NEWS.d/next/Tests/2019-09-26-15-48-36.bpo-38239.MfoVzY.rst b/Misc/NEWS.d/next/Tests/2019-09-26-15-48-36.bpo-38239.MfoVzY.rst new file mode 100644 index 00000000000000..f79da29fa18288 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2019-09-26-15-48-36.bpo-38239.MfoVzY.rst @@ -0,0 +1 @@ +Fix test_gdb for Link Time Optimization (LTO) builds.