[lldb][bindings] Fix module_access handling of regex
Fixes broken support for: `target.module[re.compile("libFoo")]`
There were two issues:
1. The type check was expecting `re.SRE_Pattern`
2. The expression to search the module path had a typo
In the first case, `re.SRE_Pattern` does not exist in Python 3, and is replaced
with `re.Pattern`.
While editing this code, I changed the type checks to us `isinstance`, which is
the conventional way of type checking.
From the docs on `type()`:
> The `isinstance()` built-in function is recommended for testing the type of an object, because it takes subclasses into account.
Differential Revision: https://reviews.llvm.org/D133130
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
Test SBTarget APIs.
|
||||
"""
|
||||
|
||||
import re
|
||||
import unittest2
|
||||
import os
|
||||
import lldb
|
||||
@@ -516,3 +517,14 @@ class TargetAPITestCase(TestBase):
|
||||
module = target.GetModuleAtIndex(i)
|
||||
self.assertTrue(target.IsLoaded(module), "Running the target should "
|
||||
"have loaded its modules.")
|
||||
|
||||
def test_module_subscript_regex(self):
|
||||
"""Exercise SBTarget.module subscripting with regex."""
|
||||
self.build()
|
||||
exe = self.getBuildArtifact("a.out")
|
||||
target = self.dbg.CreateTarget(exe)
|
||||
self.assertTrue(target, VALID_TARGET)
|
||||
modules = target.module[re.compile(r"/a[.]out$")]
|
||||
self.assertEqual(len(modules), 1)
|
||||
exe_mod = modules[0]
|
||||
self.assertEqual(exe_mod.file.fullpath, exe)
|
||||
|
||||
Reference in New Issue
Block a user