LLDB
mainline
llvm-project
lldb
source
Plugins
ScriptInterpreter
Python
Interfaces
ScriptedStopHookPythonInterface.cpp
Go to the documentation of this file.
1
//===-- ScriptedStopHookPythonInterface.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-python.h
"
10
11
#include "
lldb/Core/PluginManager.h
"
12
#include "
lldb/Target/ExecutionContext.h
"
13
#include "
lldb/Target/Target.h
"
14
#include "
lldb/Utility/Log.h
"
15
#include "
lldb/lldb-enumerations.h
"
16
17
#include "
../SWIGPythonBridge.h
"
18
#include "
../ScriptInterpreterPythonImpl.h
"
19
#include "
ScriptedStopHookPythonInterface.h
"
20
21
using namespace
lldb
;
22
using namespace
lldb_private
;
23
using namespace
lldb_private::python
;
24
25
ScriptedStopHookPythonInterface::ScriptedStopHookPythonInterface
(
26
ScriptInterpreterPythonImpl
&interpreter)
27
:
ScriptedStopHookInterface
(),
ScriptedPythonInterface
(interpreter) {}
28
29
llvm::Expected<StructuredData::GenericSP>
30
ScriptedStopHookPythonInterface::CreatePluginObject
(
31
const
ScriptedMetadata
&scripted_metadata,
lldb::TargetSP
target_sp) {
32
StructuredDataImpl
args_sp(scripted_metadata.
GetArgsSP
());
33
return
ScriptedPythonInterface::CreatePluginObject
(scripted_metadata,
nullptr
,
34
target_sp, args_sp);
35
}
36
37
llvm::Expected<bool>
38
ScriptedStopHookPythonInterface::HandleStop
(
ExecutionContext
&exe_ctx,
39
lldb::StreamSP
& output_sp) {
40
ExecutionContextRefSP
exe_ctx_ref_sp =
41
std::make_shared<ExecutionContextRef>(exe_ctx);
42
Status
error
;
43
StructuredData::ObjectSP
obj =
Dispatch
(
"handle_stop"
,
error
, exe_ctx_ref_sp, output_sp);
44
45
if
(!
ScriptedInterface::CheckStructuredDataObject
(LLVM_PRETTY_FUNCTION, obj,
46
error
)) {
47
if
(!obj)
48
return
true
;
49
return
error
.ToError();
50
}
51
52
return
obj->GetBooleanValue();
53
}
54
55
56
void
ScriptedStopHookPythonInterface::Initialize
() {
57
const
std::vector<llvm::StringRef> ci_usages = {
58
"target stop-hook add -P <script-name> [-k key -v value ...]"
};
59
const
std::vector<llvm::StringRef> api_usages = {};
60
PluginManager::RegisterPlugin
(
61
GetPluginNameStatic
(),
62
llvm::StringRef(
"Perform actions whenever the process stops, before control is returned to the user."
),
63
CreateInstance
,
eScriptLanguagePython
, {ci_usages, api_usages});
64
}
65
66
void
ScriptedStopHookPythonInterface::Terminate
() {
67
PluginManager::UnregisterPlugin
(
CreateInstance
);
68
}
error
static llvm::raw_ostream & error(Stream &strm)
Definition
CommandReturnObject.cpp:18
ExecutionContext.h
Log.h
PluginManager.h
SWIGPythonBridge.h
ScriptInterpreterPythonImpl.h
ScriptedStopHookPythonInterface.h
Target.h
lldb_private::ExecutionContext
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Definition
ExecutionContext.h:294
lldb_private::PluginManager::RegisterPlugin
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
Definition
PluginManager.cpp:672
lldb_private::PluginManager::UnregisterPlugin
static bool UnregisterPlugin(ABICreateInstance create_callback)
Definition
PluginManager.cpp:678
lldb_private::ScriptInterpreterPythonImpl
Definition
ScriptInterpreterPythonImpl.h:25
lldb_private::ScriptedInterface::CheckStructuredDataObject
static bool CheckStructuredDataObject(llvm::StringRef caller, T obj, Status &error)
Definition
ScriptedInterface.h:81
lldb_private::ScriptedInterface::CreateInstance
static bool CreateInstance(lldb::ScriptLanguage language, ScriptedInterfaceUsages usages)
Definition
ScriptedInterface.h:98
lldb_private::ScriptedMetadata
Definition
ScriptedMetadata.h:18
lldb_private::ScriptedMetadata::GetArgsSP
StructuredData::DictionarySP GetArgsSP() const
Definition
ScriptedMetadata.h:38
lldb_private::ScriptedPythonInterface::ScriptedPythonInterface
ScriptedPythonInterface(ScriptInterpreterPythonImpl &interpreter)
Definition
ScriptedPythonInterface.cpp:24
lldb_private::ScriptedPythonInterface::Dispatch
T Dispatch(llvm::StringRef method_name, Status &error, Args &&...args)
Definition
ScriptedPythonInterface.h:501
lldb_private::ScriptedPythonInterface::CreatePluginObject
llvm::Expected< StructuredData::GenericSP > CreatePluginObject(const ScriptedMetadata &scripted_metadata, StructuredData::Generic *script_obj, Args... args)
Definition
ScriptedPythonInterface.h:171
lldb_private::ScriptedStopHookInterface
Definition
ScriptedStopHookInterface.h:17
lldb_private::ScriptedStopHookPythonInterface::GetPluginNameStatic
static llvm::StringRef GetPluginNameStatic()
Definition
ScriptedStopHookPythonInterface.h:39
lldb_private::ScriptedStopHookPythonInterface::CreatePluginObject
llvm::Expected< StructuredData::GenericSP > CreatePluginObject(const ScriptedMetadata &scripted_metadata, lldb::TargetSP target_sp) override
Definition
ScriptedStopHookPythonInterface.cpp:30
lldb_private::ScriptedStopHookPythonInterface::Initialize
static void Initialize()
Definition
ScriptedStopHookPythonInterface.cpp:56
lldb_private::ScriptedStopHookPythonInterface::ScriptedStopHookPythonInterface
ScriptedStopHookPythonInterface(ScriptInterpreterPythonImpl &interpreter)
Definition
ScriptedStopHookPythonInterface.cpp:25
lldb_private::ScriptedStopHookPythonInterface::HandleStop
llvm::Expected< bool > HandleStop(ExecutionContext &exe_ctx, lldb::StreamSP &output_sp) override
"handle_stop" will return a bool with the meaning "should_stop"... If nothing is returned,...
Definition
ScriptedStopHookPythonInterface.cpp:38
lldb_private::ScriptedStopHookPythonInterface::Terminate
static void Terminate()
Definition
ScriptedStopHookPythonInterface.cpp:66
lldb_private::Status
An error handling class.
Definition
Status.h:118
lldb_private::StructuredDataImpl
Definition
StructuredDataImpl.h:26
lldb_private::StructuredData::ObjectSP
std::shared_ptr< Object > ObjectSP
Definition
StructuredData.h:66
lldb-enumerations.h
lldb-python.h
lldb_private::python
Definition
SBBreakpoint.h:18
lldb_private
A class that represents a running process on the host machine.
Definition
SBAddressRange.h:14
lldb
Definition
SBAddress.h:15
lldb::eScriptLanguagePython
@ eScriptLanguagePython
Definition
lldb-enumerations.h:232
lldb::StreamSP
std::shared_ptr< lldb_private::Stream > StreamSP
Definition
lldb-forward.h:452
lldb::TargetSP
std::shared_ptr< lldb_private::Target > TargetSP
Definition
lldb-forward.h:470
lldb::ExecutionContextRefSP
std::shared_ptr< lldb_private::ExecutionContextRef > ExecutionContextRefSP
Definition
lldb-forward.h:358
Generated on
for LLDB by
1.14.0