1 //===-- ScriptInterpreter.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_SCRIPTINTERPRETER_H 10 #define LLDB_INTERPRETER_SCRIPTINTERPRETER_H 11 12 #include "lldb/API/SBAttachInfo.h" 13 #include "lldb/API/SBBreakpoint.h" 14 #include "lldb/API/SBData.h" 15 #include "lldb/API/SBError.h" 16 #include "lldb/API/SBEvent.h" 17 #include "lldb/API/SBExecutionContext.h" 18 #include "lldb/API/SBLaunchInfo.h" 19 #include "lldb/API/SBMemoryRegionInfo.h" 20 #include "lldb/API/SBStream.h" 21 #include "lldb/Breakpoint/BreakpointOptions.h" 22 #include "lldb/Core/PluginInterface.h" 23 #include "lldb/Core/SearchFilter.h" 24 #include "lldb/Core/ThreadedCommunication.h" 25 #include "lldb/Host/PseudoTerminal.h" 26 #include "lldb/Host/StreamFile.h" 27 #include "lldb/Interpreter/Interfaces/OperatingSystemInterface.h" 28 #include "lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h" 29 #include "lldb/Interpreter/Interfaces/ScriptedProcessInterface.h" 30 #include "lldb/Interpreter/Interfaces/ScriptedThreadInterface.h" 31 #include "lldb/Interpreter/ScriptObject.h" 32 #include "lldb/Utility/Broadcaster.h" 33 #include "lldb/Utility/Status.h" 34 #include "lldb/Utility/StructuredData.h" 35 #include "lldb/lldb-private.h" 36 #include <optional> 37 38 namespace lldb_private { 39 40 class ScriptInterpreterLocker { 41 public: 42 ScriptInterpreterLocker() = default; 43 44 virtual ~ScriptInterpreterLocker() = default; 45 46 private: 47 ScriptInterpreterLocker(const ScriptInterpreterLocker &) = delete; 48 const ScriptInterpreterLocker & 49 operator=(const ScriptInterpreterLocker &) = delete; 50 }; 51 52 class ExecuteScriptOptions { 53 public: 54 ExecuteScriptOptions() = default; 55 GetEnableIO()56 bool GetEnableIO() const { return m_enable_io; } 57 GetSetLLDBGlobals()58 bool GetSetLLDBGlobals() const { return m_set_lldb_globals; } 59 60 // If this is true then any exceptions raised by the script will be 61 // cleared with PyErr_Clear(). If false then they will be left for 62 // the caller to clean up GetMaskoutErrors()63 bool GetMaskoutErrors() const { return m_maskout_errors; } 64 SetEnableIO(bool enable)65 ExecuteScriptOptions &SetEnableIO(bool enable) { 66 m_enable_io = enable; 67 return *this; 68 } 69 SetSetLLDBGlobals(bool set)70 ExecuteScriptOptions &SetSetLLDBGlobals(bool set) { 71 m_set_lldb_globals = set; 72 return *this; 73 } 74 SetMaskoutErrors(bool maskout)75 ExecuteScriptOptions &SetMaskoutErrors(bool maskout) { 76 m_maskout_errors = maskout; 77 return *this; 78 } 79 80 private: 81 bool m_enable_io = true; 82 bool m_set_lldb_globals = true; 83 bool m_maskout_errors = true; 84 }; 85 86 class LoadScriptOptions { 87 public: 88 LoadScriptOptions() = default; 89 GetInitSession()90 bool GetInitSession() const { return m_init_session; } GetSilent()91 bool GetSilent() const { return m_silent; } 92 SetInitSession(bool b)93 LoadScriptOptions &SetInitSession(bool b) { 94 m_init_session = b; 95 return *this; 96 } 97 SetSilent(bool b)98 LoadScriptOptions &SetSilent(bool b) { 99 m_silent = b; 100 return *this; 101 } 102 103 private: 104 bool m_init_session = false; 105 bool m_silent = false; 106 }; 107 108 class ScriptInterpreterIORedirect { 109 public: 110 /// Create an IO redirect. If IO is enabled, this will redirects the output 111 /// to the command return object if set or to the debugger otherwise. If IO 112 /// is disabled, it will redirect all IO to /dev/null. 113 static llvm::Expected<std::unique_ptr<ScriptInterpreterIORedirect>> 114 Create(bool enable_io, Debugger &debugger, CommandReturnObject *result); 115 116 ~ScriptInterpreterIORedirect(); 117 GetInputFile()118 lldb::FileSP GetInputFile() const { return m_input_file_sp; } GetOutputFile()119 lldb::FileSP GetOutputFile() const { 120 return m_output_file_sp->GetUnlockedFileSP(); 121 } GetErrorFile()122 lldb::FileSP GetErrorFile() const { 123 return m_error_file_sp->GetUnlockedFileSP(); 124 } 125 126 /// Flush our output and error file handles. 127 void Flush(); 128 129 private: 130 ScriptInterpreterIORedirect(std::unique_ptr<File> input, 131 std::unique_ptr<File> output); 132 ScriptInterpreterIORedirect(Debugger &debugger, CommandReturnObject *result); 133 134 lldb::FileSP m_input_file_sp; 135 lldb::LockableStreamFileSP m_output_file_sp; 136 lldb::LockableStreamFileSP m_error_file_sp; 137 LockableStreamFile::Mutex m_output_mutex; 138 ThreadedCommunication m_communication; 139 bool m_disconnect; 140 }; 141 142 class ScriptInterpreter : public PluginInterface { 143 public: 144 enum ScriptReturnType { 145 eScriptReturnTypeCharPtr, 146 eScriptReturnTypeBool, 147 eScriptReturnTypeShortInt, 148 eScriptReturnTypeShortIntUnsigned, 149 eScriptReturnTypeInt, 150 eScriptReturnTypeIntUnsigned, 151 eScriptReturnTypeLongInt, 152 eScriptReturnTypeLongIntUnsigned, 153 eScriptReturnTypeLongLong, 154 eScriptReturnTypeLongLongUnsigned, 155 eScriptReturnTypeFloat, 156 eScriptReturnTypeDouble, 157 eScriptReturnTypeChar, 158 eScriptReturnTypeCharStrOrNone, 159 eScriptReturnTypeOpaqueObject 160 }; 161 162 ScriptInterpreter(Debugger &debugger, lldb::ScriptLanguage script_lang); 163 164 virtual StructuredData::DictionarySP GetInterpreterInfo(); 165 166 ~ScriptInterpreter() override = default; 167 Interrupt()168 virtual bool Interrupt() { return false; } 169 170 virtual bool ExecuteOneLine( 171 llvm::StringRef command, CommandReturnObject *result, 172 const ExecuteScriptOptions &options = ExecuteScriptOptions()) = 0; 173 174 virtual void ExecuteInterpreterLoop() = 0; 175 176 virtual bool ExecuteOneLineWithReturn( 177 llvm::StringRef in_string, ScriptReturnType return_type, void *ret_value, 178 const ExecuteScriptOptions &options = ExecuteScriptOptions()) { 179 return true; 180 } 181 182 virtual Status ExecuteMultipleLines( 183 const char *in_string, 184 const ExecuteScriptOptions &options = ExecuteScriptOptions()) { 185 return Status::FromErrorString("not implemented"); 186 } 187 188 virtual Status ExportFunctionDefinitionToInterpreter(StringList & function_def)189 ExportFunctionDefinitionToInterpreter(StringList &function_def) { 190 return Status::FromErrorString("not implemented"); 191 } 192 GenerateBreakpointCommandCallbackData(StringList & input,std::string & output,bool has_extra_args,bool is_callback)193 virtual Status GenerateBreakpointCommandCallbackData(StringList &input, 194 std::string &output, 195 bool has_extra_args, 196 bool is_callback) { 197 return Status::FromErrorString("not implemented"); 198 } 199 GenerateWatchpointCommandCallbackData(StringList & input,std::string & output,bool is_callback)200 virtual bool GenerateWatchpointCommandCallbackData(StringList &input, 201 std::string &output, 202 bool is_callback) { 203 return false; 204 } 205 206 virtual bool GenerateTypeScriptFunction(const char *oneliner, 207 std::string &output, 208 const void *name_token = nullptr) { 209 return false; 210 } 211 212 virtual bool GenerateTypeScriptFunction(StringList &input, 213 std::string &output, 214 const void *name_token = nullptr) { 215 return false; 216 } 217 GenerateScriptAliasFunction(StringList & input,std::string & output)218 virtual bool GenerateScriptAliasFunction(StringList &input, 219 std::string &output) { 220 return false; 221 } 222 223 virtual bool GenerateTypeSynthClass(StringList &input, std::string &output, 224 const void *name_token = nullptr) { 225 return false; 226 } 227 228 virtual bool GenerateTypeSynthClass(const char *oneliner, std::string &output, 229 const void *name_token = nullptr) { 230 return false; 231 } 232 233 virtual StructuredData::ObjectSP CreateSyntheticScriptedProvider(const char * class_name,lldb::ValueObjectSP valobj)234 CreateSyntheticScriptedProvider(const char *class_name, 235 lldb::ValueObjectSP valobj) { 236 return StructuredData::ObjectSP(); 237 } 238 239 virtual StructuredData::GenericSP CreateScriptCommandObject(const char * class_name)240 CreateScriptCommandObject(const char *class_name) { 241 return StructuredData::GenericSP(); 242 } 243 244 virtual StructuredData::GenericSP CreateFrameRecognizer(const char * class_name)245 CreateFrameRecognizer(const char *class_name) { 246 return StructuredData::GenericSP(); 247 } 248 GetRecognizedArguments(const StructuredData::ObjectSP & implementor,lldb::StackFrameSP frame_sp)249 virtual lldb::ValueObjectListSP GetRecognizedArguments( 250 const StructuredData::ObjectSP &implementor, 251 lldb::StackFrameSP frame_sp) { 252 return lldb::ValueObjectListSP(); 253 } 254 ShouldHide(const StructuredData::ObjectSP & implementor,lldb::StackFrameSP frame_sp)255 virtual bool ShouldHide(const StructuredData::ObjectSP &implementor, 256 lldb::StackFrameSP frame_sp) { 257 return false; 258 } 259 260 virtual StructuredData::GenericSP CreateScriptedBreakpointResolver(const char * class_name,const StructuredDataImpl & args_data,lldb::BreakpointSP & bkpt_sp)261 CreateScriptedBreakpointResolver(const char *class_name, 262 const StructuredDataImpl &args_data, 263 lldb::BreakpointSP &bkpt_sp) { 264 return StructuredData::GenericSP(); 265 } 266 267 virtual bool ScriptedBreakpointResolverSearchCallback(StructuredData::GenericSP implementor_sp,SymbolContext * sym_ctx)268 ScriptedBreakpointResolverSearchCallback(StructuredData::GenericSP implementor_sp, 269 SymbolContext *sym_ctx) 270 { 271 return false; 272 } 273 274 virtual lldb::SearchDepth ScriptedBreakpointResolverSearchDepth(StructuredData::GenericSP implementor_sp)275 ScriptedBreakpointResolverSearchDepth(StructuredData::GenericSP implementor_sp) 276 { 277 return lldb::eSearchDepthModule; 278 } 279 280 virtual StructuredData::ObjectSP LoadPluginModule(const FileSpec & file_spec,lldb_private::Status & error)281 LoadPluginModule(const FileSpec &file_spec, lldb_private::Status &error) { 282 return StructuredData::ObjectSP(); 283 } 284 285 virtual StructuredData::DictionarySP GetDynamicSettings(StructuredData::ObjectSP plugin_module_sp,Target * target,const char * setting_name,lldb_private::Status & error)286 GetDynamicSettings(StructuredData::ObjectSP plugin_module_sp, Target *target, 287 const char *setting_name, lldb_private::Status &error) { 288 return StructuredData::DictionarySP(); 289 } 290 GenerateFunction(const char * signature,const StringList & input,bool is_callback)291 virtual Status GenerateFunction(const char *signature, 292 const StringList &input, 293 bool is_callback) { 294 return Status::FromErrorString("not implemented"); 295 } 296 297 virtual void CollectDataForBreakpointCommandCallback( 298 std::vector<std::reference_wrapper<BreakpointOptions>> &options, 299 CommandReturnObject &result); 300 301 virtual void 302 CollectDataForWatchpointCommandCallback(WatchpointOptions *wp_options, 303 CommandReturnObject &result); 304 305 /// Set the specified text as the callback for the breakpoint. 306 Status SetBreakpointCommandCallback( 307 std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec, 308 const char *callback_text); 309 SetBreakpointCommandCallback(BreakpointOptions & bp_options,const char * callback_text,bool is_callback)310 virtual Status SetBreakpointCommandCallback(BreakpointOptions &bp_options, 311 const char *callback_text, 312 bool is_callback) { 313 return Status::FromErrorString("not implemented"); 314 } 315 316 /// This one is for deserialization: SetBreakpointCommandCallback(BreakpointOptions & bp_options,std::unique_ptr<BreakpointOptions::CommandData> & data_up)317 virtual Status SetBreakpointCommandCallback( 318 BreakpointOptions &bp_options, 319 std::unique_ptr<BreakpointOptions::CommandData> &data_up) { 320 return Status::FromErrorString("not implemented"); 321 } 322 323 Status SetBreakpointCommandCallbackFunction( 324 std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec, 325 const char *function_name, StructuredData::ObjectSP extra_args_sp); 326 327 /// Set a script function as the callback for the breakpoint. 328 virtual Status SetBreakpointCommandCallbackFunction(BreakpointOptions & bp_options,const char * function_name,StructuredData::ObjectSP extra_args_sp)329 SetBreakpointCommandCallbackFunction(BreakpointOptions &bp_options, 330 const char *function_name, 331 StructuredData::ObjectSP extra_args_sp) { 332 return Status::FromErrorString("not implemented"); 333 } 334 335 /// Set a one-liner as the callback for the watchpoint. SetWatchpointCommandCallback(WatchpointOptions * wp_options,const char * user_input,bool is_callback)336 virtual void SetWatchpointCommandCallback(WatchpointOptions *wp_options, 337 const char *user_input, 338 bool is_callback) {} 339 GetScriptedSummary(const char * function_name,lldb::ValueObjectSP valobj,StructuredData::ObjectSP & callee_wrapper_sp,const TypeSummaryOptions & options,std::string & retval)340 virtual bool GetScriptedSummary(const char *function_name, 341 lldb::ValueObjectSP valobj, 342 StructuredData::ObjectSP &callee_wrapper_sp, 343 const TypeSummaryOptions &options, 344 std::string &retval) { 345 return false; 346 } 347 348 // Calls the specified formatter matching Python function and returns its 349 // result (true if it's a match, false if we should keep looking for a 350 // matching formatter). FormatterCallbackFunction(const char * function_name,lldb::TypeImplSP type_impl_sp)351 virtual bool FormatterCallbackFunction(const char *function_name, 352 lldb::TypeImplSP type_impl_sp) { 353 return true; 354 } 355 Clear()356 virtual void Clear() { 357 // Clean up any ref counts to SBObjects that might be in global variables 358 } 359 360 virtual size_t CalculateNumChildren(const StructuredData::ObjectSP & implementor,uint32_t max)361 CalculateNumChildren(const StructuredData::ObjectSP &implementor, 362 uint32_t max) { 363 return 0; 364 } 365 366 virtual lldb::ValueObjectSP GetChildAtIndex(const StructuredData::ObjectSP & implementor,uint32_t idx)367 GetChildAtIndex(const StructuredData::ObjectSP &implementor, uint32_t idx) { 368 return lldb::ValueObjectSP(); 369 } 370 371 virtual llvm::Expected<int> GetIndexOfChildWithName(const StructuredData::ObjectSP & implementor,const char * child_name)372 GetIndexOfChildWithName(const StructuredData::ObjectSP &implementor, 373 const char *child_name) { 374 return llvm::createStringError("Type has no child named '%s'", child_name); 375 } 376 377 virtual bool UpdateSynthProviderInstance(const StructuredData::ObjectSP & implementor)378 UpdateSynthProviderInstance(const StructuredData::ObjectSP &implementor) { 379 return false; 380 } 381 MightHaveChildrenSynthProviderInstance(const StructuredData::ObjectSP & implementor)382 virtual bool MightHaveChildrenSynthProviderInstance( 383 const StructuredData::ObjectSP &implementor) { 384 return true; 385 } 386 387 virtual lldb::ValueObjectSP GetSyntheticValue(const StructuredData::ObjectSP & implementor)388 GetSyntheticValue(const StructuredData::ObjectSP &implementor) { 389 return nullptr; 390 } 391 392 virtual ConstString GetSyntheticTypeName(const StructuredData::ObjectSP & implementor)393 GetSyntheticTypeName(const StructuredData::ObjectSP &implementor) { 394 return ConstString(); 395 } 396 397 virtual bool RunScriptBasedCommand(const char * impl_function,llvm::StringRef args,ScriptedCommandSynchronicity synchronicity,lldb_private::CommandReturnObject & cmd_retobj,Status & error,const lldb_private::ExecutionContext & exe_ctx)398 RunScriptBasedCommand(const char *impl_function, llvm::StringRef args, 399 ScriptedCommandSynchronicity synchronicity, 400 lldb_private::CommandReturnObject &cmd_retobj, 401 Status &error, 402 const lldb_private::ExecutionContext &exe_ctx) { 403 return false; 404 } 405 RunScriptBasedCommand(StructuredData::GenericSP impl_obj_sp,llvm::StringRef args,ScriptedCommandSynchronicity synchronicity,lldb_private::CommandReturnObject & cmd_retobj,Status & error,const lldb_private::ExecutionContext & exe_ctx)406 virtual bool RunScriptBasedCommand( 407 StructuredData::GenericSP impl_obj_sp, llvm::StringRef args, 408 ScriptedCommandSynchronicity synchronicity, 409 lldb_private::CommandReturnObject &cmd_retobj, Status &error, 410 const lldb_private::ExecutionContext &exe_ctx) { 411 return false; 412 } 413 RunScriptBasedParsedCommand(StructuredData::GenericSP impl_obj_sp,Args & args,ScriptedCommandSynchronicity synchronicity,lldb_private::CommandReturnObject & cmd_retobj,Status & error,const lldb_private::ExecutionContext & exe_ctx)414 virtual bool RunScriptBasedParsedCommand( 415 StructuredData::GenericSP impl_obj_sp, Args& args, 416 ScriptedCommandSynchronicity synchronicity, 417 lldb_private::CommandReturnObject &cmd_retobj, Status &error, 418 const lldb_private::ExecutionContext &exe_ctx) { 419 return false; 420 } 421 422 virtual std::optional<std::string> GetRepeatCommandForScriptedCommand(StructuredData::GenericSP impl_obj_sp,Args & args)423 GetRepeatCommandForScriptedCommand(StructuredData::GenericSP impl_obj_sp, 424 Args &args) { 425 return std::nullopt; 426 } 427 428 virtual StructuredData::DictionarySP HandleArgumentCompletionForScriptedCommand(StructuredData::GenericSP impl_obj_sp,std::vector<llvm::StringRef> & args,size_t args_pos,size_t char_in_arg)429 HandleArgumentCompletionForScriptedCommand( 430 StructuredData::GenericSP impl_obj_sp, std::vector<llvm::StringRef> &args, 431 size_t args_pos, size_t char_in_arg) { 432 return {}; 433 } 434 435 virtual StructuredData::DictionarySP HandleOptionArgumentCompletionForScriptedCommand(StructuredData::GenericSP impl_obj_sp,llvm::StringRef & long_name,size_t char_in_arg)436 HandleOptionArgumentCompletionForScriptedCommand( 437 StructuredData::GenericSP impl_obj_sp, llvm::StringRef &long_name, 438 size_t char_in_arg) { 439 return {}; 440 } 441 RunScriptFormatKeyword(const char * impl_function,Process * process,std::string & output,Status & error)442 virtual bool RunScriptFormatKeyword(const char *impl_function, 443 Process *process, std::string &output, 444 Status &error) { 445 error = Status::FromErrorString("unimplemented"); 446 return false; 447 } 448 RunScriptFormatKeyword(const char * impl_function,Thread * thread,std::string & output,Status & error)449 virtual bool RunScriptFormatKeyword(const char *impl_function, Thread *thread, 450 std::string &output, Status &error) { 451 error = Status::FromErrorString("unimplemented"); 452 return false; 453 } 454 RunScriptFormatKeyword(const char * impl_function,Target * target,std::string & output,Status & error)455 virtual bool RunScriptFormatKeyword(const char *impl_function, Target *target, 456 std::string &output, Status &error) { 457 error = Status::FromErrorString("unimplemented"); 458 return false; 459 } 460 RunScriptFormatKeyword(const char * impl_function,StackFrame * frame,std::string & output,Status & error)461 virtual bool RunScriptFormatKeyword(const char *impl_function, 462 StackFrame *frame, std::string &output, 463 Status &error) { 464 error = Status::FromErrorString("unimplemented"); 465 return false; 466 } 467 RunScriptFormatKeyword(const char * impl_function,ValueObject * value,std::string & output,Status & error)468 virtual bool RunScriptFormatKeyword(const char *impl_function, 469 ValueObject *value, std::string &output, 470 Status &error) { 471 error = Status::FromErrorString("unimplemented"); 472 return false; 473 } 474 GetDocumentationForItem(const char * item,std::string & dest)475 virtual bool GetDocumentationForItem(const char *item, std::string &dest) { 476 dest.clear(); 477 return false; 478 } 479 480 virtual bool GetShortHelpForCommandObject(StructuredData::GenericSP cmd_obj_sp,std::string & dest)481 GetShortHelpForCommandObject(StructuredData::GenericSP cmd_obj_sp, 482 std::string &dest) { 483 dest.clear(); 484 return false; 485 } 486 487 virtual StructuredData::ObjectSP GetOptionsForCommandObject(StructuredData::GenericSP cmd_obj_sp)488 GetOptionsForCommandObject(StructuredData::GenericSP cmd_obj_sp) { 489 return {}; 490 } 491 492 virtual StructuredData::ObjectSP GetArgumentsForCommandObject(StructuredData::GenericSP cmd_obj_sp)493 GetArgumentsForCommandObject(StructuredData::GenericSP cmd_obj_sp) { 494 return {}; 495 } 496 SetOptionValueForCommandObject(StructuredData::GenericSP cmd_obj_sp,ExecutionContext * exe_ctx,llvm::StringRef long_option,llvm::StringRef value)497 virtual bool SetOptionValueForCommandObject( 498 StructuredData::GenericSP cmd_obj_sp, ExecutionContext *exe_ctx, 499 llvm::StringRef long_option, llvm::StringRef value) { 500 return false; 501 } 502 503 virtual void OptionParsingStartedForCommandObject(StructuredData::GenericSP cmd_obj_sp)504 OptionParsingStartedForCommandObject(StructuredData::GenericSP cmd_obj_sp) {} 505 506 virtual uint32_t GetFlagsForCommandObject(StructuredData::GenericSP cmd_obj_sp)507 GetFlagsForCommandObject(StructuredData::GenericSP cmd_obj_sp) { 508 return 0; 509 } 510 GetLongHelpForCommandObject(StructuredData::GenericSP cmd_obj_sp,std::string & dest)511 virtual bool GetLongHelpForCommandObject(StructuredData::GenericSP cmd_obj_sp, 512 std::string &dest) { 513 dest.clear(); 514 return false; 515 } 516 CheckObjectExists(const char * name)517 virtual bool CheckObjectExists(const char *name) { return false; } 518 519 virtual bool 520 LoadScriptingModule(const char *filename, const LoadScriptOptions &options, 521 lldb_private::Status &error, 522 StructuredData::ObjectSP *module_sp = nullptr, 523 FileSpec extra_search_dir = {}, 524 lldb::TargetSP loaded_into_target_sp = {}); 525 IsReservedWord(const char * word)526 virtual bool IsReservedWord(const char *word) { return false; } 527 528 virtual std::unique_ptr<ScriptInterpreterLocker> AcquireInterpreterLock(); 529 530 const char *GetScriptInterpreterPtyName(); 531 532 virtual llvm::Expected<unsigned> GetMaxPositionalArgumentsForCallable(const llvm::StringRef & callable_name)533 GetMaxPositionalArgumentsForCallable(const llvm::StringRef &callable_name) { 534 return llvm::createStringError( 535 llvm::inconvertibleErrorCode(), "Unimplemented function"); 536 } 537 538 static std::string LanguageToString(lldb::ScriptLanguage language); 539 540 static lldb::ScriptLanguage StringToLanguage(const llvm::StringRef &string); 541 GetLanguage()542 lldb::ScriptLanguage GetLanguage() { return m_script_lang; } 543 CreateScriptedProcessInterface()544 virtual lldb::ScriptedProcessInterfaceUP CreateScriptedProcessInterface() { 545 return {}; 546 } 547 CreateScriptedThreadInterface()548 virtual lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() { 549 return {}; 550 } 551 552 virtual lldb::ScriptedThreadPlanInterfaceSP CreateScriptedThreadPlanInterface()553 CreateScriptedThreadPlanInterface() { 554 return {}; 555 } 556 CreateOperatingSystemInterface()557 virtual lldb::OperatingSystemInterfaceSP CreateOperatingSystemInterface() { 558 return {}; 559 } 560 GetScriptedPlatformInterface()561 virtual lldb::ScriptedPlatformInterfaceUP GetScriptedPlatformInterface() { 562 return {}; 563 } 564 CreateScriptedStopHookInterface()565 virtual lldb::ScriptedStopHookInterfaceSP CreateScriptedStopHookInterface() { 566 return {}; 567 } 568 569 virtual StructuredData::ObjectSP CreateStructuredDataFromScriptObject(ScriptObject obj)570 CreateStructuredDataFromScriptObject(ScriptObject obj) { 571 return {}; 572 } 573 574 lldb::DataExtractorSP 575 GetDataExtractorFromSBData(const lldb::SBData &data) const; 576 577 Status GetStatusFromSBError(const lldb::SBError &error) const; 578 579 Event *GetOpaqueTypeFromSBEvent(const lldb::SBEvent &event) const; 580 581 lldb::StreamSP GetOpaqueTypeFromSBStream(const lldb::SBStream &stream) const; 582 583 lldb::BreakpointSP 584 GetOpaqueTypeFromSBBreakpoint(const lldb::SBBreakpoint &breakpoint) const; 585 586 lldb::ProcessAttachInfoSP 587 GetOpaqueTypeFromSBAttachInfo(const lldb::SBAttachInfo &attach_info) const; 588 589 lldb::ProcessLaunchInfoSP 590 GetOpaqueTypeFromSBLaunchInfo(const lldb::SBLaunchInfo &launch_info) const; 591 592 std::optional<MemoryRegionInfo> GetOpaqueTypeFromSBMemoryRegionInfo( 593 const lldb::SBMemoryRegionInfo &mem_region) const; 594 595 lldb::ExecutionContextRefSP GetOpaqueTypeFromSBExecutionContext( 596 const lldb::SBExecutionContext &exe_ctx) const; 597 598 protected: 599 Debugger &m_debugger; 600 lldb::ScriptLanguage m_script_lang; 601 }; 602 603 } // namespace lldb_private 604 605 #endif // LLDB_INTERPRETER_SCRIPTINTERPRETER_H 606