[Lldb-commits] [PATCH] D146152: Add __lldb_init_module_with_target for use when sourcing modules for a target

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 15 10:16:06 PDT 2023


jingham created this revision.
jingham added reviewers: clayborg, JDevlieghere, jasonmolenda, bulbazord.
Herald added a project: All.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

We load python modules in two main ways: through `command script import` and automatically when we read in a dSYM and find a scripting resource in the dSYM.  The latter case has a slight flaw currently which is that when the scripting resource from the dSYM is loaded, the target it's being loaded for is in the process of being created, so the module being imported has no way of knowing what that target is.  Even if the debugger had selected this new target before loading the scripting resource, it would still be relying on that being the "currently selected target" which is racy.  It's better to do this explicitly.

This patch adds a detector for an optional:

__lldb_init_module_with_target

and if that is present it will run that routine - passing in the target - before running __lldb_init_module.

I considered making an overload of __lldb_init_module that also passed in the target, but that trick seems to end up being confusing.  And this will allow more convenient "dual use" modules, where if you are being sourced for a target you can prime the state for the regular init, and if not, then run the regular init.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146152

Files:
  lldb/bindings/python/python-wrapper.swig
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/source/Core/Module.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/test/API/commands/add-dsym/uuid/TestAddDsymCommand.py
  lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146152.505546.patch
Type: text/x-patch
Size: 8214 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230315/9c99d463/attachment-0001.bin>


More information about the lldb-commits mailing list