Skip to content

Commit 8e1c14a

Browse files
fixup! Add python binding methods
1 parent ac17112 commit 8e1c14a

File tree

6 files changed

+21
-5
lines changed

6 files changed

+21
-5
lines changed

lldb/include/lldb/Interpreter/Interfaces/OperatingSystemInterface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class OperatingSystemInterface : virtual public ScriptedThreadInterface {
2727
virtual std::optional<std::string> GetRegisterContextForTID(lldb::tid_t tid) {
2828
return std::nullopt;
2929
}
30+
31+
virtual std::optional<bool> DoesPluginReportAllThreads() { return {}; }
3032
};
3133
} // namespace lldb_private
3234

lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,10 @@ lldb::ThreadSP OperatingSystemPython::CreateThread(lldb::tid_t tid,
387387
}
388388

389389
bool OperatingSystemPython::DoesPluginReportAllThreads() {
390+
// If the python plugin has a "DoesPluginReportAllThreads" method, use it.
391+
if (std::optional<bool> plugin_answer =
392+
m_operating_system_interface_sp->DoesPluginReportAllThreads())
393+
return *plugin_answer;
390394
return m_process->GetOSPluginReportsAllThreads();
391395
}
392396

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/OperatingSystemPythonInterface.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ OperatingSystemPythonInterface::GetRegisterContextForTID(lldb::tid_t tid) {
8282
return obj->GetAsString()->GetValue().str();
8383
}
8484

85+
std::optional<bool> OperatingSystemPythonInterface::DoesPluginReportAllThreads() {
86+
Status error;
87+
StructuredData::ObjectSP obj = Dispatch("does_plugin_report_all_threads", error);
88+
if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,
89+
error))
90+
return {};
91+
92+
return obj->GetAsBoolean()->GetValue();
93+
}
94+
8595
void OperatingSystemPythonInterface::Initialize() {
8696
const std::vector<llvm::StringRef> ci_usages = {
8797
"settings set target.process.python-os-plugin-path <script-path>",

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/OperatingSystemPythonInterface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class OperatingSystemPythonInterface
4545

4646
std::optional<std::string> GetRegisterContextForTID(lldb::tid_t tid) override;
4747

48+
std::optional<bool> DoesPluginReportAllThreads() override;
49+
4850
static void Initialize();
4951

5052
static void Terminate();

lldb/test/API/functionalities/plugins/python_os_plugin/stepping_plugin_threads/TestOSPluginStepping.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ def is_os_thread(self, thread):
4040
def run_python_os_step_missing_thread(self, do_prune):
4141
"""Test that the Python operating system plugin works correctly"""
4242

43-
# Our OS plugin does NOT report all threads:
44-
result = self.dbg.HandleCommand(
45-
"settings set process.experimental.os-plugin-reports-all-threads false"
46-
)
47-
4843
python_os_plugin_path = os.path.join(self.getSourceDir(), "operating_system.py")
4944
(target, self.process, thread, thread_bkpt) = lldbutil.run_to_source_breakpoint(
5045
self, "first stop in thread - do a step out", self.main_file

lldb/test/API/functionalities/plugins/python_os_plugin/stepping_plugin_threads/operating_system.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def __init__(self, process):
3434
if not self.g_value.IsValid():
3535
print("Could not find g_value")
3636

37+
def does_plugin_report_all_threads(self):
38+
return False
39+
3740
def create_thread(self, tid, context):
3841
print("Called create thread with tid: ", tid)
3942
return None

0 commit comments

Comments
 (0)