1 //===-- ScriptInterpreter.h -------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_ScriptInterpreter_h_
11 #define liblldb_ScriptInterpreter_h_
13 #include "lldb/lldb-private.h"
15 #include "lldb/Core/Broadcaster.h"
16 #include "lldb/Core/Error.h"
17 #include "lldb/Core/StructuredData.h"
19 #include "lldb/Utility/PseudoTerminal.h"
22 namespace lldb_private {
24 class ScriptInterpreterLocker
28 ScriptInterpreterLocker ()
32 virtual ~ScriptInterpreterLocker ()
36 DISALLOW_COPY_AND_ASSIGN (ScriptInterpreterLocker);
40 class ScriptInterpreter
46 eScriptReturnTypeCharPtr,
47 eScriptReturnTypeBool,
48 eScriptReturnTypeShortInt,
49 eScriptReturnTypeShortIntUnsigned,
51 eScriptReturnTypeIntUnsigned,
52 eScriptReturnTypeLongInt,
53 eScriptReturnTypeLongIntUnsigned,
54 eScriptReturnTypeLongLong,
55 eScriptReturnTypeLongLongUnsigned,
56 eScriptReturnTypeFloat,
57 eScriptReturnTypeDouble,
58 eScriptReturnTypeChar,
59 eScriptReturnTypeCharStrOrNone,
60 eScriptReturnTypeOpaqueObject
63 ScriptInterpreter (CommandInterpreter &interpreter, lldb::ScriptLanguage script_lang);
65 virtual ~ScriptInterpreter ();
67 struct ExecuteScriptOptions
70 ExecuteScriptOptions () :
72 m_set_lldb_globals(true),
73 m_maskout_errors(true)
84 GetSetLLDBGlobals () const
86 return m_set_lldb_globals;
90 GetMaskoutErrors () const
92 return m_maskout_errors;
96 SetEnableIO (bool enable)
102 ExecuteScriptOptions&
103 SetSetLLDBGlobals (bool set)
105 m_set_lldb_globals = set;
109 ExecuteScriptOptions&
110 SetMaskoutErrors (bool maskout)
112 m_maskout_errors = maskout;
118 bool m_set_lldb_globals;
119 bool m_maskout_errors;
129 ExecuteOneLine (const char *command,
130 CommandReturnObject *result,
131 const ExecuteScriptOptions &options = ExecuteScriptOptions()) = 0;
134 ExecuteInterpreterLoop () = 0;
137 ExecuteOneLineWithReturn (const char *in_string,
138 ScriptReturnType return_type,
140 const ExecuteScriptOptions &options = ExecuteScriptOptions())
146 ExecuteMultipleLines (const char *in_string,
147 const ExecuteScriptOptions &options = ExecuteScriptOptions())
150 error.SetErrorString("not implemented");
155 ExportFunctionDefinitionToInterpreter (StringList &function_def)
158 error.SetErrorString("not implemented");
163 GenerateBreakpointCommandCallbackData (StringList &input, std::string& output)
166 error.SetErrorString("not implemented");
171 GenerateWatchpointCommandCallbackData (StringList &input, std::string& output)
177 GenerateTypeScriptFunction (const char* oneliner, std::string& output, const void* name_token = NULL)
183 GenerateTypeScriptFunction (StringList &input, std::string& output, const void* name_token = NULL)
189 GenerateScriptAliasFunction (StringList &input, std::string& output)
195 GenerateTypeSynthClass (StringList &input, std::string& output, const void* name_token = NULL)
201 GenerateTypeSynthClass (const char* oneliner, std::string& output, const void* name_token = NULL)
206 virtual StructuredData::ObjectSP
207 CreateSyntheticScriptedProvider(const char *class_name, lldb::ValueObjectSP valobj)
209 return StructuredData::ObjectSP();
212 virtual StructuredData::GenericSP
213 CreateScriptCommandObject (const char *class_name)
215 return StructuredData::GenericSP();
218 virtual StructuredData::GenericSP
219 OSPlugin_CreatePluginObject (const char *class_name,
220 lldb::ProcessSP process_sp)
222 return StructuredData::GenericSP();
225 virtual StructuredData::DictionarySP
226 OSPlugin_RegisterInfo(StructuredData::ObjectSP os_plugin_object_sp)
228 return StructuredData::DictionarySP();
231 virtual StructuredData::ArraySP
232 OSPlugin_ThreadsInfo(StructuredData::ObjectSP os_plugin_object_sp)
234 return StructuredData::ArraySP();
237 virtual StructuredData::StringSP
238 OSPlugin_RegisterContextData(StructuredData::ObjectSP os_plugin_object_sp, lldb::tid_t thread_id)
240 return StructuredData::StringSP();
243 virtual StructuredData::DictionarySP
244 OSPlugin_CreateThread(StructuredData::ObjectSP os_plugin_object_sp, lldb::tid_t tid, lldb::addr_t context)
246 return StructuredData::DictionarySP();
249 virtual StructuredData::ObjectSP
250 CreateScriptedThreadPlan(const char *class_name, lldb::ThreadPlanSP thread_plan_sp)
252 return StructuredData::ObjectSP();
256 ScriptedThreadPlanExplainsStop(StructuredData::ObjectSP implementor_sp, Event *event, bool &script_error)
263 ScriptedThreadPlanShouldStop(StructuredData::ObjectSP implementor_sp, Event *event, bool &script_error)
269 virtual lldb::StateType
270 ScriptedThreadPlanGetRunState(StructuredData::ObjectSP implementor_sp, bool &script_error)
273 return lldb::eStateStepping;
276 virtual StructuredData::ObjectSP
277 LoadPluginModule(const FileSpec &file_spec, lldb_private::Error &error)
279 return StructuredData::ObjectSP();
282 virtual StructuredData::DictionarySP
283 GetDynamicSettings(StructuredData::ObjectSP plugin_module_sp, Target *target, const char *setting_name, lldb_private::Error &error)
285 return StructuredData::DictionarySP();
289 GenerateFunction(const char *signature, const StringList &input)
292 error.SetErrorString("unimplemented");
297 CollectDataForBreakpointCommandCallback (std::vector<BreakpointOptions *> &options,
298 CommandReturnObject &result);
301 CollectDataForWatchpointCommandCallback (WatchpointOptions *wp_options,
302 CommandReturnObject &result);
304 /// Set the specified text as the callback for the breakpoint.
306 SetBreakpointCommandCallback (std::vector<BreakpointOptions *> &bp_options_vec,
307 const char *callback_text);
310 SetBreakpointCommandCallback (BreakpointOptions *bp_options,
311 const char *callback_text)
314 error.SetErrorString("unimplemented");
319 SetBreakpointCommandCallbackFunction (std::vector<BreakpointOptions *> &bp_options_vec,
320 const char *function_name);
322 /// Set a one-liner as the callback for the breakpoint.
324 SetBreakpointCommandCallbackFunction (BreakpointOptions *bp_options,
325 const char *function_name)
330 /// Set a one-liner as the callback for the watchpoint.
332 SetWatchpointCommandCallback (WatchpointOptions *wp_options,
333 const char *oneliner)
339 GetScriptedSummary(const char *function_name, lldb::ValueObjectSP valobj, StructuredData::ObjectSP &callee_wrapper_sp,
340 const TypeSummaryOptions &options, std::string &retval)
348 // Clean up any ref counts to SBObjects that might be in global variables
352 CalculateNumChildren(const StructuredData::ObjectSP &implementor)
357 virtual lldb::ValueObjectSP
358 GetChildAtIndex(const StructuredData::ObjectSP &implementor, uint32_t idx)
360 return lldb::ValueObjectSP();
364 GetIndexOfChildWithName(const StructuredData::ObjectSP &implementor, const char *child_name)
370 UpdateSynthProviderInstance(const StructuredData::ObjectSP &implementor)
376 MightHaveChildrenSynthProviderInstance(const StructuredData::ObjectSP &implementor)
381 virtual lldb::ValueObjectSP
382 GetSyntheticValue(const StructuredData::ObjectSP &implementor)
388 RunScriptBasedCommand (const char* impl_function,
390 ScriptedCommandSynchronicity synchronicity,
391 lldb_private::CommandReturnObject& cmd_retobj,
393 const lldb_private::ExecutionContext& exe_ctx)
399 RunScriptBasedCommand (StructuredData::GenericSP impl_obj_sp,
401 ScriptedCommandSynchronicity synchronicity,
402 lldb_private::CommandReturnObject& cmd_retobj,
404 const lldb_private::ExecutionContext& exe_ctx)
410 RunScriptFormatKeyword (const char* impl_function,
415 error.SetErrorString("unimplemented");
420 RunScriptFormatKeyword (const char* impl_function,
425 error.SetErrorString("unimplemented");
430 RunScriptFormatKeyword (const char* impl_function,
435 error.SetErrorString("unimplemented");
440 RunScriptFormatKeyword (const char* impl_function,
445 error.SetErrorString("unimplemented");
450 RunScriptFormatKeyword (const char* impl_function,
455 error.SetErrorString("unimplemented");
460 GetDocumentationForItem (const char* item, std::string& dest)
467 GetShortHelpForCommandObject (StructuredData::GenericSP cmd_obj_sp,
475 GetFlagsForCommandObject (StructuredData::GenericSP cmd_obj_sp)
481 GetLongHelpForCommandObject (StructuredData::GenericSP cmd_obj_sp,
489 CheckObjectExists (const char* name)
495 LoadScriptingModule(const char *filename, bool can_reload, bool init_session, lldb_private::Error &error,
496 StructuredData::ObjectSP *module_sp = nullptr)
498 error.SetErrorString("loading unimplemented");
503 IsReservedWord (const char* word)
508 virtual std::unique_ptr<ScriptInterpreterLocker>
509 AcquireInterpreterLock ();
512 GetScriptInterpreterPtyName ();
515 GetMasterFileDescriptor ();
518 GetCommandInterpreter ();
521 LanguageToString (lldb::ScriptLanguage language);
524 ResetOutputFileHandle (FILE *new_fh) { } //By default, do nothing.
527 CommandInterpreter &m_interpreter;
528 lldb::ScriptLanguage m_script_lang;
531 } // namespace lldb_private
533 #endif // #ifndef liblldb_ScriptInterpreter_h_