LLDB mainline
ScriptedHookPythonInterface.h
Go to the documentation of this file.
1//===-- ScriptedHookPythonInterface.h ---------------------------*- C++ -*-===//
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#ifndef LLDB_SOURCE_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDHOOKPYTHONINTERFACE_H
10#define LLDB_SOURCE_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDHOOKPYTHONINTERFACE_H
11
13
15
16namespace lldb_private {
19 public PluginInterface {
20public:
22
23 llvm::Expected<StructuredData::GenericSP>
24 CreatePluginObject(const ScriptedMetadata &scripted_metadata,
25 lldb::TargetSP target_sp) override;
26
27 /// `handle_stop` is required so a hook can always be attached via
28 /// `target stop-hook add -P`. `handle_module_loaded` and
29 /// `handle_module_unloaded` are optional; if a hook doesn't implement
30 /// them, the corresponding events are simply not delivered.
31 llvm::SmallVector<AbstractMethodRequirement>
33 return llvm::SmallVector<AbstractMethodRequirement>({{"handle_stop", 2}});
34 }
35
36 /// Check which of the three hook methods the Python class implements.
37 SupportedHookMethods GetSupportedMethods() override;
38
39 void HandleModuleLoaded(lldb::StreamSP &output_sp) override;
40 void HandleModuleUnloaded(lldb::StreamSP &output_sp) override;
41 llvm::Expected<bool> HandleStop(ExecutionContext &exe_ctx,
42 lldb::StreamSP &output_sp) override;
43
44 static void Initialize();
45 static void Terminate();
46
47 static llvm::StringRef GetPluginNameStatic() {
48 return "ScriptedHookPythonInterface";
49 }
50
51 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
52};
53} // namespace lldb_private
54
55#endif // LLDB_SOURCE_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDHOOKPYTHONINTERFACE_H
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
SupportedHookMethods GetSupportedMethods() override
Check which of the three hook methods the Python class implements.
llvm::SmallVector< AbstractMethodRequirement > GetAbstractMethodRequirements() const override
handle_stop is required so a hook can always be attached via target stop-hook add -P.
void HandleModuleUnloaded(lldb::StreamSP &output_sp) override
Called when modules are unloaded from the target. Optional.
void HandleModuleLoaded(lldb::StreamSP &output_sp) override
Called when modules are loaded into the target.
llvm::Expected< StructuredData::GenericSP > CreatePluginObject(const ScriptedMetadata &scripted_metadata, lldb::TargetSP target_sp) override
llvm::Expected< bool > HandleStop(ExecutionContext &exe_ctx, lldb::StreamSP &output_sp) override
Called when the process stops.
ScriptedHookPythonInterface(ScriptInterpreterPythonImpl &interpreter)
ScriptedPythonInterface(ScriptInterpreterPythonImpl &interpreter)
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::Stream > StreamSP
std::shared_ptr< lldb_private::Target > TargetSP