diff options
Diffstat (limited to 'include/lldb/Interpreter')
-rw-r--r-- | include/lldb/Interpreter/Args.h | 6 | ||||
-rw-r--r-- | include/lldb/Interpreter/CommandCompletions.h | 2 | ||||
-rw-r--r-- | include/lldb/Interpreter/CommandInterpreter.h | 10 | ||||
-rw-r--r-- | include/lldb/Interpreter/CommandObject.h | 33 | ||||
-rw-r--r-- | include/lldb/Interpreter/CommandOptionValidators.h | 30 | ||||
-rw-r--r-- | include/lldb/Interpreter/CommandReturnObject.h | 13 | ||||
-rw-r--r-- | include/lldb/Interpreter/Options.h | 8 | ||||
-rw-r--r-- | include/lldb/Interpreter/PythonDataObjects.h | 6 | ||||
-rw-r--r-- | include/lldb/Interpreter/ScriptInterpreter.h | 51 | ||||
-rw-r--r-- | include/lldb/Interpreter/ScriptInterpreterPython.h | 41 |
10 files changed, 158 insertions, 42 deletions
diff --git a/include/lldb/Interpreter/Args.h b/include/lldb/Interpreter/Args.h index 27feca63e4ad9..06617f1e59268 100644 --- a/include/lldb/Interpreter/Args.h +++ b/include/lldb/Interpreter/Args.h @@ -293,7 +293,7 @@ public: /// A copy \a arg_cstr will be made. /// /// @param[in] arg_cstr - /// The argument to push on the front the the argument stack. + /// The argument to push on the front of the argument stack. /// /// @param[in] quote_char /// If the argument was originally quoted, put in the quote char here. @@ -308,7 +308,7 @@ public: /// Parse the arguments in the contained arguments. /// /// The arguments that are consumed by the argument parsing process - /// will be removed from the argument vector. The arguements that + /// will be removed from the argument vector. The arguments that /// get processed start at the second argument. The first argument /// is assumed to be the command and will not be touched. /// @@ -430,7 +430,7 @@ public: EncodeEscapeSequences (const char *src, std::string &dst); // ExpandEscapeSequences will change a string of possibly non-printable - // characters and expand them into text. So '\n' will turn into two chracters + // characters and expand them into text. So '\n' will turn into two characters // like "\n" which is suitable for human reading. When a character is not // printable and isn't one of the common in escape sequences listed in the // help for EncodeEscapeSequences, then it will be encoded as octal. Printable diff --git a/include/lldb/Interpreter/CommandCompletions.h b/include/lldb/Interpreter/CommandCompletions.h index c4ab1b61adebf..9df3041584ead 100644 --- a/include/lldb/Interpreter/CommandCompletions.h +++ b/include/lldb/Interpreter/CommandCompletions.h @@ -195,7 +195,7 @@ public: }; //---------------------------------------------------------------------- - // SouceFileCompleter implements the source file completer + // SourceFileCompleter implements the source file completer //---------------------------------------------------------------------- class SourceFileCompleter : public Completer { diff --git a/include/lldb/Interpreter/CommandInterpreter.h b/include/lldb/Interpreter/CommandInterpreter.h index bcb9b5538c842..c33d71a6dbbb7 100644 --- a/include/lldb/Interpreter/CommandInterpreter.h +++ b/include/lldb/Interpreter/CommandInterpreter.h @@ -252,7 +252,7 @@ public: // This version just returns matches, and doesn't compute the substring. It is here so the // Help command can call it for the first argument. - // word_complete tells whether a the completions are considered a "complete" response (so the + // word_complete tells whether the completions are considered a "complete" response (so the // completer should complete the quote & put a space after the word. int @@ -332,6 +332,9 @@ public: void Initialize (); + + void + Clear (); void SetScriptLanguage (lldb::ScriptLanguage lang); @@ -476,12 +479,15 @@ protected: std::string &line); virtual ConstString - GetControlSequence (char ch) + IOHandlerGetControlSequence (char ch) { if (ch == 'd') return ConstString("quit\n"); return ConstString(); } + + virtual bool + IOHandlerInterrupt (IOHandler &io_handler); size_t GetProcessOutput (); diff --git a/include/lldb/Interpreter/CommandObject.h b/include/lldb/Interpreter/CommandObject.h index 8544fd9f9c3fb..7bdf55a393d72 100644 --- a/include/lldb/Interpreter/CommandObject.h +++ b/include/lldb/Interpreter/CommandObject.h @@ -269,7 +269,7 @@ public: // // Ensures a valid register context (from the selected frame if there // is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx) - // is availble from m_exe_ctx prior to executing the command. If a + // is available from m_exe_ctx prior to executing the command. If a // target doesn't exist or is invalid, the command will fail and // CommandObject::GetInvalidRegContextDescription() will be returned as // the error. CommandObject subclasses can override the virtual function @@ -460,25 +460,37 @@ public: return NULL; } - CommandOverrideCallback - GetOverrideCallback () const + bool + HasOverrideCallback () const { - return m_command_override_callback; + return m_command_override_callback || m_deprecated_command_override_callback; } - void * - GetOverrideCallbackBaton () const + void + SetOverrideCallback (lldb::CommandOverrideCallback callback, void *baton) { - return m_command_override_baton; + m_deprecated_command_override_callback = callback; + m_command_override_baton = baton; } - + void - SetOverrideCallback (CommandOverrideCallback callback, void *baton) + SetOverrideCallback (lldb::CommandOverrideCallbackWithResult callback, void *baton) { m_command_override_callback = callback; m_command_override_baton = baton; } + bool + InvokeOverrideCallback (const char **argv, CommandReturnObject &result) + { + if (m_command_override_callback) + return m_command_override_callback(m_command_override_baton, argv, result); + else if (m_deprecated_command_override_callback) + return m_deprecated_command_override_callback(m_command_override_baton, argv); + else + return false; + } + virtual bool Execute (const char *args_string, CommandReturnObject &result) = 0; @@ -540,7 +552,8 @@ protected: bool m_is_alias; Flags m_flags; std::vector<CommandArgumentEntry> m_arguments; - CommandOverrideCallback m_command_override_callback; + lldb::CommandOverrideCallback m_deprecated_command_override_callback; + lldb::CommandOverrideCallbackWithResult m_command_override_callback; void * m_command_override_baton; // Helper function to populate IDs or ID ranges as the command argument data diff --git a/include/lldb/Interpreter/CommandOptionValidators.h b/include/lldb/Interpreter/CommandOptionValidators.h new file mode 100644 index 0000000000000..6be247ad4b65c --- /dev/null +++ b/include/lldb/Interpreter/CommandOptionValidators.h @@ -0,0 +1,30 @@ +//===-- CommandOptionValidators.h -------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_CommandOptionValidators_h_ +#define liblldb_CommandOptionValidators_h_ + +#include "lldb/lldb-private-types.h" + +namespace lldb_private { + +class Platform; +class ExecutionContext; + +class PosixPlatformCommandOptionValidator : public OptionValidator +{ + virtual bool IsValid(Platform &platform, const ExecutionContext &target) const; + virtual const char* ShortConditionString() const; + virtual const char* LongConditionString() const; +}; + +} // namespace lldb_private + + +#endif // liblldb_CommandOptionValidators_h_ diff --git a/include/lldb/Interpreter/CommandReturnObject.h b/include/lldb/Interpreter/CommandReturnObject.h index acd03992e5e6c..b922e1731d7e5 100644 --- a/include/lldb/Interpreter/CommandReturnObject.h +++ b/include/lldb/Interpreter/CommandReturnObject.h @@ -160,9 +160,17 @@ public: bool HasResult (); - bool GetDidChangeProcessState (); + bool + GetDidChangeProcessState (); + + void + SetDidChangeProcessState (bool b); - void SetDidChangeProcessState (bool b); + bool + GetInteractive () const; + + void + SetInteractive (bool b); private: enum @@ -176,6 +184,7 @@ private: lldb::ReturnStatus m_status; bool m_did_change_process_state; + bool m_interactive; // If true, then the input handle from the debugger will be hooked up }; } // namespace lldb_private diff --git a/include/lldb/Interpreter/Options.h b/include/lldb/Interpreter/Options.h index 2b4ac11905579..6ecf08d28e750 100644 --- a/include/lldb/Interpreter/Options.h +++ b/include/lldb/Interpreter/Options.h @@ -159,7 +159,7 @@ public: void OutputFormattedUsageText (Stream &strm, - const char *text, + const OptionDefinition &option_def, uint32_t output_max_columns); void @@ -301,6 +301,12 @@ public: int max_return_elements, bool &word_complete, StringList &matches); + + CommandInterpreter& + GetInterpreter() + { + return m_interpreter; + } protected: // This is a set of options expressed as indexes into the options table for this Option. diff --git a/include/lldb/Interpreter/PythonDataObjects.h b/include/lldb/Interpreter/PythonDataObjects.h index 63f1ad5f67bf5..a1145b6f33d9b 100644 --- a/include/lldb/Interpreter/PythonDataObjects.h +++ b/include/lldb/Interpreter/PythonDataObjects.h @@ -62,9 +62,11 @@ namespace lldb_private { { if (py_obj != m_py_obj) { - Py_XDECREF(m_py_obj); + if (Py_IsInitialized()) + Py_XDECREF(m_py_obj); m_py_obj = py_obj; - Py_XINCREF(m_py_obj); + if (Py_IsInitialized()) + Py_XINCREF(m_py_obj); } return true; } diff --git a/include/lldb/Interpreter/ScriptInterpreter.h b/include/lldb/Interpreter/ScriptInterpreter.h index 1d62c9b0fb529..5a8322f8eb4f6 100644 --- a/include/lldb/Interpreter/ScriptInterpreter.h +++ b/include/lldb/Interpreter/ScriptInterpreter.h @@ -254,16 +254,20 @@ public: return error; } - virtual bool + virtual Error ExportFunctionDefinitionToInterpreter (StringList &function_def) { - return false; + Error error; + error.SetErrorString("not implemented"); + return error; } - virtual bool + virtual Error GenerateBreakpointCommandCallbackData (StringList &input, std::string& output) { - return false; + Error error; + error.SetErrorString("not implemented"); + return error; } virtual bool @@ -359,24 +363,44 @@ public: return lldb::ScriptInterpreterObjectSP(); } - virtual bool + virtual Error GenerateFunction(const char *signature, const StringList &input) { - return false; + Error error; + error.SetErrorString("unimplemented"); + return error; } virtual void - CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, + CollectDataForBreakpointCommandCallback (std::vector<BreakpointOptions *> &options, CommandReturnObject &result); virtual void CollectDataForWatchpointCommandCallback (WatchpointOptions *wp_options, CommandReturnObject &result); + /// Set the specified text as the callback for the breakpoint. + Error + SetBreakpointCommandCallback (std::vector<BreakpointOptions *> &bp_options_vec, + const char *callback_text); + + virtual Error + SetBreakpointCommandCallback (BreakpointOptions *bp_options, + const char *callback_text) + { + Error error; + error.SetErrorString("unimplemented"); + return error; + } + + void + SetBreakpointCommandCallbackFunction (std::vector<BreakpointOptions *> &bp_options_vec, + const char *function_name); + /// Set a one-liner as the callback for the breakpoint. virtual void - SetBreakpointCommandCallback (BreakpointOptions *bp_options, - const char *oneliner) + SetBreakpointCommandCallbackFunction (BreakpointOptions *bp_options, + const char *function_name) { return; } @@ -398,6 +422,12 @@ public: return false; } + virtual void + Clear () + { + // Clean up any ref counts to SBObjects that might be in global variables + } + virtual size_t CalculateNumChildren (const lldb::ScriptInterpreterObjectSP& implementor) { @@ -545,9 +575,6 @@ public: SWIGPythonScriptKeyword_Frame swig_run_script_keyword_frame, SWIGPython_GetDynamicSetting swig_plugin_get); - static void - TerminateInterpreter (); - virtual void ResetOutputFileHandle (FILE *new_fh) { } //By default, do nothing. diff --git a/include/lldb/Interpreter/ScriptInterpreterPython.h b/include/lldb/Interpreter/ScriptInterpreterPython.h index ba532808673fe..14a62d67fde60 100644 --- a/include/lldb/Interpreter/ScriptInterpreterPython.h +++ b/include/lldb/Interpreter/ScriptInterpreterPython.h @@ -24,6 +24,8 @@ #include "lldb/Interpreter/PythonDataObjects.h" #include "lldb/Host/Terminal.h" +class IOHandlerPythonInterpreter; + namespace lldb_private { class ScriptInterpreterPython : @@ -56,7 +58,7 @@ public: ExecuteMultipleLines (const char *in_string, const ExecuteScriptOptions &options = ExecuteScriptOptions()); - bool + Error ExportFunctionDefinitionToInterpreter (StringList &function_def); bool @@ -130,10 +132,10 @@ public: lldb_private::CommandReturnObject& cmd_retobj, Error& error); - bool + Error GenerateFunction(const char *signature, const StringList &input); - bool + Error GenerateBreakpointCommandCallbackData (StringList &input, std::string& output); bool @@ -170,6 +172,9 @@ public: lldb::ScriptInterpreterObjectSP& callee_wrapper_sp, std::string& retval); + virtual void + Clear (); + virtual bool GetDocumentationForItem (const char* item, std::string& dest); @@ -220,17 +225,21 @@ public: AcquireInterpreterLock (); void - CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, + CollectDataForBreakpointCommandCallback (std::vector<BreakpointOptions *> &bp_options_vec, CommandReturnObject &result); void CollectDataForWatchpointCommandCallback (WatchpointOptions *wp_options, CommandReturnObject &result); - /// Set a Python one-liner as the callback for the breakpoint. - void + /// Set the callback body text into the callback for the breakpoint. + Error SetBreakpointCommandCallback (BreakpointOptions *bp_options, - const char *oneliner); + const char *callback_body); + + void + SetBreakpointCommandCallbackFunction (BreakpointOptions *bp_options, + const char *function_name); /// Set a one-liner as the callback for the watchpoint. void @@ -275,6 +284,19 @@ public: } + PyThreadState * + GetThreadState() + { + return m_command_thread_state; + } + + void + SetThreadState (PyThreadState *s) + { + if (s) + m_command_thread_state = s; + } + //---------------------------------------------------------------------- // IOHandlerDelegate //---------------------------------------------------------------------- @@ -335,7 +357,8 @@ protected: virtual ~ScriptInterpreterPythonObject() { - Py_XDECREF(m_object); + if (Py_IsInitialized()) + Py_XDECREF(m_object); m_object = NULL; } private: @@ -392,7 +415,7 @@ public: // FILE* m_tmp_fh; PyGILState_STATE m_GILState; }; -private: +protected: enum ActiveIOHandler { eIOHandlerNone, |