diff options
Diffstat (limited to 'include/lldb/Interpreter')
26 files changed, 518 insertions, 487 deletions
diff --git a/include/lldb/Interpreter/Args.h b/include/lldb/Interpreter/Args.h index fe29df468de7d..e11636b63f179 100644 --- a/include/lldb/Interpreter/Args.h +++ b/include/lldb/Interpreter/Args.h @@ -18,6 +18,7 @@ #include <utility> // Other libraries and framework includes +#include "llvm/ADT/StringRef.h" // Project includes #include "lldb/lldb-private-types.h" #include "lldb/lldb-types.h" @@ -75,11 +76,9 @@ public: /// A NULL terminated command that will be copied and split up /// into arguments. /// - /// @see Args::SetCommandString(const char *) + /// @see Args::SetCommandString(llvm::StringRef) //------------------------------------------------------------------ - Args (const char *command = NULL); - - Args (const char *command, size_t len); + Args (llvm::StringRef command = llvm::StringRef()); Args (const Args &rhs); @@ -108,7 +107,7 @@ public: /// that can be accessed via the accessor functions. /// /// @param[in] command - /// A NULL terminated command that will be copied and split up + /// A command StringRef that will be copied and split up /// into arguments. /// /// @see Args::GetArgumentCount() const @@ -118,10 +117,7 @@ public: /// @see Args::Unshift (const char *) //------------------------------------------------------------------ void - SetCommandString (const char *command); - - void - SetCommandString (const char *command, size_t len); + SetCommandString (llvm::StringRef command); bool GetCommandString (std::string &command) const; @@ -449,6 +445,9 @@ protected: void UpdateArgvFromArgs (); + + llvm::StringRef + ParseSingleArgument (llvm::StringRef command); }; } // namespace lldb_private diff --git a/include/lldb/Interpreter/CommandInterpreter.h b/include/lldb/Interpreter/CommandInterpreter.h index 20b6ff95be8bf..1962050dffcbf 100644 --- a/include/lldb/Interpreter/CommandInterpreter.h +++ b/include/lldb/Interpreter/CommandInterpreter.h @@ -625,6 +625,12 @@ public: bool GetPromptOnQuit () const; + void + SetPromptOnQuit (bool b); + + void + ResolveCommand(const char *command_line, CommandReturnObject &result); + bool GetStopCmdSourceOnError () const; @@ -685,6 +691,13 @@ private: Error PreprocessCommand (std::string &command); + // Completely resolves aliases and abbreviations, returning a pointer to the + // final command object and updating command_line to the fully substituted + // and translated command. + CommandObject * + ResolveCommandImpl(std::string &command_line, CommandReturnObject &result); + + Debugger &m_debugger; // The debugger session that this interpreter is associated with ExecutionContextRef m_exe_ctx_ref; // The current execution context to use when handling commands bool m_synchronous_execution; diff --git a/include/lldb/Interpreter/CommandObject.h b/include/lldb/Interpreter/CommandObject.h index bace3264dafa6..c0901d5e30321 100644 --- a/include/lldb/Interpreter/CommandObject.h +++ b/include/lldb/Interpreter/CommandObject.h @@ -98,7 +98,7 @@ public: return m_interpreter; } - const char * + virtual const char * GetHelp (); virtual const char * @@ -114,6 +114,9 @@ public: SetHelp (const char * str); void + SetHelp (std::string str); + + void SetHelpLong (const char * str); void @@ -192,7 +195,7 @@ public: static lldb::CommandArgumentType LookupArgumentName (const char *arg_name); - static ArgumentTableEntry * + static const ArgumentTableEntry * FindArgumentDataByType (lldb::CommandArgumentType arg_type); int @@ -217,89 +220,6 @@ public: bool IsPairType (ArgumentRepetitionType arg_repeat_type); - - enum - { - //---------------------------------------------------------------------- - // eFlagRequiresTarget - // - // Ensures a valid target is contained in m_exe_ctx prior to executing - // the command. If a target doesn't exist or is invalid, the command - // will fail and CommandObject::GetInvalidTargetDescription() will be - // returned as the error. CommandObject subclasses can override the - // virtual function for GetInvalidTargetDescription() to provide custom - // strings when needed. - //---------------------------------------------------------------------- - eFlagRequiresTarget = (1u << 0), - //---------------------------------------------------------------------- - // eFlagRequiresProcess - // - // Ensures a valid process is contained in m_exe_ctx prior to executing - // the command. If a process doesn't exist or is invalid, the command - // will fail and CommandObject::GetInvalidProcessDescription() will be - // returned as the error. CommandObject subclasses can override the - // virtual function for GetInvalidProcessDescription() to provide custom - // strings when needed. - //---------------------------------------------------------------------- - eFlagRequiresProcess = (1u << 1), - //---------------------------------------------------------------------- - // eFlagRequiresThread - // - // Ensures a valid thread is contained in m_exe_ctx prior to executing - // the command. If a thread doesn't exist or is invalid, the command - // will fail and CommandObject::GetInvalidThreadDescription() will be - // returned as the error. CommandObject subclasses can override the - // virtual function for GetInvalidThreadDescription() to provide custom - // strings when needed. - //---------------------------------------------------------------------- - eFlagRequiresThread = (1u << 2), - //---------------------------------------------------------------------- - // eFlagRequiresFrame - // - // Ensures a valid frame is contained in m_exe_ctx prior to executing - // the command. If a frame doesn't exist or is invalid, the command - // will fail and CommandObject::GetInvalidFrameDescription() will be - // returned as the error. CommandObject subclasses can override the - // virtual function for GetInvalidFrameDescription() to provide custom - // strings when needed. - //---------------------------------------------------------------------- - eFlagRequiresFrame = (1u << 3), - //---------------------------------------------------------------------- - // eFlagRequiresRegContext - // - // 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 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 - // for GetInvalidRegContextDescription() to provide custom strings when - // needed. - //---------------------------------------------------------------------- - eFlagRequiresRegContext = (1u << 4), - //---------------------------------------------------------------------- - // eFlagTryTargetAPILock - // - // Attempts to acquire the target lock if a target is selected in the - // command interpreter. If the command object fails to acquire the API - // lock, the command will fail with an appropriate error message. - //---------------------------------------------------------------------- - eFlagTryTargetAPILock = (1u << 5), - //---------------------------------------------------------------------- - // eFlagProcessMustBeLaunched - // - // Verifies that there is a launched process in m_exe_ctx, if there - // isn't, the command will fail with an appropriate error message. - //---------------------------------------------------------------------- - eFlagProcessMustBeLaunched = (1u << 6), - //---------------------------------------------------------------------- - // eFlagProcessMustBePaused - // - // Verifies that there is a paused process in m_exe_ctx, if there - // isn't, the command will fail with an appropriate error message. - //---------------------------------------------------------------------- - eFlagProcessMustBePaused = (1u << 7) - }; bool ParseOptions (Args& args, CommandReturnObject &result); diff --git a/include/lldb/Interpreter/OptionValue.h b/include/lldb/Interpreter/OptionValue.h index 787430a96ef5f..fd751f744de63 100644 --- a/include/lldb/Interpreter/OptionValue.h +++ b/include/lldb/Interpreter/OptionValue.h @@ -40,6 +40,7 @@ namespace lldb_private { eTypeFileSpec, eTypeFileSpecList, eTypeFormat, + eTypeLanguage, eTypePathMap, eTypeProperties, eTypeRegex, @@ -106,7 +107,7 @@ namespace lldb_private { DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) = 0; virtual Error - SetValueFromCString (const char *value, VarSetOperationType op = eVarSetOperationAssign); + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool Clear () = 0; @@ -187,6 +188,7 @@ namespace lldb_private { case 1u << eTypeFileSpec: return eTypeFileSpec; case 1u << eTypeFileSpecList: return eTypeFileSpecList; case 1u << eTypeFormat: return eTypeFormat; + case 1u << eTypeLanguage: return eTypeLanguage; case 1u << eTypePathMap: return eTypePathMap; case 1u << eTypeProperties: return eTypeProperties; case 1u << eTypeRegex: return eTypeRegex; @@ -270,6 +272,12 @@ namespace lldb_private { const OptionValueFormat * GetAsFormat () const; + OptionValueLanguage * + GetAsLanguage (); + + const OptionValueLanguage * + GetAsLanguage () const; + OptionValuePathMappings * GetAsPathMappings (); @@ -348,6 +356,12 @@ namespace lldb_private { bool SetFormatValue (lldb::Format new_value); + + lldb::LanguageType + GetLanguageValue (lldb::LanguageType fail_value = lldb::eLanguageTypeUnknown) const; + + bool + SetLanguageValue (lldb::LanguageType new_language); const FormatEntity::Entry * GetFormatEntity () const; diff --git a/include/lldb/Interpreter/OptionValueArch.h b/include/lldb/Interpreter/OptionValueArch.h index 662e1ec9f6270..3d5d72619efca 100644 --- a/include/lldb/Interpreter/OptionValueArch.h +++ b/include/lldb/Interpreter/OptionValueArch.h @@ -71,7 +71,7 @@ public: DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool diff --git a/include/lldb/Interpreter/OptionValueArray.h b/include/lldb/Interpreter/OptionValueArray.h index 39ae2f6f43d6b..2e44f9f074383 100644 --- a/include/lldb/Interpreter/OptionValueArray.h +++ b/include/lldb/Interpreter/OptionValueArray.h @@ -49,7 +49,7 @@ public: DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool diff --git a/include/lldb/Interpreter/OptionValueBoolean.h b/include/lldb/Interpreter/OptionValueBoolean.h index e024f3a0f3db5..214fd1649d39a 100644 --- a/include/lldb/Interpreter/OptionValueBoolean.h +++ b/include/lldb/Interpreter/OptionValueBoolean.h @@ -54,7 +54,7 @@ public: DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool diff --git a/include/lldb/Interpreter/OptionValueChar.h b/include/lldb/Interpreter/OptionValueChar.h index 55f4b63538eae..8fc02093e3d99 100644 --- a/include/lldb/Interpreter/OptionValueChar.h +++ b/include/lldb/Interpreter/OptionValueChar.h @@ -54,7 +54,7 @@ public: DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool diff --git a/include/lldb/Interpreter/OptionValueDictionary.h b/include/lldb/Interpreter/OptionValueDictionary.h index 5fb698b9f221a..efa15dd6ef880 100644 --- a/include/lldb/Interpreter/OptionValueDictionary.h +++ b/include/lldb/Interpreter/OptionValueDictionary.h @@ -50,7 +50,7 @@ public: DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool diff --git a/include/lldb/Interpreter/OptionValueEnumeration.h b/include/lldb/Interpreter/OptionValueEnumeration.h index 68beddfce0d02..e820729385de3 100644 --- a/include/lldb/Interpreter/OptionValueEnumeration.h +++ b/include/lldb/Interpreter/OptionValueEnumeration.h @@ -55,7 +55,7 @@ public: DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool diff --git a/include/lldb/Interpreter/OptionValueFileSpec.h b/include/lldb/Interpreter/OptionValueFileSpec.h index 7e74b605660c6..80dd77ecef2a6 100644 --- a/include/lldb/Interpreter/OptionValueFileSpec.h +++ b/include/lldb/Interpreter/OptionValueFileSpec.h @@ -22,12 +22,14 @@ namespace lldb_private { class OptionValueFileSpec : public OptionValue { public: - OptionValueFileSpec (); + OptionValueFileSpec (bool resolve = true); - OptionValueFileSpec (const FileSpec &value); + OptionValueFileSpec (const FileSpec &value, + bool resolve = true); OptionValueFileSpec (const FileSpec ¤t_value, - const FileSpec &default_value); + const FileSpec &default_value, + bool resolve = true); virtual ~OptionValueFileSpec() @@ -48,7 +50,7 @@ public: DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool @@ -57,6 +59,7 @@ public: m_current_value = m_default_value; m_value_was_set = false; m_data_sp.reset(); + m_data_mod_time.Clear(); return true; } @@ -121,7 +124,9 @@ protected: FileSpec m_current_value; FileSpec m_default_value; lldb::DataBufferSP m_data_sp; + TimeValue m_data_mod_time; uint32_t m_completion_mask; + bool m_resolve; }; } // namespace lldb_private diff --git a/include/lldb/Interpreter/OptionValueFileSpecList.h b/include/lldb/Interpreter/OptionValueFileSpecList.h index 792de4e23af61..a105d22e45f9a 100644 --- a/include/lldb/Interpreter/OptionValueFileSpecList.h +++ b/include/lldb/Interpreter/OptionValueFileSpecList.h @@ -54,7 +54,7 @@ public: DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool diff --git a/include/lldb/Interpreter/OptionValueFormat.h b/include/lldb/Interpreter/OptionValueFormat.h index 245b2eeb5af15..06ed128543182 100644 --- a/include/lldb/Interpreter/OptionValueFormat.h +++ b/include/lldb/Interpreter/OptionValueFormat.h @@ -55,7 +55,7 @@ public: DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool diff --git a/include/lldb/Interpreter/OptionValueFormatEntity.h b/include/lldb/Interpreter/OptionValueFormatEntity.h index cc988998bda09..18ace3a6a1b69 100644 --- a/include/lldb/Interpreter/OptionValueFormatEntity.h +++ b/include/lldb/Interpreter/OptionValueFormatEntity.h @@ -43,7 +43,7 @@ public: DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override; Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign) override; bool diff --git a/include/lldb/Interpreter/OptionValueLanguage.h b/include/lldb/Interpreter/OptionValueLanguage.h new file mode 100644 index 0000000000000..fba5e22821e0d --- /dev/null +++ b/include/lldb/Interpreter/OptionValueLanguage.h @@ -0,0 +1,107 @@ +//===-- OptionValueLanguage.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_OptionValueLanguage_h_ +#define liblldb_OptionValueLanguage_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-enumerations.h" +#include "lldb/Interpreter/OptionValue.h" + +namespace lldb_private { + +class OptionValueLanguage : public OptionValue +{ +public: + OptionValueLanguage (lldb::LanguageType value) : + OptionValue(), + m_current_value (value), + m_default_value (value) + { + } + + OptionValueLanguage (lldb::LanguageType current_value, + lldb::LanguageType default_value) : + OptionValue(), + m_current_value (current_value), + m_default_value (default_value) + { + } + + virtual + ~OptionValueLanguage () + { + } + + //--------------------------------------------------------------------- + // Virtual subclass pure virtual overrides + //--------------------------------------------------------------------- + + OptionValue::Type + GetType () const override + { + return eTypeLanguage; + } + + void + DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override; + + Error + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign) override; + + bool + Clear () override + { + m_current_value = m_default_value; + m_value_was_set = false; + return true; + } + + lldb::OptionValueSP + DeepCopy () const override; + + //--------------------------------------------------------------------- + // Subclass specific functions + //--------------------------------------------------------------------- + + lldb::LanguageType + GetCurrentValue() const + { + return m_current_value; + } + + lldb::LanguageType + GetDefaultValue() const + { + return m_default_value; + } + + void + SetCurrentValue (lldb::LanguageType value) + { + m_current_value = value; + } + + void + SetDefaultValue (lldb::LanguageType value) + { + m_default_value = value; + } + +protected: + lldb::LanguageType m_current_value; + lldb::LanguageType m_default_value; +}; + +} // namespace lldb_private + +#endif // liblldb_OptionValueLanguage_h_ diff --git a/include/lldb/Interpreter/OptionValuePathMappings.h b/include/lldb/Interpreter/OptionValuePathMappings.h index 7ebf4947c6af2..7b476a9cd366a 100644 --- a/include/lldb/Interpreter/OptionValuePathMappings.h +++ b/include/lldb/Interpreter/OptionValuePathMappings.h @@ -48,7 +48,7 @@ public: DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool diff --git a/include/lldb/Interpreter/OptionValueProperties.h b/include/lldb/Interpreter/OptionValueProperties.h index 6f7f4995ed159..405beefff6d15 100644 --- a/include/lldb/Interpreter/OptionValueProperties.h +++ b/include/lldb/Interpreter/OptionValueProperties.h @@ -61,7 +61,7 @@ public: DeepCopy () const; virtual Error - SetValueFromCString (const char *value, VarSetOperationType op = eVarSetOperationAssign); + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual void DumpValue (const ExecutionContext *exe_ctx, diff --git a/include/lldb/Interpreter/OptionValueRegex.h b/include/lldb/Interpreter/OptionValueRegex.h index 295bb98b69e64..5e04218dbfdfc 100644 --- a/include/lldb/Interpreter/OptionValueRegex.h +++ b/include/lldb/Interpreter/OptionValueRegex.h @@ -49,7 +49,7 @@ public: DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool diff --git a/include/lldb/Interpreter/OptionValueSInt64.h b/include/lldb/Interpreter/OptionValueSInt64.h index 8bc8fb2da2d53..36ae97ccfcf87 100644 --- a/include/lldb/Interpreter/OptionValueSInt64.h +++ b/include/lldb/Interpreter/OptionValueSInt64.h @@ -77,7 +77,7 @@ public: DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool diff --git a/include/lldb/Interpreter/OptionValueString.h b/include/lldb/Interpreter/OptionValueString.h index a82e1403b74ba..c75745d402bef 100644 --- a/include/lldb/Interpreter/OptionValueString.h +++ b/include/lldb/Interpreter/OptionValueString.h @@ -137,7 +137,7 @@ public: DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool diff --git a/include/lldb/Interpreter/OptionValueUInt64.h b/include/lldb/Interpreter/OptionValueUInt64.h index 9b5496f9835c3..51ff8818dcff4 100644 --- a/include/lldb/Interpreter/OptionValueUInt64.h +++ b/include/lldb/Interpreter/OptionValueUInt64.h @@ -70,7 +70,7 @@ public: DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool diff --git a/include/lldb/Interpreter/OptionValueUUID.h b/include/lldb/Interpreter/OptionValueUUID.h index caf436e576f5f..c6ab48a627f6b 100644 --- a/include/lldb/Interpreter/OptionValueUUID.h +++ b/include/lldb/Interpreter/OptionValueUUID.h @@ -53,7 +53,7 @@ public: DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); virtual Error - SetValueFromCString (const char *value, + SetValueFromString (llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); virtual bool diff --git a/include/lldb/Interpreter/OptionValues.h b/include/lldb/Interpreter/OptionValues.h index 2ccab994674bf..44e1f09758268 100644 --- a/include/lldb/Interpreter/OptionValues.h +++ b/include/lldb/Interpreter/OptionValues.h @@ -21,6 +21,7 @@ #include "lldb/Interpreter/OptionValueFileSpec.h" #include "lldb/Interpreter/OptionValueFileSpecList.h" #include "lldb/Interpreter/OptionValueFormat.h" +#include "lldb/Interpreter/OptionValueLanguage.h" #include "lldb/Interpreter/OptionValueFormatEntity.h" #include "lldb/Interpreter/OptionValuePathMappings.h" #include "lldb/Interpreter/OptionValueProperties.h" diff --git a/include/lldb/Interpreter/PythonDataObjects.h b/include/lldb/Interpreter/PythonDataObjects.h index a1145b6f33d9b..df281b533cba8 100644 --- a/include/lldb/Interpreter/PythonDataObjects.h +++ b/include/lldb/Interpreter/PythonDataObjects.h @@ -17,12 +17,61 @@ // Project includes #include "lldb/lldb-defines.h" #include "lldb/Core/ConstString.h" +#include "lldb/Core/StructuredData.h" #include "lldb/Core/Flags.h" #include "lldb/Interpreter/OptionValue.h" #include "lldb/lldb-python.h" namespace lldb_private { - +class PythonString; +class PythonList; +class PythonDictionary; +class PythonObject; +class PythonInteger; + +class StructuredPythonObject : public StructuredData::Generic +{ + public: + StructuredPythonObject() + : StructuredData::Generic() + { + } + + StructuredPythonObject(void *obj) + : StructuredData::Generic(obj) + { + Py_XINCREF(GetValue()); + } + + virtual ~StructuredPythonObject() + { + if (Py_IsInitialized()) + Py_XDECREF(GetValue()); + SetValue(nullptr); + } + + bool + IsValid() const override + { + return GetValue() && GetValue() != Py_None; + } + + void Dump(Stream &s) const override; + + private: + DISALLOW_COPY_AND_ASSIGN(StructuredPythonObject); +}; + +enum class PyObjectType +{ + Unknown, + None, + Integer, + Dictionary, + List, + String +}; + class PythonObject { public: @@ -42,8 +91,6 @@ namespace lldb_private { { Reset (rhs.m_py_obj); } - - explicit PythonObject (const lldb::ScriptInterpreterObjectSP &script_object_sp); virtual ~PythonObject () @@ -89,6 +136,8 @@ namespace lldb_private { return m_py_obj; } + PyObjectType GetObjectType() const; + PythonString Repr (); @@ -102,7 +151,9 @@ namespace lldb_private { bool IsNULLOrNone () const; - + + StructuredData::ObjectSP CreateStructuredObject() const; + protected: PyObject* m_py_obj; }; @@ -110,25 +161,25 @@ namespace lldb_private { class PythonString: public PythonObject { public: - PythonString (); PythonString (PyObject *o); PythonString (const PythonObject &object); - PythonString (const lldb::ScriptInterpreterObjectSP &script_object_sp); - PythonString (const char* string); + PythonString (llvm::StringRef string); + PythonString (const char *string); virtual ~PythonString (); - + virtual bool Reset (PyObject* py_obj = NULL); - const char* + llvm::StringRef GetString() const; size_t GetSize() const; - void - SetString (const char* string); + void SetString(llvm::StringRef string); + + StructuredData::StringSP CreateStructuredString() const; }; class PythonInteger: public PythonObject @@ -138,18 +189,18 @@ namespace lldb_private { PythonInteger (); PythonInteger (PyObject* py_obj); PythonInteger (const PythonObject &object); - PythonInteger (const lldb::ScriptInterpreterObjectSP &script_object_sp); PythonInteger (int64_t value); virtual ~PythonInteger (); virtual bool Reset (PyObject* py_obj = NULL); - - int64_t - GetInteger(); - + + int64_t GetInteger() const; + void SetInteger (int64_t value); + + StructuredData::IntegerSP CreateStructuredInteger() const; }; class PythonList: public PythonObject @@ -159,24 +210,23 @@ namespace lldb_private { PythonList (bool create_empty); PythonList (PyObject* py_obj); PythonList (const PythonObject &object); - PythonList (const lldb::ScriptInterpreterObjectSP &script_object_sp); PythonList (uint32_t count); virtual ~PythonList (); virtual bool Reset (PyObject* py_obj = NULL); - - uint32_t - GetSize(); - - PythonObject - GetItemAtIndex (uint32_t index); - + + uint32_t GetSize() const; + + PythonObject GetItemAtIndex(uint32_t index) const; + void SetItemAtIndex (uint32_t index, const PythonObject &object); void AppendItem (const PythonObject &object); + + StructuredData::ArraySP CreateStructuredArray() const; }; class PythonDictionary: public PythonObject @@ -186,14 +236,13 @@ namespace lldb_private { explicit PythonDictionary (bool create_empty); PythonDictionary (PyObject* object); PythonDictionary (const PythonObject &object); - PythonDictionary (const lldb::ScriptInterpreterObjectSP &script_object_sp); virtual ~PythonDictionary (); virtual bool Reset (PyObject* object = NULL); - - uint32_t GetSize(); - + + uint32_t GetSize() const; + PythonObject GetItemForKey (const PythonString &key) const; @@ -222,6 +271,8 @@ namespace lldb_private { void SetItemForKey (const PythonString &key, const PythonObject& value); + + StructuredData::DictionarySP CreateStructuredDictionary() const; }; } // namespace lldb_private diff --git a/include/lldb/Interpreter/ScriptInterpreter.h b/include/lldb/Interpreter/ScriptInterpreter.h index 1b4b881619274..0f45dd8245e9f 100644 --- a/include/lldb/Interpreter/ScriptInterpreter.h +++ b/include/lldb/Interpreter/ScriptInterpreter.h @@ -14,53 +14,12 @@ #include "lldb/Core/Broadcaster.h" #include "lldb/Core/Error.h" +#include "lldb/Core/StructuredData.h" #include "lldb/Utility/PseudoTerminal.h" namespace lldb_private { - -class ScriptInterpreterObject -{ -public: - ScriptInterpreterObject() : - m_object(NULL) - {} - - ScriptInterpreterObject(void* obj) : - m_object(obj) - {} - - ScriptInterpreterObject(const ScriptInterpreterObject& rhs) - : m_object(rhs.m_object) - {} - - virtual void* - GetObject() - { - return m_object; - } - - explicit operator bool () - { - return m_object != NULL; - } - - ScriptInterpreterObject& - operator = (const ScriptInterpreterObject& rhs) - { - if (this != &rhs) - m_object = rhs.m_object; - return *this; - } - - virtual - ~ScriptInterpreterObject() - {} - -protected: - void* m_object; -}; class ScriptInterpreterLocker { @@ -82,87 +41,6 @@ class ScriptInterpreter { public: - typedef void (*SWIGInitCallback) (void); - - typedef bool (*SWIGBreakpointCallbackFunction) (const char *python_function_name, - const char *session_dictionary_name, - const lldb::StackFrameSP& frame_sp, - const lldb::BreakpointLocationSP &bp_loc_sp); - - typedef bool (*SWIGWatchpointCallbackFunction) (const char *python_function_name, - const char *session_dictionary_name, - const lldb::StackFrameSP& frame_sp, - const lldb::WatchpointSP &wp_sp); - - typedef bool (*SWIGPythonTypeScriptCallbackFunction) (const char *python_function_name, - void *session_dictionary, - const lldb::ValueObjectSP& valobj_sp, - void** pyfunct_wrapper, - const lldb::TypeSummaryOptionsSP& options, - std::string& retval); - - typedef void* (*SWIGPythonCreateSyntheticProvider) (const char *python_class_name, - const char *session_dictionary_name, - const lldb::ValueObjectSP& valobj_sp); - - typedef void* (*SWIGPythonCreateScriptedThreadPlan) (const char *python_class_name, - const char *session_dictionary_name, - const lldb::ThreadPlanSP& thread_plan_sp); - - typedef bool (*SWIGPythonCallThreadPlan) (void *implementor, const char *method_name, Event *event_sp, bool &got_error); - - typedef void* (*SWIGPythonCreateOSPlugin) (const char *python_class_name, - const char *session_dictionary_name, - const lldb::ProcessSP& process_sp); - - typedef uint32_t (*SWIGPythonCalculateNumChildren) (void *implementor); - typedef void* (*SWIGPythonGetChildAtIndex) (void *implementor, uint32_t idx); - typedef int (*SWIGPythonGetIndexOfChildWithName) (void *implementor, const char* child_name); - typedef void* (*SWIGPythonCastPyObjectToSBValue) (void* data); - typedef lldb::ValueObjectSP (*SWIGPythonGetValueObjectSPFromSBValue) (void* data); - typedef bool (*SWIGPythonUpdateSynthProviderInstance) (void* data); - typedef bool (*SWIGPythonMightHaveChildrenSynthProviderInstance) (void* data); - typedef void* (*SWIGPythonGetValueSynthProviderInstance) (void *implementor); - - typedef bool (*SWIGPythonCallCommand) (const char *python_function_name, - const char *session_dictionary_name, - lldb::DebuggerSP& debugger, - const char* args, - lldb_private::CommandReturnObject& cmd_retobj, - lldb::ExecutionContextRefSP exe_ctx_ref_sp); - - typedef bool (*SWIGPythonCallModuleInit) (const char *python_module_name, - const char *session_dictionary_name, - lldb::DebuggerSP& debugger); - - typedef bool (*SWIGPythonScriptKeyword_Process) (const char* python_function_name, - const char* session_dictionary_name, - lldb::ProcessSP& process, - std::string& output); - typedef bool (*SWIGPythonScriptKeyword_Thread) (const char* python_function_name, - const char* session_dictionary_name, - lldb::ThreadSP& thread, - std::string& output); - - typedef bool (*SWIGPythonScriptKeyword_Target) (const char* python_function_name, - const char* session_dictionary_name, - lldb::TargetSP& target, - std::string& output); - - typedef bool (*SWIGPythonScriptKeyword_Frame) (const char* python_function_name, - const char* session_dictionary_name, - lldb::StackFrameSP& frame, - std::string& output); - - typedef bool (*SWIGPythonScriptKeyword_Value) (const char* python_function_name, - const char* session_dictionary_name, - lldb::ValueObjectSP& value, - std::string& output); - - typedef void* (*SWIGPython_GetDynamicSetting) (void* module, - const char* setting, - const lldb::TargetSP& target_sp); - typedef enum { eScriptReturnTypeCharPtr, @@ -324,95 +202,87 @@ public: { return false; } - - virtual lldb::ScriptInterpreterObjectSP - CreateSyntheticScriptedProvider (const char *class_name, - lldb::ValueObjectSP valobj) + + virtual StructuredData::ObjectSP + CreateSyntheticScriptedProvider(const char *class_name, lldb::ValueObjectSP valobj) { - return lldb::ScriptInterpreterObjectSP(); + return StructuredData::ObjectSP(); } - - virtual lldb::ScriptInterpreterObjectSP + + virtual StructuredData::GenericSP + CreateScriptCommandObject (const char *class_name) + { + return StructuredData::GenericSP(); + } + + virtual StructuredData::GenericSP OSPlugin_CreatePluginObject (const char *class_name, lldb::ProcessSP process_sp) { - return lldb::ScriptInterpreterObjectSP(); + return StructuredData::GenericSP(); } - - virtual lldb::ScriptInterpreterObjectSP - OSPlugin_RegisterInfo (lldb::ScriptInterpreterObjectSP os_plugin_object_sp) + + virtual StructuredData::DictionarySP + OSPlugin_RegisterInfo(StructuredData::ObjectSP os_plugin_object_sp) { - return lldb::ScriptInterpreterObjectSP(); + return StructuredData::DictionarySP(); } - - virtual lldb::ScriptInterpreterObjectSP - OSPlugin_ThreadsInfo (lldb::ScriptInterpreterObjectSP os_plugin_object_sp) + + virtual StructuredData::ArraySP + OSPlugin_ThreadsInfo(StructuredData::ObjectSP os_plugin_object_sp) { - return lldb::ScriptInterpreterObjectSP(); + return StructuredData::ArraySP(); } - - virtual lldb::ScriptInterpreterObjectSP - OSPlugin_RegisterContextData (lldb::ScriptInterpreterObjectSP os_plugin_object_sp, - lldb::tid_t thread_id) + + virtual StructuredData::StringSP + OSPlugin_RegisterContextData(StructuredData::ObjectSP os_plugin_object_sp, lldb::tid_t thread_id) { - return lldb::ScriptInterpreterObjectSP(); + return StructuredData::StringSP(); } - virtual lldb::ScriptInterpreterObjectSP - OSPlugin_CreateThread (lldb::ScriptInterpreterObjectSP os_plugin_object_sp, - lldb::tid_t tid, - lldb::addr_t context) + virtual StructuredData::DictionarySP + OSPlugin_CreateThread(StructuredData::ObjectSP os_plugin_object_sp, lldb::tid_t tid, lldb::addr_t context) { - return lldb::ScriptInterpreterObjectSP(); + return StructuredData::DictionarySP(); } - - virtual lldb::ScriptInterpreterObjectSP - CreateScriptedThreadPlan (const char *class_name, - lldb::ThreadPlanSP thread_plan_sp) + + virtual StructuredData::ObjectSP + CreateScriptedThreadPlan(const char *class_name, lldb::ThreadPlanSP thread_plan_sp) { - return lldb::ScriptInterpreterObjectSP(); + return StructuredData::ObjectSP(); } virtual bool - ScriptedThreadPlanExplainsStop (lldb::ScriptInterpreterObjectSP implementor_sp, - Event *event, - bool &script_error) + ScriptedThreadPlanExplainsStop(StructuredData::ObjectSP implementor_sp, Event *event, bool &script_error) { script_error = true; return true; } virtual bool - ScriptedThreadPlanShouldStop (lldb::ScriptInterpreterObjectSP implementor_sp, - Event *event, - bool &script_error) + ScriptedThreadPlanShouldStop(StructuredData::ObjectSP implementor_sp, Event *event, bool &script_error) { script_error = true; return true; } virtual lldb::StateType - ScriptedThreadPlanGetRunState (lldb::ScriptInterpreterObjectSP implementor_sp, - bool &script_error) + ScriptedThreadPlanGetRunState(StructuredData::ObjectSP implementor_sp, bool &script_error) { script_error = true; return lldb::eStateStepping; } - virtual lldb::ScriptInterpreterObjectSP - LoadPluginModule (const FileSpec& file_spec, - lldb_private::Error& error) + virtual StructuredData::ObjectSP + LoadPluginModule(const FileSpec &file_spec, lldb_private::Error &error) { - return lldb::ScriptInterpreterObjectSP(); + return StructuredData::ObjectSP(); } - - virtual lldb::ScriptInterpreterObjectSP - GetDynamicSettings (lldb::ScriptInterpreterObjectSP plugin_module_sp, - Target* target, - const char* setting_name, - lldb_private::Error& error) + + virtual StructuredData::DictionarySP + GetDynamicSettings(StructuredData::ObjectSP plugin_module_sp, Target *target, const char *setting_name, lldb_private::Error &error) { - return lldb::ScriptInterpreterObjectSP(); + return StructuredData::DictionarySP(); } virtual Error @@ -464,13 +334,10 @@ public: { return; } - + virtual bool - GetScriptedSummary (const char *function_name, - lldb::ValueObjectSP valobj, - lldb::ScriptInterpreterObjectSP& callee_wrapper_sp, - const TypeSummaryOptions& options, - std::string& retval) + GetScriptedSummary(const char *function_name, lldb::ValueObjectSP valobj, StructuredData::ObjectSP &callee_wrapper_sp, + const TypeSummaryOptions &options, std::string &retval) { return false; } @@ -480,39 +347,39 @@ public: { // Clean up any ref counts to SBObjects that might be in global variables } - + virtual size_t - CalculateNumChildren (const lldb::ScriptInterpreterObjectSP& implementor) + CalculateNumChildren(const StructuredData::ObjectSP &implementor) { return 0; } - + virtual lldb::ValueObjectSP - GetChildAtIndex (const lldb::ScriptInterpreterObjectSP& implementor, uint32_t idx) + GetChildAtIndex(const StructuredData::ObjectSP &implementor, uint32_t idx) { return lldb::ValueObjectSP(); } - + virtual int - GetIndexOfChildWithName (const lldb::ScriptInterpreterObjectSP& implementor, const char* child_name) + GetIndexOfChildWithName(const StructuredData::ObjectSP &implementor, const char *child_name) { return UINT32_MAX; } - + virtual bool - UpdateSynthProviderInstance (const lldb::ScriptInterpreterObjectSP& implementor) + UpdateSynthProviderInstance(const StructuredData::ObjectSP &implementor) { return false; } - + virtual bool - MightHaveChildrenSynthProviderInstance (const lldb::ScriptInterpreterObjectSP& implementor) + MightHaveChildrenSynthProviderInstance(const StructuredData::ObjectSP &implementor) { return true; } - + virtual lldb::ValueObjectSP - GetSyntheticValue (const lldb::ScriptInterpreterObjectSP& implementor) + GetSyntheticValue(const StructuredData::ObjectSP &implementor) { return nullptr; } @@ -529,6 +396,17 @@ public: } virtual bool + RunScriptBasedCommand (StructuredData::GenericSP impl_obj_sp, + const char* args, + ScriptedCommandSynchronicity synchronicity, + lldb_private::CommandReturnObject& cmd_retobj, + Error& error, + const lldb_private::ExecutionContext& exe_ctx) + { + return false; + } + + virtual bool RunScriptFormatKeyword (const char* impl_function, Process* process, std::string& output, @@ -586,26 +464,45 @@ public: } virtual bool + GetShortHelpForCommandObject (StructuredData::GenericSP cmd_obj_sp, + std::string& dest) + { + dest.clear(); + return false; + } + + virtual uint32_t + GetFlagsForCommandObject (StructuredData::GenericSP cmd_obj_sp) + { + return 0; + } + + virtual bool + GetLongHelpForCommandObject (StructuredData::GenericSP cmd_obj_sp, + std::string& dest) + { + dest.clear(); + return false; + } + + virtual bool CheckObjectExists (const char* name) { return false; } virtual bool - LoadScriptingModule (const char* filename, - bool can_reload, - bool init_session, - lldb_private::Error& error, - lldb::ScriptInterpreterObjectSP* module_sp = nullptr) + LoadScriptingModule(const char *filename, bool can_reload, bool init_session, lldb_private::Error &error, + StructuredData::ObjectSP *module_sp = nullptr) { error.SetErrorString("loading unimplemented"); return false; } - - virtual lldb::ScriptInterpreterObjectSP - MakeScriptObject (void* object) + + virtual bool + IsReservedWord (const char* word) { - return lldb::ScriptInterpreterObjectSP(new ScriptInterpreterObject(object)); + return false; } virtual std::unique_ptr<ScriptInterpreterLocker> @@ -622,32 +519,6 @@ public: static std::string LanguageToString (lldb::ScriptLanguage language); - - static void - InitializeInterpreter (SWIGInitCallback python_swig_init_callback, - SWIGBreakpointCallbackFunction swig_breakpoint_callback, - SWIGWatchpointCallbackFunction swig_watchpoint_callback, - SWIGPythonTypeScriptCallbackFunction swig_typescript_callback, - SWIGPythonCreateSyntheticProvider swig_synthetic_script, - SWIGPythonCalculateNumChildren swig_calc_children, - SWIGPythonGetChildAtIndex swig_get_child_index, - SWIGPythonGetIndexOfChildWithName swig_get_index_child, - SWIGPythonCastPyObjectToSBValue swig_cast_to_sbvalue , - SWIGPythonGetValueObjectSPFromSBValue swig_get_valobj_sp_from_sbvalue, - SWIGPythonUpdateSynthProviderInstance swig_update_provider, - SWIGPythonMightHaveChildrenSynthProviderInstance swig_mighthavechildren_provider, - SWIGPythonGetValueSynthProviderInstance swig_getvalue_provider, - SWIGPythonCallCommand swig_call_command, - SWIGPythonCallModuleInit swig_call_module_init, - SWIGPythonCreateOSPlugin swig_create_os_plugin, - SWIGPythonScriptKeyword_Process swig_run_script_keyword_process, - SWIGPythonScriptKeyword_Thread swig_run_script_keyword_thread, - SWIGPythonScriptKeyword_Target swig_run_script_keyword_target, - SWIGPythonScriptKeyword_Frame swig_run_script_keyword_frame, - SWIGPythonScriptKeyword_Value swig_run_script_keyword_value, - SWIGPython_GetDynamicSetting swig_plugin_get, - SWIGPythonCreateScriptedThreadPlan swig_thread_plan_script, - SWIGPythonCallThreadPlan swig_call_thread_plan); 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 94ed16e02ca2a..058058ecccb52 100644 --- a/include/lldb/Interpreter/ScriptInterpreterPython.h +++ b/include/lldb/Interpreter/ScriptInterpreterPython.h @@ -33,8 +33,99 @@ class ScriptInterpreterPython : public IOHandlerDelegateMultiline { public: + typedef void (*SWIGInitCallback) (void); - friend class IOHandlerPythonInterpreter; + typedef bool (*SWIGBreakpointCallbackFunction) (const char *python_function_name, + const char *session_dictionary_name, + const lldb::StackFrameSP& frame_sp, + const lldb::BreakpointLocationSP &bp_loc_sp); + + typedef bool (*SWIGWatchpointCallbackFunction) (const char *python_function_name, + const char *session_dictionary_name, + const lldb::StackFrameSP& frame_sp, + const lldb::WatchpointSP &wp_sp); + + typedef bool (*SWIGPythonTypeScriptCallbackFunction) (const char *python_function_name, + void *session_dictionary, + const lldb::ValueObjectSP& valobj_sp, + void** pyfunct_wrapper, + const lldb::TypeSummaryOptionsSP& options, + std::string& retval); + + typedef void* (*SWIGPythonCreateSyntheticProvider) (const char *python_class_name, + const char *session_dictionary_name, + const lldb::ValueObjectSP& valobj_sp); + + typedef void* (*SWIGPythonCreateCommandObject) (const char *python_class_name, + const char *session_dictionary_name, + const lldb::DebuggerSP debugger_sp); + + typedef void* (*SWIGPythonCreateScriptedThreadPlan) (const char *python_class_name, + const char *session_dictionary_name, + const lldb::ThreadPlanSP& thread_plan_sp); + + typedef bool (*SWIGPythonCallThreadPlan) (void *implementor, const char *method_name, Event *event_sp, bool &got_error); + + typedef void* (*SWIGPythonCreateOSPlugin) (const char *python_class_name, + const char *session_dictionary_name, + const lldb::ProcessSP& process_sp); + + typedef size_t (*SWIGPythonCalculateNumChildren) (void *implementor); + typedef void* (*SWIGPythonGetChildAtIndex) (void *implementor, uint32_t idx); + typedef int (*SWIGPythonGetIndexOfChildWithName) (void *implementor, const char* child_name); + typedef void* (*SWIGPythonCastPyObjectToSBValue) (void* data); + typedef lldb::ValueObjectSP (*SWIGPythonGetValueObjectSPFromSBValue) (void* data); + typedef bool (*SWIGPythonUpdateSynthProviderInstance) (void* data); + typedef bool (*SWIGPythonMightHaveChildrenSynthProviderInstance) (void* data); + typedef void* (*SWIGPythonGetValueSynthProviderInstance) (void *implementor); + + typedef bool (*SWIGPythonCallCommand) (const char *python_function_name, + const char *session_dictionary_name, + lldb::DebuggerSP& debugger, + const char* args, + lldb_private::CommandReturnObject& cmd_retobj, + lldb::ExecutionContextRefSP exe_ctx_ref_sp); + + typedef bool (*SWIGPythonCallCommandObject) (void *implementor, + lldb::DebuggerSP& debugger, + const char* args, + lldb_private::CommandReturnObject& cmd_retobj, + lldb::ExecutionContextRefSP exe_ctx_ref_sp); + + + typedef bool (*SWIGPythonCallModuleInit) (const char *python_module_name, + const char *session_dictionary_name, + lldb::DebuggerSP& debugger); + + typedef bool (*SWIGPythonScriptKeyword_Process) (const char* python_function_name, + const char* session_dictionary_name, + lldb::ProcessSP& process, + std::string& output); + typedef bool (*SWIGPythonScriptKeyword_Thread) (const char* python_function_name, + const char* session_dictionary_name, + lldb::ThreadSP& thread, + std::string& output); + + typedef bool (*SWIGPythonScriptKeyword_Target) (const char* python_function_name, + const char* session_dictionary_name, + lldb::TargetSP& target, + std::string& output); + + typedef bool (*SWIGPythonScriptKeyword_Frame) (const char* python_function_name, + const char* session_dictionary_name, + lldb::StackFrameSP& frame, + std::string& output); + + typedef bool (*SWIGPythonScriptKeyword_Value) (const char* python_function_name, + const char* session_dictionary_name, + lldb::ValueObjectSP& value, + std::string& output); + + typedef void* (*SWIGPython_GetDynamicSetting) (void* module, + const char* setting, + const lldb::TargetSP& target_sp); + + friend class ::IOHandlerPythonInterpreter; ScriptInterpreterPython (CommandInterpreter &interpreter); @@ -79,74 +170,45 @@ public: bool GenerateScriptAliasFunction (StringList &input, std::string& output) override; - - lldb::ScriptInterpreterObjectSP - CreateSyntheticScriptedProvider (const char *class_name, - lldb::ValueObjectSP valobj) override; - lldb::ScriptInterpreterObjectSP - CreateScriptedThreadPlan (const char *class_name, - lldb::ThreadPlanSP thread_plan) override; + StructuredData::ObjectSP CreateSyntheticScriptedProvider(const char *class_name, lldb::ValueObjectSP valobj) override; + + StructuredData::GenericSP CreateScriptCommandObject (const char *class_name) override; + + StructuredData::ObjectSP CreateScriptedThreadPlan(const char *class_name, lldb::ThreadPlanSP thread_plan) override; + + bool ScriptedThreadPlanExplainsStop(StructuredData::ObjectSP implementor_sp, Event *event, bool &script_error) override; + bool ScriptedThreadPlanShouldStop(StructuredData::ObjectSP implementor_sp, Event *event, bool &script_error) override; + lldb::StateType ScriptedThreadPlanGetRunState(StructuredData::ObjectSP implementor_sp, bool &script_error) override; + + StructuredData::GenericSP OSPlugin_CreatePluginObject(const char *class_name, lldb::ProcessSP process_sp) override; + + StructuredData::DictionarySP OSPlugin_RegisterInfo(StructuredData::ObjectSP os_plugin_object_sp) override; + + StructuredData::ArraySP OSPlugin_ThreadsInfo(StructuredData::ObjectSP os_plugin_object_sp) override; + + StructuredData::StringSP OSPlugin_RegisterContextData(StructuredData::ObjectSP os_plugin_object_sp, lldb::tid_t thread_id) override; + + StructuredData::DictionarySP OSPlugin_CreateThread(StructuredData::ObjectSP os_plugin_object_sp, lldb::tid_t tid, + lldb::addr_t context) override; + + StructuredData::ObjectSP LoadPluginModule(const FileSpec &file_spec, lldb_private::Error &error) override; + + StructuredData::DictionarySP GetDynamicSettings(StructuredData::ObjectSP plugin_module_sp, Target *target, const char *setting_name, + lldb_private::Error &error) override; + + size_t CalculateNumChildren(const StructuredData::ObjectSP &implementor) override; + + lldb::ValueObjectSP GetChildAtIndex(const StructuredData::ObjectSP &implementor, uint32_t idx) override; + + int GetIndexOfChildWithName(const StructuredData::ObjectSP &implementor, const char *child_name) override; + + bool UpdateSynthProviderInstance(const StructuredData::ObjectSP &implementor) override; + + bool MightHaveChildrenSynthProviderInstance(const StructuredData::ObjectSP &implementor) override; + + lldb::ValueObjectSP GetSyntheticValue(const StructuredData::ObjectSP &implementor) override; - bool - ScriptedThreadPlanExplainsStop (lldb::ScriptInterpreterObjectSP implementor_sp, - Event *event, - bool &script_error) override; - bool - ScriptedThreadPlanShouldStop (lldb::ScriptInterpreterObjectSP implementor_sp, - Event *event, - bool &script_error) override; - lldb::StateType - ScriptedThreadPlanGetRunState (lldb::ScriptInterpreterObjectSP implementor_sp, - bool &script_error) override; - - lldb::ScriptInterpreterObjectSP - OSPlugin_CreatePluginObject (const char *class_name, - lldb::ProcessSP process_sp) override; - - lldb::ScriptInterpreterObjectSP - OSPlugin_RegisterInfo (lldb::ScriptInterpreterObjectSP os_plugin_object_sp) override; - - lldb::ScriptInterpreterObjectSP - OSPlugin_ThreadsInfo (lldb::ScriptInterpreterObjectSP os_plugin_object_sp) override; - - lldb::ScriptInterpreterObjectSP - OSPlugin_RegisterContextData (lldb::ScriptInterpreterObjectSP os_plugin_object_sp, - lldb::tid_t thread_id) override; - - lldb::ScriptInterpreterObjectSP - OSPlugin_CreateThread (lldb::ScriptInterpreterObjectSP os_plugin_object_sp, - lldb::tid_t tid, - lldb::addr_t context) override; - - lldb::ScriptInterpreterObjectSP - LoadPluginModule (const FileSpec& file_spec, - lldb_private::Error& error) override; - - lldb::ScriptInterpreterObjectSP - GetDynamicSettings (lldb::ScriptInterpreterObjectSP plugin_module_sp, - Target* target, - const char* setting_name, - lldb_private::Error& error) override; - - size_t - CalculateNumChildren (const lldb::ScriptInterpreterObjectSP& implementor) override; - - lldb::ValueObjectSP - GetChildAtIndex (const lldb::ScriptInterpreterObjectSP& implementor, uint32_t idx) override; - - int - GetIndexOfChildWithName (const lldb::ScriptInterpreterObjectSP& implementor, const char* child_name) override; - - bool - UpdateSynthProviderInstance (const lldb::ScriptInterpreterObjectSP& implementor) override; - - bool - MightHaveChildrenSynthProviderInstance (const lldb::ScriptInterpreterObjectSP& implementor) override; - - lldb::ValueObjectSP - GetSyntheticValue (const lldb::ScriptInterpreterObjectSP& implementor) override; - bool RunScriptBasedCommand(const char* impl_function, const char* args, @@ -155,6 +217,14 @@ public: Error& error, const lldb_private::ExecutionContext& exe_ctx) override; + bool + RunScriptBasedCommand (StructuredData::GenericSP impl_obj_sp, + const char* args, + ScriptedCommandSynchronicity synchronicity, + lldb_private::CommandReturnObject& cmd_retobj, + Error& error, + const lldb_private::ExecutionContext& exe_ctx) override; + Error GenerateFunction(const char *signature, const StringList &input) override; @@ -188,14 +258,10 @@ public: WatchpointCallbackFunction (void *baton, StoppointCallbackContext *context, lldb::user_id_t watch_id); - - bool - GetScriptedSummary (const char *function_name, - lldb::ValueObjectSP valobj, - lldb::ScriptInterpreterObjectSP& callee_wrapper_sp, - const TypeSummaryOptions& options, - std::string& retval) override; - + + bool GetScriptedSummary(const char *function_name, lldb::ValueObjectSP valobj, StructuredData::ObjectSP &callee_wrapper_sp, + const TypeSummaryOptions &options, std::string &retval) override; + void Clear () override; @@ -203,6 +269,15 @@ public: GetDocumentationForItem (const char* item, std::string& dest) override; bool + GetShortHelpForCommandObject(StructuredData::GenericSP cmd_obj_sp, std::string& dest) override; + + uint32_t + GetFlagsForCommandObject (StructuredData::GenericSP cmd_obj_sp) override; + + bool + GetLongHelpForCommandObject(StructuredData::GenericSP cmd_obj_sp, std::string& dest) override; + + bool CheckObjectExists (const char* name) override { if (!name || !name[0]) @@ -240,17 +315,13 @@ public: ValueObject* value, std::string& output, Error& error) override; - + + bool LoadScriptingModule(const char *filename, bool can_reload, bool init_session, lldb_private::Error &error, + StructuredData::ObjectSP *module_sp = nullptr) override; + bool - LoadScriptingModule (const char* filename, - bool can_reload, - bool init_session, - lldb_private::Error& error, - lldb::ScriptInterpreterObjectSP* module_sp = nullptr) override; - - lldb::ScriptInterpreterObjectSP - MakeScriptObject (void* object) override; - + IsReservedWord (const char* word) override; + std::unique_ptr<ScriptInterpreterLocker> AcquireInterpreterLock () override; @@ -278,10 +349,9 @@ public: StringList ReadCommandInputFromUser (FILE *in_file); - - virtual void - ResetOutputFileHandle (FILE *new_fh) override; - + + void ResetOutputFileHandle(FILE *new_fh) override; + static void InitializePrivate (); @@ -291,6 +361,7 @@ public: SWIGWatchpointCallbackFunction swig_watchpoint_callback, SWIGPythonTypeScriptCallbackFunction swig_typescript_callback, SWIGPythonCreateSyntheticProvider swig_synthetic_script, + SWIGPythonCreateCommandObject swig_create_cmd, SWIGPythonCalculateNumChildren swig_calc_children, SWIGPythonGetChildAtIndex swig_get_child_index, SWIGPythonGetIndexOfChildWithName swig_get_index_child, @@ -300,6 +371,7 @@ public: SWIGPythonMightHaveChildrenSynthProviderInstance swig_mighthavechildren_provider, SWIGPythonGetValueSynthProviderInstance swig_getvalue_provider, SWIGPythonCallCommand swig_call_command, + SWIGPythonCallCommandObject swig_call_command_object, SWIGPythonCallModuleInit swig_call_module_init, SWIGPythonCreateOSPlugin swig_create_os_plugin, SWIGPythonScriptKeyword_Process swig_run_script_keyword_process, @@ -369,35 +441,6 @@ protected: ~SynchronicityHandler(); }; - class ScriptInterpreterPythonObject : public ScriptInterpreterObject - { - public: - ScriptInterpreterPythonObject() : - ScriptInterpreterObject() - {} - - ScriptInterpreterPythonObject(void* obj) : - ScriptInterpreterObject(obj) - { - Py_XINCREF(m_object); - } - - explicit operator bool () - { - return m_object && m_object != Py_None; - } - - - virtual - ~ScriptInterpreterPythonObject() - { - if (Py_IsInitialized()) - Py_XDECREF(m_object); - m_object = NULL; - } - private: - DISALLOW_COPY_AND_ASSIGN (ScriptInterpreterPythonObject); - }; public: class Locker : public ScriptInterpreterLocker { @@ -450,6 +493,13 @@ public: PyGILState_STATE m_GILState; }; protected: + enum class AddLocation + { + Beginning, + End + }; + + static void AddToSysPath(AddLocation location, std::string path); uint32_t IsExecutingPython () const |
