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  return m_dictionary_sp;
34  }
35 
36  private:
39  };
40 
41 public:
42  static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
43  lldb::ListenerSP listener_sp,
44  const FileSpec *crash_file_path,
45  bool can_connect);
46 
47  static void Initialize();
48 
49  static void Terminate();
50 
52 
53  static const char *GetPluginDescriptionStatic();
54 
55  ScriptedProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
56  const ScriptedProcess::ScriptedProcessInfo &launch_info,
57  Status &error);
58 
59  ~ScriptedProcess() override;
60 
61  bool CanDebug(lldb::TargetSP target_sp,
62  bool plugin_specified_by_name) override;
63 
64  DynamicLoader *GetDynamicLoader() override { return nullptr; }
65 
66  llvm::StringRef GetPluginName() override {
68  }
69 
70  SystemRuntime *GetSystemRuntime() override { return nullptr; }
71 
72  Status DoLoadCore() override;
73 
74  Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override;
75 
76  void DidLaunch() override;
77 
78  Status DoResume() override;
79 
80  Status DoDestroy() override;
81 
82  void RefreshStateAfterStop() override{};
83 
84  bool IsAlive() override;
85 
86  size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
87  Status &error) override;
88 
90 
92  MemoryRegionInfo &range_info) override;
93 
94  Status
96 
97  bool GetProcessInfo(ProcessInstanceInfo &info) override;
98 
99 protected:
100  Status DoStop();
101 
102  void Clear();
103 
104  bool DoUpdateThreadList(ThreadList &old_thread_list,
105  ThreadList &new_thread_list) override;
106 
107 private:
108  friend class ScriptedThread;
109 
110  void CheckInterpreterAndScriptObject() const;
112  static bool IsScriptLanguageSupported(lldb::ScriptLanguage language);
113 
114  // Member variables.
118  //@}
119 };
120 
121 } // namespace lldb_private
122 
123 #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:64
lldb_private::ProcessInstanceInfo
Definition: ProcessInfo.h:108
lldb_private::ScriptedProcess::RefreshStateAfterStop
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
Definition: ScriptedProcess.h:82
lldb::ScriptLanguage
ScriptLanguage
Script interpreter types.
Definition: lldb-enumerations.h:216
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb_private::ScriptedProcess::ScriptedProcessInfo::m_class_name
std::string m_class_name
Definition: ScriptedProcess.h:37
lldb_private::ScriptedProcess::GetInterface
ScriptedProcessInterface & GetInterface() const
Definition: ScriptedProcess.cpp:337
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:58
lldb_private::ScriptedProcess::DoDestroy
Status DoDestroy() override
Definition: ScriptedProcess.cpp:223
lldb_private::Process
Definition: Process.h:341
lldb_private::ScriptedProcess::DoLoadCore
Status DoLoadCore() override
Definition: ScriptedProcess.cpp:148
lldb_private::ScriptedProcess::ScriptedProcessInfo::GetDictionarySP
StructuredData::DictionarySP GetDictionarySP() const
Definition: ScriptedProcess.h:32
lldb_private::Module
Definition: Module.h:85
lldb_private::SystemRuntime
Definition: SystemRuntime.h:43
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:291
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::ScriptedProcess::GetProcessInfo
bool GetProcessInfo(ProcessInstanceInfo &info) override
Definition: ScriptedProcess.cpp:324
lldb_private::ScriptedProcess::DidLaunch
void DidLaunch() override
Called after launching a process.
Definition: ScriptedProcess.cpp:179
lldb_private::ScriptedProcess::Clear
void Clear()
Definition: ScriptedProcess.cpp:289
lldb_private::ScriptedProcess::IsScriptLanguageSupported
static bool IsScriptLanguageSupported(lldb::ScriptLanguage language)
Definition: ScriptedProcess.cpp:46
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:83
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:231
lldb_private::FileSpec
Definition: FileSpec.h:56
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
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:154
lldb_private::ScriptedProcess::ScriptedProcess
ScriptedProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const ScriptedProcess::ScriptedProcessInfo &launch_info, Status &error)
Definition: ScriptedProcess.cpp:88
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
lldb_private::ConstString::GetStringRef
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:202
lldb_private::StructuredData::ObjectSP
std::shared_ptr< Object > ObjectSP
Definition: StructuredData.h:59
lldb_private::MemoryRegionInfos
Definition: MemoryRegionInfo.h:164
lldb_private::ScriptedProcess::GetArchitecture
ArchSpec GetArchitecture()
Definition: ScriptedProcess.cpp:253
lldb_private::ProcessLaunchInfo::GetScriptedProcessDictionarySP
lldb_private::StructuredData::DictionarySP GetScriptedProcessDictionarySP() const
Definition: ProcessLaunchInfo.h:163
lldb_private::ThreadList
Definition: ThreadList.h:26
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::ScriptedProcess::m_script_object_sp
lldb_private::StructuredData::ObjectSP m_script_object_sp
Definition: ScriptedProcess.h:117
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:135
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::ScriptedProcess::ScriptedProcessInfo::m_dictionary_sp
StructuredData::DictionarySP m_dictionary_sp
Definition: ScriptedProcess.h:38
lldb_private::ScriptedProcess::Terminate
static void Terminate()
Definition: ScriptedProcess.cpp:144
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:115
lldb_private::Status
Definition: Status.h:44
lldb_private::ScriptedProcessInterface
Definition: ScriptedProcessInterface.h:22
lldb_private::ScriptedProcess::~ScriptedProcess
~ScriptedProcess() override
Definition: ScriptedProcess.cpp:126
lldb_private::ScriptedProcess
Definition: ScriptedProcess.h:22
lldb_private::ScriptedProcess::GetPluginName
llvm::StringRef GetPluginName() override
Definition: ScriptedProcess.h:66
ScriptedThread.h
lldb_private::ScriptedProcess::IsAlive
bool IsAlive() override
Check if a process is still alive.
Definition: ScriptedProcess.cpp:225
lldb_private::ScriptedProcess::DoLaunch
Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override
Launch a new process.
Definition: ScriptedProcess.cpp:154
lldb_private::ScriptedProcess::GetSystemRuntime
SystemRuntime * GetSystemRuntime() override
Get the system runtime plug-in for this process.
Definition: ScriptedProcess.h:70
lldb_private::ScriptInterpreter
Definition: ScriptInterpreter.h:126
lldb_private::ScriptedProcess::GetMemoryRegionInfo
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) override
Locate the memory region that contains load_addr.
Definition: ScriptedProcess.cpp:257
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:184
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
lldb_private::ScriptedProcess::GetPluginDescriptionStatic
static const char * GetPluginDescriptionStatic()
Definition: ScriptedProcess.cpp:38
ConstString.h
lldb_private::ScriptedProcess::GetMemoryRegions
Status GetMemoryRegions(lldb_private::MemoryRegionInfos &region_list) override
Obtain all the mapped memory regions within this process.
Definition: ScriptedProcess.cpp:269
lldb_private::ScriptedProcess::DoStop
Status DoStop()
Definition: ScriptedProcess.cpp:208
lldb_private::ScriptedProcess::ScriptedProcessInfo
Definition: ScriptedProcess.h:24
lldb_private::ScriptedProcess::CheckInterpreterAndScriptObject
void CheckInterpreterAndScriptObject() const
Definition: ScriptedProcess.cpp:53
lldb_private::ScriptedProcess::m_interpreter
lldb_private::ScriptInterpreter * m_interpreter
Definition: ScriptedProcess.h:116
lldb_private::ScriptedProcess::GetPluginNameStatic
static ConstString GetPluginNameStatic()
Definition: ScriptedProcess.cpp:33