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_SCRIPTED_PROCESS_H
10#define LLDB_SOURCE_PLUGINS_SCRIPTED_PROCESS_H
11
12#include "lldb/Target/Process.h"
15#include "lldb/Utility/Status.h"
16
17#include "ScriptedThread.h"
18
19#include <mutex>
20
21namespace lldb_private {
22class ScriptedProcess : public Process {
23public:
24 static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
25 lldb::ListenerSP listener_sp,
26 const FileSpec *crash_file_path,
27 bool can_connect);
28
29 static void Initialize();
30
31 static void Terminate();
32
33 static llvm::StringRef GetPluginNameStatic() { return "ScriptedProcess"; }
34
35 static llvm::StringRef GetPluginDescriptionStatic();
36
37 ~ScriptedProcess() override;
38
39 bool CanDebug(lldb::TargetSP target_sp,
40 bool plugin_specified_by_name) override;
41
42 DynamicLoader *GetDynamicLoader() override { return nullptr; }
43
44 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
45
46 Status DoLoadCore() override;
47
48 Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override;
49
50 void DidLaunch() override;
51
52 Status DoResume() override;
53
55 const ProcessAttachInfo &attach_info) override;
56
57 Status
58 DoAttachToProcessWithName(const char *process_name,
59 const ProcessAttachInfo &attach_info) override;
60
61 void DidAttach(ArchSpec &process_arch) override;
62
63 Status DoDestroy() override;
64
65 void RefreshStateAfterStop() override;
66
67 bool IsAlive() override;
68
69 size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
70 Status &error) override;
71
72 size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
73 Status &error) override;
74
76
77 Status
79
80 bool GetProcessInfo(ProcessInstanceInfo &info) override;
81
84
86
87 void UpdateQueueListIfNeeded() override;
88
89 void *GetImplementation() override;
90
91protected:
92 ScriptedProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
93 const ScriptedMetadata &scripted_metadata, Status &error);
94
95 Status DoStop();
96
97 void Clear();
98
99 bool DoUpdateThreadList(ThreadList &old_thread_list,
100 ThreadList &new_thread_list) override;
101
103 MemoryRegionInfo &range_info) override;
104
105 Status DoAttach(const ProcessAttachInfo &attach_info);
106
107private:
108 friend class ScriptedThread;
109
110 inline void CheckScriptedInterface() const {
111 lldbassert(m_interface_up && "Invalid scripted process interface.");
112 }
113
116
117 // Member variables.
119 lldb::ScriptedProcessInterfaceUP m_interface_up;
120};
121
122} // namespace lldb_private
123
124#endif // LLDB_SOURCE_PLUGINS_SCRIPTED_PROCESS_H
static llvm::raw_ostream & error(Stream &strm)
#define lldbassert(x)
Definition: LLDBAssert.h:15
An architecture specification class.
Definition: ArchSpec.h:32
A plug-in interface definition class for dynamic loaders.
Definition: DynamicLoader.h:52
A file utility class.
Definition: FileSpec.h:56
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:88
A plug-in interface definition class for debugging a process.
Definition: Process.h:343
Status DoResume() override
Resumes all of a process's threads as configured using the Thread run control functions.
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.
lldb_private::StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos() override
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
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.
lldb::ScriptedProcessInterfaceUP m_interface_up
llvm::StringRef GetPluginName() 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:44
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
ScriptLanguage
Script interpreter types.
uint64_t pid_t
Definition: lldb-types.h:85
uint64_t addr_t
Definition: lldb-types.h:83