19#include "llvm/ADT/StringSwitch.h"
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.");
54 const std::string &name, std::vector<ExtensionTemplateRequest> &extensions,
55 bool generate_non_abstract_methods, std::string output_file) {
56 return llvm::make_error<UnimplementedError>();
64 "This script interpreter does not support importing modules.");
79 llvm_unreachable(
"Unhandled ScriptInterpreter!");
99 return "OperatingSystem";
101 return "ScriptedPlatform";
103 return "ScriptedProcess";
105 return "ScriptedBreakpointResolver";
107 return "ScriptedThreadPlan";
109 return "ScriptedFrameProvider";
111 return "ScriptedHook";
113 return "ScriptedThread";
115 return "ScriptedFrame";
117 return "ScriptedStackFrameRecognizer";
119 return "ScriptedCommand";
121 return "ParsedCommand";
123 return "ScriptedStringSummary";
125 return "ScriptedSyntheticChildren";
127 llvm_unreachable(
"unhandled ScriptedExtension");
132 return llvm::StringSwitch<lldb::ScriptedExtension>(
string)
136 .CaseLower(
"ScriptedBreakpointResolver",
139 .CaseLower(
"ScriptedFrameProvider",
144 .CaseLower(
"ScriptedStackFrameRecognizer",
148 .CaseLower(
"ScriptedStringSummary",
150 .CaseLower(
"ScriptedSyntheticChildren",
156 std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
157 const char *callback_text) {
162 if (!
error.Success())
169 std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
175 if (!
error.Success())
181std::unique_ptr<ScriptInterpreterLocker>
183 return std::make_unique<ScriptInterpreterLocker>();
188 std::string sanitized_name(name);
189 std::string conflicting_keyword;
197 llvm::replace(sanitized_name,
'.',
'_');
198 llvm::replace(sanitized_name,
' ',
'_');
199 llvm::replace(sanitized_name,
'-',
'_');
200 llvm::replace(sanitized_name,
'+',
'x');
203 conflicting_keyword = sanitized_name;
204 sanitized_name.insert(sanitized_name.begin(),
'_');
208 name.str(), std::move(sanitized_name), std::move(conflicting_keyword));
213 if (src && src_len) {
215 strm->
Write(src, src_len);
220llvm::Expected<std::unique_ptr<ScriptInterpreterIORedirect>>
224 return std::unique_ptr<ScriptInterpreterIORedirect>(
230 return nullin.takeError();
235 return nullout.takeError();
237 return std::unique_ptr<ScriptInterpreterIORedirect>(
242 std::unique_ptr<File> input, std::unique_ptr<File> output)
263 std::unique_ptr<ConnectionGenericFile> conn_up =
264 std::make_unique<ConnectionGenericFile>(read_file,
true);
266 std::unique_ptr<ConnectionFileDescriptor> conn_up =
267 std::make_unique<ConnectionFileDescriptor>(
271 if (conn_up->IsConnected()) {
284 ::setbuf(outfile_handle,
nullptr);
static llvm::raw_ostream & error(Stream &strm)
static void ReadThreadBytesReceived(void *baton, const void *src, size_t src_len)
"lldb/Breakpoint/BreakpointOptions.h" Class that manages the options on a breakpoint or breakpoint lo...
void SetImmediateErrorFile(lldb::FileSP file_sp)
void AppendError(llvm::StringRef in_string)
void SetImmediateOutputFile(lldb::FileSP file_sp)
Stream & GetOutputStream()
A class to manage flag bits.
lldb::FileSP GetInputFileSP()
lldb::FileSP GetErrorFileSP()
lldb::FileSP GetOutputFileSP()
void AdoptTopIOHandlerFilesIfInvalid(lldb::FileSP &in, lldb::LockableStreamFileSP &out, lldb::LockableStreamFileSP &err)
static const char * DEV_NULL
int Open(const char *path, int flags, int mode=0600)
Wraps open in a platform-independent way.
static FileSystem & Instance()
Status CreateNew() override
int ReleaseReadFileDescriptor() override
int ReleaseWriteFileDescriptor() override
lldb::FileSP m_input_file_sp
ThreadedCommunication m_communication
~ScriptInterpreterIORedirect()
void Flush()
Flush our output and error file handles.
ScriptInterpreterIORedirect(std::unique_ptr< File > input, std::unique_ptr< File > output)
static llvm::Expected< std::unique_ptr< ScriptInterpreterIORedirect > > Create(bool enable_io, Debugger &debugger, CommandReturnObject *result)
Create an IO redirect.
lldb::LockableStreamFileSP m_error_file_sp
LockableStreamFile::Mutex m_output_mutex
lldb::LockableStreamFileSP m_output_file_sp
Holds an lldb_private::Module name and a "sanitized" version of it for the purposes of loading a scri...
static lldb::ScriptLanguage StringToLanguage(const llvm::StringRef &string)
virtual void CollectDataForBreakpointCommandCallback(std::vector< std::reference_wrapper< BreakpointOptions > > &options, CommandReturnObject &result)
virtual llvm::Expected< FileSpec > GenerateExtensionTemplate(const std::string &name, std::vector< ExtensionTemplateRequest > &extensions, bool generate_non_abstract_methods, std::string output_file)
static llvm::StringLiteral ExtensionToString(lldb::ScriptedExtension extension)
static lldb::ScriptedExtension StringToExtension(llvm::StringRef string)
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.
virtual bool LoadScriptingModule(const char *filename, const LoadScriptOptions &options, lldb_private::Status &error, StructuredData::ObjectSP *module_sp=nullptr, FileSpec extra_search_dir={}, lldb::TargetSP loaded_into_target_sp={})
static std::string LanguageToString(lldb::ScriptLanguage language)
virtual std::unique_ptr< ScriptInterpreterLocker > AcquireInterpreterLock()
virtual StructuredData::DictionarySP GetInterpreterInfo()
Status SetBreakpointCommandCallbackFunction(std::vector< std::reference_wrapper< BreakpointOptions > > &bp_options_vec, const char *function_name, StructuredData::ObjectSP extra_args_sp)
lldb::ScriptLanguage m_script_lang
virtual bool IsReservedWord(const char *word)
ScriptInterpreter(Debugger &debugger, lldb::ScriptLanguage script_lang)
virtual void CollectDataForWatchpointCommandCallback(WatchpointOptions *wp_options, CommandReturnObject &result)
virtual SanitizedScriptingModuleName GetSanitizedScriptingModuleName(llvm::StringRef name)
static Status FromErrorString(const char *str)
A stream class that can stream formatted output to a file.
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
virtual void Flush()=0
Flush the stream.
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
"lldb/Breakpoint/WatchpointOptions.h" Class that manages the options on a watchpoint.
A class that represents a running process on the host machine.
ScriptLanguage
Script interpreter types.
ScriptedExtension
Scripting extension types.
@ eScriptedExtensionOperatingSystem
@ eScriptedExtensionScriptedHook
@ eScriptedExtensionParsedCommand
@ eScriptedExtensionScriptedPlatform
@ eScriptedExtensionScriptedCommand
@ eScriptedExtensionScriptedProcess
@ eScriptedExtensionScriptedFrame
@ eScriptedExtensionScriptedBreakpointResolver
@ eScriptedExtensionScriptedThreadPlan
@ eScriptedExtensionScriptedStringSummary
@ eScriptedExtensionScriptedFrameProvider
@ eScriptedExtensionScriptedThread
@ eScriptedExtensionScriptedStackFrameRecognizer
@ eScriptedExtensionScriptedSyntheticChildren
@ eScriptedExtensionInvalid
std::shared_ptr< lldb_private::Target > TargetSP