21#include "llvm/ADT/StringSwitch.h"
39 std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
42 "This script interpreter does not support breakpoint callbacks.");
48 "This script interpreter does not support watchpoint callbacks.");
56 const std::string &name, std::vector<ExtensionTemplateRequest> &extensions,
57 bool generate_non_abstract_methods, std::string output_file) {
58 return llvm::make_error<UnimplementedError>();
66 "This script interpreter does not support importing modules.");
81 llvm_unreachable(
"Unhandled ScriptInterpreter!");
117 return std::make_shared<ProcessLaunchInfo>(
123 if (
error.m_opaque_up)
124 return error.m_opaque_up->Clone();
131 if (thread.m_opaque_sp)
132 return thread.m_opaque_sp->GetThreadSP();
145 return event.m_opaque_ptr;
151 lldb::StreamSP s = std::make_shared<lldb_private::StreamString>();
152 *s << reinterpret_cast<StreamString *>(stream.
m_opaque_up.get())->m_packet;
166std::optional<lldb_private::MemoryRegionInfo>
216 return "OperatingSystem";
218 return "ScriptedPlatform";
220 return "ScriptedProcess";
222 return "ScriptedBreakpointResolver";
224 return "ScriptedThreadPlan";
226 return "ScriptedFrameProvider";
228 return "ScriptedHook";
230 return "ScriptedThread";
232 return "ScriptedFrame";
234 return "ScriptedStackFrameRecognizer";
236 return "ScriptedCommand";
238 return "ParsedCommand";
240 return "ScriptedStringSummary";
242 return "ScriptedSyntheticChildren";
244 llvm_unreachable(
"unhandled ScriptedExtension");
249 return llvm::StringSwitch<lldb::ScriptedExtension>(
string)
253 .CaseLower(
"ScriptedBreakpointResolver",
256 .CaseLower(
"ScriptedFrameProvider",
261 .CaseLower(
"ScriptedStackFrameRecognizer",
265 .CaseLower(
"ScriptedStringSummary",
267 .CaseLower(
"ScriptedSyntheticChildren",
273 std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
274 const char *callback_text) {
279 if (!
error.Success())
286 std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
292 if (!
error.Success())
298std::unique_ptr<ScriptInterpreterLocker>
300 return std::make_unique<ScriptInterpreterLocker>();
305 std::string sanitized_name(name);
306 std::string conflicting_keyword;
314 llvm::replace(sanitized_name,
'.',
'_');
315 llvm::replace(sanitized_name,
' ',
'_');
316 llvm::replace(sanitized_name,
'-',
'_');
317 llvm::replace(sanitized_name,
'+',
'x');
320 conflicting_keyword = sanitized_name;
321 sanitized_name.insert(sanitized_name.begin(),
'_');
325 name.str(), std::move(sanitized_name), std::move(conflicting_keyword));
330 if (src && src_len) {
332 strm->
Write(src, src_len);
337llvm::Expected<std::unique_ptr<ScriptInterpreterIORedirect>>
341 return std::unique_ptr<ScriptInterpreterIORedirect>(
347 return nullin.takeError();
352 return nullout.takeError();
354 return std::unique_ptr<ScriptInterpreterIORedirect>(
359 std::unique_ptr<File> input, std::unique_ptr<File> output)
380 std::unique_ptr<ConnectionGenericFile> conn_up =
381 std::make_unique<ConnectionGenericFile>(read_file,
true);
383 std::unique_ptr<ConnectionFileDescriptor> conn_up =
384 std::make_unique<ConnectionFileDescriptor>(
388 if (conn_up->IsConnected()) {
401 ::setbuf(outfile_handle,
nullptr);
static llvm::raw_ostream & error(Stream &strm)
static void ReadThreadBytesReceived(void *baton, const void *src, size_t src_len)
ProcessAttachInfoSP m_opaque_sp
lldb::BreakpointLocationWP m_opaque_wp
lldb::BreakpointWP m_opaque_wp
std::unique_ptr< lldb_private::SBCommandReturnObjectImpl > m_opaque_up
lldb::DataExtractorSP m_opaque_sp
lldb::DebuggerSP m_opaque_sp
lldb::ExecutionContextRefSP m_exe_ctx_sp
Represents a list of SBFrame objects.
lldb::StackFrameListSP m_opaque_sp
lldb::ExecutionContextRefSP m_opaque_sp
std::shared_ptr< lldb_private::SBLaunchInfoImpl > m_opaque_sp
lldb::MemoryRegionInfoUP m_opaque_up
std::unique_ptr< lldb_private::Stream > m_opaque_up
std::unique_ptr< lldb_private::SymbolContext > m_opaque_up
lldb::TargetSP m_opaque_sp
"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)
lldb::ProcessAttachInfoSP GetOpaqueTypeFromSBAttachInfo(const lldb::SBAttachInfo &attach_info) const
lldb::StreamSP GetOpaqueTypeFromSBStream(const lldb::SBStream &stream) const
CommandReturnObject * GetOpaqueTypeFromSBCommandReturnObject(const lldb::SBCommandReturnObject &cmd_retobj) const
lldb::ExecutionContextRefSP GetOpaqueTypeFromSBExecutionContext(const lldb::SBExecutionContext &exe_ctx) const
SymbolContext GetOpaqueTypeFromSBSymbolContext(const lldb::SBSymbolContext &sym_ctx) const
virtual llvm::Expected< FileSpec > GenerateExtensionTemplate(const std::string &name, std::vector< ExtensionTemplateRequest > &extensions, bool generate_non_abstract_methods, std::string output_file)
lldb::ThreadSP GetOpaqueTypeFromSBThread(const lldb::SBThread &exe_ctx) const
static llvm::StringLiteral ExtensionToString(lldb::ScriptedExtension extension)
static lldb::ScriptedExtension StringToExtension(llvm::StringRef string)
std::optional< MemoryRegionInfo > GetOpaqueTypeFromSBMemoryRegionInfo(const lldb::SBMemoryRegionInfo &mem_region) const
lldb::ValueObjectSP GetOpaqueTypeFromSBValue(const lldb::SBValue &value) const
Event * GetOpaqueTypeFromSBEvent(const lldb::SBEvent &event) const
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.
lldb::ProcessLaunchInfoSP GetOpaqueTypeFromSBLaunchInfo(const lldb::SBLaunchInfo &launch_info) const
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)
Status GetStatusFromSBError(const lldb::SBError &error) const
virtual std::unique_ptr< ScriptInterpreterLocker > AcquireInterpreterLock()
virtual StructuredData::DictionarySP GetInterpreterInfo()
lldb::BreakpointLocationSP GetOpaqueTypeFromSBBreakpointLocation(const lldb::SBBreakpointLocation &break_loc) const
lldb::TargetSP GetOpaqueTypeFromSBTarget(const lldb::SBTarget &target) const
Status SetBreakpointCommandCallbackFunction(std::vector< std::reference_wrapper< BreakpointOptions > > &bp_options_vec, const char *function_name, StructuredData::ObjectSP extra_args_sp)
lldb::BreakpointSP GetOpaqueTypeFromSBBreakpoint(const lldb::SBBreakpoint &breakpoint) const
lldb::ScriptLanguage m_script_lang
lldb::StackFrameListSP GetOpaqueTypeFromSBFrameList(const lldb::SBFrameList &exe_ctx) const
lldb::DebuggerSP GetOpaqueTypeFromSBDebugger(const lldb::SBDebugger &debugger) const
lldb::StackFrameSP GetOpaqueTypeFromSBFrame(const lldb::SBFrame &frame) const
virtual bool IsReservedWord(const char *word)
lldb::DataExtractorSP GetDataExtractorFromSBData(const lldb::SBData &data) const
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
Defines a symbol context baton that can be handed other debug core functions.
lldb::ValueObjectSP GetLockedSP(ValueImpl &in_value)
"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::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::ProcessAttachInfo > ProcessAttachInfoSP
std::shared_ptr< lldb_private::Stream > StreamSP
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
std::shared_ptr< lldb_private::Debugger > DebuggerSP
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
std::shared_ptr< lldb_private::ProcessLaunchInfo > ProcessLaunchInfoSP
std::shared_ptr< lldb_private::StackFrameList > StackFrameListSP
std::shared_ptr< lldb_private::ExecutionContextRef > ExecutionContextRefSP