LLDB mainline
OperatingSystemPythonInterface.cpp
Go to the documentation of this file.
1//===-- ScriptedThreadPythonInterface.cpp ---------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "lldb/Host/Config.h"
11#include "lldb/Utility/Log.h"
13
14#if LLDB_ENABLE_PYTHON
15
16// LLDB Python header must be included first
17#include "../lldb-python.h"
18
19#include "../SWIGPythonBridge.h"
20#include "../ScriptInterpreterPythonImpl.h"
22
23using namespace lldb;
24using namespace lldb_private;
25using namespace lldb_private::python;
26using Locker = ScriptInterpreterPythonImpl::Locker;
27
28OperatingSystemPythonInterface::OperatingSystemPythonInterface(
29 ScriptInterpreterPythonImpl &interpreter)
30 : OperatingSystemInterface(), ScriptedThreadPythonInterface(interpreter) {}
31
32llvm::Expected<StructuredData::GenericSP>
33OperatingSystemPythonInterface::CreatePluginObject(
34 llvm::StringRef class_name, ExecutionContext &exe_ctx,
36 return ScriptedPythonInterface::CreatePluginObject(class_name, nullptr,
37 exe_ctx.GetProcessSP());
38}
39
41OperatingSystemPythonInterface::CreateThread(lldb::tid_t tid,
42 lldb::addr_t context) {
44 StructuredData::DictionarySP dict = Dispatch<StructuredData::DictionarySP>(
45 "create_thread", error, tid, context);
46
47 if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, dict,
48 error))
49 return {};
50
51 return dict;
52}
53
54StructuredData::ArraySP OperatingSystemPythonInterface::GetThreadInfo() {
57 Dispatch<StructuredData::ArraySP>("get_thread_info", error);
58
59 if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, arr,
60 error))
61 return {};
62
63 return arr;
64}
65
66StructuredData::DictionarySP OperatingSystemPythonInterface::GetRegisterInfo() {
67 return ScriptedThreadPythonInterface::GetRegisterInfo();
68}
69
70std::optional<std::string>
71OperatingSystemPythonInterface::GetRegisterContextForTID(lldb::tid_t tid) {
73 StructuredData::ObjectSP obj = Dispatch("get_register_data", error, tid);
74
75 if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,
76 error))
77 return {};
78
79 return obj->GetAsString()->GetValue().str();
80}
81
82#endif
static llvm::raw_ostream & error(Stream &strm)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
const lldb::ProcessSP & GetProcessSP() const
Get accessor to get the process shared pointer.
An error handling class.
Definition: Status.h:44
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
std::shared_ptr< Array > ArraySP
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Definition: SBAddress.h:15
uint64_t addr_t
Definition: lldb-types.h:79
uint64_t tid_t
Definition: lldb-types.h:82