1 //===-- ScriptedProcessInterface.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_INTERPRETER_INTERFACES_SCRIPTEDPROCESSINTERFACE_H 10 #define LLDB_INTERPRETER_INTERFACES_SCRIPTEDPROCESSINTERFACE_H 11 12 #include "ScriptedInterface.h" 13 #include "lldb/Core/StructuredDataImpl.h" 14 #include "lldb/Target/MemoryRegionInfo.h" 15 16 #include "lldb/lldb-private.h" 17 18 #include <optional> 19 #include <string> 20 21 namespace lldb_private { 22 class ScriptedProcessInterface : virtual public ScriptedInterface { 23 public: 24 virtual llvm::Expected<StructuredData::GenericSP> 25 CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx, 26 StructuredData::DictionarySP args_sp, 27 StructuredData::Generic *script_obj = nullptr) = 0; 28 29 virtual StructuredData::DictionarySP GetCapabilities() { return {}; } 30 31 virtual Status Attach(const ProcessAttachInfo &attach_info) { 32 return Status::FromErrorString("ScriptedProcess did not attach"); 33 } 34 35 virtual Status Launch() { 36 return Status::FromErrorString("ScriptedProcess did not launch"); 37 } 38 39 virtual Status Resume() { 40 return Status::FromErrorString("ScriptedProcess did not resume"); 41 } 42 43 virtual std::optional<MemoryRegionInfo> 44 GetMemoryRegionContainingAddress(lldb::addr_t address, Status &error) { 45 error = Status::FromErrorString("ScriptedProcess have no memory region."); 46 return {}; 47 } 48 49 virtual StructuredData::DictionarySP GetThreadsInfo() { return {}; } 50 51 virtual bool CreateBreakpoint(lldb::addr_t addr, Status &error) { 52 error = Status::FromErrorString( 53 "ScriptedProcess don't support creating breakpoints."); 54 return {}; 55 } 56 57 virtual lldb::DataExtractorSP 58 ReadMemoryAtAddress(lldb::addr_t address, size_t size, Status &error) { 59 return {}; 60 } 61 62 virtual lldb::offset_t WriteMemoryAtAddress(lldb::addr_t addr, 63 lldb::DataExtractorSP data_sp, 64 Status &error) { 65 return LLDB_INVALID_OFFSET; 66 }; 67 68 virtual StructuredData::ArraySP GetLoadedImages() { return {}; } 69 70 virtual lldb::pid_t GetProcessID() { return LLDB_INVALID_PROCESS_ID; } 71 72 virtual bool IsAlive() { return true; } 73 74 virtual std::optional<std::string> GetScriptedThreadPluginName() { 75 return std::nullopt; 76 } 77 78 virtual StructuredData::DictionarySP GetMetadata() { return {}; } 79 80 protected: 81 friend class ScriptedThread; 82 virtual lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() { 83 return {}; 84 } 85 }; 86 } // namespace lldb_private 87 88 #endif // LLDB_INTERPRETER_INTERFACES_SCRIPTEDPROCESSINTERFACE_H 89