[Lldb-commits] [lldb] 170e1fe - [lldb] Fix regex support in SBTarget.modules_access (#116452)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Nov 18 16:15:45 PST 2024
Author: Dave Lee
Date: 2024-11-18T16:15:41-08:00
New Revision: 170e1fe5a5211420923e32995d8bf3da196c2a54
URL: https://github.com/llvm/llvm-project/commit/170e1fe5a5211420923e32995d8bf3da196c2a54
DIFF: https://github.com/llvm/llvm-project/commit/170e1fe5a5211420923e32995d8bf3da196c2a54.diff
LOG: [lldb] Fix regex support in SBTarget.modules_access (#116452)
First, `SRE_Pattern` does not exist on newer Python's, use
`type(re.compile(''))` like other Python extensions do. The dynamic type
is because some earlier versions of Python 3 do not have `re.Pattern`.
Second, `SBModule` has a `file` property, not a `path` property.
Added:
Modified:
lldb/bindings/interface/SBTargetExtensions.i
lldb/test/API/lang/cpp/stl/TestStdCXXDisassembly.py
Removed:
################################################################################
diff --git a/lldb/bindings/interface/SBTargetExtensions.i b/lldb/bindings/interface/SBTargetExtensions.i
index d756a351a810ab..43125d8970615b 100644
--- a/lldb/bindings/interface/SBTargetExtensions.i
+++ b/lldb/bindings/interface/SBTargetExtensions.i
@@ -79,11 +79,11 @@ STRING_EXTENSION_LEVEL_OUTSIDE(SBTarget, lldb::eDescriptionLevelBrief)
module = self.sbtarget.GetModuleAtIndex(idx)
if module.uuid == key:
return module
- elif type(key) is re.SRE_Pattern:
+ elif isinstance(key, type(re.compile(''))):
matching_modules = []
for idx in range(num_modules):
module = self.sbtarget.GetModuleAtIndex(idx)
- re_match = key.search(module.path.fullpath)
+ re_match = key.search(module.file.fullpath)
if re_match:
matching_modules.append(module)
return matching_modules
diff --git a/lldb/test/API/lang/cpp/stl/TestStdCXXDisassembly.py b/lldb/test/API/lang/cpp/stl/TestStdCXXDisassembly.py
index 06f338b3ed1ded..bcf8735c7c3f98 100644
--- a/lldb/test/API/lang/cpp/stl/TestStdCXXDisassembly.py
+++ b/lldb/test/API/lang/cpp/stl/TestStdCXXDisassembly.py
@@ -3,6 +3,7 @@
"""
import os
+import re
import lldb
from lldbsuite.test.lldbtest import *
import lldbsuite.test.lldbutil as lldbutil
@@ -30,15 +31,11 @@ def test_stdcxx_disasm(self):
self.runCmd("disassemble -n '%s'" % function.GetName())
lib_stdcxx = "FAILHORRIBLYHERE"
- # Iterate through the available modules, looking for stdc++ library...
- for i in range(target.GetNumModules()):
- module = target.GetModuleAtIndex(i)
- fs = module.GetFileSpec()
- if fs.GetFilename().startswith("libstdc++") or fs.GetFilename().startswith(
- "libc++"
- ):
- lib_stdcxx = str(fs)
- break
+ # Find the stdc++ library...
+ stdlib_regex = re.compile(r"/lib(std)?c\+\+")
+ for module in target.module[stdlib_regex]:
+ lib_stdcxx = module.file.fullpath
+ break
# At this point, lib_stdcxx is the full path to the stdc++ library and
# module is the corresponding SBModule.
More information about the lldb-commits
mailing list