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"
14 #include "lldb/Utility/Status.h"
15 
16 #include "ScriptedThread.h"
17 
18 #include <mutex>
19 
20 namespace lldb_private {
21 
22 class ScriptedProcess : public Process {
23 protected:
25  public:
26  ScriptedProcessInfo(const ProcessLaunchInfo &launch_info) {
29  }
30 
33 
34  private:
37  };
38 
39 public:
40  static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
41  lldb::ListenerSP listener_sp,
42  const FileSpec *crash_file_path,
43  bool can_connect);
44 
45  static void Initialize();
46 
47  static void Terminate();
48 
49  static llvm::StringRef GetPluginNameStatic() { return "ScriptedProcess"; }
50 
51  static llvm::StringRef GetPluginDescriptionStatic();
52 
53  ~ScriptedProcess() override;
54 
55  bool CanDebug(lldb::TargetSP target_sp,
56  bool plugin_specified_by_name) override;
57 
58  DynamicLoader *GetDynamicLoader() override { return nullptr; }
59 
60  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
61 
62  SystemRuntime *GetSystemRuntime() override { return nullptr; }
63 
64  Status DoLoadCore() override;
65 
66  Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override;
67 
68  void DidLaunch() override;
69 
70  Status DoResume() override;
71 
72  Status DoDestroy() override;
73 
74  void RefreshStateAfterStop() override;
75 
76  bool IsAlive() override;
77 
78  size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
79  Status &error) override;
80 
82 
83  Status
85 
86  bool GetProcessInfo(ProcessInstanceInfo &info) override;
87 
90 
91 protected:
92  ScriptedProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
93  const ScriptedProcess::ScriptedProcessInfo &launch_info,
94  Status &error);
95 
96  Status DoStop();
97 
98  void Clear();
99 
100  bool DoUpdateThreadList(ThreadList &old_thread_list,
101  ThreadList &new_thread_list) override;
102 
104  MemoryRegionInfo &range_info) override;
105 
106 private:
107  friend class ScriptedThread;
108 
109  void CheckInterpreterAndScriptObject() const;
111  static bool IsScriptLanguageSupported(lldb::ScriptLanguage language);
112 
113  // Member variables.
117  //@}
118 };
119 
120 } // namespace lldb_private
121 
122 #endif // LLDB_SOURCE_PLUGINS_SCRIPTED_PROCESS_H
lldb_private::ScriptedProcess::GetDynamicLoader
DynamicLoader * GetDynamicLoader() override
Get the dynamic loader plug-in for this process.
Definition: ScriptedProcess.h:58
lldb_private::ProcessInstanceInfo
Definition: ProcessInfo.h:106
lldb::ScriptLanguage
ScriptLanguage
Script interpreter types.
Definition: lldb-enumerations.h:216
lldb_private::ArchSpec
Definition: ArchSpec.h:32
lldb_private::ScriptedProcess::ScriptedProcessInfo::m_class_name
std::string m_class_name
Definition: ScriptedProcess.h:35
lldb_private::ScriptedProcess::GetInterface
ScriptedProcessInterface & GetInterface() const
Definition: ScriptedProcess.cpp:488
lldb_private::ScriptedProcess::CreateInstance
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path, bool can_connect)
Definition: ScriptedProcess.cpp:53
lldb_private::ScriptedProcess::DoDestroy
Status DoDestroy() override
Definition: ScriptedProcess.cpp:215
lldb_private::Process
Definition: Process.h:338
lldb_private::ScriptedProcess::DoLoadCore
Status DoLoadCore() override
Definition: ScriptedProcess.cpp:142
lldb_private::Module
Definition: Module.h:85
lldb_private::SystemRuntime
Definition: SystemRuntime.h:43
lldb_private::ScriptedProcess::GetPluginNameStatic
static llvm::StringRef GetPluginNameStatic()
Definition: ScriptedProcess.h:49
lldb_private::MemoryRegionInfo
Definition: MemoryRegionInfo.h:21
lldb_private::ScriptedProcess::DoUpdateThreadList
bool DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override
Update the thread list following process plug-in's specific logic.
Definition: ScriptedProcess.cpp:283
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::ScriptedProcess::GetProcessInfo
bool GetProcessInfo(ProcessInstanceInfo &info) override
Definition: ScriptedProcess.cpp:388
lldb_private::ScriptedProcess::DidLaunch
void DidLaunch() override
Called after launching a process.
Definition: ScriptedProcess.cpp:170
lldb_private::ScriptedProcess::GetPluginDescriptionStatic
static llvm::StringRef GetPluginDescriptionStatic()
Definition: ScriptedProcess.cpp:33
lldb_private::ScriptedProcess::Clear
void Clear()
Definition: ScriptedProcess.cpp:281
lldb_private::ScriptedProcess::IsScriptLanguageSupported
static bool IsScriptLanguageSupported(lldb::ScriptLanguage language)
Definition: ScriptedProcess.cpp:41
lldb_private::ScriptedProcess::CanDebug
bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override
Check if a plug-in instance can debug the file in module.
Definition: ScriptedProcess.cpp:77
Process.h
lldb_private::ScriptedProcess::DoReadMemory
size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size, Status &error) override
Actually do the reading of memory from a process.
Definition: ScriptedProcess.cpp:223
lldb_private::ScriptedProcess::ScriptedProcessInfo::m_args_sp
StructuredData::DictionarySP m_args_sp
Definition: ScriptedProcess.h:36
lldb_private::FileSpec
Definition: FileSpec.h:55
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::ScriptedProcess::RefreshStateAfterStop
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
Definition: ScriptedProcess.cpp:382
lldb_private::ScriptedProcess::ScriptedProcessInfo::ScriptedProcessInfo
ScriptedProcessInfo(const ProcessLaunchInfo &launch_info)
Definition: ScriptedProcess.h:26
lldb_private::ProcessLaunchInfo::GetScriptedProcessClassName
std::string GetScriptedProcessClassName() const
Definition: ProcessLaunchInfo.h:151
lldb_private::ScriptedProcess::ScriptedProcess
ScriptedProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const ScriptedProcess::ScriptedProcessInfo &launch_info, Status &error)
Definition: ScriptedProcess.cpp:82
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
lldb_private::StructuredData::ObjectSP
std::shared_ptr< Object > ObjectSP
Definition: StructuredData.h:59
lldb_private::MemoryRegionInfos
Definition: MemoryRegionInfo.h:172
lldb_private::ScriptedProcess::GetArchitecture
ArchSpec GetArchitecture()
Definition: ScriptedProcess.cpp:245
lldb_private::ProcessLaunchInfo::GetScriptedProcessDictionarySP
lldb_private::StructuredData::DictionarySP GetScriptedProcessDictionarySP() const
Definition: ProcessLaunchInfo.h:160
lldb_private::ThreadList
Definition: ThreadList.h:26
lldb_private::ScriptedProcess::m_script_object_sp
lldb_private::StructuredData::ObjectSP m_script_object_sp
Definition: ScriptedProcess.h:116
lldb_private::DynamicLoader
Definition: DynamicLoader.h:52
lldb_private::StructuredData::DictionarySP
std::shared_ptr< Dictionary > DictionarySP
Definition: StructuredData.h:67
lldb_private::ScriptedProcess::Initialize
static void Initialize()
Definition: ScriptedProcess.cpp:129
lldb_private::ScriptedProcess::DoGetMemoryRegionInfo
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...
Definition: ScriptedProcess.cpp:249
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::ScriptedProcess::Terminate
static void Terminate()
Definition: ScriptedProcess.cpp:138
lldb_private::ScriptedProcess::GetLoadedDynamicLibrariesInfos
lldb_private::StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos() override
Definition: ScriptedProcess.cpp:402
lldb_private::ScriptedProcess::ScriptedProcessInfo::GetClassName
std::string GetClassName() const
Definition: ScriptedProcess.h:31
lldb_private::ScriptedProcess::m_scripted_process_info
const ScriptedProcessInfo m_scripted_process_info
Definition: ScriptedProcess.h:114
lldb_private::Status
Definition: Status.h:44
lldb_private::ScriptedProcessInterface
Definition: ScriptedProcessInterface.h:21
lldb_private::ScriptedProcess::~ScriptedProcess
~ScriptedProcess() override
Definition: ScriptedProcess.cpp:120
lldb_private::ScriptedProcess
Definition: ScriptedProcess.h:22
lldb_private::ScriptedProcess::GetPluginName
llvm::StringRef GetPluginName() override
Definition: ScriptedProcess.h:60
ScriptedThread.h
lldb_private::ScriptedProcess::IsAlive
bool IsAlive() override
Check if a process is still alive.
Definition: ScriptedProcess.cpp:217
lldb_private::ScriptedProcess::DoLaunch
Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override
Launch a new process.
Definition: ScriptedProcess.cpp:148
lldb_private::ScriptedProcess::GetSystemRuntime
SystemRuntime * GetSystemRuntime() override
Get the system runtime plug-in for this process.
Definition: ScriptedProcess.h:62
lldb_private::ScriptInterpreter
Definition: ScriptInterpreter.h:126
lldb_private::ScriptedProcess::DoResume
Status DoResume() override
Resumes all of a process's threads as configured using the Thread run control functions.
Definition: ScriptedProcess.cpp:176
Status.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::ScriptedThread
Definition: ScriptedThread.h:27
ConstString.h
lldb_private::ScriptedProcess::ScriptedProcessInfo::GetArgsSP
StructuredData::DictionarySP GetArgsSP() const
Definition: ScriptedProcess.h:32
lldb_private::ScriptedProcess::GetMemoryRegions
Status GetMemoryRegions(lldb_private::MemoryRegionInfos &region_list) override
Obtain all the mapped memory regions within this process.
Definition: ScriptedProcess.cpp:261
lldb_private::ScriptedProcess::DoStop
Status DoStop()
Definition: ScriptedProcess.cpp:200
lldb_private::ScriptedProcess::ScriptedProcessInfo
Definition: ScriptedProcess.h:24
lldb_private::ScriptedProcess::CheckInterpreterAndScriptObject
void CheckInterpreterAndScriptObject() const
Definition: ScriptedProcess.cpp:48
lldb_private::ScriptedProcess::m_interpreter
lldb_private::ScriptInterpreter * m_interpreter
Definition: ScriptedProcess.h:115