This is an archive of the discontinued LLVM Phabricator instance.

[lldb][bindings] Fix module_access handling of regex
ClosedPublic

Authored by kastiglione on Sep 1 2022, 10:39 AM.

Details

Summary

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.

Diff Detail

Event Timeline

kastiglione created this revision.Sep 1 2022, 10:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2022, 10:39 AM
kastiglione requested review of this revision.Sep 1 2022, 10:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2022, 10:39 AM
JDevlieghere accepted this revision.Sep 1 2022, 10:41 AM

Makes sense, LGTM.

This revision is now accepted and ready to land.Sep 1 2022, 10:41 AM
mib accepted this revision.Sep 1 2022, 10:44 AM

LGTM! I guess this API was not exercised (since no one noticed the path -> file typo) ... Could you add a test before landing this ? Thanks!

Add a test for subscripting a target.modules using regex

This revision was landed with ongoing or failed builds.Sep 3 2022, 10:33 AM
This revision was automatically updated to reflect the committed changes.