LLDB mainline
ScriptedProcess.h
Go to the documentation of this file.
1//===-- ScriptedProcess.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_PROCESS_SCRIPTED_SCRIPTEDPROCESS_H
10#define LLDB_SOURCE_PLUGINS_PROCESS_SCRIPTED_SCRIPTEDPROCESS_H
11
12#include "lldb/Target/Process.h"
15#include "lldb/Utility/State.h"
16#include "lldb/Utility/Status.h"
17
18#include "ScriptedThread.h"
19
20namespace lldb_private {
21class ScriptedProcess : public Process {
22public:
24 lldb::ListenerSP listener_sp,
25 const FileSpec *crash_file_path,
26 bool can_connect);
27
28 static void Initialize();
29
30 static void Terminate();
31
32 static llvm::StringRef GetPluginNameStatic() { return "ScriptedProcess"; }
33
34 static llvm::StringRef GetPluginDescriptionStatic();
35
36 ~ScriptedProcess() override;
37
38 bool CanDebug(lldb::TargetSP target_sp,
39 bool plugin_specified_by_name) override;
40
41 DynamicLoader *GetDynamicLoader() override { return nullptr; }
42
43 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
44
45 Status DoLoadCore() override;
46
47 Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override;
48
49 void DidLaunch() override;
50
51 void DidResume() override;
52
53 Status DoResume(lldb::RunDirection direction) override;
54
56 const ProcessAttachInfo &attach_info) override;
57
58 Status
59 DoAttachToProcessWithName(const char *process_name,
60 const ProcessAttachInfo &attach_info) override;
61
62 void DidAttach(ArchSpec &process_arch) override;
63
64 Status DoDestroy() override;
65
66 void RefreshStateAfterStop() override;
67
68 bool IsAlive() override;
69
70 size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
71 Status &error) override;
72
73 size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
74 Status &error) override;
75
77
79
80 Status
82
83 bool GetProcessInfo(ProcessInstanceInfo &info) override;
84
86 lldb::BinaryInformationLevel info_level) override;
87
89
90 void UpdateQueueListIfNeeded() override;
91
92 void *GetImplementation() override;
93
94 void ForceScriptedState(lldb::StateType state) override {
95 // If we're about to stop, we should fetch the loaded dynamic libraries
96 // dictionary before emitting the private stop event to avoid having the
97 // module loading happen while the process state is changing.
98 if (StateIsStoppedState(state, true))
101 SetPrivateState(state);
102 }
103
104protected:
105 ScriptedProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
106 const ScriptedMetadata &scripted_metadata, Status &error);
107
108 void Clear();
109
110 bool DoUpdateThreadList(ThreadList &old_thread_list,
111 ThreadList &new_thread_list) override;
112
114 MemoryRegionInfo &range_info) override;
115
116 Status DoAttach(const ProcessAttachInfo &attach_info);
117
118private:
119 friend class ScriptedThread;
120
121 inline void CheckScriptedInterface() const {
122 lldbassert(m_interface_up && "Invalid scripted process interface.");
123 }
124
127
128 // Member variables.
131};
132
133} // namespace lldb_private
134
135#endif // LLDB_SOURCE_PLUGINS_PROCESS_SCRIPTED_SCRIPTEDPROCESS_H
static llvm::raw_ostream & error(Stream &strm)
#define lldbassert(x)
Definition LLDBAssert.h:16
An architecture specification class.
Definition ArchSpec.h:32
Class that manages the actual breakpoint that will be inserted into the running program.
A file utility class.
Definition FileSpec.h:57
A class that describes an executable image and its associated object and symbol files.
Definition Module.h:91
Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
Construct with a shared pointer to a target, and the Process listener.
Definition Process.cpp:453
void SetPrivateState(lldb::StateType state)
Definition Process.cpp:1411
friend class DynamicLoader
Definition Process.h:362
Status DoAttachToProcessWithID(lldb::pid_t pid, const ProcessAttachInfo &attach_info) override
Attach to an existing process using a process ID.
bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override
Check if a plug-in instance can debug the file in module.
bool DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override
Update the thread list following process plug-in's specific logic.
size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size, Status &error) override
Actually do the reading of memory from a process.
const ScriptedMetadata m_scripted_metadata
void DidAttach(ArchSpec &process_arch) override
Called after attaching a process.
static llvm::StringRef GetPluginNameStatic()
Status GetMemoryRegions(lldb_private::MemoryRegionInfos &region_list) override
Obtain all the mapped memory regions within this process.
static bool IsScriptLanguageSupported(lldb::ScriptLanguage language)
bool IsAlive() override
Check if a process is still alive.
Status DoAttach(const ProcessAttachInfo &attach_info)
bool GetProcessInfo(ProcessInstanceInfo &info) override
lldb_private::StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos(lldb::BinaryInformationLevel info_level) override
Retrieve a StructuredData dictionary about all of the binaries loaded in the process at this time.
void DidResume() override
Called after resuming a process.
DynamicLoader * GetDynamicLoader() override
Get the dynamic loader plug-in for this process.
Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override
Launch a new process.
size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error) override
Actually do the writing of memory to a process.
Status DoResume(lldb::RunDirection direction) override
Resumes all of a process's threads as configured using the Thread run control functions.
ScriptedProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const ScriptedMetadata &scripted_metadata, Status &error)
lldb::ScriptedProcessInterfaceUP m_interface_up
llvm::StringRef GetPluginName() override
Status EnableBreakpointSite(BreakpointSite *bp_site) override
void ForceScriptedState(lldb::StateType state) override
lldb_private::StructuredData::DictionarySP GetMetadata() override
Fetch process defined metadata.
Status DoAttachToProcessWithName(const char *process_name, const ProcessAttachInfo &attach_info) override
Attach to an existing process using a partial process name.
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path, bool can_connect)
static llvm::StringRef GetPluginDescriptionStatic()
ScriptedProcessInterface & GetInterface() const
void DidLaunch() override
Called after launching a process.
Status DoGetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) override
DoGetMemoryRegionInfo is called by GetMemoryRegionInfo after it has removed non address bits from loa...
An error handling class.
Definition Status.h:118
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
A class that represents a running process on the host machine.
bool StateIsStoppedState(lldb::StateType state, bool must_exist)
Check if a state represents a state where the process or thread is stopped.
Definition State.cpp:89
ScriptLanguage
Script interpreter types.
RunDirection
Execution directions.
StateType
Process and Thread States.
std::shared_ptr< lldb_private::Process > ProcessSP
uint64_t pid_t
Definition lldb-types.h:83
std::shared_ptr< lldb_private::Listener > ListenerSP
uint64_t addr_t
Definition lldb-types.h:80
BinaryInformationLevel
When the Process plugin can retrieve information about all binaries loaded in the target process,...
@ eBinaryInformationLevelFull
std::shared_ptr< lldb_private::Target > TargetSP
std::unique_ptr< lldb_private::ScriptedProcessInterface > ScriptedProcessInterfaceUP