Go to the documentation of this file.
29 ScriptInterpreter::ScriptInterpreter(
31 lldb::ScriptedProcessInterfaceUP scripted_process_interface_up)
32 : m_debugger(debugger), m_script_lang(script_lang),
33 m_scripted_process_interface_up(
34 std::move(scripted_process_interface_up)) {}
37 std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
40 "This script interpreter does not support breakpoint callbacks.");
46 "This script interpreter does not support watchpoint callbacks.");
59 "This script interpreter does not support importing modules.");
74 llvm_unreachable(
"Unhandled ScriptInterpreter!");
84 if (
error.m_opaque_up)
85 return *
error.m_opaque_up.get();
90 llvm::Optional<MemoryRegionInfo>
110 std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
111 const char *callback_text) {
115 if (!
error.Success())
122 std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
128 if (!
error.Success())
134 std::unique_ptr<ScriptInterpreterLocker>
136 return std::make_unique<ScriptInterpreterLocker>();
141 if (src && src_len) {
143 strm->
Write(src, src_len);
148 llvm::Expected<std::unique_ptr<ScriptInterpreterIORedirect>>
152 return std::unique_ptr<ScriptInterpreterIORedirect>(
158 return nullin.takeError();
163 return nullin.takeError();
165 return std::unique_ptr<ScriptInterpreterIORedirect>(
170 std::unique_ptr<File> input, std::unique_ptr<File> output)
171 : m_input_file_sp(std::move(input)),
172 m_output_file_sp(std::make_shared<
StreamFile>(std::move(output))),
173 m_error_file_sp(m_output_file_sp),
174 m_communication(
"lldb.ScriptInterpreterIORedirect.comm"),
175 m_disconnect(false) {}
179 : m_communication(
"lldb.ScriptInterpreterIORedirect.comm"),
180 m_disconnect(false) {
186 Status pipe_result = pipe.CreateNew(
false);
189 pipe.ReleaseReadFileDescriptor();
190 std::unique_ptr<ConnectionGenericFile> conn_up =
191 std::make_unique<ConnectionGenericFile>(read_file,
true);
193 std::unique_ptr<ConnectionFileDescriptor> conn_up =
194 std::make_unique<ConnectionFileDescriptor>(
195 pipe.ReleaseReadFileDescriptor(),
true);
198 if (conn_up->IsConnected()) {
205 FILE *outfile_handle = fdopen(pipe.ReleaseWriteFileDescriptor(),
"w");
209 ::setbuf(outfile_handle,
nullptr);
Status SetBreakpointCommandCallback(std::vector< std::reference_wrapper< BreakpointOptions >> &bp_options_vec, const char *callback_text)
Set the specified text as the callback for the breakpoint.
int Open(const char *path, int flags, int mode)
Wraps ::open in a platform-independent way.
ScriptLanguage
Script interpreter types.
void AdoptTopIOHandlerFilesIfInvalid(lldb::FileSP &in, lldb::StreamFileSP &out, lldb::StreamFileSP &err)
std::shared_ptr< File > GetFileSP()
lldb::StreamFileSP m_error_file_sp
virtual bool LoadScriptingModule(const char *filename, const LoadScriptOptions &options, lldb_private::Status &error, StructuredData::ObjectSP *module_sp=nullptr, FileSpec extra_search_dir={})
Status GetStatusFromSBError(const lldb::SBError &error) const
static void ReadThreadBytesReceived(void *baton, const void *src, size_t src_len)
static lldb::ScriptLanguage StringToLanguage(const llvm::StringRef &string)
virtual void Flush()=0
Flush the stream.
StreamFile & GetOutputStream()
Status SetBreakpointCommandCallbackFunction(std::vector< std::reference_wrapper< BreakpointOptions >> &bp_options_vec, const char *function_name, StructuredData::ObjectSP extra_args_sp)
static llvm::Expected< std::unique_ptr< ScriptInterpreterIORedirect > > Create(bool enable_io, Debugger &debugger, CommandReturnObject *result)
Create an IO redirect.
static const char * DEV_NULL
lldb::DataExtractorSP GetDataExtractorFromSBData(const lldb::SBData &data) const
void SetConnection(std::unique_ptr< Connection > connection)
Sets the connection that it to be used by this class.
ScriptInterpreterIORedirect(std::unique_ptr< File > input, std::unique_ptr< File > output)
static llvm::raw_ostream & error(Stream &strm)
virtual void CollectDataForWatchpointCommandCallback(WatchpointOptions *wp_options, CommandReturnObject &result)
void SetImmediateOutputFile(lldb::FileSP file_sp)
llvm::Optional< MemoryRegionInfo > GetOpaqueTypeFromSBMemoryRegionInfo(const lldb::SBMemoryRegionInfo &mem_region) const
std::shared_ptr< Object > ObjectSP
Stream & GetOutputStream()
virtual bool StartReadThread(Status *error_ptr=nullptr)
Starts a read thread whose sole purpose it to read bytes from the current connection.
lldb::FileSP GetInputFileSP()
void SetReadThreadBytesReceivedCallback(ReadThreadBytesReceived callback, void *callback_baton)
std::shared_ptr< Dictionary > DictionarySP
Communication m_communication
string(SUBSTRING ${p} 10 -1 pStripped) if($
~ScriptInterpreterIORedirect()
lldb::ConnectionStatus Disconnect(Status *error_ptr=nullptr)
Disconnect the communications connection if one is currently connected.
lldb::DataExtractorSP m_opaque_sp
lldb::MemoryRegionInfoUP m_opaque_up
static std::string LanguageToString(lldb::ScriptLanguage language)
void SetImmediateErrorFile(lldb::FileSP file_sp)
void Flush()
Flush our output and error file handles.
virtual std::unique_ptr< ScriptInterpreterLocker > AcquireInterpreterLock()
virtual StructuredData::DictionarySP GetInterpreterInfo()
static FileSystem & Instance()
lldb::FileSP m_input_file_sp
A class that represents a running process on the host machine.
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
void void AppendError(llvm::StringRef in_string)
lldb::StreamFileSP m_output_file_sp
StreamFile & GetErrorStream()
virtual bool JoinReadThread(Status *error_ptr=nullptr)
virtual void CollectDataForBreakpointCommandCallback(std::vector< std::reference_wrapper< BreakpointOptions >> &options, CommandReturnObject &result)