diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:55:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:55:28 +0000 |
commit | e81d9d49145e432d917eea3a70d2ae74dcad1d89 (patch) | |
tree | 9ed5e1a91f242e2cb5911577356e487a55c01b78 /include | |
parent | 85d8ef8f1f0e0e063a8571944302be2d2026f823 (diff) | |
download | src-e81d9d49145e432d917eea3a70d2ae74dcad1d89.tar.gz src-e81d9d49145e432d917eea3a70d2ae74dcad1d89.zip |
Vendor import of stripped lldb trunk r256633:
Notes
Notes:
svn path=/vendor/lldb/dist/; revision=292932
Diffstat (limited to 'include')
318 files changed, 12030 insertions, 11374 deletions
diff --git a/include/lldb/API/LLDB.h b/include/lldb/API/LLDB.h index 66e095395f13..eed10d08c6cc 100644 --- a/include/lldb/API/LLDB.h +++ b/include/lldb/API/LLDB.h @@ -16,6 +16,7 @@ // Project includes #include "lldb/API/SBDefines.h" #include "lldb/API/SBAddress.h" +#include "lldb/API/SBAttachInfo.h" #include "lldb/API/SBBlock.h" #include "lldb/API/SBBreakpoint.h" #include "lldb/API/SBBreakpointLocation.h" @@ -30,28 +31,47 @@ #include "lldb/API/SBError.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBExecutionContext.h" +#include "lldb/API/SBExpressionOptions.h" #include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBFileSpecList.h" #include "lldb/API/SBFrame.h" #include "lldb/API/SBFunction.h" #include "lldb/API/SBHostOS.h" #include "lldb/API/SBInstruction.h" #include "lldb/API/SBInstructionList.h" +#include "lldb/API/SBLanguageRuntime.h" +#include "lldb/API/SBLaunchInfo.h" #include "lldb/API/SBLineEntry.h" #include "lldb/API/SBListener.h" #include "lldb/API/SBModule.h" +#include "lldb/API/SBModuleSpec.h" +#include "lldb/API/SBPlatform.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBQueue.h" #include "lldb/API/SBQueueItem.h" +#include "lldb/API/SBSection.h" #include "lldb/API/SBSourceManager.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" #include "lldb/API/SBSymbol.h" #include "lldb/API/SBSymbolContext.h" +#include "lldb/API/SBSymbolContextList.h" #include "lldb/API/SBTarget.h" #include "lldb/API/SBThread.h" +#include "lldb/API/SBThreadCollection.h" +#include "lldb/API/SBThreadPlan.h" #include "lldb/API/SBType.h" +#include "lldb/API/SBTypeCategory.h" +#include "lldb/API/SBTypeEnumMember.h" +#include "lldb/API/SBTypeFilter.h" +#include "lldb/API/SBTypeFormat.h" +#include "lldb/API/SBTypeNameSpecifier.h" +#include "lldb/API/SBTypeSummary.h" +#include "lldb/API/SBTypeSynthetic.h" +#include "lldb/API/SBUnixSignals.h" #include "lldb/API/SBValue.h" #include "lldb/API/SBValueList.h" #include "lldb/API/SBVariablesOptions.h" +#include "lldb/API/SBWatchpoint.h" #endif // LLDB_LLDB_h_ diff --git a/include/lldb/API/SBAttachInfo.h b/include/lldb/API/SBAttachInfo.h index 712150e128be..a246d9919cfa 100644 --- a/include/lldb/API/SBAttachInfo.h +++ b/include/lldb/API/SBAttachInfo.h @@ -23,8 +23,47 @@ public: SBAttachInfo (lldb::pid_t pid); + //------------------------------------------------------------------ + /// Attach to a process by name. + /// + /// This function implies that a future call to SBTarget::Attach(...) + /// will be synchronous. + /// + /// @param[in] path + /// A full or partial name for the process to attach to. + /// + /// @param[in] wait_for + /// If \b false, attach to an existing process whose name matches. + /// If \b true, then wait for the next process whose name matches. + //------------------------------------------------------------------ SBAttachInfo (const char *path, bool wait_for); + //------------------------------------------------------------------ + /// Attach to a process by name. + /// + /// Future calls to SBTarget::Attach(...) will be synchronous or + /// asynchronous depending on the \a async argument. + /// + /// @param[in] path + /// A full or partial name for the process to attach to. + /// + /// @param[in] wait_for + /// If \b false, attach to an existing process whose name matches. + /// If \b true, then wait for the next process whose name matches. + /// + /// @param[in] async + /// If \b false, then the SBTarget::Attach(...) call will be a + /// synchronous call with no way to cancel the attach in + /// progress. + /// If \b true, then the SBTarget::Attach(...) function will + /// return immediately and clients are expected to wait for a + /// process eStateStopped event if a suitable process is + /// eventually found. If the client wants to cancel the event, + /// SBProcess::Stop() can be called and an eStateExited process + /// event will be delivered. + //------------------------------------------------------------------ + SBAttachInfo (const char *path, bool wait_for, bool async); + SBAttachInfo (const SBAttachInfo &rhs); ~SBAttachInfo(); @@ -47,9 +86,45 @@ public: bool GetWaitForLaunch (); + //------------------------------------------------------------------ + /// Set attach by process name settings. + /// + /// Designed to be used after a call to SBAttachInfo::SetExecutable(). + /// This function implies that a call to SBTarget::Attach(...) will + /// be synchronous. + /// + /// @param[in] wait_for + /// If \b false, attach to an existing process whose name matches. + /// If \b true, then wait for the next process whose name matches. + //------------------------------------------------------------------ void SetWaitForLaunch (bool b); + //------------------------------------------------------------------ + /// Set attach by process name settings. + /// + /// Designed to be used after a call to SBAttachInfo::SetExecutable(). + /// Future calls to SBTarget::Attach(...) will be synchronous or + /// asynchronous depending on the \a async argument. + /// + /// @param[in] wait_for + /// If \b false, attach to an existing process whose name matches. + /// If \b true, then wait for the next process whose name matches. + /// + /// @param[in] async + /// If \b false, then the SBTarget::Attach(...) call will be a + /// synchronous call with no way to cancel the attach in + /// progress. + /// If \b true, then the SBTarget::Attach(...) function will + /// return immediately and clients are expected to wait for a + /// process eStateStopped event if a suitable process is + /// eventually found. If the client wants to cancel the event, + /// SBProcess::Stop() can be called and an eStateExited process + /// event will be delivered. + //------------------------------------------------------------------ + void + SetWaitForLaunch (bool b, bool async); + bool GetIgnoreExisting (); diff --git a/include/lldb/API/SBCommandInterpreter.h b/include/lldb/API/SBCommandInterpreter.h index 235a2f3ea603..a8e9bf7ed769 100644 --- a/include/lldb/API/SBCommandInterpreter.h +++ b/include/lldb/API/SBCommandInterpreter.h @@ -10,6 +10,12 @@ #ifndef LLDB_SBCommandInterpreter_h_ #define LLDB_SBCommandInterpreter_h_ +// C Includes +// C++ Includes +#include <memory> + +// Other libraries and framework includes +// Project includes #include "lldb/API/SBDefines.h" #include "lldb/API/SBDebugger.h" @@ -59,6 +65,7 @@ public: void SetAddToHistory (bool); + private: lldb_private::CommandInterpreterRunOptions * get () const; @@ -84,11 +91,11 @@ public: SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs); + ~SBCommandInterpreter (); + const lldb::SBCommandInterpreter & operator = (const lldb::SBCommandInterpreter &rhs); - ~SBCommandInterpreter (); - static const char * GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type); @@ -187,7 +194,7 @@ public: lldb::CommandOverrideCallback callback, void *baton); - SBCommandInterpreter (lldb_private::CommandInterpreter *interpreter_ptr = NULL); // Access using SBDebugger::GetCommandInterpreter(); + SBCommandInterpreter(lldb_private::CommandInterpreter *interpreter_ptr = nullptr); // Access using SBDebugger::GetCommandInterpreter(); //---------------------------------------------------------------------- /// Return true if the command interpreter is the active IO handler. @@ -213,7 +220,7 @@ public: /// /// @return /// The string that should be written into the file handle that is - /// feeding the input stream for the debugger, or NULL if there is + /// feeding the input stream for the debugger, or nullptr if there is /// no string for this control key. //---------------------------------------------------------------------- const char * @@ -233,7 +240,6 @@ public: ResolveCommand(const char *command_line, SBCommandReturnObject &result); protected: - lldb_private::CommandInterpreter & ref (); @@ -242,6 +248,7 @@ protected: void reset (lldb_private::CommandInterpreter *); + private: friend class SBDebugger; @@ -254,6 +261,9 @@ private: class SBCommandPluginInterface { public: + virtual + ~SBCommandPluginInterface() = default; + virtual bool DoExecute (lldb::SBDebugger /*debugger*/, char** /*command*/, @@ -261,16 +271,11 @@ public: { return false; } - - virtual - ~SBCommandPluginInterface () - {} }; class SBCommand { public: - SBCommand (); bool @@ -298,13 +303,12 @@ public: SetFlags (uint32_t flags); lldb::SBCommand - AddMultiwordCommand (const char* name, const char* help = NULL); + AddMultiwordCommand(const char* name, const char* help = nullptr); lldb::SBCommand - AddCommand (const char* name, lldb::SBCommandPluginInterface* impl, const char* help = NULL); + AddCommand(const char* name, lldb::SBCommandPluginInterface* impl, const char* help = nullptr); private: - friend class SBDebugger; friend class SBCommandInterpreter; diff --git a/include/lldb/API/SBCommandReturnObject.h b/include/lldb/API/SBCommandReturnObject.h index c51d6bc8d2d5..b45eb9c14c04 100644 --- a/include/lldb/API/SBCommandReturnObject.h +++ b/include/lldb/API/SBCommandReturnObject.h @@ -10,8 +10,14 @@ #ifndef LLDB_SBCommandReturnObject_h_ #define LLDB_SBCommandReturnObject_h_ +// C Includes #include <stdio.h> +// C++ Includes +#include <memory> + +// Other libraries and framework includes +// Project includes #include "lldb/API/SBDefines.h" namespace lldb { @@ -19,22 +25,20 @@ namespace lldb { class LLDB_API SBCommandReturnObject { public: - SBCommandReturnObject (); SBCommandReturnObject (const lldb::SBCommandReturnObject &rhs); + ~SBCommandReturnObject (); + const lldb::SBCommandReturnObject & operator = (const lldb::SBCommandReturnObject &rhs); - SBCommandReturnObject (lldb_private::CommandReturnObject *ptr); lldb_private::CommandReturnObject * Release (); - ~SBCommandReturnObject (); - bool IsValid() const; @@ -99,8 +103,8 @@ public: GetError (bool only_if_no_immediate); void - SetError (lldb::SBError &error, - const char *fallback_error_cstr = NULL); + SetError(lldb::SBError &error, + const char *fallback_error_cstr = nullptr); void SetError (const char* error_cstr); @@ -124,10 +128,10 @@ protected: void SetLLDBObjectPtr (lldb_private::CommandReturnObject *ptr); - private: +private: std::unique_ptr<lldb_private::CommandReturnObject> m_opaque_ap; }; } // namespace lldb -#endif // LLDB_SBCommandReturnObject_h_ +#endif // LLDB_SBCommandReturnObject_h_ diff --git a/include/lldb/API/SBDebugger.h b/include/lldb/API/SBDebugger.h index 4f2c1d7f8756..7588cfc9ec42 100644 --- a/include/lldb/API/SBDebugger.h +++ b/include/lldb/API/SBDebugger.h @@ -16,13 +16,13 @@ #include "lldb/API/SBPlatform.h" namespace lldb { - class LLDB_API SBInputReader { public: - SBInputReader(); - ~SBInputReader(); + SBInputReader() = default; + ~SBInputReader() = default; + SBError Initialize(lldb::SBDebugger&, unsigned long (*)(void*, lldb::SBInputReader*, lldb::InputReaderAction, char const*, unsigned long), void*, lldb::InputReaderGranularity, char const*, char const*, bool); void SetIsDone(bool); bool IsActive() const; @@ -31,6 +31,16 @@ public: class LLDB_API SBDebugger { public: + SBDebugger(); + + SBDebugger(const lldb::SBDebugger &rhs); + + SBDebugger(const lldb::DebuggerSP &debugger_sp); + + ~SBDebugger(); + + lldb::SBDebugger & + operator = (const lldb::SBDebugger &rhs); static void Initialize(); @@ -54,17 +64,6 @@ public: static void MemoryPressureDetected (); - SBDebugger(); - - SBDebugger(const lldb::SBDebugger &rhs); - - SBDebugger(const lldb::DebuggerSP &debugger_sp); - - lldb::SBDebugger & - operator = (const lldb::SBDebugger &rhs); - - ~SBDebugger(); - bool IsValid() const; @@ -288,6 +287,9 @@ public: GetCategory (const char* category_name); SBTypeCategory + GetCategory (lldb::LanguageType lang_type); + + SBTypeCategory CreateCategory (const char* category_name); bool @@ -329,8 +331,11 @@ public: int &num_errors, bool &quit_requested, bool &stopped_for_crash); -private: + + SBError + RunREPL (lldb::LanguageType language, const char *repl_options); +private: friend class SBCommandInterpreter; friend class SBInputReader; friend class SBListener; @@ -357,7 +362,6 @@ private: }; // class SBDebugger - } // namespace lldb #endif // LLDB_SBDebugger_h_ diff --git a/include/lldb/API/SBDefines.h b/include/lldb/API/SBDefines.h index 09bea502dd01..d81bba5a2e23 100644 --- a/include/lldb/API/SBDefines.h +++ b/include/lldb/API/SBDefines.h @@ -86,9 +86,7 @@ class LLDB_API SBTypeMemberFunction; class LLDB_API SBTypeNameSpecifier; class LLDB_API SBTypeSummary; class LLDB_API SBTypeSummaryOptions; -#ifndef LLDB_DISABLE_PYTHON class LLDB_API SBTypeSynthetic; -#endif class LLDB_API SBTypeList; class LLDB_API SBValue; class LLDB_API SBValueList; diff --git a/include/lldb/API/SBFunction.h b/include/lldb/API/SBFunction.h index 86cfeb49bb58..f76c77c44e3f 100644 --- a/include/lldb/API/SBFunction.h +++ b/include/lldb/API/SBFunction.h @@ -53,6 +53,9 @@ public: lldb::SBAddress GetEndAddress (); + const char * + GetArgumentName (uint32_t arg_idx); + uint32_t GetPrologueByteSize (); @@ -66,6 +69,9 @@ public: GetLanguage (); bool + GetIsOptimized (); + + bool operator == (const lldb::SBFunction &rhs) const; bool diff --git a/include/lldb/API/SBProcess.h b/include/lldb/API/SBProcess.h index 71bca4fc697a..1a9cc8022880 100644 --- a/include/lldb/API/SBProcess.h +++ b/include/lldb/API/SBProcess.h @@ -294,8 +294,56 @@ public: uint32_t GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const; + //------------------------------------------------------------------ + /// Load a shared library into this process. + /// + /// @param[in] remote_image_spec + /// The path for the shared library on the target what you want + /// to load. + /// + /// @param[out] error + /// An error object that gets filled in with any errors that + /// might occur when trying to load the shared library. + /// + /// @return + /// A token that represents the shared library that can be + /// later used to unload the shared library. A value of + /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared + /// library can't be opened. + //------------------------------------------------------------------ uint32_t - LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error); + LoadImage (lldb::SBFileSpec &remote_image_spec, lldb::SBError &error); + + //------------------------------------------------------------------ + /// Load a shared library into this process. + /// + /// @param[in] local_image_spec + /// The file spec that points to the shared library that you + /// want to load if the library is located on the host. The + /// library will be copied over to the location specified by + /// remote_image_spec or into the current working directory with + /// the same filename if the remote_image_spec isn't specified. + /// + /// @param[in] remote_image_spec + /// If local_image_spec is specified then the location where the + /// library should be copied over from the host. If + /// local_image_spec isn't specified, then the path for the + /// shared library on the target what you want to load. + /// + /// @param[out] error + /// An error object that gets filled in with any errors that + /// might occur when trying to load the shared library. + /// + /// @return + /// A token that represents the shared library that can be + /// later used to unload the shared library. A value of + /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared + /// library can't be opened. + //------------------------------------------------------------------ + uint32_t + LoadImage (const lldb::SBFileSpec &local_image_spec, + const lldb::SBFileSpec &remote_image_spec, + lldb::SBError &error); lldb::SBError UnloadImage (uint32_t image_token); @@ -341,6 +389,10 @@ public: bool IsInstrumentationRuntimePresent(InstrumentationRuntimeType type); + // Save the state of the process in a core file (or mini dump on Windows). + lldb::SBError + SaveCore(const char *file_name); + protected: friend class SBAddress; friend class SBBreakpoint; diff --git a/include/lldb/API/SBStream.h b/include/lldb/API/SBStream.h index 2b25cd2c68f2..e62723c2f37e 100644 --- a/include/lldb/API/SBStream.h +++ b/include/lldb/API/SBStream.h @@ -21,7 +21,9 @@ class LLDB_API SBStream public: SBStream (); - + + SBStream (SBStream &&rhs); + ~SBStream (); bool diff --git a/include/lldb/API/SBTarget.h b/include/lldb/API/SBTarget.h index 2ca0b124ce0a..723c433b521a 100644 --- a/include/lldb/API/SBTarget.h +++ b/include/lldb/API/SBTarget.h @@ -10,6 +10,10 @@ #ifndef LLDB_SBTarget_h_ #define LLDB_SBTarget_h_ +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/API/SBDefines.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBAttachInfo.h" @@ -50,14 +54,14 @@ public: SBTarget (const lldb::TargetSP& target_sp); - const lldb::SBTarget& - operator = (const lldb::SBTarget& rhs); - //------------------------------------------------------------------ // Destructor //------------------------------------------------------------------ ~SBTarget(); + const lldb::SBTarget& + operator = (const lldb::SBTarget& rhs); + bool IsValid() const; @@ -135,17 +139,17 @@ public: /// /// @param[in] stdin_path /// The path to use when re-directing the STDIN of the new - /// process. If all stdXX_path arguments are NULL, a pseudo + /// process. If all stdXX_path arguments are nullptr, a pseudo /// terminal will be used. /// /// @param[in] stdout_path /// The path to use when re-directing the STDOUT of the new - /// process. If all stdXX_path arguments are NULL, a pseudo + /// process. If all stdXX_path arguments are nullptr, a pseudo /// terminal will be used. /// /// @param[in] stderr_path /// The path to use when re-directing the STDERR of the new - /// process. If all stdXX_path arguments are NULL, a pseudo + /// process. If all stdXX_path arguments are nullptr, a pseudo /// terminal will be used. /// /// @param[in] working_directory @@ -175,8 +179,10 @@ public: uint32_t launch_flags, // See LaunchFlags bool stop_at_entry, lldb::SBError& error); - - + + SBProcess + LoadCore (const char *core_file); + //------------------------------------------------------------------ /// Launch a new process with sensible defaults. /// @@ -212,9 +218,6 @@ public: Launch (SBLaunchInfo &launch_info, SBError& error); SBProcess - LoadCore (const char *core_file); - - SBProcess Attach (SBAttachInfo &attach_info, SBError& error); //------------------------------------------------------------------ @@ -248,6 +251,7 @@ public: ::pid_t pid, // 32 bit int process ID lldb::SBError& error); // DEPRECATED #endif + //------------------------------------------------------------------ /// Attach to process with name. /// @@ -288,7 +292,7 @@ public: /// The url to connect to, e.g., 'connect://localhost:12345'. /// /// @param[in] plugin_name - /// The plugin name to be used; can be NULL. + /// The plugin name to be used; can be nullptr. /// /// @param[out] error /// An error explaining what went wrong if the connect fails. @@ -421,7 +425,6 @@ public: lldb::SBError SetModuleLoadAddress (lldb::SBModule module, int64_t sections_offset); - //------------------------------------------------------------------ /// Clear the section base load addresses for all sections in a module. @@ -618,7 +621,7 @@ public: BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line); lldb::SBBreakpoint - BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL); + BreakpointCreateByName(const char *symbol_name, const char *module_name = nullptr); // This version uses name_type_mask = eFunctionNameTypeAuto lldb::SBBreakpoint @@ -633,14 +636,29 @@ public: const SBFileSpecList &comp_unit_list); lldb::SBBreakpoint + BreakpointCreateByName (const char *symbol_name, + uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits + lldb::LanguageType symbol_language, + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list); + + lldb::SBBreakpoint + BreakpointCreateByNames (const char *symbol_name[], + uint32_t num_names, + uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list); + + lldb::SBBreakpoint BreakpointCreateByNames (const char *symbol_name[], uint32_t num_names, uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits + lldb::LanguageType symbol_language, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list); lldb::SBBreakpoint - BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL); + BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = nullptr); lldb::SBBreakpoint BreakpointCreateByRegex (const char *symbol_name_regex, @@ -648,9 +666,15 @@ public: const SBFileSpecList &comp_unit_list); lldb::SBBreakpoint - BreakpointCreateBySourceRegex (const char *source_regex, - const SBFileSpec &source_file, - const char *module_name = NULL); + BreakpointCreateByRegex (const char *symbol_name_regex, + lldb::LanguageType symbol_language, + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list); + + lldb::SBBreakpoint + BreakpointCreateBySourceRegex(const char *source_regex, + const SBFileSpec &source_file, + const char *module_name = nullptr); lldb::SBBreakpoint BreakpointCreateBySourceRegex (const char *source_regex, @@ -665,6 +689,9 @@ public: lldb::SBBreakpoint BreakpointCreateByAddress (addr_t address); + lldb::SBBreakpoint + BreakpointCreateBySBAddress (SBAddress &address); + uint32_t GetNumBreakpoints () const; @@ -808,15 +835,10 @@ protected: void SetSP (const lldb::TargetSP& target_sp); - private: - //------------------------------------------------------------------ - // For Target only - //------------------------------------------------------------------ - lldb::TargetSP m_opaque_sp; }; } // namespace lldb -#endif // LLDB_SBTarget_h_ +#endif // LLDB_SBTarget_h_ diff --git a/include/lldb/API/SBType.h b/include/lldb/API/SBType.h index 01f0c6afc795..ed3c2ff23863 100644 --- a/include/lldb/API/SBType.h +++ b/include/lldb/API/SBType.h @@ -85,7 +85,13 @@ public: const char * GetName (); - + + const char * + GetDemangledName (); + + const char * + GetMangledName (); + lldb::SBType GetType (); @@ -158,6 +164,9 @@ public: bool IsTypedefType (); + bool + IsAnonymousType (); + lldb::SBType GetPointerType(); @@ -290,7 +299,7 @@ protected: friend class SBTypeList; friend class SBValue; - SBType (const lldb_private::ClangASTType &); + SBType (const lldb_private::CompilerType &); SBType (const lldb::TypeSP &); SBType (const lldb::TypeImplSP &); diff --git a/include/lldb/API/SBTypeCategory.h b/include/lldb/API/SBTypeCategory.h index 30c338b28a46..997b3fc2f98d 100644 --- a/include/lldb/API/SBTypeCategory.h +++ b/include/lldb/API/SBTypeCategory.h @@ -36,6 +36,15 @@ namespace lldb { const char* GetName(); + lldb::LanguageType + GetLanguageAtIndex (uint32_t idx); + + uint32_t + GetNumLanguages (); + + void + AddLanguage (lldb::LanguageType language); + bool GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); diff --git a/include/lldb/API/SBTypeSummary.h b/include/lldb/API/SBTypeSummary.h index 9b367ba5f982..f4c666180085 100644 --- a/include/lldb/API/SBTypeSummary.h +++ b/include/lldb/API/SBTypeSummary.h @@ -12,8 +12,6 @@ #include "lldb/API/SBDefines.h" -#ifndef LLDB_DISABLE_PYTHON - namespace lldb { class LLDB_API SBTypeSummaryOptions { @@ -71,6 +69,9 @@ namespace lldb { public: SBTypeSummary(); + + // Native function summary formatter callback + typedef bool (*FormatCallback) (SBValue, SBTypeSummaryOptions, SBStream&); static SBTypeSummary CreateWithSummaryString (const char* data, @@ -83,6 +84,11 @@ namespace lldb { static SBTypeSummary CreateWithScriptCode (const char* data, uint32_t options = 0); // see lldb::eTypeOption values + + static SBTypeSummary + CreateWithCallback (FormatCallback cb, + uint32_t options = 0, + const char* description = nullptr); SBTypeSummary (const lldb::SBTypeSummary &rhs); @@ -126,6 +132,9 @@ namespace lldb { operator = (const lldb::SBTypeSummary &rhs); bool + DoesPrintValue (lldb::SBValue value); + + bool IsEqualTo (lldb::SBTypeSummary &rhs); bool @@ -160,6 +169,4 @@ namespace lldb { } // namespace lldb -#endif // LLDB_DISABLE_PYTHON - #endif // LLDB_SBTypeSummary_h_ diff --git a/include/lldb/API/SBValue.h b/include/lldb/API/SBValue.h index a070b149f34f..a7e015064f96 100644 --- a/include/lldb/API/SBValue.h +++ b/include/lldb/API/SBValue.h @@ -139,10 +139,8 @@ public: lldb::SBTypeFormat GetTypeFormat (); -#ifndef LLDB_DISABLE_PYTHON lldb::SBTypeSummary GetTypeSummary (); -#endif lldb::SBTypeFilter GetTypeFilter (); @@ -206,7 +204,11 @@ public: /// pointer to a 'Point' type, then the child at index zero will be /// the 'x' member, and the child at index 1 will be the 'y' member /// (the child at index zero won't be a 'Point' instance). - /// + /// + /// If you actually need an SBValue that represents the type pointed + /// to by a SBValue for which GetType().IsPointeeType() returns true, + /// regardless of the pointee type, you can do that with SBValue::Dereference. + /// /// Arrays have a preset number of children that can be accessed by /// index and will returns invalid child values for indexes that are /// out of bounds unless the \a synthetic_allowed is \b true. In this @@ -332,6 +334,9 @@ public: uint32_t GetNumChildren (); + uint32_t + GetNumChildren (uint32_t max); + void * GetOpaqueType(); @@ -350,6 +355,7 @@ public: lldb::SBValue Dereference (); + // Deprecated - please use GetType().IsPointerType() instead. bool TypeIsPointerType (); diff --git a/include/lldb/API/SystemInitializerFull.h b/include/lldb/API/SystemInitializerFull.h index 6280fe8aef04..9e37611a6598 100644 --- a/include/lldb/API/SystemInitializerFull.h +++ b/include/lldb/API/SystemInitializerFull.h @@ -26,15 +26,15 @@ class SystemInitializerFull : public SystemInitializerCommon { public: SystemInitializerFull(); - virtual ~SystemInitializerFull(); + ~SystemInitializerFull() override; void Initialize() override; void Terminate() override; private: void InitializeSWIG(); - void TerminateSWIG(); }; -} -#endif +} // namespace lldb_private + +#endif // LLDB_API_SYSTEM_INITIALIZER_FULL_H diff --git a/include/lldb/Breakpoint/Breakpoint.h b/include/lldb/Breakpoint/Breakpoint.h index a70c2787a1ef..7fdf06da3936 100644 --- a/include/lldb/Breakpoint/Breakpoint.h +++ b/include/lldb/Breakpoint/Breakpoint.h @@ -12,7 +12,10 @@ // C Includes // C++ Includes +#include <memory> +#include <string> #include <unordered_set> +#include <vector> // Other libraries and framework includes // Project includes @@ -81,11 +84,9 @@ class Breakpoint: public Stoppoint { public: - static const ConstString & GetEventIdentifier (); - //------------------------------------------------------------------ /// An enum specifying the match style for breakpoint settings. At /// present only used for function name style breakpoints. @@ -101,18 +102,16 @@ public: public EventData { public: + BreakpointEventData (lldb::BreakpointEventType sub_type, + const lldb::BreakpointSP &new_breakpoint_sp); + + ~BreakpointEventData() override; static const ConstString & GetFlavorString (); - virtual const ConstString & - GetFlavor () const; - - BreakpointEventData (lldb::BreakpointEventType sub_type, - const lldb::BreakpointSP &new_breakpoint_sp); - - virtual - ~BreakpointEventData(); + const ConstString & + GetFlavor() const override; lldb::BreakpointEventType GetBreakpointEventType () const; @@ -126,9 +125,8 @@ public: return m_locations; } - - virtual void - Dump (Stream *s) const; + void + Dump(Stream *s) const override; static lldb::BreakpointEventType GetBreakpointEventTypeFromEvent (const lldb::EventSP &event_sp); @@ -146,7 +144,6 @@ public: GetEventDataFromEvent (const Event *event_sp); private: - lldb::BreakpointEventType m_breakpoint_event; lldb::BreakpointSP m_new_breakpoint_sp; BreakpointLocationCollection m_locations; @@ -154,11 +151,10 @@ public: DISALLOW_COPY_AND_ASSIGN (BreakpointEventData); }; - class BreakpointPrecondition { public: - virtual ~BreakpointPrecondition() {} + virtual ~BreakpointPrecondition() = default; virtual bool EvaluatePrecondition(StoppointCallbackContext &context); @@ -167,7 +163,7 @@ public: ConfigurePrecondition(Args &options); virtual void - DescribePrecondition(Stream &stream, lldb::DescriptionLevel level); + GetDescription(Stream &stream, lldb::DescriptionLevel level); }; typedef std::shared_ptr<BreakpointPrecondition> BreakpointPreconditionSP; @@ -179,7 +175,7 @@ public: /// breakpoints. The varieties of breakpoints are specified instead by /// providing different resolvers & filters. //------------------------------------------------------------------ - ~Breakpoint(); + ~Breakpoint() override; //------------------------------------------------------------------ // Methods @@ -197,14 +193,13 @@ public: /// Standard "Dump" method. At present it does nothing. //------------------------------------------------------------------ void - Dump (Stream *s); + Dump(Stream *s) override; //------------------------------------------------------------------ // The next set of methods provide ways to tell the breakpoint to update // it's location list - usually done when modules appear or disappear. //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Tell this breakpoint to clear all its breakpoint sites. Done /// when the process holding the breakpoint sites is destroyed. @@ -262,7 +257,6 @@ public: bool load_event, bool delete_locations = false); - //------------------------------------------------------------------ /// Tells the breakpoint the old module \a old_module_sp has been /// replaced by new_module_sp (usually because the underlying file has been @@ -294,8 +288,8 @@ public: /// Returns a pointer to the new location. //------------------------------------------------------------------ lldb::BreakpointLocationSP - AddLocation (const Address &addr, - bool *new_location = NULL); + AddLocation(const Address &addr, + bool *new_location = nullptr); //------------------------------------------------------------------ /// Find a breakpoint location by Address. @@ -304,7 +298,7 @@ public: /// The Address specifying the location. /// @return /// Returns a shared pointer to the location at \a addr. The pointer - /// in the shared pointer will be NULL if there is no location at that address. + /// in the shared pointer will be nullptr if there is no location at that address. //------------------------------------------------------------------ lldb::BreakpointLocationSP FindLocationByAddress (const Address &addr); @@ -328,7 +322,7 @@ public: /// The ID specifying the location. /// @return /// Returns a shared pointer to the location with ID \a bp_loc_id. The pointer - /// in the shared pointer will be NULL if there is no location with that ID. + /// in the shared pointer will be nullptr if there is no location with that ID. //------------------------------------------------------------------ lldb::BreakpointLocationSP FindLocationByID (lldb::break_id_t bp_loc_id); @@ -341,7 +335,7 @@ public: /// /// @return /// Returns a shared pointer to the location with index \a - /// index. The shared pointer might contain NULL if \a index is + /// index. The shared pointer might contain nullptr if \a index is /// greater than then number of actual locations. //------------------------------------------------------------------ lldb::BreakpointLocationSP @@ -373,7 +367,7 @@ public: /// If \a enable is \b true, enable the breakpoint, if \b false disable it. //------------------------------------------------------------------ void - SetEnabled (bool enable); + SetEnabled(bool enable) override; //------------------------------------------------------------------ /// Check the Enable/Disable state. @@ -381,7 +375,7 @@ public: /// \b true if the breakpoint is enabled, \b false if disabled. //------------------------------------------------------------------ bool - IsEnabled (); + IsEnabled() override; //------------------------------------------------------------------ /// Set the breakpoint to ignore the next \a count breakpoint hits. @@ -407,7 +401,6 @@ public: uint32_t GetHitCount () const; - //------------------------------------------------------------------ /// If \a one_shot is \b true, breakpoint will be deleted on first hit. //------------------------------------------------------------------ @@ -490,7 +483,7 @@ public: /// /// @param[in] condition /// The condition expression to evaluate when the breakpoint is hit. - /// Pass in NULL to clear the condition. + /// Pass in nullptr to clear the condition. //------------------------------------------------------------------ void SetCondition (const char *condition); @@ -498,7 +491,7 @@ public: /// Return a pointer to the text of the condition expression. /// /// @return - /// A pointer to the condition expression text, or NULL if no + /// A pointer to the condition expression text, or nullptr if no // condition has been set. //------------------------------------------------------------------ const char *GetConditionText () const; @@ -560,7 +553,7 @@ public: /// Return the "kind" description for a breakpoint. /// /// @return - /// The breakpoint kind, or NULL if none is set. + /// The breakpoint kind, or nullptr if none is set. //------------------------------------------------------------------ const char *GetBreakpointKind () const { @@ -619,7 +612,6 @@ public: BreakpointOptions * GetOptions (); - //------------------------------------------------------------------ /// Invoke the callback action when the breakpoint is hit. /// @@ -713,7 +705,6 @@ protected: // Protected Methods //------------------------------------------------------------------ - //------------------------------------------------------------------ /// Constructors and Destructors /// Only the Target can make a breakpoint, and it owns the breakpoint lifespans. @@ -807,4 +798,4 @@ private: } // namespace lldb_private -#endif // liblldb_Breakpoint_h_ +#endif // liblldb_Breakpoint_h_ diff --git a/include/lldb/Breakpoint/BreakpointLocation.h b/include/lldb/Breakpoint/BreakpointLocation.h index c3e620d085c6..58d144cfb668 100644 --- a/include/lldb/Breakpoint/BreakpointLocation.h +++ b/include/lldb/Breakpoint/BreakpointLocation.h @@ -11,12 +11,10 @@ #define liblldb_BreakpointLocation_h_ // C Includes - // C++ Includes -#include <list> +#include <memory> // Other libraries and framework includes - // Project includes #include "lldb/lldb-private.h" #include "lldb/Breakpoint/StoppointLocation.h" @@ -49,7 +47,7 @@ class BreakpointLocation : public StoppointLocation { public: - ~BreakpointLocation (); + ~BreakpointLocation() override; //------------------------------------------------------------------ /// Gets the load address for this breakpoint location @@ -58,7 +56,7 @@ public: /// LLDB_INVALID_ADDRESS if not yet set. //------------------------------------------------------------------ lldb::addr_t - GetLoadAddress () const; + GetLoadAddress() const override; //------------------------------------------------------------------ /// Gets the Address for this breakpoint location @@ -74,6 +72,9 @@ public: //------------------------------------------------------------------ Breakpoint & GetBreakpoint (); + + Target & + GetTarget(); //------------------------------------------------------------------ /// Determines whether we should stop due to a hit at this @@ -88,7 +89,7 @@ public: /// \b false otherwise. //------------------------------------------------------------------ bool - ShouldStop (StoppointCallbackContext *context); + ShouldStop(StoppointCallbackContext *context) override; //------------------------------------------------------------------ // The next section deals with various breakpoint options. @@ -169,16 +170,15 @@ public: /// Return a pointer to the text of the condition expression. /// /// @return - /// A pointer to the condition expression text, or NULL if no + /// A pointer to the condition expression text, or nullptr if no // condition has been set. //------------------------------------------------------------------ const char * - GetConditionText (size_t *hash = NULL) const; + GetConditionText(size_t *hash = nullptr) const; bool ConditionSaysStop (ExecutionContext &exe_ctx, Error &error); - //------------------------------------------------------------------ /// Set the valid thread to be checked when the breakpoint is hit. /// @@ -270,7 +270,7 @@ public: /// Standard "Dump" method. At present it does nothing. //------------------------------------------------------------------ void - Dump (Stream *s) const; + Dump(Stream *s) const override; //------------------------------------------------------------------ /// Use this to set location specific breakpoint options. @@ -299,7 +299,6 @@ public: bool ValidForThisThread (Thread *thread); - //------------------------------------------------------------------ /// Invoke the callback action when the breakpoint is hit. /// @@ -418,7 +417,6 @@ private: void UndoBumpHitCount(); - //------------------------------------------------------------------ // Constructors and Destructors // @@ -459,9 +457,9 @@ private: bool m_is_indirect; Address m_address; ///< The address defining this location. Breakpoint &m_owner; ///< The breakpoint that produced this object. - std::unique_ptr<BreakpointOptions> m_options_ap; ///< Breakpoint options pointer, NULL if we're using our breakpoint's options. + std::unique_ptr<BreakpointOptions> m_options_ap; ///< Breakpoint options pointer, nullptr if we're using our breakpoint's options. lldb::BreakpointSiteSP m_bp_site_sp; ///< Our breakpoint site (it may be shared by more than one location.) - lldb::ClangUserExpressionSP m_user_expression_sp; ///< The compiled expression to use in testing our condition. + lldb::UserExpressionSP m_user_expression_sp; ///< The compiled expression to use in testing our condition. Mutex m_condition_mutex; ///< Guards parsing and evaluation of the condition, which could be evaluated by multiple processes. size_t m_condition_hash; ///< For testing whether the condition source code changed. @@ -479,4 +477,4 @@ private: } // namespace lldb_private -#endif // liblldb_BreakpointLocation_h_ +#endif // liblldb_BreakpointLocation_h_ diff --git a/include/lldb/Breakpoint/BreakpointLocationList.h b/include/lldb/Breakpoint/BreakpointLocationList.h index f67ef89ad705..81526089b427 100644 --- a/include/lldb/Breakpoint/BreakpointLocationList.h +++ b/include/lldb/Breakpoint/BreakpointLocationList.h @@ -12,8 +12,9 @@ // C Includes // C++ Includes -#include <vector> #include <map> +#include <vector> + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" @@ -56,7 +57,7 @@ public: /// The address to look for. /// /// @result - /// A shared pointer to the breakpoint. May contain a NULL + /// A shared pointer to the breakpoint. May contain a nullptr /// pointer if the breakpoint doesn't exist. //------------------------------------------------------------------ const lldb::BreakpointLocationSP @@ -70,7 +71,7 @@ public: /// The breakpoint location ID to seek for. /// /// @result - /// A shared pointer to the breakpoint. May contain a NULL + /// A shared pointer to the breakpoint. May contain a nullptr /// pointer if the breakpoint doesn't exist. //------------------------------------------------------------------ lldb::BreakpointLocationSP @@ -116,7 +117,7 @@ public: /// The breakpoint location index to seek for. /// /// @result - /// A shared pointer to the breakpoint. May contain a NULL + /// A shared pointer to the breakpoint. May contain a nullptr /// pointer if the breakpoint doesn't exist. //------------------------------------------------------------------ lldb::BreakpointLocationSP @@ -130,7 +131,7 @@ public: /// The breakpoint location index to seek for. /// /// @result - /// A shared pointer to the breakpoint. May contain a NULL + /// A shared pointer to the breakpoint. May contain a nullptr /// pointer if the breakpoint doesn't exist. //------------------------------------------------------------------ const lldb::BreakpointLocationSP @@ -216,7 +217,6 @@ public: lldb::DescriptionLevel level); protected: - //------------------------------------------------------------------ /// This is the standard constructor. /// @@ -246,9 +246,9 @@ protected: StopRecordingNewLocations(); lldb::BreakpointLocationSP - AddLocation (const Address &addr, - bool resolve_indirect_symbols, - bool *new_location = NULL); + AddLocation(const Address &addr, + bool resolve_indirect_symbols, + bool *new_location = nullptr); void SwapLocation (lldb::BreakpointLocationSP to_location_sp, lldb::BreakpointLocationSP from_location_sp); @@ -273,16 +273,17 @@ protected: mutable Mutex m_mutex; lldb::break_id_t m_next_id; BreakpointLocationCollection *m_new_location_recorder; + public: typedef AdaptedIterable<collection, lldb::BreakpointLocationSP, vector_adapter> BreakpointLocationIterable; + BreakpointLocationIterable BreakpointLocations() { return BreakpointLocationIterable(m_locations); } - }; } // namespace lldb_private -#endif // liblldb_BreakpointLocationList_h_ +#endif // liblldb_BreakpointLocationList_h_ diff --git a/include/lldb/Breakpoint/BreakpointOptions.h b/include/lldb/Breakpoint/BreakpointOptions.h index bf10fc096d75..e7882147a4da 100644 --- a/include/lldb/Breakpoint/BreakpointOptions.h +++ b/include/lldb/Breakpoint/BreakpointOptions.h @@ -12,6 +12,9 @@ // C Includes // C++ Includes +#include <memory> +#include <string> + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" @@ -115,7 +118,6 @@ public: //------------------------------------------------------------------ void SetCallback (BreakpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous = false); - //------------------------------------------------------------------ /// Remove the callback from this option set. //------------------------------------------------------------------ @@ -184,10 +186,10 @@ public: /// Return a pointer to the text of the condition expression. /// /// @return - /// A pointer to the condition expression text, or NULL if no + /// A pointer to the condition expression text, or nullptr if no // condition has been set. //------------------------------------------------------------------ - const char *GetConditionText (size_t *hash = NULL) const; + const char *GetConditionText(size_t *hash = nullptr) const; //------------------------------------------------------------------ // Enabled/Ignore Count @@ -257,10 +259,10 @@ public: } //------------------------------------------------------------------ - /// Return the current thread spec for this option. This will return NULL if the no thread + /// Return the current thread spec for this option. This will return nullptr if the no thread /// specifications have been set for this Option yet. /// @return - /// The thread specification pointer for this option, or NULL if none has + /// The thread specification pointer for this option, or nullptr if none has /// been set yet. //------------------------------------------------------------------ const ThreadSpec * @@ -298,7 +300,6 @@ public: lldb::user_id_t break_id, lldb::user_id_t break_loc_id); - struct CommandData { CommandData () : @@ -308,10 +309,8 @@ public: { } - ~CommandData () - { - } - + ~CommandData() = default; + StringList user_source; std::string script_source; bool stop_on_error; @@ -325,16 +324,14 @@ public: { } - virtual - ~CommandBaton () + ~CommandBaton() override { delete ((CommandData *)m_data); - m_data = NULL; + m_data = nullptr; } - virtual void - GetDescription (Stream *s, lldb::DescriptionLevel level) const; - + void + GetDescription (Stream *s, lldb::DescriptionLevel level) const override; }; protected: @@ -359,4 +356,4 @@ private: } // namespace lldb_private -#endif // liblldb_BreakpointOptions_h_ +#endif // liblldb_BreakpointOptions_h_ diff --git a/include/lldb/Breakpoint/BreakpointResolver.h b/include/lldb/Breakpoint/BreakpointResolver.h index 6ba53ea92f36..198abed841b2 100644 --- a/include/lldb/Breakpoint/BreakpointResolver.h +++ b/include/lldb/Breakpoint/BreakpointResolver.h @@ -66,8 +66,7 @@ public: /// The Destructor is virtual, all significant breakpoint resolvers derive /// from this class. //------------------------------------------------------------------ - virtual - ~BreakpointResolver (); + ~BreakpointResolver() override; //------------------------------------------------------------------ /// This sets the breakpoint for this resolver. @@ -105,8 +104,8 @@ public: /// @param[in] s /// Stream to which the output is copied. //------------------------------------------------------------------ - virtual void - GetDescription (Stream *s) = 0; + void + GetDescription(Stream *s) override = 0; //------------------------------------------------------------------ /// Standard "Dump" method. At present it does nothing. @@ -157,4 +156,4 @@ private: } // namespace lldb_private -#endif // liblldb_BreakpointResolver_h_ +#endif // liblldb_BreakpointResolver_h_ diff --git a/include/lldb/Breakpoint/BreakpointResolverAddress.h b/include/lldb/Breakpoint/BreakpointResolverAddress.h index c8f034d7345b..8ec1e39e52ab 100644 --- a/include/lldb/Breakpoint/BreakpointResolverAddress.h +++ b/include/lldb/Breakpoint/BreakpointResolverAddress.h @@ -15,6 +15,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Breakpoint/BreakpointResolver.h" +#include "lldb/Core/ModuleSpec.h" namespace lldb_private { @@ -31,8 +32,11 @@ public: BreakpointResolverAddress (Breakpoint *bkpt, const Address &addr); - virtual - ~BreakpointResolverAddress (); + BreakpointResolverAddress (Breakpoint *bkpt, + const Address &addr, + const FileSpec &module_spec); + + ~BreakpointResolverAddress() override; void ResolveBreakpoint (SearchFilter &filter) override; @@ -66,12 +70,15 @@ public: CopyForBreakpoint (Breakpoint &breakpoint) override; protected: - Address m_addr; - + Address m_addr; // The address - may be Section Offset or may be just an offset + lldb::addr_t m_resolved_addr; // The current value of the resolved load address for this breakpoint, + FileSpec m_module_filespec; // If this filespec is Valid, and m_addr is an offset, then it will be converted + // to a Section+Offset address in this module, whenever that module gets around to + // being loaded. private: DISALLOW_COPY_AND_ASSIGN(BreakpointResolverAddress); }; } // namespace lldb_private -#endif // liblldb_BreakpointResolverAddress_h_ +#endif // liblldb_BreakpointResolverAddress_h_ diff --git a/include/lldb/Breakpoint/BreakpointResolverFileLine.h b/include/lldb/Breakpoint/BreakpointResolverFileLine.h index 2403d24515a7..2dde1546f126 100644 --- a/include/lldb/Breakpoint/BreakpointResolverFileLine.h +++ b/include/lldb/Breakpoint/BreakpointResolverFileLine.h @@ -35,8 +35,7 @@ public: bool skip_prologue, bool exact_match); - virtual - ~BreakpointResolverFileLine (); + ~BreakpointResolverFileLine() override; Searcher::CallbackReturn SearchCallback (SearchFilter &filter, @@ -76,4 +75,4 @@ private: } // namespace lldb_private -#endif // liblldb_BreakpointResolverFileLine_h_ +#endif // liblldb_BreakpointResolverFileLine_h_ diff --git a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h index 8e18fff16447..a8d7a50b5d93 100644 --- a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h +++ b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h @@ -32,8 +32,7 @@ public: RegularExpression ®ex, bool exact_match); - virtual - ~BreakpointResolverFileRegex (); + ~BreakpointResolverFileRegex() override; Searcher::CallbackReturn SearchCallback (SearchFilter &filter, @@ -70,4 +69,4 @@ private: } // namespace lldb_private -#endif // liblldb_BreakpointResolverFileRegex_h_ +#endif // liblldb_BreakpointResolverFileRegex_h_ diff --git a/include/lldb/Breakpoint/BreakpointResolverName.h b/include/lldb/Breakpoint/BreakpointResolverName.h index c2a5b180f289..aaae9c1a12cf 100644 --- a/include/lldb/Breakpoint/BreakpointResolverName.h +++ b/include/lldb/Breakpoint/BreakpointResolverName.h @@ -14,6 +14,7 @@ // C++ Includes #include <vector> #include <string> + // Other libraries and framework includes // Project includes #include "lldb/Breakpoint/BreakpointResolver.h" @@ -34,6 +35,7 @@ public: BreakpointResolverName (Breakpoint *bkpt, const char *name, uint32_t name_type_mask, + lldb::LanguageType language, Breakpoint::MatchType type, bool skip_prologue); @@ -42,17 +44,20 @@ public: const char *names[], size_t num_names, uint32_t name_type_mask, + lldb::LanguageType language, bool skip_prologue); // This one takes a C++ array of names. It is always MatchType = Exact. BreakpointResolverName (Breakpoint *bkpt, std::vector<std::string> names, uint32_t name_type_mask, + lldb::LanguageType language, bool skip_prologue); // Creates a function breakpoint by regular expression. Takes over control of the lifespan of func_regex. BreakpointResolverName (Breakpoint *bkpt, RegularExpression &func_regex, + lldb::LanguageType language, bool skip_prologue); BreakpointResolverName (Breakpoint *bkpt, @@ -61,8 +66,7 @@ public: Breakpoint::MatchType type, bool skip_prologue); - virtual - ~BreakpointResolverName (); + ~BreakpointResolverName() override; Searcher::CallbackReturn SearchCallback (SearchFilter &filter, @@ -114,6 +118,7 @@ protected: ConstString m_class_name; RegularExpression m_regex; Breakpoint::MatchType m_match_type; + lldb::LanguageType m_language; bool m_skip_prologue; void @@ -122,4 +127,4 @@ protected: } // namespace lldb_private -#endif // liblldb_BreakpointResolverName_h_ +#endif // liblldb_BreakpointResolverName_h_ diff --git a/include/lldb/Breakpoint/BreakpointSite.h b/include/lldb/Breakpoint/BreakpointSite.h index d67fc8bb57f1..6cebcab8e2db 100644 --- a/include/lldb/Breakpoint/BreakpointSite.h +++ b/include/lldb/Breakpoint/BreakpointSite.h @@ -55,7 +55,7 @@ public: // display any breakpoint opcodes. }; - virtual ~BreakpointSite (); + ~BreakpointSite() override; //---------------------------------------------------------------------- // This section manages the breakpoint traps @@ -139,8 +139,8 @@ public: /// @return /// \b true if we should stop, \b false otherwise. //------------------------------------------------------------------ - virtual bool - ShouldStop (StoppointCallbackContext *context); + bool + ShouldStop(StoppointCallbackContext *context) override; //------------------------------------------------------------------ /// Standard Dump method @@ -149,7 +149,7 @@ public: /// The stream to dump this output. //------------------------------------------------------------------ void - Dump (Stream *s) const; + Dump(Stream *s) const override; //------------------------------------------------------------------ /// The "Owners" are the breakpoint locations that share this @@ -187,6 +187,20 @@ public: GetOwnerAtIndex (size_t idx); //------------------------------------------------------------------ + /// This method copies the breakpoint site's owners into a new collection. + /// It does this while the owners mutex is locked. + /// + /// @param[out] out_collection + /// The BreakpointLocationCollection into which to put the owners + /// of this breakpoint site. + /// + /// @return + /// The number of elements copied into out_collection. + //------------------------------------------------------------------ + size_t + CopyOwnersList (BreakpointLocationCollection &out_collection); + + //------------------------------------------------------------------ /// Check whether the owners of this breakpoint site have any /// thread specifiers, and if yes, is \a thread contained in any /// of these specifiers. @@ -201,7 +215,6 @@ public: bool ValidForThisThread (Thread *thread); - //------------------------------------------------------------------ /// Print a description of this breakpoint site to the stream \a s. /// GetDescription tells you about the breakpoint site's owners. @@ -301,4 +314,4 @@ private: } // namespace lldb_private -#endif // liblldb_BreakpointSite_h_ +#endif // liblldb_BreakpointSite_h_ diff --git a/include/lldb/Breakpoint/Watchpoint.h b/include/lldb/Breakpoint/Watchpoint.h index 926e0b506f31..34df24a92c06 100644 --- a/include/lldb/Breakpoint/Watchpoint.h +++ b/include/lldb/Breakpoint/Watchpoint.h @@ -11,19 +11,17 @@ #define liblldb_Watchpoint_h_ // C Includes - // C++ Includes -#include <list> +#include <memory> #include <string> // Other libraries and framework includes - // Project includes #include "lldb/lldb-private.h" #include "lldb/Breakpoint/WatchpointOptions.h" #include "lldb/Breakpoint/StoppointLocation.h" #include "lldb/Core/UserID.h" -#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/CompilerType.h" #include "lldb/Target/Target.h" namespace lldb_private { @@ -33,23 +31,20 @@ class Watchpoint : public StoppointLocation { public: - class WatchpointEventData : public EventData { public: + WatchpointEventData (lldb::WatchpointEventType sub_type, + const lldb::WatchpointSP &new_watchpoint_sp); + + ~WatchpointEventData() override; static const ConstString & GetFlavorString (); - virtual const ConstString & - GetFlavor () const; - - WatchpointEventData (lldb::WatchpointEventType sub_type, - const lldb::WatchpointSP &new_watchpoint_sp); - - virtual - ~WatchpointEventData(); + const ConstString & + GetFlavor() const override; lldb::WatchpointEventType GetWatchpointEventType () const; @@ -57,8 +52,8 @@ public: lldb::WatchpointSP & GetWatchpoint (); - virtual void - Dump (Stream *s) const; + void + Dump(Stream *s) const override; static lldb::WatchpointEventType GetWatchpointEventTypeFromEvent (const lldb::EventSP &event_sp); @@ -70,15 +65,15 @@ public: GetEventDataFromEvent (const Event *event_sp); private: - lldb::WatchpointEventType m_watchpoint_event; lldb::WatchpointSP m_new_watchpoint_sp; DISALLOW_COPY_AND_ASSIGN (WatchpointEventData); }; - Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const ClangASTType *type, bool hardware = true); - ~Watchpoint (); + Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const CompilerType *type, bool hardware = true); + + ~Watchpoint() override; void IncrementFalseAlarmsAndReviseHitCount(); @@ -89,11 +84,11 @@ public: void SetEnabled (bool enabled, bool notify = true); - virtual bool - IsHardware () const; + bool + IsHardware() const override; - virtual bool - ShouldStop (StoppointCallbackContext *context); + bool + ShouldStop(StoppointCallbackContext *context) override; bool WatchpointRead () const; bool WatchpointWrite () const; @@ -110,8 +105,8 @@ public: bool CaptureWatchedValue (const ExecutionContext &exe_ctx); void GetDescription (Stream *s, lldb::DescriptionLevel level); - void Dump (Stream *s) const; - void DumpSnapshots (Stream *s, const char * prefix = NULL) const; + void Dump (Stream *s) const override; + void DumpSnapshots(Stream *s, const char *prefix = nullptr) const; void DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const; Target &GetTarget() { return m_target; } const Error &GetError() { return m_error; } @@ -173,7 +168,7 @@ public: /// /// @param[in] condition /// The condition expression to evaluate when the watchpoint is hit. - /// Pass in NULL to clear the condition. + /// Pass in nullptr to clear the condition. //------------------------------------------------------------------ void SetCondition (const char *condition); @@ -181,7 +176,7 @@ public: /// Return a pointer to the text of the condition expression. /// /// @return - /// A pointer to the condition expression text, or NULL if no + /// A pointer to the condition expression text, or nullptr if no // condition has been set. //------------------------------------------------------------------ const char *GetConditionText () const; @@ -195,13 +190,12 @@ public: bool IsDisabledDuringEphemeralMode(); - const ClangASTType & - GetClangASTType() + const CompilerType & + GetCompilerType() { return m_type; } - private: friend class Target; friend class WatchpointList; @@ -240,13 +234,13 @@ private: std::string m_watch_spec_str; // Spec for the watchpoint. lldb::ValueObjectSP m_old_value_sp; lldb::ValueObjectSP m_new_value_sp; - ClangASTType m_type; + CompilerType m_type; Error m_error; // An error object describing errors associated with this watchpoint. WatchpointOptions m_options; // Settable watchpoint options, which is a delegate to handle // the callback machinery. bool m_being_created; - std::unique_ptr<ClangUserExpression> m_condition_ap; // The condition to test. + std::unique_ptr<UserExpression> m_condition_ap; // The condition to test. void SetID(lldb::watch_id_t id) { m_loc_id = id; } @@ -261,4 +255,4 @@ private: } // namespace lldb_private -#endif // liblldb_Watchpoint_h_ +#endif // liblldb_Watchpoint_h_ diff --git a/include/lldb/Breakpoint/WatchpointOptions.h b/include/lldb/Breakpoint/WatchpointOptions.h index 64c65f92b44f..eb08bb32e6ce 100644 --- a/include/lldb/Breakpoint/WatchpointOptions.h +++ b/include/lldb/Breakpoint/WatchpointOptions.h @@ -12,6 +12,9 @@ // C Includes // C++ Includes +#include <memory> +#include <string> + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" @@ -99,7 +102,6 @@ public: //------------------------------------------------------------------ void SetCallback (WatchpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous = false); - //------------------------------------------------------------------ /// Remove the callback from this option set. //------------------------------------------------------------------ @@ -150,10 +152,10 @@ public: const Baton *GetBaton () const; //------------------------------------------------------------------ - /// Return the current thread spec for this option. This will return NULL if the no thread + /// Return the current thread spec for this option. This will return nullptr if the no thread /// specifications have been set for this Option yet. /// @return - /// The thread specification pointer for this option, or NULL if none has + /// The thread specification pointer for this option, or nullptr if none has /// been set yet. //------------------------------------------------------------------ const ThreadSpec * @@ -196,7 +198,6 @@ public: StoppointCallbackContext *context, lldb::user_id_t watch_id); - struct CommandData { CommandData () : @@ -206,10 +207,8 @@ public: { } - ~CommandData () - { - } - + ~CommandData() = default; + StringList user_source; std::string script_source; bool stop_on_error; @@ -223,16 +222,14 @@ public: { } - virtual - ~CommandBaton () + ~CommandBaton() override { delete ((CommandData *)m_data); - m_data = NULL; + m_data = nullptr; } - virtual void - GetDescription (Stream *s, lldb::DescriptionLevel level) const; - + void + GetDescription(Stream *s, lldb::DescriptionLevel level) const override; }; protected: @@ -252,4 +249,4 @@ private: } // namespace lldb_private -#endif // liblldb_WatchpointOptions_h_ +#endif // liblldb_WatchpointOptions_h_ diff --git a/include/lldb/Core/Address.h b/include/lldb/Core/Address.h index cfa16c30bedb..0afe55b12be3 100644 --- a/include/lldb/Core/Address.h +++ b/include/lldb/Core/Address.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include <atomic> + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" @@ -108,7 +109,6 @@ public: { } - //------------------------------------------------------------------ /// Copy constructor /// @@ -176,6 +176,7 @@ public: const Address& operator= (const Address& rhs); #endif + //------------------------------------------------------------------ /// Clear the object's state. /// @@ -216,7 +217,7 @@ public: class ModulePointerAndOffsetLessThanFunctionObject { public: - ModulePointerAndOffsetLessThanFunctionObject () {} + ModulePointerAndOffsetLessThanFunctionObject() = default; bool operator() (const Address& a, const Address& b) const @@ -326,7 +327,8 @@ public: /// not loaded. //------------------------------------------------------------------ lldb::addr_t - GetOpcodeLoadAddress (Target *target) const; + GetOpcodeLoadAddress (Target *target, + lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const; //------------------------------------------------------------------ /// Get the section relative offset value. @@ -354,7 +356,7 @@ public: bool IsSectionOffset() const { - return IsValid() && (GetSection().get() != NULL); + return IsValid() && (GetSection().get() != nullptr); } //------------------------------------------------------------------ @@ -374,7 +376,6 @@ public: return m_offset != LLDB_INVALID_ADDRESS; } - //------------------------------------------------------------------ /// Get the memory cost of this object. /// @@ -425,7 +426,9 @@ public: SetLoadAddress (lldb::addr_t load_addr, Target *target); bool - SetOpcodeLoadAddress (lldb::addr_t load_addr, Target *target); + SetOpcodeLoadAddress (lldb::addr_t load_addr, + Target *target, + lldb::AddressClass addr_class = lldb::eAddressClassInvalid); bool SetCallableLoadAddress (lldb::addr_t load_addr, Target *target); @@ -505,6 +508,7 @@ public: { m_section_wp.reset(); } + //------------------------------------------------------------------ /// Reconstruct a symbol context from an address. /// @@ -564,10 +568,8 @@ protected: //------------------------------------------------------------------ bool SectionWasDeletedPrivate() const; - }; - //---------------------------------------------------------------------- // NOTE: Be careful using this operator. It can correctly compare two // addresses from the same Module correctly. It can't compare two @@ -584,12 +586,9 @@ protected: //---------------------------------------------------------------------- bool operator< (const Address& lhs, const Address& rhs); bool operator> (const Address& lhs, const Address& rhs); - - - bool operator== (const Address& lhs, const Address& rhs); bool operator!= (const Address& lhs, const Address& rhs); } // namespace lldb_private -#endif // liblldb_Address_h_ +#endif // liblldb_Address_h_ diff --git a/include/lldb/Core/AddressRange.h b/include/lldb/Core/AddressRange.h index 9d781f3e85ae..31e3286cb110 100644 --- a/include/lldb/Core/AddressRange.h +++ b/include/lldb/Core/AddressRange.h @@ -10,6 +10,10 @@ #ifndef liblldb_AddressRange_h_ #define liblldb_AddressRange_h_ +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/Core/Address.h" namespace lldb_private { @@ -62,7 +66,7 @@ public: /// @param[in] section_list /// A list of sections, one of which may contain the \a vaddr. //------------------------------------------------------------------ - AddressRange (lldb::addr_t file_addr, lldb::addr_t byte_size, const SectionList *section_list = NULL); + AddressRange(lldb::addr_t file_addr, lldb::addr_t byte_size, const SectionList *section_list = nullptr); //------------------------------------------------------------------ /// Construct with a Address object address and byte size. @@ -281,4 +285,4 @@ protected: } // namespace lldb_private -#endif // liblldb_AddressRange_h_ +#endif // liblldb_AddressRange_h_ diff --git a/include/lldb/Core/AddressResolver.h b/include/lldb/Core/AddressResolver.h index e5fe276e3fb1..711cc57c14a4 100644 --- a/include/lldb/Core/AddressResolver.h +++ b/include/lldb/Core/AddressResolver.h @@ -54,8 +54,7 @@ public: AddressResolver (); - virtual - ~AddressResolver (); + ~AddressResolver () override; virtual void ResolveAddress (SearchFilter &filter); @@ -64,8 +63,8 @@ public: ResolveAddressInModules (SearchFilter &filter, ModuleList &modules); - virtual void - GetDescription (Stream *s) = 0; + void + GetDescription (Stream *s) override = 0; std::vector<AddressRange> & GetAddressRanges (); @@ -86,4 +85,4 @@ private: } // namespace lldb_private -#endif // liblldb_AddressResolver_h_ +#endif // liblldb_AddressResolver_h_ diff --git a/include/lldb/Core/AddressResolverFileLine.h b/include/lldb/Core/AddressResolverFileLine.h index ddeb0e0301d2..5b47379ed18e 100644 --- a/include/lldb/Core/AddressResolverFileLine.h +++ b/include/lldb/Core/AddressResolverFileLine.h @@ -30,20 +30,19 @@ public: uint32_t line_no, bool check_inlines); - virtual - ~AddressResolverFileLine (); + ~AddressResolverFileLine () override; - virtual Searcher::CallbackReturn + Searcher::CallbackReturn SearchCallback (SearchFilter &filter, SymbolContext &context, Address *addr, - bool containing); + bool containing) override; - virtual Searcher::Depth - GetDepth (); + Searcher::Depth + GetDepth () override; - virtual void - GetDescription (Stream *s); + void + GetDescription (Stream *s) override; protected: FileSpec m_file_spec; // This is the file spec we are looking for. @@ -56,4 +55,4 @@ private: } // namespace lldb_private -#endif // liblldb_AddressResolverFileLine_h_ +#endif // liblldb_AddressResolverFileLine_h_ diff --git a/include/lldb/Core/AddressResolverName.h b/include/lldb/Core/AddressResolverName.h index afde675a89bb..cf792f5054e6 100644 --- a/include/lldb/Core/AddressResolverName.h +++ b/include/lldb/Core/AddressResolverName.h @@ -38,20 +38,19 @@ public: const char *method, AddressResolver::MatchType type); - virtual - ~AddressResolverName (); + ~AddressResolverName () override; - virtual Searcher::CallbackReturn + Searcher::CallbackReturn SearchCallback (SearchFilter &filter, SymbolContext &context, Address *addr, - bool containing); + bool containing) override; - virtual Searcher::Depth - GetDepth (); + Searcher::Depth + GetDepth () override; - virtual void - GetDescription (Stream *s); + void + GetDescription (Stream *s) override; protected: ConstString m_func_name; @@ -65,4 +64,4 @@ private: } // namespace lldb_private -#endif // liblldb_AddressResolverName_h_ +#endif // liblldb_AddressResolverName_h_ diff --git a/include/lldb/Core/ArchSpec.h b/include/lldb/Core/ArchSpec.h index 0b818a0c7123..13ff436cf08f 100644 --- a/include/lldb/Core/ArchSpec.h +++ b/include/lldb/Core/ArchSpec.h @@ -65,7 +65,11 @@ public: eMIPSAse_mips16 = 0x00000400, // MIPS16 ASE eMIPSAse_micromips = 0x00000800, // MICROMIPS ASE eMIPSAse_xpa = 0x00001000, // XPA ASE - eMIPSAse_mask = 0x00001fff + eMIPSAse_mask = 0x00001fff, + eMIPSABI_O32 = 0x00002000, + eMIPSABI_N32 = 0x00004000, + eMIPSABI_N64 = 0x00008000, + eMIPSABI_mask = 0x000ff000 }; enum Core @@ -208,7 +212,11 @@ public: kCore_mips64_last = eCore_mips64r6, kCore_mips64el_first = eCore_mips64el, - kCore_mips64el_last = eCore_mips64r6el + kCore_mips64el_last = eCore_mips64r6el, + + kCore_mips_first = eCore_mips32, + kCore_mips_last = eCore_mips64r6el + }; typedef void (* StopInfoOverrideCallbackType)(lldb_private::Thread &thread); @@ -337,10 +345,28 @@ public: } bool + TripleVendorIsUnspecifiedUnknown() const + { + return m_triple.getVendor() == llvm::Triple::UnknownVendor && m_triple.getVendorName().empty(); + } + + bool TripleOSWasSpecified() const { return !m_triple.getOSName().empty(); } + + bool + TripleEnvironmentWasSpecified () const + { + return !m_triple.getEnvironmentName().empty(); + } + + bool + TripleOSIsUnspecifiedUnknown() const + { + return m_triple.getOS() == llvm::Triple::UnknownOS && m_triple.getOSName().empty(); + } //------------------------------------------------------------------ /// Merges fields from another ArchSpec into this ArchSpec. @@ -480,6 +506,9 @@ public: return m_triple; } + void + DumpTriple(Stream &s) const; + //------------------------------------------------------------------ /// Architecture tripple setter. /// @@ -564,7 +593,18 @@ public: //------------------------------------------------------------------ StopInfoOverrideCallbackType GetStopInfoOverrideCallback () const; + + bool + IsFullySpecifiedTriple () const; + void + PiecewiseTripleCompare (const ArchSpec &other, + bool &arch_different, + bool &vendor_different, + bool &os_different, + bool &os_version_different, + bool &env_different); + uint32_t GetFlags () const { diff --git a/include/lldb/Core/Broadcaster.h b/include/lldb/Core/Broadcaster.h index 6d54b1b43133..8e59a41805ec 100644 --- a/include/lldb/Core/Broadcaster.h +++ b/include/lldb/Core/Broadcaster.h @@ -42,7 +42,7 @@ public: BroadcastEventSpec (const BroadcastEventSpec &rhs); - ~BroadcastEventSpec() {} + ~BroadcastEventSpec() = default; const ConstString &GetBroadcasterClass() const { @@ -89,7 +89,7 @@ public: BroadcasterManager (); - ~BroadcasterManager () {} + ~BroadcasterManager() = default; uint32_t RegisterListenerForEvents (Listener &listener, BroadcastEventSpec event_spec); @@ -128,7 +128,7 @@ private: { } - ~BroadcasterClassMatches () {} + ~BroadcasterClassMatches() = default; bool operator() (const event_listener_key input) const { @@ -147,7 +147,7 @@ private: { } - ~BroadcastEventSpecMatches () {} + ~BroadcastEventSpecMatches() = default; bool operator() (const event_listener_key input) const { @@ -168,7 +168,7 @@ private: { } - ~ListenerMatchesAndSharedBits () {} + ~ListenerMatchesAndSharedBits() = default; bool operator() (const event_listener_key input) const { @@ -190,7 +190,7 @@ private: { } - ~ListenerMatches() {} + ~ListenerMatches() = default; bool operator () (const event_listener_key input) const { @@ -204,7 +204,6 @@ private: const Listener *m_listener; }; - }; //---------------------------------------------------------------------- @@ -286,10 +285,10 @@ public: BroadcastEventIfUnique (lldb::EventSP &event_sp); void - BroadcastEvent (uint32_t event_type, EventData *event_data = NULL); + BroadcastEvent(uint32_t event_type, EventData *event_data = nullptr); void - BroadcastEventIfUnique (uint32_t event_type, EventData *event_data = NULL); + BroadcastEventIfUnique(uint32_t event_type, EventData *event_data = nullptr); void Clear(); @@ -332,7 +331,6 @@ public: const ConstString & GetBroadcasterName (); - //------------------------------------------------------------------ /// Get the event name(s) for one or more event bits. /// @@ -364,10 +362,10 @@ public: const char * GetEventName (uint32_t event_mask) const { - event_names_map::const_iterator pos = m_event_names.find (event_mask); + const auto pos = m_event_names.find (event_mask); if (pos != m_event_names.end()) return pos->second.c_str(); - return NULL; + return nullptr; } bool @@ -437,8 +435,6 @@ public: BroadcasterManager *GetManager(); protected: - - void PrivateBroadcastEvent (lldb::EventSP &event_sp, bool unique); diff --git a/include/lldb/Core/ClangForward.h b/include/lldb/Core/ClangForward.h index 6c627c2ad3b7..80abc15f671c 100644 --- a/include/lldb/Core/ClangForward.h +++ b/include/lldb/Core/ClangForward.h @@ -132,6 +132,8 @@ namespace clang namespace llvm { + class APInt; + class APSInt; class LLVMContext; class ExecutionEngine; } diff --git a/include/lldb/Core/Communication.h b/include/lldb/Core/Communication.h index 7924ed293d3c..d29aaca9c2ea 100644 --- a/include/lldb/Core/Communication.h +++ b/include/lldb/Core/Communication.h @@ -100,7 +100,6 @@ public: typedef void (*ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len); - //------------------------------------------------------------------ /// Construct the Communication object with the specified name for /// the Broadcaster that this object inherits from. @@ -118,8 +117,7 @@ public: /// /// The destructor is virtual since this class gets subclassed. //------------------------------------------------------------------ - virtual - ~Communication(); + ~Communication() override; void Clear (); @@ -157,7 +155,7 @@ public: /// @see bool Connection::Disconnect (); //------------------------------------------------------------------ lldb::ConnectionStatus - Disconnect (Error *error_ptr = NULL); + Disconnect(Error *error_ptr = nullptr); //------------------------------------------------------------------ /// Check if the connection is valid. @@ -177,6 +175,7 @@ public: { return m_connection_sp.get(); } + //------------------------------------------------------------------ /// Read bytes from the current connection. /// @@ -278,7 +277,7 @@ public: /// @see void Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool broadcast); //------------------------------------------------------------------ virtual bool - StartReadThread (Error *error_ptr = NULL); + StartReadThread(Error *error_ptr = nullptr); //------------------------------------------------------------------ /// Stops the read thread by cancelling it. @@ -288,10 +287,10 @@ public: /// false otherwise. //------------------------------------------------------------------ virtual bool - StopReadThread (Error *error_ptr = NULL); + StopReadThread(Error *error_ptr = nullptr); virtual bool - JoinReadThread (Error *error_ptr = NULL); + JoinReadThread(Error *error_ptr = nullptr); //------------------------------------------------------------------ /// Checks if there is a currently running read thread. /// @@ -323,7 +322,6 @@ public: SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback, void *callback_baton); - //------------------------------------------------------------------ /// Wait for the read thread to process all outstanding data. /// @@ -350,18 +348,11 @@ public: static ConstString &GetStaticBroadcasterClass (); - virtual ConstString &GetBroadcasterClass() const + ConstString &GetBroadcasterClass() const override { return GetStaticBroadcasterClass(); } -private: - //------------------------------------------------------------------ - // For Communication only - //------------------------------------------------------------------ - DISALLOW_COPY_AND_ASSIGN (Communication); - - protected: lldb::ConnectionSP m_connection_sp; ///< The connection that is current in use by this communications class. HostThread m_read_thread; ///< The read thread handle in case we need to cancel the thread. @@ -381,6 +372,7 @@ protected: uint32_t timeout_usec, lldb::ConnectionStatus &status, Error *error_ptr); + //------------------------------------------------------------------ /// Append new bytes that get read from the read thread into the /// internal object byte cache. This will cause a \b @@ -424,8 +416,11 @@ protected: //------------------------------------------------------------------ size_t GetCachedBytes (void *dst, size_t dst_len); + +private: + DISALLOW_COPY_AND_ASSIGN (Communication); }; } // namespace lldb_private -#endif // liblldb_Communication_h_ +#endif // liblldb_Communication_h_ diff --git a/include/lldb/Core/Connection.h b/include/lldb/Core/Connection.h index 121395c0b23c..4b3024ebdc57 100644 --- a/include/lldb/Core/Connection.h +++ b/include/lldb/Core/Connection.h @@ -58,7 +58,7 @@ public: /// /// @param[out] error_ptr /// A pointer to an error object that should be given an - /// approriate error value if this method returns false. This + /// appropriate error value if this method returns false. This /// value can be NULL if the error value should be ignored. /// /// @return @@ -77,7 +77,7 @@ public: /// /// @param[out] error_ptr /// A pointer to an error object that should be given an - /// approriate error value if this method returns false. This + /// appropriate error value if this method returns false. This /// value can be NULL if the error value should be ignored. /// /// @return @@ -115,12 +115,12 @@ public: /// The number of microseconds to wait for the data. /// /// @param[out] status - /// On return, indicates whether the call was sucessful or terminated + /// On return, indicates whether the call was successful or terminated /// due to some error condition. /// /// @param[out] error_ptr /// A pointer to an error object that should be given an - /// approriate error value if this method returns zero. This + /// appropriate error value if this method returns zero. This /// value can be NULL if the error value should be ignored. /// /// @return @@ -151,7 +151,7 @@ public: /// /// @param[out] error_ptr /// A pointer to an error object that should be given an - /// approriate error value if this method returns zero. This + /// appropriate error value if this method returns zero. This /// value can be NULL if the error value should be ignored. /// /// @return @@ -182,7 +182,7 @@ public: /// operation). /// /// @return - /// Returns true is the interrupt request was sucessful. + /// Returns true is the interrupt request was successful. //------------------------------------------------------------------ virtual bool InterruptRead() = 0; diff --git a/include/lldb/Core/ConnectionSharedMemory.h b/include/lldb/Core/ConnectionSharedMemory.h index 48e62142954e..d0553699e14e 100644 --- a/include/lldb/Core/ConnectionSharedMemory.h +++ b/include/lldb/Core/ConnectionSharedMemory.h @@ -28,33 +28,32 @@ public: ConnectionSharedMemory (); - virtual - ~ConnectionSharedMemory (); + ~ConnectionSharedMemory () override; - virtual bool - IsConnected () const; + bool + IsConnected () const override; virtual lldb::ConnectionStatus BytesAvailable (uint32_t timeout_usec, Error *error_ptr); - virtual lldb::ConnectionStatus - Connect (const char *s, Error *error_ptr); + lldb::ConnectionStatus + Connect (const char *s, Error *error_ptr) override; - virtual lldb::ConnectionStatus - Disconnect (Error *error_ptr); + lldb::ConnectionStatus + Disconnect (Error *error_ptr) override; - virtual size_t + size_t Read (void *dst, size_t dst_len, uint32_t timeout_usec, lldb::ConnectionStatus &status, - Error *error_ptr); + Error *error_ptr) override; - virtual size_t - Write (const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr); + size_t + Write (const void *src, size_t src_len, lldb::ConnectionStatus &status, Error *error_ptr) override; - virtual std::string - GetURI(); + std::string + GetURI() override; lldb::ConnectionStatus Open (bool create, const char *name, size_t size, Error *error_ptr); @@ -64,10 +63,12 @@ protected: std::string m_name; int m_fd; // One buffer that contains all we need DataBufferMemoryMap m_mmap; + private: + DISALLOW_COPY_AND_ASSIGN (ConnectionSharedMemory); }; } // namespace lldb_private -#endif // liblldb_ConnectionSharedMemory_h_ +#endif // liblldb_ConnectionSharedMemory_h_ diff --git a/include/lldb/Core/ConstString.h b/include/lldb/Core/ConstString.h index cfe8ea2db0e1..6e234da0a595 100644 --- a/include/lldb/Core/ConstString.h +++ b/include/lldb/Core/ConstString.h @@ -9,13 +9,14 @@ #ifndef liblldb_ConstString_h_ #define liblldb_ConstString_h_ -#if defined(__cplusplus) -#include <assert.h> - -#include "lldb/lldb-private.h" +// C Includes +// C++ Includes +// Other libraries and framework includes #include "llvm/ADT/StringRef.h" +// Project includes +#include "lldb/lldb-private.h" namespace lldb_private { @@ -41,12 +42,11 @@ public: /// /// Initializes the string to an empty string. //------------------------------------------------------------------ - ConstString (): - m_string (NULL) + ConstString(): + m_string(nullptr) { } - //------------------------------------------------------------------ /// Copy constructor /// @@ -105,10 +105,7 @@ public: /// Since constant string values are currently not reference counted, /// there isn't much to do here. //------------------------------------------------------------------ - ~ConstString () - { - } - + ~ConstString() = default; //---------------------------------------------------------------------- /// C string equality binary predicate function object for ConstString @@ -224,18 +221,16 @@ public: /// Get the value of the contained string as a NULL terminated C /// string value. /// - /// If \a value_if_empty is NULL, then NULL will be returned. + /// If \a value_if_empty is nullptr, then nullptr will be returned. /// /// @return /// Returns \a value_if_empty if the string is empty, otherwise /// the C string value contained in this object. //------------------------------------------------------------------ const char * - AsCString(const char *value_if_empty = NULL) const + AsCString(const char *value_if_empty = nullptr) const { - if (IsEmpty()) - return value_if_empty; - return m_string; + return (IsEmpty() ? value_if_empty : m_string); } //------------------------------------------------------------------ @@ -256,12 +251,12 @@ public: /// /// Get the value of the contained string as a NULL terminated C /// string value. Similar to the ConstString::AsCString() function, - /// yet this function will always return NULL if the string is not + /// yet this function will always return nullptr if the string is not /// valid. So this function is a direct accessor to the string /// pointer value. /// /// @return - /// Returns NULL the string is invalid, otherwise the C string + /// Returns nullptr the string is invalid, otherwise the C string /// value contained in this object. //------------------------------------------------------------------ const char * @@ -270,7 +265,6 @@ public: return m_string; } - //------------------------------------------------------------------ /// Get the length in bytes of string value. /// @@ -293,7 +287,7 @@ public: void Clear () { - m_string = NULL; + m_string = nullptr; } //------------------------------------------------------------------ @@ -326,18 +320,18 @@ public: /// /// Dump the string value to the stream \a s. If the contained string /// is empty, print \a value_if_empty to the stream instead. If - /// \a value_if_empty is NULL, then nothing will be dumped to the + /// \a value_if_empty is nullptr, then nothing will be dumped to the /// stream. /// /// @param[in] s /// The stream that will be used to dump the object description. /// /// @param[in] value_if_empty - /// The value to dump if the string is empty. If NULL, nothing + /// The value to dump if the string is empty. If nullptr, nothing /// will be output to the stream. //------------------------------------------------------------------ void - Dump (Stream *s, const char *value_if_empty = NULL) const; + Dump(Stream *s, const char *value_if_empty = nullptr) const; //------------------------------------------------------------------ /// Dump the object debug description to a stream. @@ -358,7 +352,7 @@ public: bool IsEmpty () const { - return m_string == NULL || m_string[0] == '\0'; + return m_string == nullptr || m_string[0] == '\0'; } //------------------------------------------------------------------ @@ -473,7 +467,6 @@ public: { return sizeof(ConstString); } - //------------------------------------------------------------------ /// Get the size in bytes of the current global string pool. @@ -503,5 +496,4 @@ Stream& operator << (Stream& s, const ConstString& str); } // namespace lldb_private -#endif // #if defined(__cplusplus) -#endif // liblldb_ConstString_h_ +#endif // liblldb_ConstString_h_ diff --git a/include/lldb/Core/DataBufferHeap.h b/include/lldb/Core/DataBufferHeap.h index ad73fabe5f1e..d379c4cf4e86 100644 --- a/include/lldb/Core/DataBufferHeap.h +++ b/include/lldb/Core/DataBufferHeap.h @@ -9,7 +9,6 @@ #ifndef liblldb_DataBufferHeap_h_ #define liblldb_DataBufferHeap_h_ -#if defined(__cplusplus) #include <vector> @@ -69,26 +68,25 @@ public: /// Virtual destructor since this class inherits from a pure virtual /// base class #DataBuffer. //------------------------------------------------------------------ - virtual - ~DataBufferHeap(); + ~DataBufferHeap() override; //------------------------------------------------------------------ /// @copydoc DataBuffer::GetBytes() //------------------------------------------------------------------ - virtual uint8_t * - GetBytes (); + uint8_t * + GetBytes () override; //------------------------------------------------------------------ /// @copydoc DataBuffer::GetBytes() const //------------------------------------------------------------------ - virtual const uint8_t * - GetBytes () const; + const uint8_t * + GetBytes () const override; //------------------------------------------------------------------ /// @copydoc DataBuffer::GetByteSize() const //------------------------------------------------------------------ - virtual lldb::offset_t - GetByteSize () const; + lldb::offset_t + GetByteSize () const override; //------------------------------------------------------------------ /// Set the number of bytes in the data buffer. @@ -138,5 +136,4 @@ private: } // namespace lldb_private -#endif // #if defined(__cplusplus) -#endif // liblldb_DataBufferHeap_h_ +#endif // liblldb_DataBufferHeap_h_ diff --git a/include/lldb/Core/DataBufferMemoryMap.h b/include/lldb/Core/DataBufferMemoryMap.h index 944b975a318a..9479d4e1a455 100644 --- a/include/lldb/Core/DataBufferMemoryMap.h +++ b/include/lldb/Core/DataBufferMemoryMap.h @@ -9,8 +9,6 @@ #ifndef liblldb_DataBufferMemoryMap_h_ #define liblldb_DataBufferMemoryMap_h_ -#if defined(__cplusplus) - #include "lldb/lldb-private.h" #include "lldb/Core/DataBuffer.h" @@ -45,8 +43,7 @@ public: /// Virtual destructor since this class inherits from a pure virtual /// base class #DataBuffer. //------------------------------------------------------------------ - virtual - ~DataBufferMemoryMap (); + ~DataBufferMemoryMap () override; //------------------------------------------------------------------ /// Reverts this object to an empty state by unmapping any memory @@ -58,20 +55,20 @@ public: //------------------------------------------------------------------ /// @copydoc DataBuffer::GetBytes() //------------------------------------------------------------------ - virtual uint8_t * - GetBytes (); + uint8_t * + GetBytes () override; //------------------------------------------------------------------ /// @copydoc DataBuffer::GetBytes() const //------------------------------------------------------------------ - virtual const uint8_t * - GetBytes () const; + const uint8_t * + GetBytes () const override; //------------------------------------------------------------------ /// @copydoc DataBuffer::GetByteSize() const //------------------------------------------------------------------ - virtual lldb::offset_t - GetByteSize () const; + lldb::offset_t + GetByteSize () const override; //------------------------------------------------------------------ /// Error get accessor. @@ -161,5 +158,4 @@ private: } // namespace lldb_private -#endif // #if defined(__cplusplus) -#endif // liblldb_DataBufferMemoryMap_h_ +#endif // liblldb_DataBufferMemoryMap_h_ diff --git a/include/lldb/Core/DataEncoder.h b/include/lldb/Core/DataEncoder.h index 7889f4191e50..8b4727eb2de2 100644 --- a/include/lldb/Core/DataEncoder.h +++ b/include/lldb/Core/DataEncoder.h @@ -252,7 +252,7 @@ public: /// The offset in bytes into the contained data at which to /// start encoding. /// - /// @param[int] src + /// @param[in] src /// The buffer that contains the bytes to encode. /// /// @param[in] src_len diff --git a/include/lldb/Core/DataExtractor.h b/include/lldb/Core/DataExtractor.h index e61189b98103..d5cb5e8ba4bc 100644 --- a/include/lldb/Core/DataExtractor.h +++ b/include/lldb/Core/DataExtractor.h @@ -9,17 +9,18 @@ #ifndef liblldb_DataExtractor_h_ #define liblldb_DataExtractor_h_ -#if defined (__cplusplus) - - -#include "lldb/lldb-private.h" - -#include "llvm/ADT/SmallVector.h" +// C Includes #include <limits.h> #include <stdint.h> #include <string.h> -#include <vector> + +// C++ Includes +// Other libraries and framework includes +#include "llvm/ADT/SmallVector.h" + +// Project includes +#include "lldb/lldb-private.h" namespace lldb_private { @@ -64,6 +65,7 @@ public: size_t src_len, uint32_t bytes_per_line, lldb::addr_t base_addr); // Pass LLDB_INVALID_ADDRESS to not show address at start of line + //------------------------------------------------------------------ /// Default constructor. /// @@ -146,6 +148,7 @@ public: DataExtractor (const DataExtractor& data, lldb::offset_t offset, lldb::offset_t length, uint32_t target_byte_size = 1); DataExtractor (const DataExtractor& rhs); + //------------------------------------------------------------------ /// Assignment operator. /// @@ -183,14 +186,14 @@ public: //------------------------------------------------------------------ /// Dumps the binary data as \a type objects to stream \a s (or to - /// Log() if \a s is NULL) starting \a offset bytes into the data + /// Log() if \a s is nullptr) starting \a offset bytes into the data /// and stopping after dumping \a length bytes. The offset into the /// data is displayed at the beginning of each line and can be /// offset by base address \a base_addr. \a num_per_line objects /// will be displayed on each line. /// /// @param[in] s - /// The stream to dump the output to. If NULL the output will + /// The stream to dump the output to. If nullptr the output will /// be dumped to Log(). /// /// @param[in] offset @@ -212,19 +215,19 @@ public: /// /// @param[in] type_format /// The optional format to use for the \a type objects. If this - /// is NULL, the default format for the \a type will be used. + /// is nullptr, the default format for the \a type will be used. /// /// @return /// The offset at which dumping ended. //------------------------------------------------------------------ lldb::offset_t - PutToLog (Log *log, - lldb::offset_t offset, - lldb::offset_t length, - uint64_t base_addr, - uint32_t num_per_line, - Type type, - const char *type_format = NULL) const; + PutToLog(Log *log, + lldb::offset_t offset, + lldb::offset_t length, + uint64_t base_addr, + uint32_t num_per_line, + Type type, + const char *type_format = nullptr) const; //------------------------------------------------------------------ /// Dumps \a item_count objects into the stream \a s. @@ -241,7 +244,7 @@ public: /// item_bit_size and \a item_bit_offset values. /// /// @param[in] s - /// The stream to dump the output to. This value can not be NULL. + /// The stream to dump the output to. This value can not be nullptr. /// /// @param[in] offset /// The offset into the data at which to start dumping. @@ -287,25 +290,25 @@ public: /// The offset at which dumping ended. //------------------------------------------------------------------ lldb::offset_t - Dump (Stream *s, - lldb::offset_t offset, - lldb::Format item_format, - size_t item_byte_size, - size_t item_count, - size_t num_per_line, - uint64_t base_addr, - uint32_t item_bit_size, - uint32_t item_bit_offset, - ExecutionContextScope *exe_scope = NULL) const; + Dump(Stream *s, + lldb::offset_t offset, + lldb::Format item_format, + size_t item_byte_size, + size_t item_count, + size_t num_per_line, + uint64_t base_addr, + uint32_t item_bit_size, + uint32_t item_bit_offset, + ExecutionContextScope *exe_scope = nullptr) const; //------------------------------------------------------------------ /// Dump a UUID value at \a offset. /// /// Dump a UUID starting at \a offset bytes into this object's data. - /// If the stream \a s is NULL, the output will be sent to Log(). + /// If the stream \a s is nullptr, the output will be sent to Log(). /// /// @param[in] s - /// The stream to dump the output to. If NULL the output will + /// The stream to dump the output to. If nullptr the output will /// be dumped to Log(). /// /// @param[in] offset @@ -418,7 +421,7 @@ public: /// A pointer to the C string value in the data. If the offset /// pointed to by \a offset_ptr is out of bounds, or if the /// offset plus the length of the C string is out of bounds, - /// NULL will be returned. + /// nullptr will be returned. //------------------------------------------------------------------ const char * GetCStr (lldb::offset_t *offset_ptr) const; @@ -443,7 +446,7 @@ public: /// A pointer to the C string value in the data. If the offset /// pointed to by \a offset_ptr is out of bounds, or if the /// offset plus the length of the field is out of bounds, or if - /// the field does not contain a NULL terminator byte, NULL will + /// the field does not contain a NULL terminator byte, nullptr will /// be returned. const char * GetCStr (lldb::offset_t *offset_ptr, lldb::offset_t len) const; @@ -454,7 +457,7 @@ public: /// Returns a pointer to a bytes in this object's data at the offset /// pointed to by \a offset_ptr. If \a length is zero or too large, /// then the offset pointed to by \a offset_ptr will not be updated - /// and NULL will be returned. + /// and nullptr will be returned. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -469,7 +472,7 @@ public: /// /// @return /// A pointer to the bytes in this object's data if the offset - /// and length are valid, or NULL otherwise. + /// and length are valid, or nullptr otherwise. //------------------------------------------------------------------ const void* GetData (lldb::offset_t *offset_ptr, lldb::offset_t length) const @@ -552,7 +555,7 @@ public: /// /// @return /// Returns a pointer to the next byte contained in this - /// object's data, or NULL of there is no data in this object. + /// object's data, or nullptr of there is no data in this object. //------------------------------------------------------------------ const uint8_t * GetDataEnd () const @@ -578,7 +581,7 @@ public: /// /// @return /// Returns a pointer to the first byte contained in this - /// object's data, or NULL of there is no data in this object. + /// object's data, or nullptr of there is no data in this object. //------------------------------------------------------------------ const uint8_t * GetDataStart () const @@ -586,7 +589,6 @@ public: return m_start; } - //------------------------------------------------------------------ /// Extract a float from \a *offset_ptr. /// @@ -908,7 +910,7 @@ public: /// /// @return /// \a dst if all values were properly extracted and copied, - /// NULL otherwise. + /// nullptr otherwise. //------------------------------------------------------------------ void * GetU8 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const; @@ -955,7 +957,7 @@ public: /// /// @return /// \a dst if all values were properly extracted and copied, - /// NULL otherwise. + /// nullptr otherwise. //------------------------------------------------------------------ void * GetU16 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const; @@ -1002,7 +1004,7 @@ public: /// /// @return /// \a dst if all values were properly extracted and copied, - /// NULL otherwise. + /// nullptr otherwise. //------------------------------------------------------------------ void * GetU32 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const; @@ -1049,7 +1051,7 @@ public: /// /// @return /// \a dst if all values were properly extracted and copied, - /// NULL otherwise. + /// nullptr otherwise. //------------------------------------------------------------------ void * GetU64 ( lldb::offset_t *offset_ptr, void *dst, uint32_t count) const; @@ -1113,8 +1115,8 @@ public: /// An offset into the data. /// /// @return - /// A non-NULL C string pointer if \a offset is a valid offset, - /// NULL otherwise. + /// A non-nullptr C string pointer if \a offset is a valid offset, + /// nullptr otherwise. //------------------------------------------------------------------ const char * PeekCStr (lldb::offset_t offset) const; @@ -1126,8 +1128,8 @@ public: /// there are \a length bytes available starting at \a offset. /// /// @return - /// A non-NULL data pointer if \a offset is a valid offset and - /// there are \a length bytes available at that offset, NULL + /// A non-nullptr data pointer if \a offset is a valid offset and + /// there are \a length bytes available at that offset, nullptr /// otherwise. //------------------------------------------------------------------ const uint8_t* @@ -1135,7 +1137,7 @@ public: { if (length > 0 && ValidOffsetForDataOfSize(offset, length)) return m_start + offset; - return NULL; + return nullptr; } //------------------------------------------------------------------ @@ -1150,6 +1152,9 @@ public: void SetAddressByteSize (uint32_t addr_size) { +#ifdef LLDB_CONFIGURATION_DEBUG + assert (addr_size == 4 || addr_size == 8); +#endif m_addr_size = addr_size; } @@ -1159,7 +1164,7 @@ public: /// Use data that is owned by the caller when extracting values. /// The data must stay around as long as this object, or any object /// that copies a subset of this object's data, is valid. If \a - /// bytes is NULL, or \a length is zero, this object will contain + /// bytes is nullptr, or \a length is zero, this object will contain /// no data. /// /// @param[in] bytes @@ -1317,10 +1322,8 @@ public: void Checksum (llvm::SmallVectorImpl<uint8_t> &dest, uint64_t max_data = 0); - protected: - //------------------------------------------------------------------ // Member variables //------------------------------------------------------------------ @@ -1334,5 +1337,4 @@ protected: } // namespace lldb_private -#endif // #if defined (__cplusplus) -#endif // #ifndef liblldb_DataExtractor_h_ +#endif // liblldb_DataExtractor_h_ diff --git a/include/lldb/Core/Debugger.h b/include/lldb/Core/Debugger.h index 0d9b90c8919d..4ca648ca296e 100644 --- a/include/lldb/Core/Debugger.h +++ b/include/lldb/Core/Debugger.h @@ -9,11 +9,17 @@ #ifndef liblldb_Debugger_h_ #define liblldb_Debugger_h_ -#if defined(__cplusplus) - +// C Includes #include <stdint.h> +// C++ Includes +#include <memory> +#include <map> +#include <vector> + +// Other libraries and framework includes +// Project includes #include "lldb/lldb-public.h" #include "lldb/Core/Broadcaster.h" #include "lldb/Core/FormatEntity.h" @@ -32,8 +38,8 @@ namespace llvm namespace sys { class DynamicLibrary; -} -} +} // namespace sys +} // namespace llvm namespace lldb_private { @@ -44,7 +50,6 @@ namespace lldb_private { /// Provides a global root objects for the debugger core. //---------------------------------------------------------------------- - class Debugger : public std::enable_shared_from_this<Debugger>, public UserID, @@ -54,9 +59,10 @@ class Debugger : friend class SourceManager; // For GetSourceFileCache. public: + ~Debugger() override; static lldb::DebuggerSP - CreateInstance (lldb::LogOutputCallback log_callback = NULL, void *baton = NULL); + CreateInstance(lldb::LogOutputCallback log_callback = nullptr, void *baton = nullptr); static lldb::TargetSP FindTargetWithProcessID (lldb::pid_t pid); @@ -79,9 +85,26 @@ public: static void Destroy (lldb::DebuggerSP &debugger_sp); - virtual - ~Debugger (); + static lldb::DebuggerSP + FindDebuggerWithID(lldb::user_id_t id); + static lldb::DebuggerSP + FindDebuggerWithInstanceName(const ConstString &instance_name); + + static size_t + GetNumDebuggers(); + + static lldb::DebuggerSP + GetDebuggerAtIndex(size_t index); + + static bool + FormatDisassemblerAddress(const FormatEntity::Entry *format, + const SymbolContext *sc, + const SymbolContext *prev_sc, + const ExecutionContext *exe_ctx, + const Address *addr, + Stream &s); + void Clear(); bool @@ -108,8 +131,6 @@ public: return m_error_file_sp; } - - void SetInputFileHandle (FILE *fh, bool tranfer_ownership); @@ -209,6 +230,10 @@ public: bool IsTopIOHandler (const lldb::IOHandlerSP& reader_sp); + + bool + CheckTopIOHandlerTypes (IOHandler::Type top_type, + IOHandler::Type second_top_type); void PrintAsync (const char *s, size_t len, bool is_stdout); @@ -222,26 +247,6 @@ public: const char * GetIOHandlerHelpPrologue(); - static lldb::DebuggerSP - FindDebuggerWithID (lldb::user_id_t id); - - static lldb::DebuggerSP - FindDebuggerWithInstanceName (const ConstString &instance_name); - - static size_t - GetNumDebuggers(); - - static lldb::DebuggerSP - GetDebuggerAtIndex (size_t index); - - static bool - FormatDisassemblerAddress (const FormatEntity::Entry *format, - const SymbolContext *sc, - const SymbolContext *prev_sc, - const ExecutionContext *exe_ctx, - const Address *addr, - Stream &s); - void ClearIOHandlers (); @@ -257,22 +262,22 @@ public: void SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton); - //---------------------------------------------------------------------- // Properties Functions //---------------------------------------------------------------------- enum StopDisassemblyType { eStopDisassemblyTypeNever = 0, + eStopDisassemblyTypeNoDebugInfo, eStopDisassemblyTypeNoSource, eStopDisassemblyTypeAlways }; - virtual Error - SetPropertyValue (const ExecutionContext *exe_ctx, - VarSetOperationType op, - const char *property_path, - const char *value); + Error + SetPropertyValue(const ExecutionContext *exe_ctx, + VarSetOperationType op, + const char *property_path, + const char *value) override; bool GetAutoConfirm () const; @@ -329,6 +334,24 @@ public: GetAutoOneLineSummaries () const; bool + GetAutoIndent () const; + + bool + SetAutoIndent (bool b); + + bool + GetPrintDecls () const; + + bool + SetPrintDecls (bool b); + + uint32_t + GetTabSize () const; + + bool + SetTabSize (uint32_t tab_size); + + bool GetEscapeNonPrintables () const; bool @@ -360,6 +383,9 @@ public: { return m_event_handler_thread.IsJoinable(); } + + Error + RunREPL (lldb::LanguageType language, const char *repl_options); // This is for use in the command interpreter, when you either want the selected target, or if no target // is present you want to prime the dummy target with entities that will be copied over to new targets. @@ -367,8 +393,8 @@ public: Target *GetDummyTarget(); protected: - friend class CommandInterpreter; + friend class REPL; bool StartEventHandlerThread(); @@ -380,11 +406,17 @@ protected: EventHandlerThread (lldb::thread_arg_t arg); bool + HasIOHandlerThread(); + + bool StartIOHandlerThread(); void StopIOHandlerThread(); + void + JoinIOHandlerThread(); + static lldb::thread_result_t IOHandlerThread (lldb::thread_arg_t arg); @@ -450,16 +482,13 @@ protected: }; private: - // Use Debugger::CreateInstance() to get a shared pointer to a new // debugger object Debugger (lldb::LogOutputCallback m_log_callback, void *baton); DISALLOW_COPY_AND_ASSIGN (Debugger); - }; } // namespace lldb_private -#endif // #if defined(__cplusplus) -#endif // liblldb_Debugger_h_ +#endif // liblldb_Debugger_h_ diff --git a/include/lldb/Core/Disassembler.h b/include/lldb/Core/Disassembler.h index e08e2def4c18..bfa99de81ea4 100644 --- a/include/lldb/Core/Disassembler.h +++ b/include/lldb/Core/Disassembler.h @@ -48,6 +48,7 @@ public: CalculateMnemonicOperandsAndCommentIfNeeded (exe_ctx); return m_opcode_name.c_str(); } + const char * GetOperands (const ExecutionContext* exe_ctx) { @@ -127,7 +128,6 @@ public: /// so this method can properly align the instruction opcodes. /// May be 0 to indicate no indentation/alignment of the opcodes. //------------------------------------------------------------------ - virtual void Dump (Stream *s, uint32_t max_opcode_byte_size, @@ -142,6 +142,9 @@ public: virtual bool DoesBranch () = 0; + virtual bool + HasDelaySlot (); + virtual size_t Decode (const Disassembler &disassembler, const DataExtractor& data, @@ -208,7 +211,6 @@ protected: } }; - class InstructionList { public: @@ -260,30 +262,32 @@ public: PseudoInstruction (); - virtual - ~PseudoInstruction (); + ~PseudoInstruction() override; - virtual bool - DoesBranch (); + bool + DoesBranch() override; - virtual void - CalculateMnemonicOperandsAndComment (const ExecutionContext* exe_ctx) + bool + HasDelaySlot() override; + + void + CalculateMnemonicOperandsAndComment(const ExecutionContext* exe_ctx) override { // TODO: fill this in and put opcode name into Instruction::m_opcode_name, // mnemonic into Instruction::m_mnemonics, and any comment into // Instruction::m_comment } - virtual size_t - Decode (const Disassembler &disassembler, - const DataExtractor &data, - lldb::offset_t data_offset); + size_t + Decode(const Disassembler &disassembler, + const DataExtractor &data, + lldb::offset_t data_offset) override; void SetOpcode (size_t opcode_size, void *opcode_data); - virtual void - SetDescription (const char *description); + void + SetDescription(const char *description) override; protected: std::string m_description; @@ -405,7 +409,7 @@ public: // Constructors and Destructors //------------------------------------------------------------------ Disassembler(const ArchSpec &arch, const char *flavor); - virtual ~Disassembler(); + ~Disassembler() override; typedef const char * (*SummaryCallback)(const Instruction& inst, ExecutionContext *exe_context, void *user_data); @@ -478,4 +482,4 @@ private: } // namespace lldb_private -#endif // liblldb_Disassembler_h_ +#endif // liblldb_Disassembler_h_ diff --git a/include/lldb/Core/EmulateInstruction.h b/include/lldb/Core/EmulateInstruction.h index 774d80968ff9..c5e60022fc96 100644 --- a/include/lldb/Core/EmulateInstruction.h +++ b/include/lldb/Core/EmulateInstruction.h @@ -19,6 +19,8 @@ #include "lldb/Core/Opcode.h" #include "lldb/Core/RegisterValue.h" +namespace lldb_private { + //---------------------------------------------------------------------- /// @class EmulateInstruction EmulateInstruction.h "lldb/Core/EmulateInstruction.h" /// @brief A class that allows emulation of CPU opcodes. @@ -79,8 +81,6 @@ /// and emulating the instruction is just a bonus. //---------------------------------------------------------------------- -namespace lldb_private { - class EmulateInstruction : public PluginInterface { @@ -233,7 +233,6 @@ public: } ISAAndImmediateSigned; uint32_t isa; - } info; Context () : @@ -387,9 +386,8 @@ public: EmulateInstruction (const ArchSpec &arch); - virtual ~EmulateInstruction() - { - } + ~EmulateInstruction() override = default; + //---------------------------------------------------------------------- // Mandatory overrides //---------------------------------------------------------------------- @@ -404,7 +402,10 @@ public: virtual bool EvaluateInstruction (uint32_t evaluate_options) = 0; - + + virtual bool + IsInstructionConditional() { return false; } + virtual bool TestEmulation (Stream *out_stream, ArchSpec &arch, OptionValueDictionary *test_data) = 0; @@ -527,7 +528,6 @@ public: return m_arch; } - static size_t ReadMemoryFrame (EmulateInstruction *instruction, void *baton, @@ -628,7 +628,6 @@ protected: lldb::addr_t m_addr; Opcode m_opcode; - private: //------------------------------------------------------------------ // For EmulateInstruction only @@ -636,6 +635,6 @@ private: DISALLOW_COPY_AND_ASSIGN (EmulateInstruction); }; -} // namespace lldb_private +} // namespace lldb_private -#endif // lldb_EmulateInstruction_h_ +#endif // lldb_EmulateInstruction_h_ diff --git a/include/lldb/Core/Event.h b/include/lldb/Core/Event.h index 1c3eec0359c3..e8867c0e7e77 100644 --- a/include/lldb/Core/Event.h +++ b/include/lldb/Core/Event.h @@ -12,7 +12,7 @@ // C Includes // C++ Includes -#include <list> +#include <memory> #include <string> // Other libraries and framework includes @@ -49,7 +49,6 @@ private: } DISALLOW_COPY_AND_ASSIGN (EventData); - }; //---------------------------------------------------------------------- @@ -67,17 +66,16 @@ public: EventDataBytes (const void *src, size_t src_len); - virtual - ~EventDataBytes(); + ~EventDataBytes() override; //------------------------------------------------------------------ // Member functions //------------------------------------------------------------------ - virtual const ConstString & - GetFlavor () const; + const ConstString & + GetFlavor () const override; - virtual void - Dump (Stream *s) const; + void + Dump (Stream *s) const override; const void * GetBytes() const; @@ -113,7 +111,6 @@ private: std::string m_bytes; DISALLOW_COPY_AND_ASSIGN (EventDataBytes); - }; //---------------------------------------------------------------------- @@ -126,10 +123,9 @@ class Event friend class EventData; public: + Event(Broadcaster *broadcaster, uint32_t event_type, EventData *data = nullptr); - Event (Broadcaster *broadcaster, uint32_t event_type, EventData *data = NULL); - - Event (uint32_t event_type, EventData *data = NULL); + Event(uint32_t event_type, EventData *data = nullptr); ~Event (); @@ -184,7 +180,6 @@ public: m_data_ap.reset(); } - private: // This is only called by Listener when it pops an event off the queue for // the listener. It calls the Event Data's DoOnRemoval() method, which is @@ -202,7 +197,6 @@ private: m_broadcaster = broadcaster; } - Broadcaster * m_broadcaster; // The broadcaster that sent this event uint32_t m_type; // The bit describing this event std::unique_ptr<EventData> m_data_ap; // User specific data for this event @@ -214,4 +208,4 @@ private: } // namespace lldb_private -#endif // liblldb_Event_h_ +#endif // liblldb_Event_h_ diff --git a/include/lldb/Core/FileLineResolver.h b/include/lldb/Core/FileLineResolver.h index e1928f1b063d..f0f7fbdf756f 100644 --- a/include/lldb/Core/FileLineResolver.h +++ b/include/lldb/Core/FileLineResolver.h @@ -38,20 +38,19 @@ public: uint32_t line_no, bool check_inlines); - virtual - ~FileLineResolver (); + ~FileLineResolver () override; - virtual Searcher::CallbackReturn + Searcher::CallbackReturn SearchCallback (SearchFilter &filter, SymbolContext &context, Address *addr, - bool containing); + bool containing) override; - virtual Searcher::Depth - GetDepth (); + Searcher::Depth + GetDepth () override; - virtual void - GetDescription (Stream *s); + void + GetDescription (Stream *s) override; const SymbolContextList & GetFileLineMatches() @@ -78,4 +77,4 @@ private: } // namespace lldb_private -#endif // liblldb_FileLineResolver_h_ +#endif // liblldb_FileLineResolver_h_ diff --git a/include/lldb/Core/FormatEntity.h b/include/lldb/Core/FormatEntity.h index db4f59132832..659b696e61fd 100644 --- a/include/lldb/Core/FormatEntity.h +++ b/include/lldb/Core/FormatEntity.h @@ -9,18 +9,21 @@ #ifndef liblldb_FormatEntity_h_ #define liblldb_FormatEntity_h_ -#if defined(__cplusplus) +// C Includes +// C++ Includes #include <string> #include <vector> +// Other libraries and framework includes +// Project includes #include "lldb/lldb-private.h" #include "lldb/Core/Error.h" namespace llvm { class StringRef; -} +} // namespace llvm namespace lldb_private { @@ -81,6 +84,7 @@ namespace lldb_private FunctionPCOffset, FunctionInitial, FunctionChanged, + FunctionIsOptimized, LineEntryFile, LineEntryLineNumber, LineEntryStartAddress, @@ -108,13 +112,13 @@ namespace lldb_private bool keep_separator; }; - Entry (Type t = Type::Invalid, - const char *s = NULL, - const char *f = NULL) : + Entry(Type t = Type::Invalid, + const char *s = nullptr, + const char *f = nullptr) : string (s ? s : ""), printf_format (f ? f : ""), children (), - definition (NULL), + definition (nullptr), type (t), fmt (lldb::eFormatDefault), number (0), @@ -146,7 +150,7 @@ namespace lldb_private string.clear(); printf_format.clear(); children.clear(); - definition = NULL; + definition = nullptr; type = Type::Invalid; fmt = lldb::eFormatDefault; number = 0; @@ -252,12 +256,10 @@ namespace lldb_private static bool FormatFileSpec (const FileSpec &file, Stream &s, llvm::StringRef elements, llvm::StringRef element_format); protected: - static Error ParseInternal (llvm::StringRef &format, Entry &parent_entry, uint32_t depth); }; +} // namespace lldb_private -} -#endif // #if defined(__cplusplus) -#endif // liblldb_FormatEntity_h_ +#endif // liblldb_FormatEntity_h_ diff --git a/include/lldb/Core/History.h b/include/lldb/Core/History.h index b3626882f843..fbb7bd8b0c1a 100644 --- a/include/lldb/Core/History.h +++ b/include/lldb/Core/History.h @@ -82,7 +82,6 @@ private: collection m_events; DISALLOW_COPY_AND_ASSIGN (HistorySource); - }; //---------------------------------------------------------------------- @@ -103,8 +102,7 @@ class HistorySourceUInt : public HistorySource { } - virtual - ~HistorySourceUInt() + ~HistorySourceUInt() override { } @@ -112,44 +110,44 @@ class HistorySourceUInt : public HistorySource // in the subclass of this class to produce a history event and push it // onto the end of the history stack. - virtual HistoryEvent - CreateHistoryEvent () + HistoryEvent + CreateHistoryEvent () override { ++m_curr_id; return (HistoryEvent)m_curr_id; } - virtual void - DeleteHistoryEvent (HistoryEvent event) + void + DeleteHistoryEvent (HistoryEvent event) override { // Nothing to delete, the event contains the integer } - virtual void - DumpHistoryEvent (Stream &strm, HistoryEvent event); + void + DumpHistoryEvent (Stream &strm, HistoryEvent event) override; - virtual size_t - GetHistoryEventCount() + size_t + GetHistoryEventCount() override { return m_curr_id; } - virtual HistoryEvent - GetHistoryEventAtIndex (uint32_t idx) + HistoryEvent + GetHistoryEventAtIndex (uint32_t idx) override { return (HistoryEvent)((uintptr_t)idx); } - virtual HistoryEvent - GetCurrentHistoryEvent () + HistoryEvent + GetCurrentHistoryEvent () override { return (HistoryEvent)m_curr_id; } // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs. - virtual int + int CompareHistoryEvents (const HistoryEvent lhs, - const HistoryEvent rhs) + const HistoryEvent rhs) override { uintptr_t lhs_uint = (uintptr_t)lhs; uintptr_t rhs_uint = (uintptr_t)rhs; @@ -160,8 +158,8 @@ class HistorySourceUInt : public HistorySource return 0; } - virtual bool - IsCurrentHistoryEvent (const HistoryEvent event) + bool + IsCurrentHistoryEvent (const HistoryEvent event) override { return (uintptr_t)event == m_curr_id; } @@ -171,7 +169,6 @@ protected: uintptr_t m_curr_id; // The current value of the history unsigned unteger }; - } // namespace lldb_private -#endif // lldb_History_h_ +#endif // lldb_History_h_ diff --git a/include/lldb/Core/IOHandler.h b/include/lldb/Core/IOHandler.h index b617d8e75f58..3eba1c3cc9d8 100644 --- a/include/lldb/Core/IOHandler.h +++ b/include/lldb/Core/IOHandler.h @@ -10,10 +10,16 @@ #ifndef liblldb_IOHandler_h_ #define liblldb_IOHandler_h_ +// C Includes #include <string.h> -#include <stack> +// C++ Includes +#include <memory> +#include <string> +#include <vector> +// Other libraries and framework includes +// Project includes #include "lldb/lldb-public.h" #include "lldb/lldb-enumerations.h" #include "lldb/Core/ConstString.h" @@ -29,7 +35,7 @@ namespace curses { class Application; typedef std::unique_ptr<Application> ApplicationAP; -} +} // namespace curses namespace lldb_private { @@ -42,6 +48,7 @@ namespace lldb_private { Confirm, Curses, Expression, + REPL, ProcessIO, PythonInterpreter, PythonCode, @@ -123,7 +130,7 @@ namespace lldb_private { GetPrompt () { // Prompt support isn't mandatory - return NULL; + return nullptr; } virtual bool @@ -142,13 +149,13 @@ namespace lldb_private { virtual const char * GetCommandPrefix () { - return NULL; + return nullptr; } virtual const char * GetHelpPrologue() { - return NULL; + return nullptr; } int @@ -257,7 +264,6 @@ namespace lldb_private { private: DISALLOW_COPY_AND_ASSIGN (IOHandler); }; - //------------------------------------------------------------------ /// A delegate class for use with IOHandler subclasses. @@ -283,9 +289,7 @@ namespace lldb_private { } virtual - ~IOHandlerDelegate() - { - } + ~IOHandlerDelegate() = default; virtual void IOHandlerActivated (IOHandler &io_handler) @@ -309,7 +313,7 @@ namespace lldb_private { virtual const char * IOHandlerGetFixIndentationCharacters () { - return NULL; + return nullptr; } //------------------------------------------------------------------ @@ -395,13 +399,13 @@ namespace lldb_private { virtual const char * IOHandlerGetCommandPrefix () { - return NULL; + return nullptr; } virtual const char * IOHandlerGetHelpPrologue () { - return NULL; + return nullptr; } //------------------------------------------------------------------ @@ -415,6 +419,7 @@ namespace lldb_private { { return false; } + protected: Completion m_completion; // Support for common builtin completions bool m_io_handler_done; @@ -438,10 +443,7 @@ namespace lldb_private { { } - virtual - ~IOHandlerDelegateMultiline () - { - } + ~IOHandlerDelegateMultiline() override = default; ConstString IOHandlerGetControlSequence (char ch) override @@ -467,11 +469,11 @@ namespace lldb_private { } return false; } + protected: const std::string m_end_line; }; - class IOHandlerEditline : public IOHandler { public: @@ -499,8 +501,7 @@ namespace lldb_private { uint32_t line_number_start, // If non-zero show line numbers starting at 'line_number_start' IOHandlerDelegate &delegate); - virtual - ~IOHandlerEditline (); + ~IOHandlerEditline() override; void Run () override; @@ -632,8 +633,7 @@ namespace lldb_private { const char *prompt, bool default_response); - virtual - ~IOHandlerConfirm (); + ~IOHandlerConfirm() override; bool GetResponse () const @@ -694,14 +694,14 @@ namespace lldb_private { public: IOHandlerCursesValueObjectList (Debugger &debugger, ValueObjectList &valobj_list); - virtual - ~IOHandlerCursesValueObjectList (); + ~IOHandlerCursesValueObjectList() override; void Run () override; void GotEOF() override; + protected: ValueObjectList m_valobj_list; }; @@ -709,17 +709,14 @@ namespace lldb_private { class IOHandlerStack { public: - IOHandlerStack () : m_stack(), m_mutex(Mutex::eMutexTypeRecursive), - m_top (NULL) + m_top (nullptr) { } - ~IOHandlerStack () - { - } + ~IOHandlerStack() = default; size_t GetSize () const @@ -771,10 +768,8 @@ namespace lldb_private { sp->SetPopped (true); } // Set m_top the non-locking IsTop() call - if (m_stack.empty()) - m_top = NULL; - else - m_top = m_stack.back().get(); + + m_top = (m_stack.empty() ? nullptr : m_stack.back().get()); } Mutex & @@ -794,53 +789,42 @@ namespace lldb_private { { Mutex::Locker locker (m_mutex); const size_t num_io_handlers = m_stack.size(); - if (num_io_handlers >= 2 && - m_stack[num_io_handlers-1]->GetType() == top_type && - m_stack[num_io_handlers-2]->GetType() == second_top_type) - { - return true; - } - return false; + return (num_io_handlers >= 2 && + m_stack[num_io_handlers-1]->GetType() == top_type && + m_stack[num_io_handlers-2]->GetType() == second_top_type); } + ConstString GetTopIOHandlerControlSequence (char ch) { - if (m_top) - return m_top->GetControlSequence(ch); - return ConstString(); + return ((m_top != nullptr) ? m_top->GetControlSequence(ch) : ConstString()); } const char * GetTopIOHandlerCommandPrefix() { - if (m_top) - return m_top->GetCommandPrefix(); - return NULL; + return ((m_top != nullptr) ? m_top->GetCommandPrefix() : nullptr); } const char * GetTopIOHandlerHelpPrologue() { - if (m_top) - return m_top->GetHelpPrologue(); - return NULL; + return ((m_top != nullptr) ? m_top->GetHelpPrologue() : nullptr); } void PrintAsync (Stream *stream, const char *s, size_t len); protected: - typedef std::vector<lldb::IOHandlerSP> collection; collection m_stack; mutable Mutex m_mutex; IOHandler *m_top; private: - DISALLOW_COPY_AND_ASSIGN (IOHandlerStack); }; } // namespace lldb_private -#endif // #ifndef liblldb_IOHandler_h_ +#endif // liblldb_IOHandler_h_ diff --git a/include/lldb/Core/Language.h b/include/lldb/Core/Language.h deleted file mode 100644 index 670c6aa695e1..000000000000 --- a/include/lldb/Core/Language.h +++ /dev/null @@ -1,117 +0,0 @@ -//===-- Language.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_Language_h_ -#define liblldb_Language_h_ - -#include "lldb/lldb-private.h" - -namespace lldb_private { - -//---------------------------------------------------------------------- -/// @class Language Language.h "lldb/Core/Language.h" -/// @brief Encapsulates the programming language for an lldb object. -/// -/// Languages are represented by an enumeration value. -/// -/// The enumeration values used when describing the programming language -/// are the same values as the latest DWARF specification. -//---------------------------------------------------------------------- -class Language -{ -public: - //------------------------------------------------------------------ - /// Construct with optional language enumeration. - //------------------------------------------------------------------ - Language(lldb::LanguageType language = lldb::eLanguageTypeUnknown); - - //------------------------------------------------------------------ - /// Destructor. - /// - /// The destructor is virtual in case this class is subclassed. - //------------------------------------------------------------------ - virtual - ~Language(); - - //------------------------------------------------------------------ - /// Get the language value as a NULL termianted C string. - /// - /// @return - /// The C string representation of the language. The returned - /// string does not need to be freed as it comes from constant - /// strings. NULL can be returned when the language is set to - /// a value that doesn't match of of the lldb::LanguageType - /// enumerations. - //------------------------------------------------------------------ - const char * - AsCString (lldb::DescriptionLevel level = lldb::eDescriptionLevelBrief) const; - - void - Clear(); - - void - GetDescription (Stream *s, lldb::DescriptionLevel level) const; - - //------------------------------------------------------------------ - /// Dump the language value to the stream \a s. - /// - /// @param[in] s - /// The stream to which to dump the language description. - //------------------------------------------------------------------ - void - Dump(Stream *s) const; - - //------------------------------------------------------------------ - /// Get accessor for the language. - /// - /// @return - /// The enumeration value that describes the programming - /// language that an object is associated with. - //------------------------------------------------------------------ - virtual lldb::LanguageType - GetLanguage() const; - - //------------------------------------------------------------------ - /// Set accessor for the language. - /// - /// @param[in] language - /// The new enumeration value that describes the programming - /// language that an object is associated with. - //------------------------------------------------------------------ - void - SetLanguage(lldb::LanguageType language); - - //------------------------------------------------------------------ - /// Set accessor for the language. - /// - /// @param[in] language_cstr - /// The language name as a C string. - //------------------------------------------------------------------ - bool - SetLanguageFromCString(const char *language_cstr); - - -protected: - //------------------------------------------------------------------ - // Member variables - //------------------------------------------------------------------ - lldb::LanguageType m_language; ///< The programming language enumeration value. - ///< The enumeration values are the same as the - ///< latest DWARF specification. -}; - -//-------------------------------------------------------------- -/// Stream the language enumeration as a string object to a -/// Stream. -//-------------------------------------------------------------- -Stream& operator << (Stream& s, const Language& language); - -} // namespace lldb_private - -#endif // liblldb_Language_h_ diff --git a/include/lldb/Core/Listener.h b/include/lldb/Core/Listener.h index 2dbd2eb436ce..b11c1644507b 100644 --- a/include/lldb/Core/Listener.h +++ b/include/lldb/Core/Listener.h @@ -14,11 +14,9 @@ // C++ Includes #include <list> #include <map> -#include <set> #include <string> #include <vector> - // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" @@ -118,13 +116,12 @@ public: HandleBroadcastEvent (lldb::EventSP &event_sp); private: - //------------------------------------------------------------------ // Classes that inherit from Listener can see and modify these //------------------------------------------------------------------ struct BroadcasterInfo { - BroadcasterInfo(uint32_t mask, HandleBroadcastCallback cb = NULL, void *ud = NULL) : + BroadcasterInfo(uint32_t mask, HandleBroadcastCallback cb = nullptr, void *ud = nullptr) : event_mask (mask), callback (cb), callback_user_data (ud) @@ -141,28 +138,28 @@ private: typedef std::vector<BroadcasterManager *> broadcaster_manager_collection; bool - FindNextEventInternal (Broadcaster *broadcaster, // NULL for any broadcaster - const ConstString *sources, // NULL for any event - uint32_t num_sources, - uint32_t event_type_mask, - lldb::EventSP &event_sp, - bool remove); + FindNextEventInternal(Broadcaster *broadcaster, // nullptr for any broadcaster + const ConstString *sources, // nullptr for any event + uint32_t num_sources, + uint32_t event_type_mask, + lldb::EventSP &event_sp, + bool remove); + + bool + GetNextEventInternal(Broadcaster *broadcaster, // nullptr for any broadcaster + const ConstString *sources, // nullptr for any event + uint32_t num_sources, + uint32_t event_type_mask, + lldb::EventSP &event_sp); bool - GetNextEventInternal (Broadcaster *broadcaster, // NULL for any broadcaster - const ConstString *sources, // NULL for any event + WaitForEventsInternal(const TimeValue *timeout, + Broadcaster *broadcaster, // nullptr for any broadcaster + const ConstString *sources, // nullptr for any event uint32_t num_sources, uint32_t event_type_mask, lldb::EventSP &event_sp); - bool - WaitForEventsInternal (const TimeValue *timeout, - Broadcaster *broadcaster, // NULL for any broadcaster - const ConstString *sources, // NULL for any event - uint32_t num_sources, - uint32_t event_type_mask, - lldb::EventSP &event_sp); - std::string m_name; broadcaster_collection m_broadcasters; Mutex m_broadcasters_mutex; // Protects m_broadcasters @@ -191,4 +188,4 @@ private: } // namespace lldb_private -#endif // liblldb_Select_h_ +#endif // liblldb_Select_h_ diff --git a/include/lldb/Core/Log.h b/include/lldb/Core/Log.h index 3aa4b4d48e17..674fdfdfc0b2 100644 --- a/include/lldb/Core/Log.h +++ b/include/lldb/Core/Log.h @@ -182,17 +182,16 @@ private: DISALLOW_COPY_AND_ASSIGN(Log); }; - class LogChannel : public PluginInterface { public: LogChannel(); - virtual ~LogChannel(); + ~LogChannel() override; static lldb::LogChannelSP FindPlugin(const char *plugin_name); - // categories is a an array of chars that ends with a NULL element. + // categories is an array of chars that ends with a NULL element. virtual void Disable(const char **categories, Stream *feedback_strm) = 0; virtual bool Enable( @@ -209,7 +208,6 @@ private: DISALLOW_COPY_AND_ASSIGN(LogChannel); }; - } // namespace lldb_private -#endif // liblldb_Log_H_ +#endif // liblldb_Log_h_ diff --git a/include/lldb/Core/Logging.h b/include/lldb/Core/Logging.h index a4dd76f11237..ca04c84b21a6 100644 --- a/include/lldb/Core/Logging.h +++ b/include/lldb/Core/Logging.h @@ -48,6 +48,7 @@ #define LIBLLDB_LOG_SYSTEM_RUNTIME (1u << 26) #define LIBLLDB_LOG_JIT_LOADER (1u << 27) #define LIBLLDB_LOG_LANGUAGE (1u << 28) +#define LIBLLDB_LOG_DATAFORMATTERS (1u << 29) #define LIBLLDB_LOG_ALL (UINT32_MAX) #define LIBLLDB_LOG_DEFAULT (LIBLLDB_LOG_PROCESS |\ LIBLLDB_LOG_THREAD |\ diff --git a/include/lldb/Core/MappedHash.h b/include/lldb/Core/MappedHash.h index 4b77ff1ab8fc..5a52ab2b8b2d 100644 --- a/include/lldb/Core/MappedHash.h +++ b/include/lldb/Core/MappedHash.h @@ -1,29 +1,38 @@ +//===-- MappedHash.h --------------------------------------------*- C++ -*-===// // -// MappedHash.h +// The LLVM Compiler Infrastructure // +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// #ifndef liblldb_MappedHash_h_ #define liblldb_MappedHash_h_ +// C Includes #include <assert.h> #include <stdint.h> +// C++ Includes +#include <algorithm> +#include <functional> #include <map> #include <vector> +// Other libraries and framework includes +// Project includes #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Stream.h" class MappedHash { public: - enum HashFunctionType { eHashFunctionDJB = 0u // Daniel J Bernstein hash function that is also used by the ELF GNU_HASH sections }; - static uint32_t HashStringUsingDJB (const char *s) { @@ -50,7 +59,6 @@ public: return 0; } - static const uint32_t HASH_MAGIC = 0x48415348u; static const uint32_t HASH_CIGAM = 0x48534148u; @@ -77,11 +85,9 @@ public: header_data () { } - + virtual - ~Header() - { - } + ~Header() = default; size_t GetByteSize() const @@ -254,8 +260,7 @@ public: header.bucket_count = num_unique_hashes; if (header.bucket_count == 0) header.bucket_count = 1; - - + std::vector<HashToHashData> hash_buckets; std::vector<uint32_t> hash_indexes (header.bucket_count, 0); std::vector<uint32_t> hash_values; @@ -345,10 +350,12 @@ public: } } } + protected: typedef std::vector<Entry> collection; collection m_entries; }; + // A class for reading and using a saved hash table from a block of data // in memory template <typename __KeyType, class __HeaderType, class __HashData> @@ -375,9 +382,9 @@ public: MemoryTable (lldb_private::DataExtractor &data) : m_header (), - m_hash_indexes (NULL), - m_hash_values (NULL), - m_hash_offsets (NULL) + m_hash_indexes (nullptr), + m_hash_values (nullptr), + m_hash_offsets (nullptr) { lldb::offset_t offset = m_header.Read (data, 0); if (offset != LLDB_INVALID_OFFSET && IsValid ()) @@ -387,12 +394,10 @@ public: m_hash_offsets = (const uint32_t *)data.GetData (&offset, m_header.hashes_count * sizeof(uint32_t)); } } - + virtual - ~MemoryTable () - { - } - + ~MemoryTable() = default; + bool IsValid () const { @@ -483,7 +488,6 @@ public: // subclass and return a valie "const char *" given a "key". The value // could also be a C string pointer, in which case just returning "key" // will suffice. - virtual const char * GetStringForKeyType (KeyType key) const = 0; @@ -506,7 +510,6 @@ public: // should be returned. If anything else goes wrong during parsing, // return "eResultError" and the corresponding "Find()" function will // be canceled and return false. - virtual Result GetHashDataForName (const char *name, lldb::offset_t* hash_data_offset_ptr, @@ -518,7 +521,6 @@ public: return m_header; } - void ForEach (std::function <bool(const HashData &hash_data)> const &callback) const { @@ -546,7 +548,6 @@ public: const uint32_t *m_hash_values; const uint32_t *m_hash_offsets; }; - }; -#endif // #ifndef liblldb_MappedHash_h_ +#endif // liblldb_MappedHash_h_ diff --git a/include/lldb/Core/Module.h b/include/lldb/Core/Module.h index 127ddaeb9fd4..35b182aa9801 100644 --- a/include/lldb/Core/Module.h +++ b/include/lldb/Core/Module.h @@ -10,6 +10,14 @@ #ifndef liblldb_Module_h_ #define liblldb_Module_h_ +// C Includes +// C++ Includes +#include <atomic> +#include <string> +#include <vector> + +// Other libraries and framework includes +// Project includes #include "lldb/lldb-forward.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/UUID.h" @@ -17,6 +25,7 @@ #include "lldb/Host/Mutex.h" #include "lldb/Host/TimeValue.h" #include "lldb/Symbol/SymbolContextScope.h" +#include "lldb/Symbol/TypeSystem.h" #include "lldb/Target/PathMappingList.h" namespace lldb_private { @@ -85,11 +94,11 @@ public: /// module within a module (.a files and modules that contain /// multiple architectures). //------------------------------------------------------------------ - Module (const FileSpec& file_spec, - const ArchSpec& arch, - const ConstString *object_name = NULL, - lldb::offset_t object_offset = 0, - const TimeValue *object_mod_time_ptr = NULL); + Module(const FileSpec& file_spec, + const ArchSpec& arch, + const ConstString *object_name = nullptr, + lldb::offset_t object_offset = 0, + const TimeValue *object_mod_time_ptr = nullptr); Module (const ModuleSpec &module_spec); @@ -99,8 +108,7 @@ public: //------------------------------------------------------------------ /// Destructor. //------------------------------------------------------------------ - virtual - ~Module (); + ~Module() override; bool MatchesModuleSpec (const ModuleSpec &module_ref); @@ -154,11 +162,11 @@ public: /// /// @see SymbolContextScope //------------------------------------------------------------------ - virtual void - CalculateSymbolContext (SymbolContext* sc); + void + CalculateSymbolContext(SymbolContext* sc) override; - virtual lldb::ModuleSP - CalculateSymbolContextModule (); + lldb::ModuleSP + CalculateSymbolContextModule() override; void GetDescription (Stream *s, @@ -207,10 +215,9 @@ public: /// /// @see SymbolContextScope //------------------------------------------------------------------ - virtual void - DumpSymbolContext (Stream *s); + void + DumpSymbolContext(Stream *s) override; - //------------------------------------------------------------------ /// Find a symbol in the object file's symbol table. /// @@ -225,7 +232,7 @@ public: /// /// @return /// Returns a valid symbol pointer if a symbol was found, - /// NULL otherwise. + /// nullptr otherwise. //------------------------------------------------------------------ const Symbol * FindFirstSymbolWithNameAndType (const ConstString &name, @@ -288,7 +295,6 @@ public: FindCompileUnits (const FileSpec &path, bool append, SymbolContextList &sc_list); - //------------------------------------------------------------------ /// Find functions by name. @@ -323,7 +329,7 @@ public: //------------------------------------------------------------------ size_t FindFunctions (const ConstString &name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool symbols_ok, bool inlines_ok, @@ -392,8 +398,8 @@ public: /// The name of the global or static variable we are looking /// for. /// - /// @param[in] namespace_decl - /// If valid, a namespace to search in. + /// @param[in] parent_decl_ctx + /// If valid, a decl context that results must exist within /// /// @param[in] append /// If \b true, any matches will be appended to \a @@ -413,7 +419,7 @@ public: //------------------------------------------------------------------ size_t FindGlobalVariables (const ConstString &name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, VariableList& variable_list); @@ -524,7 +530,7 @@ public: size_t FindTypesInNamespace (const SymbolContext& sc, const ConstString &type_name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, size_t max_matches, TypeList& type_list); @@ -646,10 +652,10 @@ public: IsLoadedInTarget (Target *target); bool - LoadScriptingResourceInTarget (Target *target, - Error& error, - Stream* feedback_stream = NULL); - + LoadScriptingResourceInTarget(Target *target, + Error& error, + Stream* feedback_stream = nullptr); + //------------------------------------------------------------------ /// Get the number of compile units for this module. /// @@ -682,7 +688,7 @@ public: /// @return /// If Module::m_file does not exist, or no plug-in was found /// that can parse the file, or the object file doesn't contain - /// the current architecture in Module::m_arch, NULL will be + /// the current architecture in Module::m_arch, nullptr will be /// returned, else a valid object file interface will be /// returned. The returned pointer is owned by this object and /// remains valid as long as the object is around. @@ -730,7 +736,7 @@ public: /// process. /// /// @return - /// The object file loaded from memory or NULL, if the operation + /// The object file loaded from memory or nullptr, if the operation /// failed (see the `error` for more information in that case). //------------------------------------------------------------------ ObjectFile * @@ -747,20 +753,20 @@ public: /// /// @return /// If this module does not have a valid object file, or no - /// plug-in can be found that can use the object file, NULL will + /// plug-in can be found that can use the object file, nullptr will /// be returned, else a valid symbol vendor plug-in interface /// will be returned. The returned pointer is owned by this /// object and remains valid as long as the object is around. //------------------------------------------------------------------ virtual SymbolVendor* GetSymbolVendor(bool can_create = true, - lldb_private::Stream *feedback_strm = NULL); + lldb_private::Stream *feedback_strm = nullptr); //------------------------------------------------------------------ /// Get accessor the type list for this module. /// /// @return - /// A valid type list pointer, or NULL if there is no valid + /// A valid type list pointer, or nullptr if there is no valid /// symbol vendor for this module. //------------------------------------------------------------------ TypeList* @@ -935,7 +941,6 @@ public: uint32_t ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list); - void SetFileSpecAndObjectName (const FileSpec &file, const ConstString &object_name); @@ -943,8 +948,8 @@ public: bool GetIsDynamicLinkEditor (); - ClangASTContext & - GetClangASTContext (); + TypeSystem * + GetTypeSystemForLanguage (lldb::LanguageType language); // Special error functions that can do printf style formatting that will prepend the message with // something appropriate for this module (like the architecture, path and object name (if any)). @@ -1041,7 +1046,6 @@ public: bool RemapSourceFile (const char *path, std::string &new_path) const; - //------------------------------------------------------------------ /// Prepare to do a function name lookup. /// @@ -1067,6 +1071,10 @@ public: /// The mask of bits from lldb::FunctionNameType enumerations /// that tell us what kind of name we are looking for. /// + /// @param[out] language + /// If known, the language to use for determining the + /// lookup_name_type_mask. + /// /// @param[out] lookup_name /// The actual name that will be used when calling /// SymbolVendor::FindFunctions() or Symtab::FindFunctionSymbols() @@ -1087,6 +1095,7 @@ public: static void PrepareForFunctionNameLookup (const ConstString &name, uint32_t name_type_mask, + lldb::LanguageType language, ConstString &lookup_name, uint32_t &lookup_name_type_mask, bool &match_name_after_lookup); @@ -1110,17 +1119,16 @@ protected: lldb::SymbolVendorUP m_symfile_ap; ///< A pointer to the symbol vendor for this module. std::vector<lldb::SymbolVendorUP> m_old_symfiles; ///< If anyone calls Module::SetSymbolFileFileSpec() and changes the symbol file, ///< we need to keep all old symbol files around in case anyone has type references to them - lldb::ClangASTContextUP m_ast; ///< The AST context for this module. + TypeSystemMap m_type_system_map; ///< A map of any type systems associated with this module PathMappingList m_source_mappings; ///< Module specific source remappings for when you have debug info for a module that doesn't match where the sources currently are lldb::SectionListUP m_sections_ap; ///< Unified section list for module that is used by the ObjectFile and and ObjectFile instances for the debug info - bool m_did_load_objfile:1, - m_did_load_symbol_vendor:1, - m_did_parse_uuid:1, - m_did_init_ast:1; + std::atomic<bool> m_did_load_objfile; + std::atomic<bool> m_did_load_symbol_vendor; + std::atomic<bool> m_did_parse_uuid; mutable bool m_file_has_changed:1, m_first_file_changed_log:1; /// See if the module was modified after it was initially opened. - + //------------------------------------------------------------------ /// Resolve a file or load virtual address. /// @@ -1178,21 +1186,19 @@ protected: friend class SymbolFile; private: - Module (); // Only used internally by CreateJITModule () size_t FindTypes_Impl (const SymbolContext& sc, const ConstString &name, - const ClangNamespaceDecl *namespace_decl, + const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, - TypeList& types); + TypeMap& types); - DISALLOW_COPY_AND_ASSIGN (Module); }; } // namespace lldb_private -#endif // liblldb_Module_h_ +#endif // liblldb_Module_h_ diff --git a/include/lldb/Core/ModuleList.h b/include/lldb/Core/ModuleList.h index f4c12cf168ac..a0dd43263a2c 100644 --- a/include/lldb/Core/ModuleList.h +++ b/include/lldb/Core/ModuleList.h @@ -10,10 +10,14 @@ #ifndef liblldb_ModuleList_h_ #define liblldb_ModuleList_h_ -#include <vector> -#include <list> +// C Includes +// C++ Includes #include <functional> +#include <list> +#include <vector> +// Other libraries and framework includes +// Project includes #include "lldb/lldb-private.h" #include "lldb/Host/Mutex.h" #include "lldb/Utility/Iterable.h" @@ -30,10 +34,12 @@ namespace lldb_private { class ModuleList { public: - class Notifier { public: + virtual + ~Notifier() = default; + virtual void ModuleAdded (const ModuleList& module_list, const lldb::ModuleSP& module_sp) = 0; virtual void @@ -43,10 +49,6 @@ public: const lldb::ModuleSP& new_module_sp) = 0; virtual void WillClearList (const ModuleList& module_list) = 0; - - virtual - ~Notifier () - {} }; //------------------------------------------------------------------ @@ -144,6 +146,7 @@ public: //------------------------------------------------------------------ void Destroy(); + //------------------------------------------------------------------ /// Dump the description of each module contained in this list. /// @@ -209,7 +212,7 @@ public: /// An index into this module collection. /// /// @return - /// A pointer to a Module which can by NULL if \a idx is out + /// A pointer to a Module which can by nullptr if \a idx is out /// of range. /// /// @see ModuleList::GetSize() @@ -226,7 +229,7 @@ public: /// An index into this module collection. /// /// @return - /// A pointer to a Module which can by NULL if \a idx is out + /// A pointer to a Module which can by nullptr if \a idx is out /// of range. /// /// @see ModuleList::GetSize() @@ -534,10 +537,10 @@ public: GetSize () const; bool - LoadScriptingResourcesInTarget (Target *target, - std::list<Error>& errors, - Stream* feedback_stream = NULL, - bool continue_on_error = true); + LoadScriptingResourcesInTarget(Target *target, + std::list<Error>& errors, + Stream* feedback_stream = nullptr, + bool continue_on_error = true); static bool ModuleIsInCache (const Module *module_ptr); @@ -606,9 +609,8 @@ public: { return ModuleIterableNoLocking(m_modules); } - }; } // namespace lldb_private -#endif // liblldb_ModuleList_h_ +#endif // liblldb_ModuleList_h_ diff --git a/include/lldb/Core/ModuleSpec.h b/include/lldb/Core/ModuleSpec.h index be7041981a0a..95de7f375736 100644 --- a/include/lldb/Core/ModuleSpec.h +++ b/include/lldb/Core/ModuleSpec.h @@ -10,6 +10,12 @@ #ifndef liblldb_ModuleSpec_h_ #define liblldb_ModuleSpec_h_ +// C Includes +// C++ Includes +#include <vector> + +// Other libraries and framework includes +// Project includes #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Stream.h" #include "lldb/Core/UUID.h" @@ -100,17 +106,13 @@ public: FileSpec * GetFileSpecPtr () { - if (m_file) - return &m_file; - return NULL; + return (m_file ? &m_file : nullptr); } const FileSpec * GetFileSpecPtr () const { - if (m_file) - return &m_file; - return NULL; + return (m_file ? &m_file : nullptr); } FileSpec & @@ -118,6 +120,7 @@ public: { return m_file; } + const FileSpec & GetFileSpec () const { @@ -127,17 +130,13 @@ public: FileSpec * GetPlatformFileSpecPtr () { - if (m_platform_file) - return &m_platform_file; - return NULL; + return (m_platform_file ? &m_platform_file : nullptr); } const FileSpec * GetPlatformFileSpecPtr () const { - if (m_platform_file) - return &m_platform_file; - return NULL; + return (m_platform_file ? &m_platform_file : nullptr); } FileSpec & @@ -155,17 +154,13 @@ public: FileSpec * GetSymbolFileSpecPtr () { - if (m_symbol_file) - return &m_symbol_file; - return NULL; + return (m_symbol_file ? &m_symbol_file : nullptr); } const FileSpec * GetSymbolFileSpecPtr () const { - if (m_symbol_file) - return &m_symbol_file; - return NULL; + return (m_symbol_file ? &m_symbol_file : nullptr); } FileSpec & @@ -180,21 +175,16 @@ public: return m_symbol_file; } - ArchSpec * GetArchitecturePtr () { - if (m_arch.IsValid()) - return &m_arch; - return NULL; + return (m_arch.IsValid() ? &m_arch : nullptr); } const ArchSpec * GetArchitecturePtr () const { - if (m_arch.IsValid()) - return &m_arch; - return NULL; + return (m_arch.IsValid() ? &m_arch : nullptr); } ArchSpec & @@ -212,17 +202,13 @@ public: UUID * GetUUIDPtr () { - if (m_uuid.IsValid()) - return &m_uuid; - return NULL; + return (m_uuid.IsValid() ? &m_uuid : nullptr); } const UUID * GetUUIDPtr () const { - if (m_uuid.IsValid()) - return &m_uuid; - return NULL; + return (m_uuid.IsValid() ? &m_uuid : nullptr); } UUID & @@ -306,7 +292,6 @@ public: m_object_mod_time.Clear(); } - explicit operator bool () const { if (m_file) @@ -329,7 +314,7 @@ public: } void - Dump (Stream &strm) + Dump (Stream &strm) const { bool dumped_something = false; if (m_file) @@ -361,7 +346,8 @@ public: { if (dumped_something) strm.PutCString(", "); - strm.Printf("arch = %s", m_arch.GetTriple().str().c_str()); + strm.Printf("arch = "); + m_arch.DumpTriple(strm); dumped_something = true; } if (m_uuid.IsValid()) @@ -476,9 +462,7 @@ public: m_specs = rhs.m_specs; } - ~ModuleSpecList () - { - } + ~ModuleSpecList() = default; ModuleSpecList & operator = (const ModuleSpecList &rhs) @@ -528,6 +512,7 @@ public: { return m_specs[i]; } + bool GetModuleSpecAtIndex (size_t i, ModuleSpec &module_spec) const { @@ -540,8 +525,7 @@ public: module_spec.Clear(); return false; } - - + bool FindMatchingModuleSpec (const ModuleSpec &module_spec, ModuleSpec &match_module_spec) const { @@ -620,4 +604,4 @@ protected: } // namespace lldb_private -#endif // liblldb_ModuleSpec_h_ +#endif // liblldb_ModuleSpec_h_ diff --git a/include/lldb/Core/Opcode.h b/include/lldb/Core/Opcode.h index 57b8077477ce..eac0746baba1 100644 --- a/include/lldb/Core/Opcode.h +++ b/include/lldb/Core/Opcode.h @@ -16,6 +16,7 @@ // C++ Includes // Other libraries and framework includes #include "llvm/Support/MathExtras.h" + // Project includes #include "lldb/Host/Endian.h" #include "lldb/lldb-public.h" @@ -23,7 +24,7 @@ namespace lldb { class SBInstruction; -} +} // namespace lldb namespace lldb_private { @@ -76,6 +77,7 @@ namespace lldb_private { m_byte_order = lldb::eByteOrderInvalid; m_type = Opcode::eTypeInvalid; } + Opcode::Type GetType () const { @@ -189,7 +191,7 @@ namespace lldb_private { void SetOpcodeBytes (const void *bytes, size_t length) { - if (bytes && length > 0) + if (bytes != nullptr && length > 0) { m_type = eTypeBytes; m_data.inst.length = length; @@ -210,9 +212,7 @@ namespace lldb_private { const void * GetOpcodeBytes () const { - if (m_type == Opcode::eTypeBytes) - return m_data.inst.bytes; - return NULL; + return ((m_type == Opcode::eTypeBytes) ? m_data.inst.bytes : nullptr); } uint32_t @@ -252,7 +252,7 @@ namespace lldb_private { case Opcode::eType64: return &m_data.inst64; case Opcode::eTypeBytes: return m_data.inst.bytes; } - return NULL; + return nullptr; } lldb::ByteOrder @@ -261,8 +261,8 @@ namespace lldb_private { bool GetEndianSwap() const { - return (m_byte_order == lldb::eByteOrderBig && lldb::endian::InlHostByteOrder() == lldb::eByteOrderLittle) || - (m_byte_order == lldb::eByteOrderLittle && lldb::endian::InlHostByteOrder() == lldb::eByteOrderBig); + return (m_byte_order == lldb::eByteOrderBig && endian::InlHostByteOrder() == lldb::eByteOrderLittle) || + (m_byte_order == lldb::eByteOrderLittle && endian::InlHostByteOrder() == lldb::eByteOrderBig); } lldb::ByteOrder m_byte_order; @@ -284,4 +284,4 @@ namespace lldb_private { } // namespace lldb_private -#endif // lldb_Opcode_h +#endif // lldb_Opcode_h diff --git a/include/lldb/Core/PluginManager.h b/include/lldb/Core/PluginManager.h index af940d788ab0..6f8001fbfd2b 100644 --- a/include/lldb/Core/PluginManager.h +++ b/include/lldb/Core/PluginManager.h @@ -7,10 +7,13 @@ // //===----------------------------------------------------------------------===// - #ifndef liblldb_PluginManager_h_ #define liblldb_PluginManager_h_ +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/lldb-private.h" #include "lldb/Host/FileSpec.h" @@ -42,7 +45,6 @@ public: static ABICreateInstance GetABICreateCallbackForPluginName (const ConstString &name); - //------------------------------------------------------------------ // Disassembler //------------------------------------------------------------------ @@ -60,15 +62,14 @@ public: static DisassemblerCreateInstance GetDisassemblerCreateCallbackForPluginName (const ConstString &name); - //------------------------------------------------------------------ // DynamicLoader //------------------------------------------------------------------ static bool - RegisterPlugin (const ConstString &name, - const char *description, - DynamicLoaderCreateInstance create_callback, - DebuggerInitializeCallback debugger_init_callback = NULL); + RegisterPlugin(const ConstString &name, + const char *description, + DynamicLoaderCreateInstance create_callback, + DebuggerInitializeCallback debugger_init_callback = nullptr); static bool UnregisterPlugin (DynamicLoaderCreateInstance create_callback); @@ -83,10 +84,10 @@ public: // JITLoader //------------------------------------------------------------------ static bool - RegisterPlugin (const ConstString &name, - const char *description, - JITLoaderCreateInstance create_callback, - DebuggerInitializeCallback debugger_init_callback = NULL); + RegisterPlugin(const ConstString &name, + const char *description, + JITLoaderCreateInstance create_callback, + DebuggerInitializeCallback debugger_init_callback = nullptr); static bool UnregisterPlugin (JITLoaderCreateInstance create_callback); @@ -117,11 +118,10 @@ public: //------------------------------------------------------------------ // OperatingSystem //------------------------------------------------------------------ - static bool - RegisterPlugin (const ConstString &name, - const char *description, - OperatingSystemCreateInstance create_callback); - + static bool RegisterPlugin(const ConstString &name, const char *description, + OperatingSystemCreateInstance create_callback, + DebuggerInitializeCallback debugger_init_callback); + static bool UnregisterPlugin (OperatingSystemCreateInstance create_callback); @@ -132,6 +132,23 @@ public: GetOperatingSystemCreateCallbackForPluginName (const ConstString &name); //------------------------------------------------------------------ + // Language + //------------------------------------------------------------------ + static bool + RegisterPlugin (const ConstString &name, + const char *description, + LanguageCreateInstance create_callback); + + static bool + UnregisterPlugin (LanguageCreateInstance create_callback); + + static LanguageCreateInstance + GetLanguageCreateCallbackAtIndex (uint32_t idx); + + static LanguageCreateInstance + GetLanguageCreateCallbackForPluginName (const ConstString &name); + + //------------------------------------------------------------------ // LanguageRuntime //------------------------------------------------------------------ static bool @@ -152,7 +169,6 @@ public: static LanguageRuntimeCreateInstance GetLanguageRuntimeCreateCallbackForPluginName (const ConstString &name); - //------------------------------------------------------------------ // SystemRuntime //------------------------------------------------------------------ @@ -170,17 +186,16 @@ public: static SystemRuntimeCreateInstance GetSystemRuntimeCreateCallbackForPluginName (const ConstString &name); - //------------------------------------------------------------------ // ObjectFile //------------------------------------------------------------------ static bool - RegisterPlugin (const ConstString &name, - const char *description, - ObjectFileCreateInstance create_callback, - ObjectFileCreateMemoryInstance create_memory_callback, - ObjectFileGetModuleSpecifications get_module_specifications, - ObjectFileSaveCore save_core = NULL); + RegisterPlugin(const ConstString &name, + const char *description, + ObjectFileCreateInstance create_callback, + ObjectFileCreateMemoryInstance create_memory_callback, + ObjectFileGetModuleSpecifications get_module_specifications, + ObjectFileSaveCore save_core = nullptr); static bool UnregisterPlugin (ObjectFileCreateInstance create_callback); @@ -248,10 +263,10 @@ public: // Platform //------------------------------------------------------------------ static bool - RegisterPlugin (const ConstString &name, - const char *description, - PlatformCreateInstance create_callback, - DebuggerInitializeCallback debugger_init_callback = NULL); + RegisterPlugin(const ConstString &name, + const char *description, + PlatformCreateInstance create_callback, + DebuggerInitializeCallback debugger_init_callback = nullptr); static bool UnregisterPlugin (PlatformCreateInstance create_callback); @@ -275,10 +290,10 @@ public: // Process //------------------------------------------------------------------ static bool - RegisterPlugin (const ConstString &name, - const char *description, - ProcessCreateInstance create_callback, - DebuggerInitializeCallback debugger_init_callback = NULL); + RegisterPlugin(const ConstString &name, + const char *description, + ProcessCreateInstance create_callback, + DebuggerInitializeCallback debugger_init_callback = nullptr); static bool UnregisterPlugin (ProcessCreateInstance create_callback); @@ -296,12 +311,30 @@ public: GetProcessPluginDescriptionAtIndex (uint32_t idx); //------------------------------------------------------------------ + // ScriptInterpreter + //------------------------------------------------------------------ + static bool + RegisterPlugin(const ConstString &name, const char *description, lldb::ScriptLanguage script_lang, + ScriptInterpreterCreateInstance create_callback); + + static bool + UnregisterPlugin(ScriptInterpreterCreateInstance create_callback); + + static ScriptInterpreterCreateInstance + GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx); + + static lldb::ScriptInterpreterSP + GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang, + CommandInterpreter &interpreter); + + //------------------------------------------------------------------ // SymbolFile //------------------------------------------------------------------ static bool RegisterPlugin (const ConstString &name, const char *description, - SymbolFileCreateInstance create_callback); + SymbolFileCreateInstance create_callback, + DebuggerInitializeCallback debugger_init_callback = nullptr); static bool UnregisterPlugin (SymbolFileCreateInstance create_callback); @@ -312,7 +345,6 @@ public: static SymbolFileCreateInstance GetSymbolFileCreateCallbackForPluginName (const ConstString &name); - //------------------------------------------------------------------ // SymbolVendor //------------------------------------------------------------------ @@ -385,6 +417,53 @@ public: static InstrumentationRuntimeCreateInstance GetInstrumentationRuntimeCreateCallbackForPluginName (const ConstString &name); + //------------------------------------------------------------------ + // TypeSystem + //------------------------------------------------------------------ + static bool + RegisterPlugin (const ConstString &name, + const char *description, + TypeSystemCreateInstance create_callback, + TypeSystemEnumerateSupportedLanguages enumerate_languages_callback); + + static bool + UnregisterPlugin (TypeSystemCreateInstance create_callback); + + static TypeSystemCreateInstance + GetTypeSystemCreateCallbackAtIndex (uint32_t idx); + + static TypeSystemCreateInstance + GetTypeSystemCreateCallbackForPluginName (const ConstString &name); + + static TypeSystemEnumerateSupportedLanguages + GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx); + + static TypeSystemEnumerateSupportedLanguages + GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name); + + //------------------------------------------------------------------ + // REPL + //------------------------------------------------------------------ + static bool + RegisterPlugin (const ConstString &name, + const char *description, + REPLCreateInstance create_callback, + REPLEnumerateSupportedLanguages enumerate_languages_callback); + + static bool + UnregisterPlugin (REPLCreateInstance create_callback); + + static REPLCreateInstance + GetREPLCreateCallbackAtIndex (uint32_t idx); + + static REPLCreateInstance + GetREPLCreateCallbackForPluginName (const ConstString &name); + + static REPLEnumerateSupportedLanguages + GetREPLEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx); + + static REPLEnumerateSupportedLanguages + GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name); //------------------------------------------------------------------ // Some plug-ins might register a DebuggerInitializeCallback @@ -419,16 +498,41 @@ public: static lldb::OptionValuePropertiesSP GetSettingForProcessPlugin (Debugger &debugger, const ConstString &setting_name); - + static bool CreateSettingForProcessPlugin (Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, const ConstString &description, bool is_global_property); -}; + static lldb::OptionValuePropertiesSP + GetSettingForSymbolFilePlugin (Debugger &debugger, + const ConstString &setting_name); + + static bool + CreateSettingForSymbolFilePlugin (Debugger &debugger, + const lldb::OptionValuePropertiesSP &properties_sp, + const ConstString &description, + bool is_global_property); + + static lldb::OptionValuePropertiesSP + GetSettingForJITLoaderPlugin (Debugger &debugger, + const ConstString &setting_name); + static bool + CreateSettingForJITLoaderPlugin (Debugger &debugger, + const lldb::OptionValuePropertiesSP &properties_sp, + const ConstString &description, + bool is_global_property); + + static lldb::OptionValuePropertiesSP GetSettingForOperatingSystemPlugin(Debugger &debugger, + const ConstString &setting_name); + + static bool CreateSettingForOperatingSystemPlugin(Debugger &debugger, + const lldb::OptionValuePropertiesSP &properties_sp, + const ConstString &description, bool is_global_property); +}; } // namespace lldb_private -#endif // liblldb_PluginManager_h_ +#endif // liblldb_PluginManager_h_ diff --git a/include/lldb/Core/RangeMap.h b/include/lldb/Core/RangeMap.h index d2c43a5d794d..b2e3f06f08a9 100644 --- a/include/lldb/Core/RangeMap.h +++ b/include/lldb/Core/RangeMap.h @@ -10,16 +10,21 @@ #ifndef liblldb_RangeMap_h_ #define liblldb_RangeMap_h_ +// C Includes +// C++ Includes +#include <algorithm> #include <vector> -#include "lldb/lldb-private.h" +// Other libraries and framework includes #include "llvm/ADT/SmallVector.h" +// Project includes +#include "lldb/lldb-private.h" + // Uncomment to make sure all Range objects are sorted when needed //#define ASSERT_RANGEMAP_ARE_SORTED namespace lldb_private { - //---------------------------------------------------------------------- // Templatized classes for dealing with generic ranges and also @@ -187,16 +192,11 @@ namespace lldb_private { typedef S SizeType; typedef Range<B,S> Entry; typedef llvm::SmallVector<Entry, N> Collection; - - RangeArray () : - m_entries () - { - } - - ~RangeArray() - { - } - + + RangeArray() = default; + + ~RangeArray() = default; + void Append (const Entry &entry) { @@ -236,6 +236,7 @@ namespace lldb_private { return true; } #endif + void CombineConsecutiveRanges () { @@ -281,7 +282,6 @@ namespace lldb_private { } } - BaseType GetMinRangeBase (BaseType fail_value) const { @@ -337,9 +337,7 @@ namespace lldb_private { const Entry * GetEntryAtIndex (size_t i) const { - if (i<m_entries.size()) - return &m_entries[i]; - return NULL; + return ((i < m_entries.size()) ? &m_entries[i] : nullptr); } // Clients must ensure that "i" is a valid index prior to calling this function @@ -352,17 +350,13 @@ namespace lldb_private { Entry * Back() { - if (m_entries.empty()) - return NULL; - return &m_entries.back(); + return (m_entries.empty() ? nullptr : &m_entries.back()); } const Entry * Back() const { - if (m_entries.empty()) - return NULL; - return &m_entries.back(); + return (m_entries.empty() ? nullptr : &m_entries.back()); } static bool @@ -424,7 +418,7 @@ namespace lldb_private { } } } - return NULL; + return nullptr; } const Entry * @@ -452,7 +446,7 @@ namespace lldb_private { } } } - return NULL; + return nullptr; } protected: @@ -467,16 +461,11 @@ namespace lldb_private { typedef S SizeType; typedef Range<B,S> Entry; typedef std::vector<Entry> Collection; - - RangeVector () : - m_entries () - { - } - - ~RangeVector() - { - } - + + RangeVector() = default; + + ~RangeVector() = default; + void Append (const Entry &entry) { @@ -516,6 +505,7 @@ namespace lldb_private { return true; } #endif + void CombineConsecutiveRanges () { @@ -560,8 +550,7 @@ namespace lldb_private { } } } - - + BaseType GetMinRangeBase (BaseType fail_value) const { @@ -623,9 +612,7 @@ namespace lldb_private { const Entry * GetEntryAtIndex (size_t i) const { - if (i<m_entries.size()) - return &m_entries[i]; - return NULL; + return ((i < m_entries.size()) ? &m_entries[i] : nullptr); } // Clients must ensure that "i" is a valid index prior to calling this function @@ -638,17 +625,13 @@ namespace lldb_private { Entry * Back() { - if (m_entries.empty()) - return NULL; - return &m_entries.back(); + return (m_entries.empty() ? nullptr : &m_entries.back()); } const Entry * Back() const { - if (m_entries.empty()) - return NULL; - return &m_entries.back(); + return (m_entries.empty() ? nullptr : &m_entries.back()); } static bool @@ -710,7 +693,7 @@ namespace lldb_private { } } } - return NULL; + return nullptr; } const Entry * @@ -738,7 +721,7 @@ namespace lldb_private { } } } - return NULL; + return nullptr; } protected: @@ -812,15 +795,10 @@ namespace lldb_private { typedef RangeData<B,S,T> Entry; typedef llvm::SmallVector<Entry, N> Collection; + RangeDataArray() = default; + + ~RangeDataArray() = default; - RangeDataArray () - { - } - - ~RangeDataArray() - { - } - void Append (const Entry &entry) { @@ -911,9 +889,7 @@ namespace lldb_private { const Entry * GetEntryAtIndex (size_t i) const { - if (i<m_entries.size()) - return &m_entries[i]; - return NULL; + return ((i < m_entries.size()) ? &m_entries[i] : nullptr); } // Clients must ensure that "i" is a valid index prior to calling this function @@ -984,8 +960,9 @@ namespace lldb_private { } } } - return NULL; + return nullptr; } + const Entry * FindEntryThatContains (B addr) const { @@ -1014,7 +991,7 @@ namespace lldb_private { } } } - return NULL; + return nullptr; } const Entry * @@ -1042,23 +1019,19 @@ namespace lldb_private { } } } - return NULL; + return nullptr; } Entry * Back() { - if (!m_entries.empty()) - return &m_entries.back(); - return NULL; + return (m_entries.empty() ? nullptr : &m_entries.back()); } const Entry * Back() const { - if (!m_entries.empty()) - return &m_entries.back(); - return NULL; + return (m_entries.empty() ? nullptr : &m_entries.back()); } protected: @@ -1073,15 +1046,11 @@ namespace lldb_private { public: typedef RangeData<B,S,T> Entry; typedef std::vector<Entry> Collection; - - RangeDataVector () - { - } - - ~RangeDataVector() - { - } - + + RangeDataVector() = default; + + ~RangeDataVector() = default; + void Append (const Entry &entry) { @@ -1181,7 +1150,6 @@ namespace lldb_private { } } } - } void @@ -1211,9 +1179,7 @@ namespace lldb_private { const Entry * GetEntryAtIndex (size_t i) const { - if (i<m_entries.size()) - return &m_entries[i]; - return NULL; + return ((i < m_entries.size()) ? &m_entries[i] : nullptr); } // Clients must ensure that "i" is a valid index prior to calling this function @@ -1272,8 +1238,9 @@ namespace lldb_private { if (pos != end && pos->Contains(addr)) return &(*pos); } - return NULL; + return nullptr; } + const Entry * FindEntryThatContains (B addr) const { @@ -1295,7 +1262,7 @@ namespace lldb_private { if (pos != end && pos->Contains(addr)) return &(*pos); } - return NULL; + return nullptr; } const Entry * @@ -1316,30 +1283,25 @@ namespace lldb_private { if (pos != end && pos->Contains(range)) return &(*pos); } - return NULL; + return nullptr; } Entry * Back() { - if (!m_entries.empty()) - return &m_entries.back(); - return NULL; + return (m_entries.empty() ? nullptr : &m_entries.back()); } const Entry * Back() const { - if (!m_entries.empty()) - return &m_entries.back(); - return NULL; + return (m_entries.empty() ? nullptr : &m_entries.back()); } protected: Collection m_entries; }; - - + //---------------------------------------------------------------------- // A simple range with data class where you get to define the type of // the range base "B", the type used for the range byte size "S", and @@ -1389,7 +1351,6 @@ namespace lldb_private { } }; - template <typename B, typename T, unsigned N> class AddressDataArray { @@ -1397,15 +1358,10 @@ namespace lldb_private { typedef AddressData<B,T> Entry; typedef llvm::SmallVector<Entry, N> Collection; + AddressDataArray() = default; + + ~AddressDataArray() = default; - AddressDataArray () - { - } - - ~AddressDataArray() - { - } - void Append (const Entry &entry) { @@ -1456,9 +1412,7 @@ namespace lldb_private { const Entry * GetEntryAtIndex (size_t i) const { - if (i<m_entries.size()) - return &m_entries[i]; - return NULL; + return ((i < m_entries.size()) ? &m_entries[i] : nullptr); } // Clients must ensure that "i" is a valid index prior to calling this function @@ -1497,7 +1451,7 @@ namespace lldb_private { return &(*pos); } } - return NULL; + return nullptr; } const Entry * @@ -1505,23 +1459,19 @@ namespace lldb_private { { if (entry >= &*m_entries.begin() && entry + 1 < &*m_entries.end()) return entry + 1; - return NULL; + return nullptr; } Entry * Back() { - if (!m_entries.empty()) - return &m_entries.back(); - return NULL; + return (m_entries.empty() ? nullptr : &m_entries.back()); } const Entry * Back() const { - if (!m_entries.empty()) - return &m_entries.back(); - return NULL; + return (m_entries.empty() ? nullptr : &m_entries.back()); } protected: @@ -1530,4 +1480,4 @@ namespace lldb_private { } // namespace lldb_private -#endif // liblldb_RangeMap_h_ +#endif // liblldb_RangeMap_h_ diff --git a/include/lldb/Core/RegisterValue.h b/include/lldb/Core/RegisterValue.h index 1b1a71a11c5a..030b849212c4 100644 --- a/include/lldb/Core/RegisterValue.h +++ b/include/lldb/Core/RegisterValue.h @@ -1,4 +1,4 @@ -//===-- RegisterValue.h ------------------------------------------*- C++ -*-===// +//===-- RegisterValue.h -----------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -15,12 +15,14 @@ // C++ Includes // Other libraries and framework includes +#include "llvm/ADT/APInt.h" + // Project includes #include "lldb/lldb-public.h" #include "lldb/lldb-private.h" #include "lldb/Host/Endian.h" +#include "lldb/Core/Scalar.h" -//#define ENABLE_128_BIT_SUPPORT 1 namespace lldb_private { class RegisterValue @@ -30,6 +32,7 @@ namespace lldb_private { { kMaxRegisterByteSize = 32u }; + enum Type { eTypeInvalid, @@ -37,9 +40,7 @@ namespace lldb_private { eTypeUInt16, eTypeUInt32, eTypeUInt64, -#if defined (ENABLE_128_BIT_SUPPORT) eTypeUInt128, -#endif eTypeFloat, eTypeDouble, eTypeLongDouble, @@ -47,7 +48,8 @@ namespace lldb_private { }; RegisterValue () : - m_type (eTypeInvalid) + m_type (eTypeInvalid), + m_scalar ((unsigned long)0) { } @@ -55,57 +57,56 @@ namespace lldb_private { RegisterValue (uint8_t inst) : m_type (eTypeUInt8) { - m_data.uint8 = inst; + m_scalar = inst; } explicit RegisterValue (uint16_t inst) : m_type (eTypeUInt16) { - m_data.uint16 = inst; + m_scalar = inst; } explicit RegisterValue (uint32_t inst) : m_type (eTypeUInt32) { - m_data.uint32 = inst; + m_scalar = inst; } explicit RegisterValue (uint64_t inst) : m_type (eTypeUInt64) { - m_data.uint64 = inst; + m_scalar = inst; } -#if defined (ENABLE_128_BIT_SUPPORT) explicit - RegisterValue (__uint128_t inst) : + RegisterValue (llvm::APInt inst) : m_type (eTypeUInt128) { - m_data.uint128 = inst; + m_scalar = llvm::APInt(inst); } -#endif + explicit RegisterValue (float value) : m_type (eTypeFloat) { - m_data.ieee_float = value; + m_scalar = value; } explicit RegisterValue (double value) : m_type (eTypeDouble) { - m_data.ieee_double = value; + m_scalar = value; } explicit RegisterValue (long double value) : m_type (eTypeLongDouble) { - m_data.ieee_long_double = value; + m_scalar = value; } explicit @@ -161,13 +162,13 @@ namespace lldb_private { GetScalarValue (Scalar &scalar) const; uint8_t - GetAsUInt8 (uint8_t fail_value = UINT8_MAX, bool *success_ptr = NULL) const + GetAsUInt8(uint8_t fail_value = UINT8_MAX, bool *success_ptr = nullptr) const { if (m_type == eTypeUInt8) { if (success_ptr) *success_ptr = true; - return m_data.uint8; + return m_scalar.UChar(fail_value); } if (success_ptr) *success_ptr = true; @@ -175,27 +176,25 @@ namespace lldb_private { } uint16_t - GetAsUInt16 (uint16_t fail_value = UINT16_MAX, bool *success_ptr = NULL) const; + GetAsUInt16(uint16_t fail_value = UINT16_MAX, bool *success_ptr = nullptr) const; uint32_t - GetAsUInt32 (uint32_t fail_value = UINT32_MAX, bool *success_ptr = NULL) const; + GetAsUInt32(uint32_t fail_value = UINT32_MAX, bool *success_ptr = nullptr) const; uint64_t - GetAsUInt64 (uint64_t fail_value = UINT64_MAX, bool *success_ptr = NULL) const; + GetAsUInt64(uint64_t fail_value = UINT64_MAX, bool *success_ptr = nullptr) const; -#if defined (ENABLE_128_BIT_SUPPORT) - __uint128_t - GetAsUInt128 (__uint128_t fail_value = ~((__uint128_t)0), bool *success_ptr = NULL) const; -#endif + llvm::APInt + GetAsUInt128(const llvm::APInt& fail_value, bool *success_ptr = nullptr) const; float - GetAsFloat (float fail_value = 0.0f, bool *success_ptr = NULL) const; + GetAsFloat(float fail_value = 0.0f, bool *success_ptr = nullptr) const; double - GetAsDouble (double fail_value = 0.0, bool *success_ptr = NULL) const; + GetAsDouble(double fail_value = 0.0, bool *success_ptr = nullptr) const; long double - GetAsLongDouble (long double fail_value = 0.0, bool *success_ptr = NULL) const; + GetAsLongDouble(long double fail_value = 0.0, bool *success_ptr = nullptr) const; void SetValueToInvalid () @@ -219,95 +218,93 @@ namespace lldb_private { operator = (uint8_t uint) { m_type = eTypeUInt8; - m_data.uint8 = uint; + m_scalar = uint; } void operator = (uint16_t uint) { m_type = eTypeUInt16; - m_data.uint16 = uint; + m_scalar = uint; } void operator = (uint32_t uint) { m_type = eTypeUInt32; - m_data.uint32 = uint; + m_scalar = uint; } void operator = (uint64_t uint) { m_type = eTypeUInt64; - m_data.uint64 = uint; + m_scalar = uint; } -#if defined (ENABLE_128_BIT_SUPPORT) void - operator = (__uint128_t uint) + operator = (llvm::APInt uint) { m_type = eTypeUInt128; - m_data.uint128 = uint; + m_scalar = llvm::APInt(uint); } -#endif + void operator = (float f) { m_type = eTypeFloat; - m_data.ieee_float = f; + m_scalar = f; } void operator = (double f) { m_type = eTypeDouble; - m_data.ieee_double = f; + m_scalar = f; } void operator = (long double f) { m_type = eTypeLongDouble; - m_data.ieee_long_double = f; + m_scalar = f; } void SetUInt8 (uint8_t uint) { m_type = eTypeUInt8; - m_data.uint8 = uint; + m_scalar = uint; } void SetUInt16 (uint16_t uint) { m_type = eTypeUInt16; - m_data.uint16 = uint; + m_scalar = uint; } void SetUInt32 (uint32_t uint, Type t = eTypeUInt32) { m_type = t; - m_data.uint32 = uint; + m_scalar = uint; } void SetUInt64 (uint64_t uint, Type t = eTypeUInt64) { m_type = t; - m_data.uint64 = uint; + m_scalar = uint; } -#if defined (ENABLE_128_BIT_SUPPORT) void - SetUInt128 (__uint128_t uint) + SetUInt128 (llvm::APInt uint) { m_type = eTypeUInt128; - m_data.uint128 = uint; + m_scalar = uint; } -#endif + bool SetUInt (uint64_t uint, uint32_t byte_size); @@ -315,21 +312,21 @@ namespace lldb_private { SetFloat (float f) { m_type = eTypeFloat; - m_data.ieee_float = f; + m_scalar = f; } void SetDouble (double f) { m_type = eTypeDouble; - m_data.ieee_double = f; + m_scalar = f; } void SetLongDouble (long double f) { m_type = eTypeLongDouble; - m_data.ieee_long_double = f; + m_scalar = f; } void @@ -367,8 +364,8 @@ namespace lldb_private { GetByteOrder () const { if (m_type == eTypeBytes) - return m_data.buffer.byte_order; - return lldb::endian::InlHostByteOrder(); + return buffer.byte_order; + return endian::InlHostByteOrder(); } uint32_t @@ -384,29 +381,17 @@ namespace lldb_private { Clear(); protected: - RegisterValue::Type m_type; - union - { - uint8_t uint8; - uint16_t uint16; - uint32_t uint32; - uint64_t uint64; -#if defined (ENABLE_128_BIT_SUPPORT) - __uint128_t uint128; -#endif - float ieee_float; - double ieee_double; - long double ieee_long_double; - struct - { - uint8_t bytes[kMaxRegisterByteSize]; // This must be big enough to hold any register for any supported target. - uint8_t length; - lldb::ByteOrder byte_order; - } buffer; - } m_data; + Scalar m_scalar; + + struct + { + uint8_t bytes[kMaxRegisterByteSize]; // This must be big enough to hold any register for any supported target. + uint8_t length; + lldb::ByteOrder byte_order; + } buffer; }; } // namespace lldb_private -#endif // lldb_RegisterValue_h +#endif // lldb_RegisterValue_h diff --git a/include/lldb/Core/RegularExpression.h b/include/lldb/Core/RegularExpression.h index a58d17b4a794..b0ece5154ce1 100644 --- a/include/lldb/Core/RegularExpression.h +++ b/include/lldb/Core/RegularExpression.h @@ -7,9 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_DBRegex_h_ -#define liblldb_DBRegex_h_ -#if defined(__cplusplus) +#ifndef liblldb_RegularExpression_h_ +#define liblldb_RegularExpression_h_ #ifdef _WIN32 #include "../lib/Support/regex_impl.h" @@ -37,7 +36,6 @@ inline void regfree(llvm_regex_t * a) { llvm_regfree(a); } - #else #if __ANDROID_NDK__ #include <regex> @@ -52,7 +50,7 @@ inline void regfree(llvm_regex_t * a) namespace llvm { class StringRef; -} +} // namespace llvm namespace lldb_private { @@ -95,9 +93,7 @@ public: regmatch_t * GetData () { - if (m_matches.empty()) - return NULL; - return m_matches.data(); + return (m_matches.empty() ? nullptr : m_matches.data()); } bool @@ -110,9 +106,9 @@ public: GetMatchSpanningIndices (const char* s, uint32_t idx1, uint32_t idx2, llvm::StringRef& match_str) const; protected: - std::vector<regmatch_t> m_matches; ///< Where parenthesized subexpressions results are stored }; + //------------------------------------------------------------------ /// Default constructor. /// @@ -172,14 +168,14 @@ public: /// @param[in] match /// A pointer to a RegularExpression::Match structure that was /// properly initialized with the desired number of maximum - /// matches, or NULL if no parenthesized matching is needed. + /// matches, or nullptr if no parenthesized matching is needed. /// /// @return /// \b true if \a string matches the compiled regular /// expression, \b false otherwise. //------------------------------------------------------------------ bool - Execute (const char* string, Match *match = NULL) const; + Execute(const char* string, Match *match = nullptr) const; size_t GetErrorAsCString (char *err_str, size_t err_str_max_len) const; @@ -246,5 +242,4 @@ private: } // namespace lldb_private -#endif // #if defined(__cplusplus) -#endif // liblldb_DBRegex_h_ +#endif // liblldb_RegularExpression_h_ diff --git a/include/lldb/Core/STLUtils.h b/include/lldb/Core/STLUtils.h index 9321e057a397..b3c2124f447d 100644 --- a/include/lldb/Core/STLUtils.h +++ b/include/lldb/Core/STLUtils.h @@ -9,14 +9,18 @@ #ifndef liblldb_STLUtils_h_ #define liblldb_STLUtils_h_ -#if defined(__cplusplus) +// C Includes #include <string.h> +// C++ Includes #include <map> #include <ostream> #include <vector> +// Other libraries and framework includes +// Project includes + //---------------------------------------------------------------------- // C string less than compare function object //---------------------------------------------------------------------- @@ -28,7 +32,6 @@ struct CStringCompareFunctionObject } }; - //---------------------------------------------------------------------- // C string equality function object (binary predicate). //---------------------------------------------------------------------- @@ -40,7 +43,6 @@ struct CStringEqualBinaryPredicate } }; - //---------------------------------------------------------------------- // Templated type for finding an entry in a std::map<F,S> whose value // is equal to something @@ -48,21 +50,26 @@ struct CStringEqualBinaryPredicate template <class F, class S> class ValueEquals { -private: - S second_value; - public: ValueEquals (const S& val) : second_value(val) {} + // Compare the second item bool operator() (std::pair<const F, S> elem) { return elem.second == second_value; } + +private: + S second_value; }; template <class T> -inline void PrintAllCollectionElements (std::ostream &s, const T& coll, const char* header_cstr=NULL, const char* separator_cstr=" ") +inline void +PrintAllCollectionElements(std::ostream &s, + const T& coll, + const char* header_cstr = nullptr, + const char* separator_cstr = " ") { typename T::const_iterator pos; @@ -88,7 +95,4 @@ struct for_each_cplusplus_delete typedef std::vector<std::string> STLStringArray; typedef std::vector<const char *> CStringArray; - - -#endif // #if defined(__cplusplus) -#endif // liblldb_STLUtils_h_ +#endif // liblldb_STLUtils_h_ diff --git a/include/lldb/Core/Scalar.h b/include/lldb/Core/Scalar.h index 821a0fb1ae21..a476cd3bd867 100644 --- a/include/lldb/Core/Scalar.h +++ b/include/lldb/Core/Scalar.h @@ -11,6 +11,11 @@ #define liblldb_Scalar_h_ #include "lldb/lldb-private.h" +#include "llvm/ADT/APInt.h" +#include "llvm/ADT/APFloat.h" + +#define NUM_OF_WORDS_INT128 2 +#define BITWIDTH_INT128 128 namespace lldb_private { @@ -34,22 +39,60 @@ public: e_ulonglong, e_float, e_double, - e_long_double + e_long_double, + e_uint128, + e_sint128 }; //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ Scalar(); - Scalar(int v) : m_type(e_sint), m_data() { m_data.sint = v; } - Scalar(unsigned int v) : m_type(e_uint), m_data() { m_data.uint = v; } - Scalar(long v) : m_type(e_slong), m_data() { m_data.slong = v; } - Scalar(unsigned long v) : m_type(e_ulong), m_data() { m_data.ulong = v; } - Scalar(long long v) : m_type(e_slonglong), m_data() { m_data.slonglong = v; } - Scalar(unsigned long long v): m_type(e_ulonglong), m_data() { m_data.ulonglong = v; } - Scalar(float v) : m_type(e_float), m_data() { m_data.flt = v; } - Scalar(double v) : m_type(e_double), m_data() { m_data.dbl = v; } - Scalar(long double v) : m_type(e_long_double), m_data() { m_data.ldbl = v; } + Scalar(int v) : m_type(e_sint), m_float((float)0) { m_integer = llvm::APInt(sizeof(int) * 8, v, true);} + Scalar(unsigned int v) : m_type(e_uint), m_float((float)0) { m_integer = llvm::APInt(sizeof(int) * 8, v);} + Scalar(long v) : m_type(e_slong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long) * 8, v, true);} + Scalar(unsigned long v) : m_type(e_ulong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long) * 8, v);} + Scalar(long long v) : m_type(e_slonglong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long long) * 8, v, true);} + Scalar(unsigned long long v): m_type(e_ulonglong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long long) * 8, v);} + Scalar(float v) : m_type(e_float), m_float(v) { m_float = llvm::APFloat(v); } + Scalar(double v) : m_type(e_double), m_float(v) { m_float = llvm::APFloat(v); } + Scalar(long double v, bool ieee_quad) + : m_type(e_long_double), m_float((float)0), m_ieee_quad(ieee_quad) + { + if(ieee_quad) + m_float = llvm::APFloat(llvm::APFloat::IEEEquad, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x)); + else + m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x)); + } + Scalar(llvm::APInt v) : + m_type(), + m_float((float)0) + { + m_integer = llvm::APInt(v); + switch(m_integer.getBitWidth()) + { + case 8: + case 16: + case 32: + if(m_integer.isSignedIntN(sizeof(sint_t) * 8)) + m_type = e_sint; + else + m_type = e_uint; + break; + case 64: + if(m_integer.isSignedIntN(sizeof(slonglong_t) * 8)) + m_type = e_slonglong; + else + m_type = e_ulonglong; + break; + case 128: + if(m_integer.isSignedIntN(BITWIDTH_INT128)) + m_type = e_sint128; + else + m_type = e_uint128; + break; + } + } Scalar(const Scalar& rhs); //Scalar(const RegisterValue& reg_value); virtual ~Scalar(); @@ -61,15 +104,18 @@ public: ExtractBitfield (uint32_t bit_size, uint32_t bit_offset); + bool + SetBit(uint32_t bit); + + bool + ClearBit(uint32_t bit); + + void * + GetBytes() const; + size_t GetByteSize() const; - static size_t - GetMaxByteSize() - { - return sizeof(ValueData); - } - bool GetData (DataExtractor &data, size_t limit_byte_size = UINT32_MAX) const; @@ -83,7 +129,7 @@ public: IsZero() const; void - Clear() { m_type = e_void; m_data.ulonglong = 0; } + Clear() { m_type = e_void; m_integer.clearAllBits(); } const char * GetTypeAsCString() const; @@ -133,6 +179,7 @@ public: Scalar& operator= (float v); Scalar& operator= (double v); Scalar& operator= (long double v); + Scalar& operator= (llvm::APInt v); Scalar& operator= (const Scalar& rhs); // Assignment operator Scalar& operator+= (const Scalar& rhs); Scalar& operator<<= (const Scalar& rhs); // Shift left @@ -174,6 +221,9 @@ public: Scalar::Type GetType() const { return m_type; } + void + SetType(const RegisterInfo*); + //---------------------------------------------------------------------- // Returns a casted value of the current contained data without // modifying the current value. FAIL_VALUE will be returned if the type @@ -194,6 +244,18 @@ public: unsigned long long RawULongLong () const; + unsigned char + UChar(unsigned char fail_value = 0) const; + + char + SChar(char fail_value = 0) const; + + unsigned short + UShort(unsigned short fail_value = 0) const; + + short + SShort(short fail_value = 0) const; + unsigned int UInt(unsigned int fail_value = 0) const; @@ -209,6 +271,12 @@ public: unsigned long long ULongLong(unsigned long long fail_value = 0) const; + llvm::APInt + SInt128(llvm::APInt& fail_value) const; + + llvm::APInt + UInt128(const llvm::APInt& fail_value) const; + float Float(float fail_value = 0.0f) const; @@ -255,6 +323,10 @@ public: } protected: + typedef char schar_t; + typedef unsigned char uchar_t; + typedef short sshort_t; + typedef unsigned short ushort_t; typedef int sint_t; typedef unsigned int uint_t; typedef long slong_t; @@ -265,24 +337,13 @@ protected: typedef double double_t; typedef long double long_double_t; - union ValueData - { - int sint; - unsigned int uint; - long slong; - unsigned long ulong; - long long slonglong; - unsigned long long ulonglong; - float flt; - double dbl; - long double ldbl; - }; - //------------------------------------------------------------------ // Classes that inherit from Scalar can see and modify these //------------------------------------------------------------------ Scalar::Type m_type; - ValueData m_data; + llvm::APInt m_integer; + llvm::APFloat m_float; + bool m_ieee_quad = false; private: friend const Scalar operator+ (const Scalar& lhs, const Scalar& rhs); diff --git a/include/lldb/Core/SearchFilter.h b/include/lldb/Core/SearchFilter.h index bbb7509cedb2..3d5e1fb39b43 100644 --- a/include/lldb/Core/SearchFilter.h +++ b/include/lldb/Core/SearchFilter.h @@ -272,7 +272,7 @@ class SearchFilterForUnconstrainedSearches : { public: SearchFilterForUnconstrainedSearches (const lldb::TargetSP &target_sp) : SearchFilter(target_sp) {} - ~SearchFilterForUnconstrainedSearches () {} + ~SearchFilterForUnconstrainedSearches() override = default; bool ModulePasses (const FileSpec &module_spec) override; @@ -283,7 +283,6 @@ public: protected: lldb::SearchFilterSP DoCopyForBreakpoint (Breakpoint &breakpoint) override; - }; //---------------------------------------------------------------------- @@ -311,8 +310,7 @@ public: SearchFilterByModule (const SearchFilterByModule& rhs); - virtual - ~SearchFilterByModule (); + ~SearchFilterByModule() override; const SearchFilterByModule& operator=(const SearchFilterByModule& rhs); @@ -372,8 +370,7 @@ public: SearchFilterByModuleList (const SearchFilterByModuleList& rhs); - virtual - ~SearchFilterByModuleList (); + ~SearchFilterByModuleList() override; const SearchFilterByModuleList& operator=(const SearchFilterByModuleList& rhs); @@ -409,7 +406,7 @@ protected: lldb::SearchFilterSP DoCopyForBreakpoint (Breakpoint &breakpoint) override; -private: +protected: FileSpecList m_module_spec_list; }; @@ -434,8 +431,7 @@ public: SearchFilterByModuleListAndCU (const SearchFilterByModuleListAndCU& rhs); - virtual - ~SearchFilterByModuleListAndCU (); + ~SearchFilterByModuleListAndCU() override; const SearchFilterByModuleListAndCU& operator=(const SearchFilterByModuleListAndCU& rhs); @@ -466,10 +462,9 @@ protected: DoCopyForBreakpoint (Breakpoint &breakpoint) override; private: - FileSpecList m_module_spec_list; FileSpecList m_cu_spec_list; }; } // namespace lldb_private -#endif // liblldb_SearchFilter_h_ +#endif // liblldb_SearchFilter_h_ diff --git a/include/lldb/Core/Section.h b/include/lldb/Core/Section.h index 65d408e29867..8c92f1ba667e 100644 --- a/include/lldb/Core/Section.h +++ b/include/lldb/Core/Section.h @@ -64,9 +64,6 @@ public: lldb::SectionSP FindSectionContainingFileAddress (lldb::addr_t addr, uint32_t depth = UINT32_MAX) const; - bool - GetSectionData (const DataExtractor& module_data, DataExtractor& section_data) const; - // Get the number of sections in this list only size_t GetSize () const @@ -288,6 +285,46 @@ public: return m_obj_file; } + //------------------------------------------------------------------ + /// Read the section data from the object file that the section + /// resides in. + /// + /// @param[in] dst + /// Where to place the data + /// + /// @param[in] dst_len + /// How many bytes of section data to read + /// + /// @param[in] offset + /// The offset in bytes within this section's data at which to + /// start copying data from. + /// + /// @return + /// The number of bytes read from the section, or zero if the + /// section has no data or \a offset is not a valid offset + /// in this section. + //------------------------------------------------------------------ + lldb::offset_t + GetSectionData (void *dst, lldb::offset_t dst_len, lldb::offset_t offset = 0); + + //------------------------------------------------------------------ + /// Get the shared reference to the section data from the object + /// file that the section resides in. No copies of the data will be + /// make unless the object file has been read from memory. If the + /// object file is on disk, it will shared the mmap data for the + /// entire object file. + /// + /// @param[in] data + /// Where to place the data, address byte size, and byte order + /// + /// @return + /// The number of bytes read from the section, or zero if the + /// section has no data or \a offset is not a valid offset + /// in this section. + //------------------------------------------------------------------ + lldb::offset_t + GetSectionData (DataExtractor& data) const; + uint32_t GetLog2Align() { return m_log2align; diff --git a/include/lldb/Core/SourceManager.h b/include/lldb/Core/SourceManager.h index 0f65be1bee4b..5504bafd6b7e 100644 --- a/include/lldb/Core/SourceManager.h +++ b/include/lldb/Core/SourceManager.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include <map> +#include <memory> #include <vector> // Other libraries and framework includes @@ -26,15 +27,17 @@ class SourceManager { public: #ifndef SWIG - class File { - friend bool operator== (const SourceManager::File &lhs, const SourceManager::File &rhs); + friend bool operator== (const SourceManager::File &lhs, const SourceManager::File &rhs); + public: - File (const FileSpec &file_spec, Target *target); ~File(); + void + UpdateIfNeeded (); + size_t DisplaySourceLines (uint32_t line, uint32_t context_before, @@ -80,7 +83,6 @@ public: GetNumLines (); protected: - bool CalculateLineOffsets (uint32_t line = UINT32_MAX); @@ -92,20 +94,18 @@ public: typedef std::vector<uint32_t> LineOffsets; LineOffsets m_offsets; }; - #endif // SWIG typedef std::shared_ptr<File> FileSP; #ifndef SWIG - // The SourceFileCache class separates the source manager from the cache of source files, so the // cache can be stored in the Debugger, but the source managers can be per target. class SourceFileCache { public: - SourceFileCache () {} - ~SourceFileCache() {} + SourceFileCache() = default; + ~SourceFileCache() = default; void AddSourceFile (const FileSP &file_sp); FileSP FindSourceFile (const FileSpec &file_spec) const; @@ -114,8 +114,7 @@ public: typedef std::map <FileSpec, FileSP> FileCache; FileCache m_file_cache; }; -#endif - +#endif // SWIG //------------------------------------------------------------------ // Constructors and Destructors @@ -127,7 +126,6 @@ public: ~SourceManager(); - FileSP GetLastFile () { @@ -135,28 +133,28 @@ public: } size_t - DisplaySourceLinesWithLineNumbers (const FileSpec &file, - uint32_t line, - uint32_t context_before, - uint32_t context_after, - const char* current_line_cstr, - Stream *s, - const SymbolContextList *bp_locs = NULL); + DisplaySourceLinesWithLineNumbers(const FileSpec &file, + uint32_t line, + uint32_t context_before, + uint32_t context_after, + const char* current_line_cstr, + Stream *s, + const SymbolContextList *bp_locs = nullptr); // This variant uses the last file we visited. size_t - DisplaySourceLinesWithLineNumbersUsingLastFile (uint32_t start_line, - uint32_t count, - uint32_t curr_line, - const char* current_line_cstr, - Stream *s, - const SymbolContextList *bp_locs = NULL); + DisplaySourceLinesWithLineNumbersUsingLastFile(uint32_t start_line, + uint32_t count, + uint32_t curr_line, + const char* current_line_cstr, + Stream *s, + const SymbolContextList *bp_locs = nullptr); size_t - DisplayMoreWithLineNumbers (Stream *s, - uint32_t count, - bool reverse, - const SymbolContextList *bp_locs = NULL); + DisplayMoreWithLineNumbers(Stream *s, + uint32_t count, + bool reverse, + const SymbolContextList *bp_locs = nullptr); bool SetDefaultFileAndLine (const FileSpec &file_spec, uint32_t line); @@ -167,7 +165,7 @@ public: bool DefaultFileAndLineSet () { - return (m_last_file_sp.get() != NULL); + return (m_last_file_sp.get() != nullptr); } void @@ -181,10 +179,6 @@ public: GetFile (const FileSpec &file_spec); protected: - - //------------------------------------------------------------------ - // Classes that inherit from SourceManager can see and modify these - //------------------------------------------------------------------ FileSP m_last_file_sp; uint32_t m_last_line; uint32_t m_last_count; @@ -193,13 +187,11 @@ protected: lldb::DebuggerWP m_debugger_wp; private: - //------------------------------------------------------------------ - // For SourceManager only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN (SourceManager); }; bool operator== (const SourceManager::File &lhs, const SourceManager::File &rhs); + } // namespace lldb_private -#endif // liblldb_SourceManager_h_ +#endif // liblldb_SourceManager_h_ diff --git a/include/lldb/Core/Stream.h b/include/lldb/Core/Stream.h index 11780aa6ff0f..f784069894ec 100644 --- a/include/lldb/Core/Stream.h +++ b/include/lldb/Core/Stream.h @@ -9,11 +9,15 @@ #ifndef liblldb_Stream_h_ #define liblldb_Stream_h_ -#if defined(__cplusplus) +// C Includes +#include <stdarg.h> + +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/lldb-private.h" #include "lldb/Core/Flags.h" -#include <stdarg.h> namespace lldb_private { @@ -221,7 +225,7 @@ public: /// in one statement. //------------------------------------------------------------------ Stream& - operator<< (void *p); + operator<< (const void *p); //------------------------------------------------------------------ /// Output a character \a ch to the stream \a s. @@ -353,13 +357,13 @@ public: /// Size in bytes of the address, used for formatting. /// /// @param[in] prefix - /// A prefix C string. If NULL, no prefix will be output. + /// A prefix C string. If nullptr, no prefix will be output. /// /// @param[in] suffix - /// A suffix C string. If NULL, no suffix will be output. + /// A suffix C string. If nullptr, no suffix will be output. //------------------------------------------------------------------ void - Address (uint64_t addr, uint32_t addr_size, const char *prefix = NULL, const char *suffix = NULL); + Address(uint64_t addr, uint32_t addr_size, const char *prefix = nullptr, const char *suffix = nullptr); //------------------------------------------------------------------ /// Output an address range to this stream. @@ -377,13 +381,13 @@ public: /// Size in bytes of the address, used for formatting. /// /// @param[in] prefix - /// A prefix C string. If NULL, no prefix will be output. + /// A prefix C string. If nullptr, no prefix will be output. /// /// @param[in] suffix - /// A suffix C string. If NULL, no suffix will be output. + /// A suffix C string. If nullptr, no suffix will be output. //------------------------------------------------------------------ void - AddressRange(uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size, const char *prefix = NULL, const char *suffix = NULL); + AddressRange(uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size, const char *prefix = nullptr, const char *suffix = nullptr); //------------------------------------------------------------------ /// Output a C string to the stream. @@ -475,11 +479,11 @@ public: /// print an optional string following the indentation spaces. /// /// @param[in] s - /// A C string to print following the indentation. If NULL, just + /// A C string to print following the indentation. If nullptr, just /// output the indentation characters. //------------------------------------------------------------------ size_t - Indent(const char *s = NULL); + Indent(const char *s = nullptr); //------------------------------------------------------------------ /// Decrement the current indentation level. @@ -607,6 +611,4 @@ protected: } // namespace lldb_private -#endif // #if defined(__cplusplus) #endif // liblldb_Stream_h_ - diff --git a/include/lldb/Core/StreamAsynchronousIO.h b/include/lldb/Core/StreamAsynchronousIO.h index d3b054463fa7..b069cfd496e1 100644 --- a/include/lldb/Core/StreamAsynchronousIO.h +++ b/include/lldb/Core/StreamAsynchronousIO.h @@ -22,14 +22,13 @@ class StreamAsynchronousIO : public: StreamAsynchronousIO (Debugger &debugger, bool for_stdout); - virtual ~StreamAsynchronousIO (); + ~StreamAsynchronousIO () override; - virtual void - Flush (); - - virtual size_t - Write (const void *src, size_t src_len); + void + Flush () override; + size_t + Write (const void *src, size_t src_len) override; private: Debugger &m_debugger; @@ -38,4 +37,5 @@ private: }; } // namespace lldb_private -#endif // #ifndef liblldb_StreamAsynchronousIO_h + +#endif // liblldb_StreamAsynchronousIO_h diff --git a/include/lldb/Core/StreamCallback.h b/include/lldb/Core/StreamCallback.h index b5fb91c6ce07..e5a9da7512bb 100644 --- a/include/lldb/Core/StreamCallback.h +++ b/include/lldb/Core/StreamCallback.h @@ -24,14 +24,13 @@ class StreamCallback : public: StreamCallback (lldb::LogOutputCallback callback, void *baton); - virtual ~StreamCallback (); + ~StreamCallback () override; - virtual void - Flush (); - - virtual size_t - Write (const void *src, size_t src_len); + void + Flush () override; + size_t + Write (const void *src, size_t src_len) override; private: typedef std::map<lldb::tid_t, StreamString> collection; @@ -44,4 +43,5 @@ private: }; } // namespace lldb_private -#endif // #ifndef liblldb_StreamCallback_h + +#endif // liblldb_StreamCallback_h diff --git a/include/lldb/Core/StreamFile.h b/include/lldb/Core/StreamFile.h index 55bb361780a5..781f0a599493 100644 --- a/include/lldb/Core/StreamFile.h +++ b/include/lldb/Core/StreamFile.h @@ -43,8 +43,7 @@ public: StreamFile (FILE *fh, bool transfer_ownership); - virtual - ~StreamFile(); + ~StreamFile() override; File & GetFile () @@ -58,11 +57,11 @@ public: return m_file; } - virtual void - Flush (); + void + Flush () override; - virtual size_t - Write (const void *s, size_t length); + size_t + Write (const void *s, size_t length) override; protected: //------------------------------------------------------------------ @@ -76,4 +75,4 @@ private: } // namespace lldb_private -#endif // liblldb_StreamFile_h_ +#endif // liblldb_StreamFile_h_ diff --git a/include/lldb/Core/StreamGDBRemote.h b/include/lldb/Core/StreamGDBRemote.h index 3fdb6f6e7012..834f412d0a03 100644 --- a/include/lldb/Core/StreamGDBRemote.h +++ b/include/lldb/Core/StreamGDBRemote.h @@ -29,8 +29,7 @@ namespace lldb_private { uint32_t addr_size, lldb::ByteOrder byte_order); - virtual - ~StreamGDBRemote (); + ~StreamGDBRemote() override; //------------------------------------------------------------------ /// Output a block of data to the stream performing GDB-remote escaping. @@ -51,4 +50,4 @@ namespace lldb_private { } // namespace lldb_private -#endif // liblldb_StreamGDBRemote_h_ +#endif // liblldb_StreamGDBRemote_h_ diff --git a/include/lldb/Core/StreamString.h b/include/lldb/Core/StreamString.h index 1aa46dd80a68..5b6bde7a13c2 100644 --- a/include/lldb/Core/StreamString.h +++ b/include/lldb/Core/StreamString.h @@ -25,14 +25,13 @@ public: uint32_t addr_size, lldb::ByteOrder byte_order); - virtual - ~StreamString (); + ~StreamString () override; - virtual void - Flush (); + void + Flush () override; - virtual size_t - Write (const void *s, size_t length); + size_t + Write (const void *s, size_t length) override; void Clear(); @@ -60,8 +59,8 @@ public: protected: std::string m_packet; - }; } // namespace lldb_private -#endif // #ifndef liblldb_StreamString_h_ + +#endif // liblldb_StreamString_h_ diff --git a/include/lldb/Core/StreamTee.h b/include/lldb/Core/StreamTee.h index e2a29a374553..7ab619b3bb79 100644 --- a/include/lldb/Core/StreamTee.h +++ b/include/lldb/Core/StreamTee.h @@ -59,8 +59,7 @@ public: m_streams = rhs.m_streams; } - virtual - ~StreamTee () + ~StreamTee () override { } @@ -76,8 +75,8 @@ public: return *this; } - virtual void - Flush () + void + Flush () override { Mutex::Locker locker (m_streams_mutex); collection::iterator pos, end; @@ -93,8 +92,8 @@ public: } } - virtual size_t - Write (const void *s, size_t length) + size_t + Write (const void *s, size_t length) override { Mutex::Locker locker (m_streams_mutex); if (m_streams.empty()) @@ -164,7 +163,6 @@ public: m_streams[idx] = stream_sp; } - protected: typedef std::vector<lldb::StreamSP> collection; mutable Mutex m_streams_mutex; @@ -172,4 +170,5 @@ protected: }; } // namespace lldb_private -#endif // #ifndef liblldb_StreamTee_h_ + +#endif // liblldb_StreamTee_h_ diff --git a/include/lldb/Core/StringList.h b/include/lldb/Core/StringList.h index c69ed872c30d..3e341b994075 100644 --- a/include/lldb/Core/StringList.h +++ b/include/lldb/Core/StringList.h @@ -10,18 +10,24 @@ #ifndef liblldb_StringList_h_ #define liblldb_StringList_h_ +// C Includes #include <stdint.h> -#include "lldb/Core/STLUtils.h" -#include "lldb/lldb-forward.h" +// C++ Includes +#include <string> + +// Other libraries and framework includes #include "llvm/ADT/StringRef.h" +// Project includes +#include "lldb/lldb-forward.h" +#include "lldb/Core/STLUtils.h" + namespace lldb_private { class StringList { public: - StringList (); StringList (const char *str); @@ -120,7 +126,7 @@ public: SplitIntoLines (const char *lines, size_t len); std::string - CopyList(const char* item_preamble = NULL, + CopyList(const char* item_preamble = nullptr, const char* items_sep = "\n") const; StringList& @@ -142,7 +148,6 @@ public: size_t &exact_matches_idx) const; private: - STLStringArray m_strings; }; diff --git a/include/lldb/Core/StructuredData.h b/include/lldb/Core/StructuredData.h index 7da29e48299d..52f34521ef0e 100644 --- a/include/lldb/Core/StructuredData.h +++ b/include/lldb/Core/StructuredData.h @@ -12,16 +12,16 @@ // C Includes // C++ Includes - #include <functional> #include <map> +#include <memory> #include <string> #include <utility> #include <vector> +// Other libraries and framework includes #include "llvm/ADT/StringRef.h" -// Other libraries and framework includes // Project includes #include "lldb/lldb-defines.h" #include "lldb/Core/ConstString.h" @@ -47,7 +47,6 @@ namespace lldb_private { class StructuredData { public: - class Object; class Array; class Integer; @@ -89,9 +88,7 @@ public: { } - virtual ~Object () - { - } + virtual ~Object() = default; virtual bool IsValid() const @@ -120,80 +117,62 @@ public: Array * GetAsArray () { - if (m_type == Type::eTypeArray) - return (Array *)this; - return NULL; + return ((m_type == Type::eTypeArray) ? static_cast<Array *>(this) : nullptr); } Dictionary * GetAsDictionary () { - if (m_type == Type::eTypeDictionary) - return (Dictionary *)this; - return NULL; + return ((m_type == Type::eTypeDictionary) ? static_cast<Dictionary *>(this) : nullptr); } Integer * GetAsInteger () { - if (m_type == Type::eTypeInteger) - return (Integer *)this; - return NULL; + return ((m_type == Type::eTypeInteger) ? static_cast<Integer *>(this) : nullptr); } uint64_t GetIntegerValue (uint64_t fail_value = 0) { Integer *integer = GetAsInteger (); - if (integer) - return integer->GetValue(); - return fail_value; + return ((integer != nullptr) ? integer->GetValue() : fail_value); } Float * GetAsFloat () { - if (m_type == Type::eTypeFloat) - return (Float *)this; - return NULL; + return ((m_type == Type::eTypeFloat) ? static_cast<Float *>(this) : nullptr); } double GetFloatValue (double fail_value = 0.0) { Float *f = GetAsFloat (); - if (f) - return f->GetValue(); - return fail_value; + return ((f != nullptr) ? f->GetValue() : fail_value); } Boolean * GetAsBoolean () { - if (m_type == Type::eTypeBoolean) - return (Boolean *)this; - return NULL; + return ((m_type == Type::eTypeBoolean) ? static_cast<Boolean *>(this) : nullptr); } bool GetBooleanValue (bool fail_value = false) { Boolean *b = GetAsBoolean (); - if (b) - return b->GetValue(); - return fail_value; + return ((b != nullptr) ? b->GetValue() : fail_value); } String * GetAsString () { - if (m_type == Type::eTypeString) - return (String *)this; - return NULL; + return ((m_type == Type::eTypeString) ? static_cast<String *>(this) : nullptr); } std::string - GetStringValue(const char *fail_value = NULL) + GetStringValue(const char *fail_value = nullptr) { String *s = GetAsString (); if (s) @@ -208,9 +187,7 @@ public: Generic * GetAsGeneric() { - if (m_type == Type::eTypeGeneric) - return (Generic *)this; - return NULL; + return ((m_type == Type::eTypeGeneric) ? static_cast<Generic *>(this) : nullptr); } ObjectSP @@ -233,10 +210,7 @@ public: { } - virtual - ~Array() - { - } + ~Array() override = default; bool ForEach (std::function <bool(Object* object)> const &foreach_callback) const @@ -249,7 +223,6 @@ public: return true; } - size_t GetSize() const { @@ -277,11 +250,14 @@ public: bool GetItemAtIndexAsInteger(size_t idx, IntType &result) const { - ObjectSP value = GetItemAtIndex(idx); - if (auto int_value = value->GetAsInteger()) + ObjectSP value_sp = GetItemAtIndex(idx); + if (value_sp.get()) { - result = static_cast<IntType>(int_value->GetValue()); - return true; + if (auto int_value = value_sp->GetAsInteger()) + { + result = static_cast<IntType>(int_value->GetValue()); + return true; + } } return false; } @@ -299,11 +275,14 @@ public: bool GetItemAtIndexAsString(size_t idx, std::string &result) const { - ObjectSP value = GetItemAtIndex(idx); - if (auto string_value = value->GetAsString()) + ObjectSP value_sp = GetItemAtIndex(idx); + if (value_sp.get()) { - result = string_value->GetValue(); - return true; + if (auto string_value = value_sp->GetAsString()) + { + result = string_value->GetValue(); + return true; + } } return false; } @@ -320,13 +299,13 @@ public: bool GetItemAtIndexAsString(size_t idx, ConstString &result) const { - ObjectSP value = GetItemAtIndex(idx); - if (!value) - return false; - if (auto string_value = value->GetAsString()) - { - result = ConstString(string_value->GetValue()); - return true; + ObjectSP value_sp = GetItemAtIndex(idx); + if (value_sp.get()) { + if (auto string_value = value_sp->GetAsString()) + { + result = ConstString(string_value->GetValue()); + return true; + } } return false; } @@ -343,17 +322,27 @@ public: bool GetItemAtIndexAsDictionary(size_t idx, Dictionary *&result) const { - ObjectSP value = GetItemAtIndex(idx); - result = value->GetAsDictionary(); - return (result != nullptr); + result = nullptr; + ObjectSP value_sp = GetItemAtIndex(idx); + if (value_sp.get()) + { + result = value_sp->GetAsDictionary(); + return (result != nullptr); + } + return false; } bool GetItemAtIndexAsArray(size_t idx, Array *&result) const { - ObjectSP value = GetItemAtIndex(idx); - result = value->GetAsArray(); - return (result != nullptr); + result = nullptr; + ObjectSP value_sp = GetItemAtIndex(idx); + if (value_sp.get()) + { + result = value_sp->GetAsArray(); + return (result != nullptr); + } + return false; } void @@ -375,8 +364,7 @@ public: collection m_items; }; - - class Integer : public Object + class Integer : public Object { public: Integer (uint64_t i = 0) : @@ -385,9 +373,7 @@ public: { } - virtual ~Integer() - { - } + ~Integer() override = default; void SetValue (uint64_t value) @@ -407,7 +393,7 @@ public: uint64_t m_value; }; - class Float : public Object + class Float : public Object { public: Float (double d = 0.0) : @@ -416,9 +402,7 @@ public: { } - virtual ~Float() - { - } + ~Float() override = default; void SetValue (double value) @@ -438,7 +422,7 @@ public: double m_value; }; - class Boolean : public Object + class Boolean : public Object { public: Boolean (bool b = false) : @@ -447,9 +431,7 @@ public: { } - virtual ~Boolean() - { - } + ~Boolean() override = default; void SetValue (bool value) @@ -469,12 +451,10 @@ public: bool m_value; }; - - - class String : public Object + class String : public Object { public: - String (const char *cstr = NULL) : + String(const char *cstr = nullptr) : Object (Type::eTypeString), m_value () { @@ -522,9 +502,7 @@ public: { } - virtual ~Dictionary() - { - } + ~Dictionary() override = default; size_t GetSize() const @@ -580,13 +558,13 @@ public: bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const { - ObjectSP value = GetValueForKey(key); - if (!value) - return false; - if (auto int_value = value->GetAsInteger()) - { - result = static_cast<IntType>(int_value->GetValue()); - return true; + ObjectSP value_sp = GetValueForKey(key); + if (value_sp) { + if (auto int_value = value_sp->GetAsInteger()) + { + result = static_cast<IntType>(int_value->GetValue()); + return true; + } } return false; } @@ -604,13 +582,14 @@ public: bool GetValueForKeyAsString(llvm::StringRef key, std::string &result) const { - ObjectSP value = GetValueForKey(key); - if (!value) - return false; - if (auto string_value = value->GetAsString()) + ObjectSP value_sp = GetValueForKey(key); + if (value_sp.get()) { - result = string_value->GetValue(); - return true; + if (auto string_value = value_sp->GetAsString()) + { + result = string_value->GetValue(); + return true; + } } return false; } @@ -632,13 +611,14 @@ public: bool GetValueForKeyAsString(llvm::StringRef key, ConstString &result) const { - ObjectSP value = GetValueForKey(key); - if (!value) - return false; - if (auto string_value = value->GetAsString()) + ObjectSP value_sp = GetValueForKey(key); + if (value_sp.get()) { - result = ConstString(string_value->GetValue()); - return true; + if (auto string_value = value_sp->GetAsString()) + { + result = ConstString(string_value->GetValue()); + return true; + } } return false; } @@ -656,22 +636,26 @@ public: GetValueForKeyAsDictionary(llvm::StringRef key, Dictionary *&result) const { result = nullptr; - ObjectSP value = GetValueForKey(key); - if (!value) - return false; - result = value->GetAsDictionary(); - return true; + ObjectSP value_sp = GetValueForKey(key); + if (value_sp.get()) + { + result = value_sp->GetAsDictionary(); + return (result != nullptr); + } + return false; } bool GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const { result = nullptr; - ObjectSP value = GetValueForKey(key); - if (!value) - return false; - result = value->GetAsArray(); - return true; + ObjectSP value_sp = GetValueForKey(key); + if (value_sp.get()) + { + result = value_sp->GetAsArray(); + return (result != nullptr); + } + return false; } bool @@ -683,10 +667,10 @@ public: } void - AddItem (llvm::StringRef key, ObjectSP value) + AddItem (llvm::StringRef key, ObjectSP value_sp) { ConstString key_cs(key); - m_dict[key_cs] = value; + m_dict[key_cs] = value_sp; } void @@ -728,9 +712,7 @@ public: { } - virtual ~Null() - { - } + ~Null() override = default; bool IsValid() const override @@ -739,13 +721,11 @@ public: } void Dump(Stream &s) const override; - - protected: }; class Generic : public Object { - public: + public: explicit Generic(void *object = nullptr) : Object (Type::eTypeGeneric), m_object (object) @@ -772,16 +752,14 @@ public: void Dump(Stream &s) const override; - private: + private: void *m_object; }; static ObjectSP ParseJSON (std::string json_text); - -}; // class StructuredData - +}; } // namespace lldb_private -#endif // liblldb_StructuredData_h_ +#endif // liblldb_StructuredData_h_ diff --git a/include/lldb/Core/ThreadSafeDenseMap.h b/include/lldb/Core/ThreadSafeDenseMap.h index f5a7ccfb2ffa..6b2b59b7617c 100644 --- a/include/lldb/Core/ThreadSafeDenseMap.h +++ b/include/lldb/Core/ThreadSafeDenseMap.h @@ -54,7 +54,27 @@ public: Mutex::Locker locker(m_mutex); return m_map.lookup(k); } - + + bool + Lookup (_KeyType k, + _ValueType& v) + { + Mutex::Locker locker(m_mutex); + auto iter = m_map.find(k), + end = m_map.end(); + if (iter == end) + return false; + v = iter->second; + return true; + } + + void + Clear () + { + Mutex::Locker locker(m_mutex); + m_map.clear(); + } + protected: LLVMMapType m_map; Mutex m_mutex; diff --git a/include/lldb/Core/ThreadSafeDenseSet.h b/include/lldb/Core/ThreadSafeDenseSet.h index 19c67b65e8c1..e019c70ed5e5 100644 --- a/include/lldb/Core/ThreadSafeDenseSet.h +++ b/include/lldb/Core/ThreadSafeDenseSet.h @@ -55,6 +55,13 @@ namespace lldb_private { return (m_set.count(e) > 0); } + void + Clear () + { + Mutex::Locker locker(m_mutex); + m_set.clear(); + } + protected: LLVMSetType m_set; Mutex m_mutex; diff --git a/include/lldb/Core/Timer.h b/include/lldb/Core/Timer.h index e354d91be442..ffaeba6fce9b 100644 --- a/include/lldb/Core/Timer.h +++ b/include/lldb/Core/Timer.h @@ -9,11 +9,17 @@ #ifndef liblldb_Timer_h_ #define liblldb_Timer_h_ -#if defined(__cplusplus) +// C Includes #include <stdarg.h> #include <stdio.h> -#include <string> + +// C++ Includes +#include <atomic> +#include <mutex> + +// Other libraries and framework includes +// Project includes #include "lldb/lldb-private.h" #include "lldb/Host/TimeValue.h" @@ -34,19 +40,19 @@ namespace lldb_private { class Timer { public: - static void - Initialize (); - //-------------------------------------------------------------- /// Default constructor. //-------------------------------------------------------------- Timer(const char *category, const char *format, ...) __attribute__ ((format (printf, 3, 4))); //-------------------------------------------------------------- - /// Desstructor + /// Destructor //-------------------------------------------------------------- ~Timer(); + static void + Initialize (); + void Dump (); @@ -63,7 +69,6 @@ public: ResetCategoryTimes (); protected: - void ChildStarted (const TimeValue& time); @@ -76,17 +81,17 @@ protected: uint64_t GetTimerElapsedNanoSeconds(); - //-------------------------------------------------------------- - /// Member variables - //-------------------------------------------------------------- const char *m_category; TimeValue m_total_start; TimeValue m_timer_start; uint64_t m_total_ticks; // Total running time for this timer including when other timers below this are running uint64_t m_timer_ticks; // Ticks for this timer that do not include when other timers below this one are running - static uint32_t g_depth; - static uint32_t g_display_depth; - static FILE * g_file; + + static std::atomic<bool> g_quiet; + static std::atomic<unsigned> g_display_depth; + static std::mutex g_file_mutex; + static FILE* g_file; + private: Timer(); DISALLOW_COPY_AND_ASSIGN (Timer); @@ -99,10 +104,8 @@ public: m_start (TimeValue::Now()) { } - - ~IntervalTimer() - { - } + + ~IntervalTimer() = default; uint64_t GetElapsedNanoSeconds() const @@ -121,7 +124,7 @@ public: { TimeValue now (TimeValue::Now()); const uint64_t elapsed_nsec = now - m_start; - const char *unit = NULL; + const char *unit = nullptr; float elapsed_value; if (elapsed_nsec < 1000) { @@ -150,11 +153,11 @@ public: va_end (args); return result; } + protected: TimeValue m_start; }; } // namespace lldb_private -#endif // #if defined(__cplusplus) -#endif // #ifndef liblldb_Timer_h_ +#endif // liblldb_Timer_h_ diff --git a/include/lldb/Core/UUID.h b/include/lldb/Core/UUID.h index 3bb14421b1e9..88426cfb6c75 100644 --- a/include/lldb/Core/UUID.h +++ b/include/lldb/Core/UUID.h @@ -16,7 +16,6 @@ // Other libraries and framework includes // Project includes - #include "lldb/lldb-private.h" namespace lldb_private { @@ -58,7 +57,7 @@ public: SetBytes (const void *uuid_bytes, uint32_t num_uuid_bytes = 16); std::string - GetAsString (const char *separator = NULL) const; + GetAsString(const char *separator = nullptr) const; size_t SetFromCString (const char *c_str, uint32_t num_uuid_bytes = 16); @@ -80,7 +79,7 @@ public: /// decoded UUID. /// /// @param[out] end - /// If \a end is not NULL, it will be filled in with the a + /// If \a end is not nullptr, it will be filled in with the a /// pointer to the character after the last successfully decoded /// byte. /// diff --git a/include/lldb/Core/UniqueCStringMap.h b/include/lldb/Core/UniqueCStringMap.h index 972c0d53ea99..1e50f747f2a8 100644 --- a/include/lldb/Core/UniqueCStringMap.h +++ b/include/lldb/Core/UniqueCStringMap.h @@ -9,18 +9,18 @@ #ifndef liblldb_UniqueCStringMap_h_ #define liblldb_UniqueCStringMap_h_ -#if defined(__cplusplus) -#include <assert.h> +// C Includes +// C++ Includes #include <algorithm> #include <vector> +// Other libraries and framework includes +// Project includes #include "lldb/Core/RegularExpression.h" namespace lldb_private { - - //---------------------------------------------------------------------- // Templatized uniqued string map. // @@ -37,7 +37,7 @@ public: struct Entry { Entry () : - cstring(NULL), + cstring(nullptr), value() { } @@ -146,9 +146,7 @@ public: const char * GetCStringAtIndex (uint32_t idx) const { - if (idx < m_map.size()) - return m_map[idx].cstring; - return NULL; + return ((idx < m_map.size()) ? m_map[idx].cstring : nullptr); } //------------------------------------------------------------------ @@ -172,8 +170,9 @@ public: } return fail_value; } + //------------------------------------------------------------------ - // Get a pointer to the first entry that matches "name". NULL will + // Get a pointer to the first entry that matches "name". nullptr will // be returned if there is no entry that matches "name". // // The caller is responsible for ensuring that the collection does @@ -191,12 +190,12 @@ public: if (pos_cstr == unique_cstr) return &(*pos); } - return NULL; + return nullptr; } //------------------------------------------------------------------ // Get a pointer to the next entry that matches "name" from a - // previously returned Entry pointer. NULL will be returned if there + // previously returned Entry pointer. nullptr will be returned if there // is no subsequent entry that matches "name". // // The caller is responsible for ensuring that the collection does @@ -216,7 +215,7 @@ public: return next_entry; } } - return NULL; + return nullptr; } size_t @@ -261,7 +260,6 @@ public: return m_map.size(); } - //------------------------------------------------------------------ // Returns true if this map is empty. //------------------------------------------------------------------ @@ -346,6 +344,7 @@ public: } return num_removed; } + protected: typedef std::vector<Entry> collection; typedef typename collection::iterator iterator; @@ -353,9 +352,6 @@ protected: collection m_map; }; - - } // namespace lldb_private -#endif // #if defined(__cplusplus) -#endif // liblldb_UniqueCStringMap_h_ +#endif // liblldb_UniqueCStringMap_h_ diff --git a/include/lldb/Core/Value.h b/include/lldb/Core/Value.h index 957cedeb0dcc..a6d934afd294 100644 --- a/include/lldb/Core/Value.h +++ b/include/lldb/Core/Value.h @@ -12,23 +12,21 @@ // C Includes // C++ Includes -#include <string> #include <vector> + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" -#include "lldb/Core/ClangForward.h" #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/Error.h" #include "lldb/Core/Scalar.h" -#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/CompilerType.h" namespace lldb_private { class Value { public: - // Values Less than zero are an error, greater than or equal to zero // returns what the Scalar result is. enum ValueType @@ -101,6 +99,7 @@ public: // Casts a vector, if valid, to an unsigned int of matching or largest supported size. // Truncates to the beginning of the vector if required. // Returns a default constructed Scalar if the Vector data is internally inconsistent. + llvm::APInt rhs = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)bytes)->x); Scalar GetAsScalar() const { @@ -111,11 +110,7 @@ public: else if (length == 2) scalar = *(const uint16_t *)bytes; else if (length == 4) scalar = *(const uint32_t *)bytes; else if (length == 8) scalar = *(const uint64_t *)bytes; -#if defined (ENABLE_128_BIT_SUPPORT) - else if (length >= 16) scalar = *(const __uint128_t *)bytes; -#else - else if (length >= 16) scalar = *(const uint64_t *)bytes; -#endif + else if (length >= 16) scalar = rhs; } return scalar; } @@ -136,11 +131,11 @@ public: Value & operator=(const Value &rhs); - const ClangASTType & - GetClangType(); + const CompilerType & + GetCompilerType(); void - SetClangType (const ClangASTType &clang_type); + SetCompilerType (const CompilerType &compiler_type); ValueType GetValueType() const; @@ -163,7 +158,7 @@ public: void ClearContext () { - m_context = NULL; + m_context = nullptr; m_context_type = eContextTypeInvalid; } @@ -269,13 +264,13 @@ public: GetValueDefaultFormat (); uint64_t - GetValueByteSize (Error *error_ptr); + GetValueByteSize (Error *error_ptr, ExecutionContext *exe_ctx); Error - GetValueAsData (ExecutionContext *exe_ctx, - DataExtractor &data, - uint32_t data_offset, - Module *module); // Can be NULL + GetValueAsData(ExecutionContext *exe_ctx, + DataExtractor &data, + uint32_t data_offset, + Module *module); // Can be nullptr static const char * GetValueTypeAsCString (ValueType context_type); @@ -292,7 +287,7 @@ public: protected: Scalar m_value; Vector m_vector; - ClangASTType m_clang_type; + CompilerType m_compiler_type; void * m_context; ValueType m_value_type; ContextType m_context_type; @@ -309,9 +304,7 @@ public: ValueList (const ValueList &rhs); - ~ValueList () - { - } + ~ValueList() = default; const ValueList & operator= (const ValueList &rhs); @@ -322,8 +315,6 @@ public: Value *GetValueAtIndex(size_t idx); void Clear(); -protected: - private: typedef std::vector<Value> collection; @@ -332,4 +323,4 @@ private: } // namespace lldb_private -#endif // liblldb_Value_h_ +#endif // liblldb_Value_h_ diff --git a/include/lldb/Core/ValueObject.h b/include/lldb/Core/ValueObject.h index cdc507093b28..c066cc7d3661 100644 --- a/include/lldb/Core/ValueObject.h +++ b/include/lldb/Core/ValueObject.h @@ -12,6 +12,8 @@ // C Includes // C++ Includes +#include <functional> +#include <initializer_list> #include <map> #include <vector> @@ -27,7 +29,7 @@ #include "lldb/Core/ConstString.h" #include "lldb/Core/UserID.h" #include "lldb/Core/Value.h" -#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/CompilerType.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/Process.h" @@ -69,7 +71,6 @@ namespace lldb_private { class ValueObject : public UserID { public: - enum GetExpressionPathFormat { eGetExpressionPathFormatDereferencePointers = 1, @@ -221,13 +222,11 @@ public: return g_default_options; } - }; class EvaluationPoint { public: - EvaluationPoint (); EvaluationPoint (ExecutionContextScope *exe_scope, bool use_selected = false); @@ -326,6 +325,8 @@ public: bool m_needs_update; }; + virtual ~ValueObject(); + const EvaluationPoint & GetUpdatePoint () const { @@ -371,10 +372,8 @@ public: void SetNeedsUpdate (); - virtual ~ValueObject(); - - ClangASTType - GetClangType (); + CompilerType + GetCompilerType (); // this vends a TypeImpl that is useful at the SB API layer virtual TypeImpl @@ -408,7 +407,7 @@ public: GetObjectRuntimeLanguage(); virtual uint32_t - GetTypeInfo (ClangASTType *pointee_or_element_clang_type = NULL); + GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr); virtual bool IsPointerType (); @@ -425,8 +424,11 @@ public: virtual bool IsPossibleDynamicType (); - virtual bool - IsObjCNil (); + bool + IsNilReference (); + + bool + IsUninitializedReference (); virtual bool IsBaseClass () @@ -454,20 +456,20 @@ public: lldb::ValueObjectSP GetValueForExpressionPath(const char* expression, - const char** first_unparsed = NULL, - ExpressionPathScanEndReason* reason_to_stop = NULL, - ExpressionPathEndResultType* final_value_type = NULL, + const char** first_unparsed = nullptr, + ExpressionPathScanEndReason* reason_to_stop = nullptr, + ExpressionPathEndResultType* final_value_type = nullptr, const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(), - ExpressionPathAftermath* final_task_on_target = NULL); + ExpressionPathAftermath* final_task_on_target = nullptr); int GetValuesForExpressionPath(const char* expression, lldb::ValueObjectListSP& list, - const char** first_unparsed = NULL, - ExpressionPathScanEndReason* reason_to_stop = NULL, - ExpressionPathEndResultType* final_value_type = NULL, + const char** first_unparsed = nullptr, + ExpressionPathScanEndReason* reason_to_stop = nullptr, + ExpressionPathEndResultType* final_value_type = nullptr, const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(), - ExpressionPathAftermath* final_task_on_target = NULL); + ExpressionPathAftermath* final_task_on_target = nullptr); virtual bool IsInScope () @@ -517,10 +519,10 @@ public: std::string& destination); virtual uint64_t - GetValueAsUnsigned (uint64_t fail_value, bool *success = NULL); + GetValueAsUnsigned(uint64_t fail_value, bool *success = nullptr); virtual int64_t - GetValueAsSigned (int64_t fail_value, bool *success = NULL); + GetValueAsSigned(int64_t fail_value, bool *success = nullptr); virtual bool SetValueFromCString (const char *value_str, Error& error); @@ -556,37 +558,37 @@ public: // this will always create the children if necessary lldb::ValueObjectSP - GetChildAtIndexPath (const std::initializer_list<size_t> &idxs, - size_t* index_of_error = NULL); + GetChildAtIndexPath(const std::initializer_list<size_t> &idxs, + size_t* index_of_error = nullptr); lldb::ValueObjectSP - GetChildAtIndexPath (const std::vector<size_t> &idxs, - size_t* index_of_error = NULL); + GetChildAtIndexPath(const std::vector<size_t> &idxs, + size_t* index_of_error = nullptr); lldb::ValueObjectSP - GetChildAtIndexPath (const std::initializer_list< std::pair<size_t, bool> > &idxs, - size_t* index_of_error = NULL); + GetChildAtIndexPath(const std::initializer_list< std::pair<size_t, bool> > &idxs, + size_t* index_of_error = nullptr); lldb::ValueObjectSP - GetChildAtIndexPath (const std::vector< std::pair<size_t, bool> > &idxs, - size_t* index_of_error = NULL); + GetChildAtIndexPath(const std::vector< std::pair<size_t, bool> > &idxs, + size_t* index_of_error = nullptr); // this will always create the children if necessary lldb::ValueObjectSP - GetChildAtNamePath (const std::initializer_list<ConstString> &names, - ConstString* name_of_error = NULL); + GetChildAtNamePath(const std::initializer_list<ConstString> &names, + ConstString* name_of_error = nullptr); lldb::ValueObjectSP - GetChildAtNamePath (const std::vector<ConstString> &names, - ConstString* name_of_error = NULL); + GetChildAtNamePath(const std::vector<ConstString> &names, + ConstString* name_of_error = nullptr); lldb::ValueObjectSP - GetChildAtNamePath (const std::initializer_list< std::pair<ConstString, bool> > &names, - ConstString* name_of_error = NULL); + GetChildAtNamePath(const std::initializer_list< std::pair<ConstString, bool> > &names, + ConstString* name_of_error = nullptr); lldb::ValueObjectSP - GetChildAtNamePath (const std::vector< std::pair<ConstString, bool> > &names, - ConstString* name_of_error = NULL); + GetChildAtNamePath(const std::vector< std::pair<ConstString, bool> > &names, + ConstString* name_of_error = nullptr); virtual lldb::ValueObjectSP GetChildMemberWithName (const ConstString &name, bool can_create); @@ -595,7 +597,7 @@ public: GetIndexOfChildWithName (const ConstString &name); size_t - GetNumChildren (); + GetNumChildren (uint32_t max=UINT32_MAX); const Value & GetValue() const; @@ -606,15 +608,22 @@ public: virtual bool ResolveValue (Scalar &scalar); + // return 'false' whenever you set the error, otherwise + // callers may assume true means everything is OK - this will + // break breakpoint conditions among potentially a few others + virtual bool + IsLogicalTrue (Error& error); + virtual const char * GetLocationAsCString (); const char * - GetSummaryAsCString (); + GetSummaryAsCString (lldb::LanguageType lang = lldb::eLanguageTypeUnknown); bool GetSummaryAsCString (TypeSummaryImpl* summary_ptr, - std::string& destination); + std::string& destination, + lldb::LanguageType lang = lldb::eLanguageTypeUnknown); bool GetSummaryAsCString (std::string& destination, @@ -671,11 +680,11 @@ public: SetName (const ConstString &name); virtual lldb::addr_t - GetAddressOf (bool scalar_is_load_address = true, - AddressType *address_type = NULL); + GetAddressOf(bool scalar_is_load_address = true, + AddressType *address_type = nullptr); lldb::addr_t - GetPointerValue (AddressType *address_type = NULL); + GetPointerValue(AddressType *address_type = nullptr); lldb::ValueObjectSP GetSyntheticChild (const ConstString &key) const; @@ -690,10 +699,10 @@ public: GetSyntheticExpressionPathChild(const char* expression, bool can_create); virtual lldb::ValueObjectSP - GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create); + GetSyntheticChildAtOffset(uint32_t offset, const CompilerType& type, bool can_create); virtual lldb::ValueObjectSP - GetSyntheticBase (uint32_t offset, const ClangASTType& type, bool can_create); + GetSyntheticBase (uint32_t offset, const CompilerType& type, bool can_create); virtual lldb::ValueObjectSP GetDynamicValue (lldb::DynamicValueType valueType); @@ -746,11 +755,11 @@ public: GetCPPVTableAddress(AddressType &address_type); virtual lldb::ValueObjectSP - Cast (const ClangASTType &clang_ast_type); + Cast (const CompilerType &compiler_type); virtual lldb::ValueObjectSP CastPointerType (const char *name, - ClangASTType &ast_type); + CompilerType &ast_type); virtual lldb::ValueObjectSP CastPointerType (const char *name, @@ -809,13 +818,13 @@ public: CreateValueObjectFromAddress (const char* name, uint64_t address, const ExecutionContext& exe_ctx, - ClangASTType type); + CompilerType type); static lldb::ValueObjectSP CreateValueObjectFromData (const char* name, const DataExtractor& data, const ExecutionContext& exe_ctx, - ClangASTType type); + CompilerType type); void LogValueObject (Log *log); @@ -834,7 +843,7 @@ public: bool IsCStringContainer (bool check_pointer = false); - size_t + std::pair<size_t,bool> ReadPointedString (lldb::DataBufferSP& buffer_sp, Error& error, uint32_t max_length = 0, @@ -861,7 +870,7 @@ public: bool NeedsUpdating () { - const bool accept_invalid_exe_ctx = CanUpdateWithInvalidExecutionContext(); + const bool accept_invalid_exe_ctx = (CanUpdateWithInvalidExecutionContext() == eLazyBoolYes); return m_update_point.NeedsUpdating(accept_invalid_exe_ctx); } @@ -881,8 +890,7 @@ public: ClearUserVisibleData(eClearUserVisibleDataItemsValue); m_format = format; } - - + virtual lldb::LanguageType GetPreferredDisplayLanguage (); @@ -999,8 +1007,20 @@ public: virtual bool MightHaveChildren(); + virtual lldb::VariableSP + GetVariable () + { + return nullptr; + } + virtual bool IsRuntimeSupportValue (); + + virtual uint64_t + GetLanguageFlags (); + + virtual void + SetLanguageFlags (uint64_t flags); protected: typedef ClusterManager<ValueObject> ValueObjectManager; @@ -1018,21 +1038,15 @@ protected: HasChildAtIndex (size_t idx) { Mutex::Locker locker(m_mutex); - ChildrenIterator iter = m_children.find(idx); - ChildrenIterator end = m_children.end(); - return (iter != end); + return (m_children.find(idx) != m_children.end()); } ValueObject* GetChildAtIndex (size_t idx) { Mutex::Locker locker(m_mutex); - ChildrenIterator iter = m_children.find(idx); - ChildrenIterator end = m_children.end(); - if (iter == end) - return NULL; - else - return iter->second; + const auto iter = m_children.find(idx); + return ((iter == m_children.end()) ? nullptr : iter->second); } void @@ -1075,8 +1089,8 @@ protected: //------------------------------------------------------------------ // Classes that inherit from ValueObject can see and modify these //------------------------------------------------------------------ - ValueObject * m_parent; // The parent value object, or NULL if this has no parent - ValueObject * m_root; // The root of the hierarchy for this ValueObject (or NULL if never calculated) + ValueObject * m_parent; // The parent value object, or nullptr if this has no parent + ValueObject * m_root; // The root of the hierarchy for this ValueObject (or nullptr if never calculated) EvaluationPoint m_update_point; // Stores both the stop id and the full context at which this value was last // updated. When we are asked to update the value object, we check whether // the context & stop id are the same before updating. @@ -1093,7 +1107,7 @@ protected: llvm::Optional<std::pair<TypeValidatorResult, std::string>> m_validation_result; - ClangASTType m_override_type;// If the type of the value object should be overridden, the type to impose. + CompilerType m_override_type;// If the type of the value object should be overridden, the type to impose. ValueObjectManager *m_manager; // This object is managed by the root object (any ValueObject that gets created // without a parent.) The manager gets passed through all the generations of @@ -1125,6 +1139,8 @@ protected: lldb::LanguageType m_preferred_display_language; + uint64_t m_language_flags; + bool m_value_is_valid:1, m_value_did_change:1, m_children_count_valid:1, @@ -1139,7 +1155,7 @@ protected: friend class ValueObjectChild; friend class ClangExpressionDeclMap; // For GetValue - friend class ClangExpressionVariable; // For SetName + friend class ExpressionVariable; // For SetName friend class Target; // For SetName friend class ValueObjectConstResultImpl; friend class ValueObjectSynthetic; // For ClearUserVisibleData @@ -1172,10 +1188,10 @@ protected: virtual bool UpdateValue () = 0; - virtual bool + virtual LazyBool CanUpdateWithInvalidExecutionContext () { - return false; + return eLazyBoolCalculate; } virtual void @@ -1203,7 +1219,7 @@ protected: // Should only be called by ValueObject::GetNumChildren() virtual size_t - CalculateNumChildren() = 0; + CalculateNumChildren(uint32_t max=UINT32_MAX) = 0; void SetNumChildren (size_t num_children); @@ -1231,8 +1247,8 @@ protected: // Subclasses must implement the functions below. //------------------------------------------------------------------ - virtual ClangASTType - GetClangTypeImpl () = 0; + virtual CompilerType + GetCompilerTypeImpl () = 0; const char * GetLocationAsCStringImpl (const Value& value, @@ -1241,12 +1257,11 @@ protected: bool IsChecksumEmpty (); -private: - //------------------------------------------------------------------ - // For ValueObject only - //------------------------------------------------------------------ + void + SetPreferredDisplayLanguageIfNeeded (lldb::LanguageType); - virtual ClangASTType +private: + virtual CompilerType MaybeCalculateCompleteType (); lldb::ValueObjectSP @@ -1270,12 +1285,10 @@ private: ExpressionPathEndResultType* final_value_type, const GetValueForExpressionPathOptions& options, ExpressionPathAftermath* final_task_on_target); - - - DISALLOW_COPY_AND_ASSIGN (ValueObject); + DISALLOW_COPY_AND_ASSIGN (ValueObject); }; } // namespace lldb_private -#endif // liblldb_ValueObject_h_ +#endif // liblldb_ValueObject_h_ diff --git a/include/lldb/Core/ValueObjectCast.h b/include/lldb/Core/ValueObjectCast.h index 1538d7a55639..8c7ffe5ec5e2 100644 --- a/include/lldb/Core/ValueObjectCast.h +++ b/include/lldb/Core/ValueObjectCast.h @@ -1,4 +1,4 @@ -//===-- ValueObjectDynamicValue.h -----------------------------------*- C++ -*-===// +//===-- ValueObjectDynamicValue.h -------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -24,64 +24,54 @@ namespace lldb_private { class ValueObjectCast : public ValueObject { public: + ~ValueObjectCast() override; + static lldb::ValueObjectSP Create (ValueObject &parent, const ConstString &name, - const ClangASTType &cast_type); + const CompilerType &cast_type); - virtual - ~ValueObjectCast(); - - virtual uint64_t - GetByteSize(); + uint64_t + GetByteSize() override; - virtual size_t - CalculateNumChildren(); + size_t + CalculateNumChildren(uint32_t max) override; - virtual lldb::ValueType - GetValueType() const; + lldb::ValueType + GetValueType() const override; - virtual bool - IsInScope (); + bool + IsInScope() override; - virtual ValueObject * - GetParent() + ValueObject * + GetParent() override { - if (m_parent) - return m_parent->GetParent(); - else - return NULL; + return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr); } - virtual const ValueObject * - GetParent() const + const ValueObject * + GetParent() const override { - if (m_parent) - return m_parent->GetParent(); - else - return NULL; + return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr); } protected: - virtual bool - UpdateValue (); + ValueObjectCast(ValueObject &parent, + const ConstString &name, + const CompilerType &cast_type); + + bool + UpdateValue () override; - virtual ClangASTType - GetClangTypeImpl (); + CompilerType + GetCompilerTypeImpl () override; - ClangASTType m_cast_type; + CompilerType m_cast_type; private: - ValueObjectCast (ValueObject &parent, - const ConstString &name, - const ClangASTType &cast_type); - - //------------------------------------------------------------------ - // For ValueObject only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN (ValueObjectCast); }; } // namespace lldb_private -#endif // liblldb_ValueObjectCast_h_ +#endif // liblldb_ValueObjectCast_h_ diff --git a/include/lldb/Core/ValueObjectChild.h b/include/lldb/Core/ValueObjectChild.h index bf8707ea3b05..13e26c6ab0c1 100644 --- a/include/lldb/Core/ValueObjectChild.h +++ b/include/lldb/Core/ValueObjectChild.h @@ -16,6 +16,8 @@ // Project includes #include "lldb/Core/ValueObject.h" +#include "llvm/ADT/Optional.h" + namespace lldb_private { //---------------------------------------------------------------------- @@ -24,76 +26,76 @@ namespace lldb_private { class ValueObjectChild : public ValueObject { public: - virtual ~ValueObjectChild(); + ~ValueObjectChild() override; - virtual uint64_t - GetByteSize() + uint64_t + GetByteSize() override { return m_byte_size; } - virtual lldb::offset_t - GetByteOffset() + lldb::offset_t + GetByteOffset() override { return m_byte_offset; } - virtual uint32_t - GetBitfieldBitSize() + uint32_t + GetBitfieldBitSize() override { return m_bitfield_bit_size; } - virtual uint32_t - GetBitfieldBitOffset() + uint32_t + GetBitfieldBitOffset() override { return m_bitfield_bit_offset; } - virtual lldb::ValueType - GetValueType() const; + lldb::ValueType + GetValueType() const override; - virtual size_t - CalculateNumChildren(); + size_t + CalculateNumChildren(uint32_t max) override; - virtual ConstString - GetTypeName(); + ConstString + GetTypeName() override; - virtual ConstString - GetQualifiedTypeName(); + ConstString + GetQualifiedTypeName() override; - virtual ConstString - GetDisplayTypeName(); + ConstString + GetDisplayTypeName() override; - virtual bool - IsInScope (); + bool + IsInScope() override; - virtual bool - IsBaseClass () + bool + IsBaseClass() override { return m_is_base_class; } - virtual bool - IsDereferenceOfParent () + bool + IsDereferenceOfParent() override { return m_is_deref_of_parent; } protected: - virtual bool - UpdateValue (); + bool + UpdateValue() override; - virtual bool - CanUpdateWithInvalidExecutionContext (); + LazyBool + CanUpdateWithInvalidExecutionContext() override; - virtual ClangASTType - GetClangTypeImpl () + CompilerType + GetCompilerTypeImpl() override { - return m_clang_type; + return m_compiler_type; } - ClangASTType m_clang_type; + CompilerType m_compiler_type; ConstString m_type_name; uint64_t m_byte_size; int32_t m_byte_offset; @@ -101,6 +103,7 @@ protected: uint8_t m_bitfield_bit_offset; bool m_is_base_class; bool m_is_deref_of_parent; + llvm::Optional<LazyBool> m_can_update_with_invalid_exe_ctx; // // void @@ -110,8 +113,9 @@ protected: friend class ValueObject; friend class ValueObjectConstResult; friend class ValueObjectConstResultImpl; + ValueObjectChild (ValueObject &parent, - const ClangASTType &clang_type, + const CompilerType &compiler_type, const ConstString &name, uint64_t byte_size, int32_t byte_offset, @@ -119,11 +123,12 @@ protected: uint32_t bitfield_bit_offset, bool is_base_class, bool is_deref_of_parent, - AddressType child_ptr_or_ref_addr_type); + AddressType child_ptr_or_ref_addr_type, + uint64_t language_flags); DISALLOW_COPY_AND_ASSIGN (ValueObjectChild); }; } // namespace lldb_private -#endif // liblldb_ValueObjectChild_h_ +#endif // liblldb_ValueObjectChild_h_ diff --git a/include/lldb/Core/ValueObjectConstResult.h b/include/lldb/Core/ValueObjectConstResult.h index 4e05d50132ec..f63ee83284df 100644 --- a/include/lldb/Core/ValueObjectConstResult.h +++ b/include/lldb/Core/ValueObjectConstResult.h @@ -26,6 +26,8 @@ namespace lldb_private { class ValueObjectConstResult : public ValueObject { public: + ~ValueObjectConstResult() override; + static lldb::ValueObjectSP Create (ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, @@ -34,14 +36,14 @@ public: static lldb::ValueObjectSP Create (ExecutionContextScope *exe_scope, - const ClangASTType &clang_type, + const CompilerType &compiler_type, const ConstString &name, const DataExtractor &data, lldb::addr_t address = LLDB_INVALID_ADDRESS); static lldb::ValueObjectSP Create (ExecutionContextScope *exe_scope, - const ClangASTType &clang_type, + const CompilerType &compiler_type, const ConstString &name, const lldb::DataBufferSP &result_data_sp, lldb::ByteOrder byte_order, @@ -50,7 +52,7 @@ public: static lldb::ValueObjectSP Create (ExecutionContextScope *exe_scope, - const ClangASTType &clang_type, + const CompilerType &compiler_type, const ConstString &name, lldb::addr_t address, AddressType address_type, @@ -67,76 +69,76 @@ public: Create (ExecutionContextScope *exe_scope, const Error& error); - virtual ~ValueObjectConstResult(); - - virtual uint64_t - GetByteSize(); + uint64_t + GetByteSize() override; - virtual lldb::ValueType - GetValueType() const; + lldb::ValueType + GetValueType() const override; - virtual size_t - CalculateNumChildren(); + size_t + CalculateNumChildren(uint32_t max) override; - virtual ConstString - GetTypeName(); + ConstString + GetTypeName() override; - virtual ConstString - GetDisplayTypeName(); + ConstString + GetDisplayTypeName() override; - virtual bool - IsInScope (); + bool + IsInScope() override; void SetByteSize (size_t size); - virtual lldb::ValueObjectSP - Dereference (Error &error); + lldb::ValueObjectSP + Dereference(Error &error) override; - virtual ValueObject * - CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index); + ValueObject * + CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override; - virtual lldb::ValueObjectSP - GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create); + lldb::ValueObjectSP + GetSyntheticChildAtOffset(uint32_t offset, const CompilerType& type, bool can_create) override; - virtual lldb::ValueObjectSP - AddressOf (Error &error); + lldb::ValueObjectSP + AddressOf(Error &error) override; - virtual lldb::addr_t - GetAddressOf (bool scalar_is_load_address = true, - AddressType *address_type = NULL); + lldb::addr_t + GetAddressOf(bool scalar_is_load_address = true, + AddressType *address_type = nullptr) override; - virtual size_t - GetPointeeData (DataExtractor& data, - uint32_t item_idx = 0, - uint32_t item_count = 1); + size_t + GetPointeeData(DataExtractor& data, + uint32_t item_idx = 0, + uint32_t item_count = 1) override; - virtual lldb::addr_t - GetLiveAddress() + lldb::addr_t + GetLiveAddress() override { return m_impl.GetLiveAddress(); } - virtual void + void SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS, - AddressType address_type = eAddressTypeLoad) + AddressType address_type = eAddressTypeLoad) override { - m_impl.SetLiveAddress(addr, - address_type); + m_impl.SetLiveAddress(addr, address_type); } - virtual lldb::ValueObjectSP - GetDynamicValue (lldb::DynamicValueType valueType); + lldb::ValueObjectSP + GetDynamicValue(lldb::DynamicValueType valueType) override; - virtual lldb::LanguageType - GetPreferredDisplayLanguage (); + lldb::LanguageType + GetPreferredDisplayLanguage() override; + + lldb::ValueObjectSP + Cast(const CompilerType &compiler_type) override; protected: - virtual bool - UpdateValue (); + bool + UpdateValue() override; - virtual ClangASTType - GetClangTypeImpl (); + CompilerType + GetCompilerTypeImpl() override; ConstString m_type_name; uint64_t m_byte_size; @@ -145,19 +147,20 @@ protected: private: friend class ValueObjectConstResultImpl; + ValueObjectConstResult (ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address); ValueObjectConstResult (ExecutionContextScope *exe_scope, - const ClangASTType &clang_type, + const CompilerType &compiler_type, const ConstString &name, const DataExtractor &data, lldb::addr_t address); ValueObjectConstResult (ExecutionContextScope *exe_scope, - const ClangASTType &clang_type, + const CompilerType &compiler_type, const ConstString &name, const lldb::DataBufferSP &result_data_sp, lldb::ByteOrder byte_order, @@ -165,7 +168,7 @@ private: lldb::addr_t address); ValueObjectConstResult (ExecutionContextScope *exe_scope, - const ClangASTType &clang_type, + const CompilerType &compiler_type, const ConstString &name, lldb::addr_t address, AddressType address_type, @@ -184,4 +187,4 @@ private: } // namespace lldb_private -#endif // liblldb_ValueObjectConstResult_h_ +#endif // liblldb_ValueObjectConstResult_h_ diff --git a/include/lldb/Core/ValueObjectConstResultCast.h b/include/lldb/Core/ValueObjectConstResultCast.h new file mode 100644 index 000000000000..395820dad6c7 --- /dev/null +++ b/include/lldb/Core/ValueObjectConstResultCast.h @@ -0,0 +1,76 @@ +//===-- ValueObjectConstResultCast.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_ValueObjectConstResultCast_h_ +#define liblldb_ValueObjectConstResultCast_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/ValueObjectCast.h" +#include "lldb/Core/ValueObjectConstResultImpl.h" + +namespace lldb_private { + +class ValueObjectConstResultCast : public ValueObjectCast +{ +public: + ValueObjectConstResultCast ( + ValueObject &parent, + const ConstString &name, + const CompilerType &cast_type, + lldb::addr_t live_address = LLDB_INVALID_ADDRESS); + + ~ValueObjectConstResultCast() override; + + lldb::ValueObjectSP + Dereference(Error &error) override; + + ValueObject * + CreateChildAtIndex(size_t idx, + bool synthetic_array_member, + int32_t synthetic_index) override; + + virtual CompilerType + GetCompilerType () + { + return ValueObjectCast::GetCompilerType(); + } + + lldb::ValueObjectSP + GetSyntheticChildAtOffset(uint32_t offset, + const CompilerType& type, + bool can_create) override; + + lldb::ValueObjectSP + AddressOf (Error &error) override; + + size_t + GetPointeeData (DataExtractor& data, + uint32_t item_idx = 0, + uint32_t item_count = 1) override; + + lldb::ValueObjectSP + Cast (const CompilerType &compiler_type) override; + +protected: + ValueObjectConstResultImpl m_impl; + +private: + friend class ValueObject; + friend class ValueObjectConstResult; + friend class ValueObjectConstResultImpl; + + DISALLOW_COPY_AND_ASSIGN (ValueObjectConstResultCast); +}; + +} // namespace lldb_private + +#endif // liblldb_ValueObjectConstResultCast_h_ diff --git a/include/lldb/Core/ValueObjectConstResultChild.h b/include/lldb/Core/ValueObjectConstResultChild.h index 9063276b0198..356d175a64ae 100644 --- a/include/lldb/Core/ValueObjectConstResultChild.h +++ b/include/lldb/Core/ValueObjectConstResultChild.h @@ -27,39 +27,44 @@ class ValueObjectConstResultChild : public ValueObjectChild public: ValueObjectConstResultChild (ValueObject &parent, - const ClangASTType &clang_type, + const CompilerType &compiler_type, const ConstString &name, uint32_t byte_size, int32_t byte_offset, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, bool is_base_class, - bool is_deref_of_parent); + bool is_deref_of_parent, + lldb::addr_t live_address, + uint64_t language_flags); - virtual ~ValueObjectConstResultChild(); + ~ValueObjectConstResultChild() override; - virtual lldb::ValueObjectSP - Dereference (Error &error); + lldb::ValueObjectSP + Dereference(Error &error) override; - virtual ValueObject * - CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index); + ValueObject * + CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override; - virtual ClangASTType - GetClangType () + virtual CompilerType + GetCompilerType () { - return ValueObjectChild::GetClangType(); + return ValueObjectChild::GetCompilerType(); } - virtual lldb::ValueObjectSP - GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create); + lldb::ValueObjectSP + GetSyntheticChildAtOffset(uint32_t offset, const CompilerType& type, bool can_create) override; - virtual lldb::ValueObjectSP - AddressOf (Error &error); + lldb::ValueObjectSP + AddressOf (Error &error) override; - virtual size_t + size_t GetPointeeData (DataExtractor& data, uint32_t item_idx = 0, - uint32_t item_count = 1); + uint32_t item_count = 1) override; + + lldb::ValueObjectSP + Cast (const CompilerType &compiler_type) override; protected: ValueObjectConstResultImpl m_impl; @@ -74,4 +79,4 @@ private: } // namespace lldb_private -#endif // liblldb_ValueObjectConstResultChild_h_ +#endif // liblldb_ValueObjectConstResultChild_h_ diff --git a/include/lldb/Core/ValueObjectConstResultImpl.h b/include/lldb/Core/ValueObjectConstResultImpl.h index e3574e8a4d4e..36b82f00a240 100644 --- a/include/lldb/Core/ValueObjectConstResultImpl.h +++ b/include/lldb/Core/ValueObjectConstResultImpl.h @@ -1,4 +1,4 @@ -//===-- ValueObjectConstResultImpl.h -----------------------------*- C++ -*-===// +//===-- ValueObjectConstResultImpl.h ----------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -26,15 +26,12 @@ namespace lldb_private { class ValueObjectConstResultImpl { public: - ValueObjectConstResultImpl (ValueObject* valobj, lldb::addr_t live_address = LLDB_INVALID_ADDRESS); - + virtual - ~ValueObjectConstResultImpl() - { - } - + ~ValueObjectConstResultImpl() = default; + lldb::ValueObjectSP Dereference (Error &error); @@ -42,7 +39,7 @@ public: CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index); lldb::ValueObjectSP - GetSyntheticChildAtOffset (uint32_t offset, const ClangASTType& type, bool can_create); + GetSyntheticChildAtOffset (uint32_t offset, const CompilerType& type, bool can_create); lldb::ValueObjectSP AddressOf (Error &error); @@ -52,6 +49,9 @@ public: { return m_live_address; } + + lldb::ValueObjectSP + Cast (const CompilerType &compiler_type); void SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS, @@ -62,16 +62,15 @@ public: } virtual lldb::addr_t - GetAddressOf (bool scalar_is_load_address = true, - AddressType *address_type = NULL); + GetAddressOf(bool scalar_is_load_address = true, + AddressType *address_type = nullptr); virtual size_t - GetPointeeData (DataExtractor& data, - uint32_t item_idx = 0, - uint32_t item_count = 1); + GetPointeeData(DataExtractor& data, + uint32_t item_idx = 0, + uint32_t item_count = 1); private: - ValueObject *m_impl_backend; lldb::addr_t m_live_address; AddressType m_live_address_type; @@ -83,4 +82,4 @@ private: } // namespace lldb_private -#endif // liblldb_ValueObjectConstResultImpl_h_ +#endif // liblldb_ValueObjectConstResultImpl_h_ diff --git a/include/lldb/Core/ValueObjectDynamicValue.h b/include/lldb/Core/ValueObjectDynamicValue.h index 8d42706be166..80f37f104765 100644 --- a/include/lldb/Core/ValueObjectDynamicValue.h +++ b/include/lldb/Core/ValueObjectDynamicValue.h @@ -1,4 +1,4 @@ -//===-- ValueObjectDynamicValue.h -----------------------------------*- C++ -*-===// +//===-- ValueObjectDynamicValue.h -------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -26,109 +26,131 @@ namespace lldb_private { class ValueObjectDynamicValue : public ValueObject { public: - virtual - ~ValueObjectDynamicValue(); + ~ValueObjectDynamicValue() override; - virtual uint64_t - GetByteSize(); + uint64_t + GetByteSize() override; - virtual ConstString - GetTypeName(); + ConstString + GetTypeName() override; - virtual ConstString - GetQualifiedTypeName(); + ConstString + GetQualifiedTypeName() override; - virtual ConstString - GetDisplayTypeName(); + ConstString + GetDisplayTypeName() override; - virtual size_t - CalculateNumChildren(); + size_t + CalculateNumChildren(uint32_t max) override; - virtual lldb::ValueType - GetValueType() const; + lldb::ValueType + GetValueType() const override; - virtual bool - IsInScope (); + bool + IsInScope() override; - virtual bool - IsDynamic () + bool + IsDynamic() override { return true; } - virtual bool - GetIsConstant () const + bool + IsBaseClass () override { + if (m_parent) + return m_parent->IsBaseClass(); return false; } - virtual ValueObject * - GetParent() + bool + GetIsConstant() const override { - if (m_parent) - return m_parent->GetParent(); - else - return NULL; + return false; + } + + ValueObject * + GetParent() override + { + return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr); } - virtual const ValueObject * - GetParent() const + const ValueObject * + GetParent() const override { - if (m_parent) - return m_parent->GetParent(); - else - return NULL; + return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr); } - virtual lldb::ValueObjectSP - GetStaticValue () + lldb::ValueObjectSP + GetStaticValue() override { return m_parent->GetSP(); } - + void SetOwningSP (lldb::ValueObjectSP &owning_sp) { if (m_owning_valobj_sp == owning_sp) return; - assert (m_owning_valobj_sp.get() == NULL); + assert (m_owning_valobj_sp.get() == nullptr); m_owning_valobj_sp = owning_sp; } - virtual bool - SetValueFromCString (const char *value_str, Error& error); + bool + SetValueFromCString(const char *value_str, Error& error) override; + + bool + SetData(DataExtractor &data, Error &error) override; + + TypeImpl + GetTypeImpl() override; + + lldb::VariableSP + GetVariable () override + { + return m_parent ? m_parent->GetVariable() : nullptr; + } + + lldb::LanguageType + GetPreferredDisplayLanguage() override; - virtual bool - SetData (DataExtractor &data, Error &error); + void + SetPreferredDisplayLanguage (lldb::LanguageType); + + bool + GetDeclaration(Declaration &decl) override; - virtual TypeImpl - GetTypeImpl (); + uint64_t + GetLanguageFlags () override; + void + SetLanguageFlags (uint64_t flags) override; + protected: - virtual bool - UpdateValue (); + bool + UpdateValue() override; - virtual bool - CanUpdateWithInvalidExecutionContext () + LazyBool + CanUpdateWithInvalidExecutionContext() override { - return true; + return eLazyBoolYes; } - virtual lldb::DynamicValueType - GetDynamicValueTypeImpl () + lldb::DynamicValueType + GetDynamicValueTypeImpl() override { return m_use_dynamic; } - virtual bool - HasDynamicValueTypeInfo () + bool + HasDynamicValueTypeInfo() override { return true; } - virtual ClangASTType - GetClangTypeImpl (); + CompilerType + GetCompilerTypeImpl() override; Address m_address; ///< The variable that this value object is based upon TypeAndOrName m_dynamic_type_info; // We can have a type_sp or just a name @@ -141,12 +163,9 @@ private: friend class ValueObjectConstResult; ValueObjectDynamicValue (ValueObject &parent, lldb::DynamicValueType use_dynamic); - //------------------------------------------------------------------ - // For ValueObject only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN (ValueObjectDynamicValue); }; } // namespace lldb_private -#endif // liblldb_ValueObjectDynamicValue_h_ +#endif // liblldb_ValueObjectDynamicValue_h_ diff --git a/include/lldb/Core/ValueObjectList.h b/include/lldb/Core/ValueObjectList.h index 6565367cc61c..4f5e7b246fbd 100644 --- a/include/lldb/Core/ValueObjectList.h +++ b/include/lldb/Core/ValueObjectList.h @@ -17,7 +17,6 @@ // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" -#include "lldb/Core/ClangForward.h" #include "lldb/Core/UserID.h" #include "lldb/Target/ExecutionContextScope.h" diff --git a/include/lldb/Core/ValueObjectMemory.h b/include/lldb/Core/ValueObjectMemory.h index 41b43188a46a..0e12fc7e3f28 100644 --- a/include/lldb/Core/ValueObjectMemory.h +++ b/include/lldb/Core/ValueObjectMemory.h @@ -15,7 +15,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/ValueObject.h" -#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/CompilerType.h" namespace lldb_private { @@ -26,6 +26,8 @@ namespace lldb_private { class ValueObjectMemory : public ValueObject { public: + ~ValueObjectMemory() override; + static lldb::ValueObjectSP Create (ExecutionContextScope *exe_scope, const char *name, @@ -36,42 +38,39 @@ public: Create (ExecutionContextScope *exe_scope, const char *name, const Address &address, - const ClangASTType &ast_type); - - virtual - ~ValueObjectMemory(); + const CompilerType &ast_type); - virtual uint64_t - GetByteSize(); + uint64_t + GetByteSize() override; - virtual ConstString - GetTypeName(); + ConstString + GetTypeName() override; - virtual ConstString - GetDisplayTypeName(); + ConstString + GetDisplayTypeName() override; - virtual size_t - CalculateNumChildren(); + size_t + CalculateNumChildren(uint32_t max) override; - virtual lldb::ValueType - GetValueType() const; + lldb::ValueType + GetValueType() const override; - virtual bool - IsInScope (); + bool + IsInScope() override; - virtual lldb::ModuleSP - GetModule(); + lldb::ModuleSP + GetModule() override; protected: - virtual bool - UpdateValue (); + bool + UpdateValue() override; - virtual ClangASTType - GetClangTypeImpl (); + CompilerType + GetCompilerTypeImpl() override; Address m_address; ///< The variable that this value object is based upon lldb::TypeSP m_type_sp; - ClangASTType m_clang_type; + CompilerType m_compiler_type; private: ValueObjectMemory (ExecutionContextScope *exe_scope, @@ -82,7 +81,7 @@ private: ValueObjectMemory (ExecutionContextScope *exe_scope, const char *name, const Address &address, - const ClangASTType &ast_type); + const CompilerType &ast_type); //------------------------------------------------------------------ // For ValueObject only //------------------------------------------------------------------ @@ -91,4 +90,4 @@ private: } // namespace lldb_private -#endif // liblldb_ValueObjectMemory_h_ +#endif // liblldb_ValueObjectMemory_h_ diff --git a/include/lldb/Core/ValueObjectRegister.h b/include/lldb/Core/ValueObjectRegister.h index f7c7683d60bc..ac76f9e4280b 100644 --- a/include/lldb/Core/ValueObjectRegister.h +++ b/include/lldb/Core/ValueObjectRegister.h @@ -27,40 +27,38 @@ namespace lldb_private { class ValueObjectRegisterContext : public ValueObject { public: + ~ValueObjectRegisterContext() override; - virtual - ~ValueObjectRegisterContext(); + uint64_t + GetByteSize() override; - virtual uint64_t - GetByteSize(); - - virtual lldb::ValueType - GetValueType () const + lldb::ValueType + GetValueType() const override { return lldb::eValueTypeRegisterSet; } - virtual ConstString - GetTypeName(); + ConstString + GetTypeName() override; - virtual ConstString - GetQualifiedTypeName(); + ConstString + GetQualifiedTypeName() override; - virtual ConstString - GetDisplayTypeName(); + ConstString + GetDisplayTypeName() override; - virtual size_t - CalculateNumChildren(); + size_t + CalculateNumChildren(uint32_t max) override; - virtual ValueObject * - CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index); + ValueObject * + CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override; protected: - virtual bool - UpdateValue (); + bool + UpdateValue() override; - virtual ClangASTType - GetClangTypeImpl (); + CompilerType + GetCompilerTypeImpl() override; lldb::RegisterContextSP m_reg_ctx_sp; @@ -75,46 +73,44 @@ private: class ValueObjectRegisterSet : public ValueObject { public: + ~ValueObjectRegisterSet() override; + static lldb::ValueObjectSP Create (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t set_idx); - virtual - ~ValueObjectRegisterSet(); - - virtual uint64_t - GetByteSize(); + uint64_t + GetByteSize() override; - virtual lldb::ValueType - GetValueType () const + lldb::ValueType + GetValueType() const override { return lldb::eValueTypeRegisterSet; } - virtual ConstString - GetTypeName(); + ConstString + GetTypeName() override; - virtual ConstString - GetQualifiedTypeName(); + ConstString + GetQualifiedTypeName() override; - virtual size_t - CalculateNumChildren(); + size_t + CalculateNumChildren(uint32_t max) override; - virtual ValueObject * - CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index); + ValueObject * + CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override; - virtual lldb::ValueObjectSP - GetChildMemberWithName (const ConstString &name, bool can_create); - - virtual size_t - GetIndexOfChildWithName (const ConstString &name); + lldb::ValueObjectSP + GetChildMemberWithName(const ConstString &name, bool can_create) override; + size_t + GetIndexOfChildWithName(const ConstString &name) override; protected: - virtual bool - UpdateValue (); + bool + UpdateValue() override; - virtual ClangASTType - GetClangTypeImpl (); + CompilerType + GetCompilerTypeImpl() override; lldb::RegisterContextSP m_reg_ctx_sp; const RegisterSet *m_reg_set; @@ -122,6 +118,7 @@ protected: private: friend class ValueObjectRegisterContext; + ValueObjectRegisterSet (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t set_idx); //------------------------------------------------------------------ @@ -133,57 +130,58 @@ private: class ValueObjectRegister : public ValueObject { public: + ~ValueObjectRegister() override; + static lldb::ValueObjectSP Create (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num); - virtual - ~ValueObjectRegister(); - - virtual uint64_t - GetByteSize(); + uint64_t + GetByteSize() override; - virtual lldb::ValueType - GetValueType () const + lldb::ValueType + GetValueType() const override { return lldb::eValueTypeRegister; } - virtual ConstString - GetTypeName(); + ConstString + GetTypeName() override; - virtual size_t - CalculateNumChildren(); + size_t + CalculateNumChildren(uint32_t max) override; - virtual bool - SetValueFromCString (const char *value_str, Error& error); + bool + SetValueFromCString(const char *value_str, Error& error) override; - virtual bool - SetData (DataExtractor &data, Error &error); + bool + SetData(DataExtractor &data, Error &error) override; - virtual bool - ResolveValue (Scalar &scalar); + bool + ResolveValue(Scalar &scalar) override; - virtual void - GetExpressionPath (Stream &s, bool qualify_cxx_base_classes, GetExpressionPathFormat epformat = eGetExpressionPathFormatDereferencePointers); + void + GetExpressionPath(Stream &s, bool qualify_cxx_base_classes, + GetExpressionPathFormat epformat = eGetExpressionPathFormatDereferencePointers) override; protected: - virtual bool - UpdateValue (); + bool + UpdateValue() override; - virtual ClangASTType - GetClangTypeImpl (); + CompilerType + GetCompilerTypeImpl() override; lldb::RegisterContextSP m_reg_ctx_sp; RegisterInfo m_reg_info; RegisterValue m_reg_value; ConstString m_type_name; - ClangASTType m_clang_type; + CompilerType m_compiler_type; private: void ConstructObject (uint32_t reg_num); friend class ValueObjectRegisterSet; + ValueObjectRegister (ValueObject &parent, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num); ValueObjectRegister (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num); @@ -195,4 +193,4 @@ private: } // namespace lldb_private -#endif // liblldb_ValueObjectRegister_h_ +#endif // liblldb_ValueObjectRegister_h_ diff --git a/include/lldb/Core/ValueObjectSyntheticFilter.h b/include/lldb/Core/ValueObjectSyntheticFilter.h index 88824ef4fa54..05bc3781a3cc 100644 --- a/include/lldb/Core/ValueObjectSyntheticFilter.h +++ b/include/lldb/Core/ValueObjectSyntheticFilter.h @@ -1,4 +1,4 @@ -//===-- ValueObjectSyntheticFilter.h -------------------------------*- C++ -*-===// +//===-- ValueObjectSyntheticFilter.h ----------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -12,7 +12,8 @@ // C Includes // C++ Includes -#include <vector> +#include <memory> + // Other libraries and framework includes // Project includes #include "lldb/Core/ThreadSafeSTLMap.h" @@ -30,140 +31,142 @@ namespace lldb_private { class ValueObjectSynthetic : public ValueObject { public: - virtual - ~ValueObjectSynthetic(); + ~ValueObjectSynthetic() override; - virtual uint64_t - GetByteSize(); + uint64_t + GetByteSize() override; - virtual ConstString - GetTypeName(); + ConstString + GetTypeName() override; - virtual ConstString - GetQualifiedTypeName(); + ConstString + GetQualifiedTypeName() override; - virtual ConstString - GetDisplayTypeName(); + ConstString + GetDisplayTypeName() override; - virtual bool - MightHaveChildren(); + bool + MightHaveChildren() override; - virtual size_t - CalculateNumChildren(); + size_t + CalculateNumChildren(uint32_t max) override; - virtual lldb::ValueType - GetValueType() const; + lldb::ValueType + GetValueType() const override; - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx, bool can_create); + lldb::ValueObjectSP + GetChildAtIndex(size_t idx, bool can_create) override; - virtual lldb::ValueObjectSP - GetChildMemberWithName (const ConstString &name, bool can_create); + lldb::ValueObjectSP + GetChildMemberWithName(const ConstString &name, bool can_create) override; - virtual size_t - GetIndexOfChildWithName (const ConstString &name); + size_t + GetIndexOfChildWithName(const ConstString &name) override; - virtual lldb::ValueObjectSP - GetDynamicValue (lldb::DynamicValueType valueType); + lldb::ValueObjectSP + GetDynamicValue(lldb::DynamicValueType valueType) override; - virtual bool - IsInScope (); + bool + IsInScope() override; - virtual bool - HasSyntheticValue() + bool + HasSyntheticValue() override { return false; } - virtual bool - IsSynthetic() { return true; } + bool + IsSynthetic() override + { + return true; + } - virtual void - CalculateSyntheticValue (bool use_synthetic) + void + CalculateSyntheticValue(bool use_synthetic) override { } - virtual bool - IsDynamic () + bool + IsDynamic() override { - if (m_parent) - return m_parent->IsDynamic(); - else - return false; + return ((m_parent != nullptr) ? m_parent->IsDynamic() : false); } - virtual lldb::ValueObjectSP - GetStaticValue () + lldb::ValueObjectSP + GetStaticValue() override { - if (m_parent) - return m_parent->GetStaticValue(); - else - return GetSP(); + return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP()); } virtual lldb::DynamicValueType GetDynamicValueType () { - if (m_parent) - return m_parent->GetDynamicValueType(); - else - return lldb::eNoDynamicValues; + return ((m_parent != nullptr) ? m_parent->GetDynamicValueType() : lldb::eNoDynamicValues); } - virtual ValueObject * - GetParent() + ValueObject * + GetParent() override { - if (m_parent) - return m_parent->GetParent(); - else - return NULL; + return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr); } - virtual const ValueObject * - GetParent() const + const ValueObject * + GetParent() const override { - if (m_parent) - return m_parent->GetParent(); - else - return NULL; + return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr); } - virtual lldb::ValueObjectSP - GetNonSyntheticValue (); + lldb::ValueObjectSP + GetNonSyntheticValue() override; - virtual bool - CanProvideValue (); + bool + CanProvideValue() override; - virtual bool - DoesProvideSyntheticValue () + bool + DoesProvideSyntheticValue() override { return (UpdateValueIfNeeded(), m_provides_value == eLazyBoolYes); } - virtual bool - GetIsConstant () const + bool + GetIsConstant() const override { return false; } - virtual bool - SetValueFromCString (const char *value_str, Error& error); + bool + SetValueFromCString(const char *value_str, Error& error) override; - virtual void - SetFormat (lldb::Format format); + void + SetFormat(lldb::Format format) override; + + lldb::LanguageType + GetPreferredDisplayLanguage() override; + + void + SetPreferredDisplayLanguage (lldb::LanguageType); + + bool + GetDeclaration(Declaration &decl) override; + + uint64_t + GetLanguageFlags () override; + + void + SetLanguageFlags (uint64_t flags) override; protected: - virtual bool - UpdateValue (); + bool + UpdateValue() override; - virtual bool - CanUpdateWithInvalidExecutionContext () + LazyBool + CanUpdateWithInvalidExecutionContext() override { - return true; + return eLazyBoolYes; } - virtual ClangASTType - GetClangTypeImpl (); + CompilerType + GetCompilerTypeImpl() override; virtual void CreateSynthFilter (); @@ -195,12 +198,9 @@ private: void CopyValueData (ValueObject *source); - //------------------------------------------------------------------ - // For ValueObject only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN (ValueObjectSynthetic); }; } // namespace lldb_private -#endif // liblldb_ValueObjectSyntheticFilter_h_ +#endif // liblldb_ValueObjectSyntheticFilter_h_ diff --git a/include/lldb/Core/ValueObjectVariable.h b/include/lldb/Core/ValueObjectVariable.h index 0e32d09057dc..4adb6bad0ada 100644 --- a/include/lldb/Core/ValueObjectVariable.h +++ b/include/lldb/Core/ValueObjectVariable.h @@ -25,61 +25,66 @@ namespace lldb_private { class ValueObjectVariable : public ValueObject { public: + ~ValueObjectVariable() override; + static lldb::ValueObjectSP Create (ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp); - virtual - ~ValueObjectVariable(); - - virtual uint64_t - GetByteSize(); + uint64_t + GetByteSize() override; - virtual ConstString - GetTypeName(); + ConstString + GetTypeName() override; - virtual ConstString - GetQualifiedTypeName(); + ConstString + GetQualifiedTypeName() override; - virtual ConstString - GetDisplayTypeName(); + ConstString + GetDisplayTypeName() override; - virtual size_t - CalculateNumChildren(); + size_t + CalculateNumChildren(uint32_t max) override; - virtual lldb::ValueType - GetValueType() const; + lldb::ValueType + GetValueType() const override; - virtual bool - IsInScope (); + bool + IsInScope() override; - virtual lldb::ModuleSP - GetModule(); + lldb::ModuleSP + GetModule() override; - virtual SymbolContextScope * - GetSymbolContextScope(); + SymbolContextScope * + GetSymbolContextScope() override; - virtual bool - GetDeclaration (Declaration &decl); + bool + GetDeclaration(Declaration &decl) override; - virtual const char * - GetLocationAsCString (); + const char * + GetLocationAsCString() override; - virtual bool - SetValueFromCString (const char *value_str, Error& error); + bool + SetValueFromCString(const char *value_str, Error& error) override; - virtual bool - SetData (DataExtractor &data, Error &error); + bool + SetData(DataExtractor &data, Error &error) override; + + virtual lldb::VariableSP + GetVariable () override + { + return m_variable_sp; + } protected: - virtual bool - UpdateValue (); + bool + UpdateValue() override; - virtual ClangASTType - GetClangTypeImpl (); + CompilerType + GetCompilerTypeImpl() override; lldb::VariableSP m_variable_sp; ///< The variable that this value object is based upon Value m_resolved_value; ///< The value that DWARFExpression resolves this variable to before we patch it up - + private: ValueObjectVariable (ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp); //------------------------------------------------------------------ @@ -90,4 +95,4 @@ private: } // namespace lldb_private -#endif // liblldb_ValueObjectVariable_h_ +#endif // liblldb_ValueObjectVariable_h_ diff --git a/include/lldb/Core/dwarf.h b/include/lldb/Core/dwarf.h index 9fa8816229a9..649a93154b3f 100644 --- a/include/lldb/Core/dwarf.h +++ b/include/lldb/Core/dwarf.h @@ -14,13 +14,16 @@ // Get the DWARF constant definitions from llvm #include "llvm/Support/Dwarf.h" + +#include "lldb/Core/RangeMap.h" + // and stuff them in our default namespace using namespace llvm::dwarf; typedef uint32_t dw_uleb128_t; typedef int32_t dw_sleb128_t; typedef uint16_t dw_attr_t; -typedef uint8_t dw_form_t; +typedef uint16_t dw_form_t; typedef uint16_t dw_tag_t; typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for any addresses in the compile units that get parsed @@ -59,5 +62,6 @@ typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for //#define DW_OP_APPLE_clear 0xFE // clears the entire expression stack, ok if the stack is empty //#define DW_OP_APPLE_error 0xFF // Stops expression evaluation and returns an error (no args) +typedef lldb_private::RangeArray<dw_addr_t, dw_addr_t, 2> DWARFRangeList; #endif // DebugBase_dwarf_h_ diff --git a/include/lldb/DataFormatters/CXXFormatterFunctions.h b/include/lldb/DataFormatters/CXXFormatterFunctions.h deleted file mode 100644 index a175e1a4d164..000000000000 --- a/include/lldb/DataFormatters/CXXFormatterFunctions.h +++ /dev/null @@ -1,375 +0,0 @@ -//===-- CXXFormatterFunctions.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_CXXFormatterFunctions_h_ -#define liblldb_CXXFormatterFunctions_h_ - -#include <stdint.h> -#include <time.h> - -#include "lldb/lldb-forward.h" - -#include "lldb/Core/ConstString.h" -#include "lldb/DataFormatters/FormatClasses.h" -#include "lldb/DataFormatters/TypeSynthetic.h" -#include "lldb/DataFormatters/VectorType.h" -#include "lldb/Target/ExecutionContext.h" -#include "lldb/Target/ObjCLanguageRuntime.h" -#include "lldb/Target/Target.h" - -#include "clang/AST/ASTContext.h" - -namespace lldb_private { - namespace formatters - { - StackFrame* - GetViableFrame (ExecutionContext exe_ctx); - - bool - ExtractValueFromObjCExpression (ValueObject &valobj, - const char* target_type, - const char* selector, - uint64_t &value); - - bool - ExtractSummaryFromObjCExpression (ValueObject &valobj, - const char* target_type, - const char* selector, - Stream &stream); - - lldb::ValueObjectSP - CallSelectorOnObject (ValueObject &valobj, - const char* return_type, - const char* selector, - uint64_t index); - - lldb::ValueObjectSP - CallSelectorOnObject (ValueObject &valobj, - const char* return_type, - const char* selector, - const char* key); - - size_t - ExtractIndexFromString (const char* item_name); - - time_t - GetOSXEpoch (); - - bool - FunctionPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // C++ function pointer - - bool - Char16StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char16_t* and unichar* - - bool - Char32StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char32_t* - - bool - WCharStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // wchar_t* - - bool - Char16SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char16_t and unichar - - bool - Char32SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char32_t - - bool - WCharSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // wchar_t - - bool - LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::string - - bool - LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::wstring - - bool - LibcxxSmartPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::shared_ptr<> and std::weak_ptr<> - - bool - ObjCClassSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - SyntheticChildrenFrontEnd* ObjCClassSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - - template<bool name_entries> - bool - NSDictionarySummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - NSIndexSetSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - NSArraySummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - template<bool cf_style> - bool - NSSetSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - template<bool needs_at> - bool - NSDataSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - NSNumberSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - NSNotificationSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - NSTimeZoneSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - NSMachPortSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - CFBagSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - CFBinaryHeapSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - CFBitVectorSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - NSDateSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - CFAbsoluteTimeSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - NSBundleSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - NSStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - NSTaggedString_SummaryProvider (ObjCLanguageRuntime::ClassDescriptorSP descriptor, Stream& stream); - - bool - NSAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - NSMutableAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - NSURLSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - ObjCBOOLSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - template <bool is_sel_ptr> - bool - ObjCSELSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - bool - RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - extern template bool - NSDictionarySummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&) ; - - extern template bool - NSDictionarySummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&) ; - - extern template bool - NSDataSummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&) ; - - extern template bool - NSDataSummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&) ; - - extern template bool - ObjCSELSummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&); - - extern template bool - ObjCSELSummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&); - - bool - CMTimeSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - SyntheticChildrenFrontEnd* NSArraySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - - SyntheticChildrenFrontEnd* NSDictionarySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - - SyntheticChildrenFrontEnd* NSSetSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - - SyntheticChildrenFrontEnd* NSIndexPathSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - - class LibcxxVectorBoolSyntheticFrontEnd : public SyntheticChildrenFrontEnd - { - public: - LibcxxVectorBoolSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); - - virtual size_t - CalculateNumChildren (); - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx); - - virtual bool - Update(); - - virtual bool - MightHaveChildren (); - - virtual size_t - GetIndexOfChildWithName (const ConstString &name); - - virtual - ~LibcxxVectorBoolSyntheticFrontEnd (); - private: - ClangASTType m_bool_type; - ExecutionContextRef m_exe_ctx_ref; - uint64_t m_count; - lldb::addr_t m_base_data_address; - std::map<size_t,lldb::ValueObjectSP> m_children; - }; - - SyntheticChildrenFrontEnd* LibcxxVectorBoolSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - - bool - LibcxxContainerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); - - class LibstdcppMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd - { - public: - LibstdcppMapIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); - - virtual size_t - CalculateNumChildren (); - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx); - - virtual bool - Update(); - - virtual bool - MightHaveChildren (); - - virtual size_t - GetIndexOfChildWithName (const ConstString &name); - - virtual - ~LibstdcppMapIteratorSyntheticFrontEnd (); - private: - ExecutionContextRef m_exe_ctx_ref; - lldb::addr_t m_pair_address; - ClangASTType m_pair_type; - EvaluateExpressionOptions m_options; - lldb::ValueObjectSP m_pair_sp; - }; - - SyntheticChildrenFrontEnd* LibstdcppMapIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - - class LibCxxMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd - { - public: - LibCxxMapIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); - - virtual size_t - CalculateNumChildren (); - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx); - - virtual bool - Update(); - - virtual bool - MightHaveChildren (); - - virtual size_t - GetIndexOfChildWithName (const ConstString &name); - - virtual - ~LibCxxMapIteratorSyntheticFrontEnd (); - private: - ValueObject *m_pair_ptr; - }; - - SyntheticChildrenFrontEnd* LibCxxMapIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - - class VectorIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd - { - public: - VectorIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp, - ConstString item_name); - - virtual size_t - CalculateNumChildren (); - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx); - - virtual bool - Update(); - - virtual bool - MightHaveChildren (); - - virtual size_t - GetIndexOfChildWithName (const ConstString &name); - - virtual - ~VectorIteratorSyntheticFrontEnd (); - private: - ExecutionContextRef m_exe_ctx_ref; - ConstString m_item_name; - lldb::ValueObjectSP m_item_sp; - }; - - SyntheticChildrenFrontEnd* LibCxxVectorIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - - SyntheticChildrenFrontEnd* LibStdcppVectorIteratorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - - class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd - { - public: - LibcxxSharedPtrSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); - - virtual size_t - CalculateNumChildren (); - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx); - - virtual bool - Update(); - - virtual bool - MightHaveChildren (); - - virtual size_t - GetIndexOfChildWithName (const ConstString &name); - - virtual - ~LibcxxSharedPtrSyntheticFrontEnd (); - private: - ValueObject* m_cntrl; - lldb::ValueObjectSP m_count_sp; - lldb::ValueObjectSP m_weak_count_sp; - uint8_t m_ptr_size; - lldb::ByteOrder m_byte_order; - }; - - SyntheticChildrenFrontEnd* LibcxxSharedPtrSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - - SyntheticChildrenFrontEnd* LibcxxStdVectorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - - SyntheticChildrenFrontEnd* LibcxxStdListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - - SyntheticChildrenFrontEnd* LibcxxStdMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - - SyntheticChildrenFrontEnd* LibcxxStdUnorderedMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - - SyntheticChildrenFrontEnd* LibcxxInitializerListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - - SyntheticChildrenFrontEnd* VectorTypeSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - } // namespace formatters -} // namespace lldb_private - -#endif // liblldb_CXXFormatterFunctions_h_ diff --git a/include/lldb/DataFormatters/CXXFunctionPointer.h b/include/lldb/DataFormatters/CXXFunctionPointer.h new file mode 100644 index 000000000000..eaa39582eaaa --- /dev/null +++ b/include/lldb/DataFormatters/CXXFunctionPointer.h @@ -0,0 +1,23 @@ +//===-- CXXFunctionPointer.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_CXXFunctionPointer_h_ +#define liblldb_CXXFunctionPointer_h_ + +#include "lldb/lldb-forward.h" + +namespace lldb_private { + namespace formatters + { + bool + CXXFunctionPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); + } // namespace formatters +} // namespace lldb_private + +#endif // liblldb_CXXFunctionPointer_h_ diff --git a/include/lldb/DataFormatters/DataVisualization.h b/include/lldb/DataFormatters/DataVisualization.h index a0b2e58bba28..856156670c96 100644 --- a/include/lldb/DataFormatters/DataVisualization.h +++ b/include/lldb/DataFormatters/DataVisualization.h @@ -1,4 +1,4 @@ -//===-- DataVisualization.h ----------------------------------------*- C++ -*-===// +//===-- DataVisualization.h -------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -28,7 +28,6 @@ namespace lldb_private { class DataVisualization { public: - // use this call to force the FM to consider itself updated even when there is no apparent reason for that static void ForceUpdate(); @@ -83,8 +82,8 @@ public: AnyMatches(ConstString type_name, TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES, bool only_enabled = true, - const char** matching_category = NULL, - TypeCategoryImpl::FormatCategoryItems* matching_type = NULL); + const char** matching_category = nullptr, + TypeCategoryImpl::FormatCategoryItems* matching_type = nullptr); class NamedSummaryFormats { @@ -102,7 +101,7 @@ public: Clear (); static void - LoopThrough (TypeSummaryImpl::SummaryCallback callback, void* callback_baton); + ForEach (std::function<bool(ConstString, const lldb::TypeSummaryImplSP&)> callback); static uint32_t GetCount (); @@ -111,12 +110,15 @@ public: class Categories { public: - static bool GetCategory (const ConstString &category, lldb::TypeCategoryImplSP &entry, bool allow_create = true); + static bool + GetCategory (lldb::LanguageType language, + lldb::TypeCategoryImplSP &entry); + static void Add (const ConstString &category); @@ -134,7 +136,13 @@ public: TypeCategoryMap::Position = TypeCategoryMap::Default); static void + Enable (lldb::LanguageType lang_type); + + static void Disable (const ConstString& category); + + static void + Disable (lldb::LanguageType lang_type); static void Enable (const lldb::TypeCategoryImplSP& category, @@ -150,7 +158,7 @@ public: DisableStar (); static void - LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton); + ForEach (TypeCategoryMap::ForEachCallback callback); static uint32_t GetCount (); @@ -160,7 +168,6 @@ public: }; }; - } // namespace lldb_private -#endif // lldb_DataVisualization_h_ +#endif// lldb_DataVisualization_h_ diff --git a/include/lldb/DataFormatters/DumpValueObjectOptions.h b/include/lldb/DataFormatters/DumpValueObjectOptions.h new file mode 100644 index 000000000000..f65ee7b95845 --- /dev/null +++ b/include/lldb/DataFormatters/DumpValueObjectOptions.h @@ -0,0 +1,185 @@ +//===-- DumpValueObjectOptions.h --------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef lldb_DumpValueObjectOptions_h_ +#define lldb_DumpValueObjectOptions_h_ + +// C Includes +// C++ Includes +#include <string> + +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-private.h" +#include "lldb/lldb-public.h" + +#include <functional> +#include <string> + +namespace lldb_private { + +class DumpValueObjectOptions +{ +public: + struct PointerDepth + { + enum class Mode + { + Always, + Formatters, + Default, + Never + } m_mode; + uint32_t m_count; + + PointerDepth + operator --() const + { + if (m_count > 0) + return PointerDepth {m_mode,m_count-1}; + return PointerDepth {m_mode,m_count}; + } + + bool + CanAllowExpansion () const; + + bool + CanAllowExpansion (bool is_root, + TypeSummaryImpl* entry, + ValueObject *valobj, + const std::string& summary); + }; + + typedef std::function<bool(ConstString, + ConstString, + const DumpValueObjectOptions &, + Stream&)> DeclPrintingHelper; + + static const DumpValueObjectOptions + DefaultOptions() + { + static DumpValueObjectOptions g_default_options; + + return g_default_options; + } + + DumpValueObjectOptions(); + + DumpValueObjectOptions (const DumpValueObjectOptions& rhs) = default; + + DumpValueObjectOptions (ValueObject& valobj); + + DumpValueObjectOptions& + SetMaximumPointerDepth(PointerDepth depth = {PointerDepth::Mode::Never,0}); + + DumpValueObjectOptions& + SetMaximumDepth(uint32_t depth = 0); + + DumpValueObjectOptions& + SetDeclPrintingHelper(DeclPrintingHelper helper); + + DumpValueObjectOptions& + SetShowTypes(bool show = false); + + DumpValueObjectOptions& + SetShowLocation(bool show = false); + + DumpValueObjectOptions& + SetUseObjectiveC(bool use = false); + + DumpValueObjectOptions& + SetShowSummary(bool show = true); + + DumpValueObjectOptions& + SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues); + + DumpValueObjectOptions& + SetUseSyntheticValue(bool use_synthetic = true); + + DumpValueObjectOptions& + SetScopeChecked(bool check = true); + + DumpValueObjectOptions& + SetFlatOutput(bool flat = false); + + DumpValueObjectOptions& + SetOmitSummaryDepth(uint32_t depth = 0); + + DumpValueObjectOptions& + SetIgnoreCap(bool ignore = false); + + DumpValueObjectOptions& + SetRawDisplay(); + + DumpValueObjectOptions& + SetFormat (lldb::Format format = lldb::eFormatDefault); + + DumpValueObjectOptions& + SetSummary (lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP()); + + DumpValueObjectOptions& + SetRootValueObjectName(const char* name = nullptr); + + DumpValueObjectOptions& + SetHideRootType (bool hide_root_type = false); + + DumpValueObjectOptions& + SetHideName (bool hide_name = false); + + DumpValueObjectOptions& + SetHideValue (bool hide_value = false); + + DumpValueObjectOptions& + SetHidePointerValue (bool hide = false); + + DumpValueObjectOptions& + SetVariableFormatDisplayLanguage (lldb::LanguageType lang = lldb::eLanguageTypeUnknown); + + DumpValueObjectOptions& + SetRunValidator (bool run = true); + + DumpValueObjectOptions& + SetUseTypeDisplayName (bool dis = false); + + DumpValueObjectOptions& + SetAllowOnelinerMode (bool oneliner = false); + + DumpValueObjectOptions& + SetRevealEmptyAggregates (bool reveal = true); + +public: + uint32_t m_max_depth = UINT32_MAX; + lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues; + uint32_t m_omit_summary_depth = 0; + lldb::Format m_format = lldb::eFormatDefault; + lldb::TypeSummaryImplSP m_summary_sp; + std::string m_root_valobj_name; + lldb::LanguageType m_varformat_language = lldb::eLanguageTypeUnknown; + PointerDepth m_max_ptr_depth; + DeclPrintingHelper m_decl_printing_helper; + bool m_use_synthetic : 1; + bool m_scope_already_checked : 1; + bool m_flat_output : 1; + bool m_ignore_cap : 1; + bool m_show_types : 1; + bool m_show_location : 1; + bool m_use_objc : 1; + bool m_hide_root_type : 1; + bool m_hide_name : 1; + bool m_hide_value : 1; + bool m_run_validator : 1; + bool m_use_type_display_name : 1; + bool m_allow_oneliner_mode : 1; + bool m_hide_pointer_value : 1; + bool m_reveal_empty_aggregates : 1; +}; + +} // namespace lldb_private + +#endif // lldb_DumpValueObjectOptions_h_ diff --git a/include/lldb/DataFormatters/FormatCache.h b/include/lldb/DataFormatters/FormatCache.h index fa46306e5404..9f1e078f7199 100644 --- a/include/lldb/DataFormatters/FormatCache.h +++ b/include/lldb/DataFormatters/FormatCache.h @@ -19,7 +19,6 @@ #include "lldb/lldb-public.h" #include "lldb/Core/ConstString.h" #include "lldb/Host/Mutex.h" -#include "lldb/DataFormatters/FormatClasses.h" namespace lldb_private { class FormatCache diff --git a/include/lldb/DataFormatters/FormatClasses.h b/include/lldb/DataFormatters/FormatClasses.h index 651160371c69..b5ac41c2bd6e 100644 --- a/include/lldb/DataFormatters/FormatClasses.h +++ b/include/lldb/DataFormatters/FormatClasses.h @@ -10,25 +10,45 @@ #ifndef lldb_FormatClasses_h_ #define lldb_FormatClasses_h_ +// C Includes // C++ Includes +#include <functional> +#include <memory> #include <string> #include <vector> // Other libraries and framework includes - // Project includes #include "lldb/lldb-public.h" #include "lldb/lldb-enumerations.h" - -#include "lldb/Symbol/ClangASTType.h" +#include "lldb/DataFormatters/TypeFormat.h" +#include "lldb/DataFormatters/TypeSummary.h" +#include "lldb/DataFormatters/TypeSynthetic.h" +#include "lldb/DataFormatters/TypeValidator.h" +#include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Type.h" namespace lldb_private { +class HardcodedFormatters { +public: + template <typename FormatterType> + using HardcodedFormatterFinder = std::function<typename FormatterType::SharedPointer (lldb_private::ValueObject&, + lldb::DynamicValueType, + FormatManager&)>; + + template <typename FormatterType> + using HardcodedFormatterFinders = std::vector<HardcodedFormatterFinder<FormatterType>>; + + typedef HardcodedFormatterFinders<TypeFormatImpl> HardcodedFormatFinder; + typedef HardcodedFormatterFinders<TypeSummaryImpl> HardcodedSummaryFinder; + typedef HardcodedFormatterFinders<SyntheticChildren> HardcodedSyntheticFinder; + typedef HardcodedFormatterFinders<TypeValidatorImpl> HardcodedValidatorFinder; +}; + class FormattersMatchCandidate { public: - FormattersMatchCandidate (ConstString name, uint32_t reason, bool strip_ptr, @@ -41,10 +61,9 @@ public: m_stripped_typedef(strip_tydef) { } - - ~FormattersMatchCandidate () - {} - + + ~FormattersMatchCandidate() = default; + ConstString GetTypeName () const { @@ -99,6 +118,36 @@ private: }; typedef std::vector<FormattersMatchCandidate> FormattersMatchVector; +typedef std::vector<lldb::LanguageType> CandidateLanguagesVector; + +class FormattersMatchData +{ +public: + FormattersMatchData (ValueObject&, + lldb::DynamicValueType); + + FormattersMatchVector + GetMatchesVector (); + + ConstString + GetTypeForCache (); + + CandidateLanguagesVector + GetCandidateLanguages (); + + ValueObject& + GetValueObject (); + + lldb::DynamicValueType + GetDynamicValueType (); + +private: + ValueObject& m_valobj; + lldb::DynamicValueType m_dynamic_value_type; + std::pair<FormattersMatchVector,bool> m_formatters_match_vector; + ConstString m_type_for_cache; + CandidateLanguagesVector m_candidate_languages; +}; class TypeNameSpecifierImpl { @@ -130,7 +179,7 @@ public: } } - TypeNameSpecifierImpl (ClangASTType type) : + TypeNameSpecifierImpl (CompilerType type) : m_is_regex(false), m_type() { @@ -146,7 +195,7 @@ public: { if (m_type.m_type_name.size()) return m_type.m_type_name.c_str(); - return NULL; + return nullptr; } lldb::TypeSP @@ -157,12 +206,12 @@ public: return lldb::TypeSP(); } - ClangASTType - GetClangASTType () + CompilerType + GetCompilerType () { if (m_type.m_type_pair.IsValid()) - return m_type.m_type_pair.GetClangASTType(); - return ClangASTType(); + return m_type.m_type_pair.GetCompilerType(); + return CompilerType(); } bool @@ -174,19 +223,18 @@ public: private: bool m_is_regex; // this works better than TypeAndOrName because the latter only wraps a TypeSP - // whereas TypePair can also be backed by a ClangASTType + // whereas TypePair can also be backed by a CompilerType struct TypeOrName { std::string m_type_name; TypePair m_type_pair; }; TypeOrName m_type; - - + private: DISALLOW_COPY_AND_ASSIGN(TypeNameSpecifierImpl); }; } // namespace lldb_private -#endif // lldb_FormatClasses_h_ +#endif // lldb_FormatClasses_h_ diff --git a/include/lldb/DataFormatters/FormatManager.h b/include/lldb/DataFormatters/FormatManager.h index a1f4b59fb344..24ba5a7f0aa5 100644 --- a/include/lldb/DataFormatters/FormatManager.h +++ b/include/lldb/DataFormatters/FormatManager.h @@ -1,4 +1,4 @@ -//===-- FormatManager.h -------------------------------------------*- C++ -*-===// +//===-- FormatManager.h -----------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -12,6 +12,10 @@ // C Includes // C++ Includes +#include <atomic> +#include <initializer_list> +#include <map> +#include <vector> // Other libraries and framework includes // Project includes @@ -21,12 +25,10 @@ #include "lldb/DataFormatters/FormatCache.h" #include "lldb/DataFormatters/FormatClasses.h" #include "lldb/DataFormatters/FormattersContainer.h" +#include "lldb/DataFormatters/LanguageCategory.h" #include "lldb/DataFormatters/TypeCategory.h" #include "lldb/DataFormatters/TypeCategoryMap.h" -#include <atomic> -#include <functional> - namespace lldb_private { // this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization @@ -39,19 +41,12 @@ class FormatManager : public IFormatChangeListener typedef FormatMap<ConstString, TypeSummaryImpl> NamedSummariesMap; typedef TypeCategoryMap::MapType::iterator CategoryMapIterator; public: + typedef std::map<lldb::LanguageType, LanguageCategory::UniquePointer> LanguageCategories; - template <typename FormatterType> - using HardcodedFormatterFinder = std::function<typename FormatterType::SharedPointer (lldb_private::ValueObject&, - lldb::DynamicValueType, - FormatManager&)>; - - template <typename FormatterType> - using HardcodedFormatterFinders = std::vector<HardcodedFormatterFinder<FormatterType>>; - - typedef TypeCategoryMap::CallbackType CategoryCallback; - - FormatManager (); + FormatManager(); + ~FormatManager() override = default; + NamedSummariesMap& GetNamedSummaryContainer () { @@ -62,8 +57,34 @@ public: EnableCategory (const ConstString& category_name, TypeCategoryMap::Position pos = TypeCategoryMap::Default) { - m_categories_map.Enable(category_name, - pos); + EnableCategory(category_name, + pos, + std::initializer_list<lldb::LanguageType>()); + } + + void + EnableCategory (const ConstString& category_name, + TypeCategoryMap::Position pos, + lldb::LanguageType lang) + { + std::initializer_list<lldb::LanguageType> langs = {lang}; + EnableCategory(category_name, + pos, + langs); + } + + void + EnableCategory (const ConstString& category_name, + TypeCategoryMap::Position pos = TypeCategoryMap::Default, + std::initializer_list<lldb::LanguageType> langs = {}) + { + TypeCategoryMap::ValueSP category_sp; + if (m_categories_map.Get(category_name, category_sp) && category_sp) + { + m_categories_map.Enable(category_sp, pos); + for (const lldb::LanguageType lang : langs) + category_sp->AddLanguage(lang); + } } void @@ -87,16 +108,10 @@ public: } void - EnableAllCategories () - { - m_categories_map.EnableAllCategories (); - } + EnableAllCategories (); void - DisableAllCategories () - { - m_categories_map.DisableAllCategories (); - } + DisableAllCategories (); bool DeleteCategory (const ConstString& category_name) @@ -123,14 +138,11 @@ public: } void - LoopThroughCategories (CategoryCallback callback, void* param) - { - m_categories_map.LoopThrough(callback, param); - } + ForEachCategory (TypeCategoryMap::ForEachCallback callback); lldb::TypeCategoryImplSP - GetCategory (const char* category_name = NULL, - bool can_create = true) + GetCategory(const char* category_name = nullptr, + bool can_create = true) { if (!category_name) return GetCategory(m_default_category_name); @@ -182,11 +194,11 @@ public: lldb::DynamicValueType use_dynamic); bool - AnyMatches (ConstString type_name, - TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES, - bool only_enabled = true, - const char** matching_category = NULL, - TypeCategoryImpl::FormatCategoryItems* matching_type = NULL) + AnyMatches(ConstString type_name, + TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES, + bool only_enabled = true, + const char** matching_category = nullptr, + TypeCategoryImpl::FormatCategoryItems* matching_type = nullptr) { return m_categories_map.AnyMatches(type_name, items, @@ -226,29 +238,21 @@ public: ShouldPrintAsOneLiner (ValueObject& valobj); void - Changed () - { - ++m_last_revision; - m_format_cache.Clear (); - } + Changed () override; uint32_t - GetCurrentRevision () + GetCurrentRevision () override { return m_last_revision; } - - ~FormatManager () - { - } - + static FormattersMatchVector GetPossibleMatches (ValueObject& valobj, lldb::DynamicValueType use_dynamic) { FormattersMatchVector matches; GetPossibleMatches (valobj, - valobj.GetClangType(), + valobj.GetCompilerType(), lldb_private::eFormatterChoiceCriterionDirectChoice, use_dynamic, matches, @@ -258,12 +262,23 @@ public: true); return matches; } + + static ConstString + GetTypeForCache (ValueObject&, lldb::DynamicValueType); + + LanguageCategory* + GetCategoryForLanguage (lldb::LanguageType lang_type); + + static std::vector<lldb::LanguageType> + GetCandidateLanguages (lldb::LanguageType lang_type); private: + static std::vector<lldb::LanguageType> + GetCandidateLanguages (ValueObject& valobj); static void GetPossibleMatches (ValueObject& valobj, - ClangASTType clang_type, + CompilerType compiler_type, uint32_t reason, lldb::DynamicValueType use_dynamic, FormattersMatchVector& entries, @@ -271,40 +286,29 @@ private: bool did_strip_ref, bool did_strip_typedef, bool root_level = false); - + + std::atomic<uint32_t> m_last_revision; FormatCache m_format_cache; + Mutex m_language_categories_mutex; + LanguageCategories m_language_categories_map; NamedSummariesMap m_named_summaries_map; - std::atomic<uint32_t> m_last_revision; TypeCategoryMap m_categories_map; ConstString m_default_category_name; ConstString m_system_category_name; - ConstString m_gnu_cpp_category_name; - ConstString m_libcxx_category_name; - ConstString m_objc_category_name; - ConstString m_corefoundation_category_name; - ConstString m_coregraphics_category_name; - ConstString m_coreservices_category_name; ConstString m_vectortypes_category_name; - ConstString m_appkit_category_name; - ConstString m_coremedia_category_name; - - HardcodedFormatterFinders<TypeFormatImpl> m_hardcoded_formats; - HardcodedFormatterFinders<TypeSummaryImpl> m_hardcoded_summaries; - HardcodedFormatterFinders<SyntheticChildren> m_hardcoded_synthetics; - HardcodedFormatterFinders<TypeValidatorImpl> m_hardcoded_validators; lldb::TypeFormatImplSP - GetHardcodedFormat (ValueObject&,lldb::DynamicValueType); + GetHardcodedFormat (FormattersMatchData&); lldb::TypeSummaryImplSP - GetHardcodedSummaryFormat (ValueObject&,lldb::DynamicValueType); + GetHardcodedSummaryFormat (FormattersMatchData&); lldb::SyntheticChildrenSP - GetHardcodedSyntheticChildren (ValueObject&,lldb::DynamicValueType); + GetHardcodedSyntheticChildren (FormattersMatchData&); lldb::TypeValidatorImplSP - GetHardcodedValidator (ValueObject&,lldb::DynamicValueType); + GetHardcodedValidator (FormattersMatchData&); TypeCategoryMap& GetCategories () @@ -312,29 +316,20 @@ private: return m_categories_map; } - // WARNING: these are temporary functions that setup formatters - // while a few of these actually should be globally available and setup by LLDB itself - // most would actually belong to the users' lldbinit file or to some other form of configurable - // storage - void - LoadLibStdcppFormatters (); - - void - LoadLibcxxFormatters (); - + // These functions are meant to initialize formatters that are very low-level/global in nature + // and do not naturally belong in any language. The intent is that most formatters go in + // language-specific categories. Eventually, the runtimes should also be allowed to vend their + // own formatters, and then one could put formatters that depend on specific library load events + // in the language runtimes, on an as-needed basis void LoadSystemFormatters (); void - LoadObjCFormatters (); - - void - LoadCoreMediaFormatters (); + LoadVectorFormatters (); - void - LoadHardcodedFormatters (); + friend class FormattersMatchData; }; } // namespace lldb_private -#endif // lldb_FormatManager_h_ +#endif // lldb_FormatManager_h_ diff --git a/include/lldb/DataFormatters/FormattersContainer.h b/include/lldb/DataFormatters/FormattersContainer.h index daf2f24ae3e5..dcd08211f19b 100644 --- a/include/lldb/DataFormatters/FormattersContainer.h +++ b/include/lldb/DataFormatters/FormattersContainer.h @@ -1,4 +1,4 @@ -//===-- FormattersContainer.h ----------------------------------------*- C++ -*-===// +//===-- FormattersContainer.h -----------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -12,53 +12,38 @@ // C Includes // C++ Includes +#include <functional> +#include <map> +#include <memory> +#include <string> // Other libraries and framework includes -#include "clang/AST/DeclCXX.h" -#include "clang/AST/Type.h" -#include "clang/AST/DeclObjC.h" - // Project includes #include "lldb/lldb-public.h" -#include "lldb/Core/Log.h" #include "lldb/Core/RegularExpression.h" #include "lldb/Core/ValueObject.h" - #include "lldb/DataFormatters/FormatClasses.h" #include "lldb/DataFormatters/TypeFormat.h" #include "lldb/DataFormatters/TypeSummary.h" #include "lldb/DataFormatters/TypeSynthetic.h" #include "lldb/DataFormatters/TypeValidator.h" - -#include "lldb/Symbol/ClangASTContext.h" -#include "lldb/Symbol/ClangASTType.h" - -#include "lldb/Target/ObjCLanguageRuntime.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/StackFrame.h" -#include "lldb/Target/TargetList.h" - +#include "lldb/Symbol/CompilerType.h" #include "lldb/Utility/StringLexer.h" namespace lldb_private { -// this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization -// class DataVisualization is the high-level front-end of this feature -// clients should refer to that class as the entry-point into the data formatters -// unless they have a good reason to bypass it and prefer to use this file's objects directly class IFormatChangeListener { public: + virtual + ~IFormatChangeListener() = default; + virtual void Changed () = 0; - - virtual - ~IFormatChangeListener () {} - + virtual uint32_t GetCurrentRevision () = 0; - }; // if the user tries to add formatters for, say, "struct Foo" @@ -92,11 +77,10 @@ template<typename KeyType, typename ValueType> class FormatMap { public: - typedef typename ValueType::SharedPointer ValueSP; typedef std::map<KeyType, ValueSP> MapType; typedef typename MapType::iterator MapIterator; - typedef bool(*CallbackType)(void*, KeyType, const ValueSP&); + typedef std::function<bool(KeyType, const ValueSP&)> ForEachCallback; FormatMap(IFormatChangeListener* lst) : m_map(), @@ -155,7 +139,7 @@ public: } void - LoopThrough (CallbackType callback, void* param) + ForEach (ForEachCallback callback) { if (callback) { @@ -164,7 +148,7 @@ public: for (pos = m_map.begin(); pos != end; pos++) { KeyType type = pos->first; - if (!callback(param, type, pos->second)) + if (!callback(type, pos->second)) break; } } @@ -227,7 +211,6 @@ protected: friend class FormattersContainer<KeyType, ValueType>; friend class FormatManager; - }; template<typename KeyType, typename ValueType> @@ -241,7 +224,7 @@ public: typedef typename MapType::iterator MapIterator; typedef typename MapType::key_type MapKeyType; typedef typename MapType::mapped_type MapValueType; - typedef typename BackEndType::CallbackType CallbackType; + typedef typename BackEndType::ForEachCallback ForEachCallback; typedef typename std::shared_ptr<FormattersContainer<KeyType, ValueType> > SharedPointer; friend class TypeCategoryImpl; @@ -256,23 +239,23 @@ public: void Add (const MapKeyType &type, const MapValueType& entry) { - Add_Impl(type, entry, (KeyType*)NULL); + Add_Impl(type, entry, static_cast<KeyType*>(nullptr)); } bool Delete (ConstString type) { - return Delete_Impl(type, (KeyType*)NULL); + return Delete_Impl(type, static_cast<KeyType*>(nullptr)); } bool Get(ValueObject& valobj, MapValueType& entry, lldb::DynamicValueType use_dynamic, - uint32_t* why = NULL) + uint32_t* why = nullptr) { uint32_t value = lldb_private::eFormatterChoiceCriterionDirectChoice; - ClangASTType ast_type(valobj.GetClangType()); + CompilerType ast_type(valobj.GetCompilerType()); bool ret = Get(valobj, ast_type, entry, use_dynamic, value); if (ret) entry = MapValueType(entry); @@ -286,13 +269,13 @@ public: bool Get (ConstString type, MapValueType& entry) { - return Get_Impl(type, entry, (KeyType*)NULL); + return Get_Impl(type, entry, static_cast<KeyType*>(nullptr)); } bool GetExact (ConstString type, MapValueType& entry) { - return GetExact_Impl(type, entry, (KeyType*)NULL); + return GetExact_Impl(type, entry, static_cast<KeyType*>(nullptr)); } MapValueType @@ -304,7 +287,7 @@ public: lldb::TypeNameSpecifierImplSP GetTypeNameSpecifierAtIndex (size_t index) { - return GetTypeNameSpecifierAtIndex_Impl(index, (KeyType*)NULL); + return GetTypeNameSpecifierAtIndex_Impl(index, static_cast<KeyType*>(nullptr)); } void @@ -314,9 +297,9 @@ public: } void - LoopThrough (CallbackType callback, void* param) + ForEach (ForEachCallback callback) { - m_format_map.LoopThrough(callback,param); + m_format_map.ForEach(callback); } uint32_t @@ -377,7 +360,7 @@ protected: bool GetExact_Impl (ConstString type, MapValueType& entry, ConstString *dummy) { - return Get_Impl(type,entry, (KeyType*)0); + return Get_Impl(type, entry, static_cast<KeyType*>(nullptr)); } lldb::TypeNameSpecifierImplSP @@ -395,7 +378,7 @@ protected: GetTypeNameSpecifierAtIndex_Impl (size_t index, lldb::RegularExpressionSP *dummy) { lldb::RegularExpressionSP regex = m_format_map.GetKeyAtIndex(index); - if (regex.get() == NULL) + if (regex.get() == nullptr) return lldb::TypeNameSpecifierImplSP(); return lldb::TypeNameSpecifierImplSP(new TypeNameSpecifierImpl(regex->GetText(), true)); @@ -447,7 +430,6 @@ protected: { for (const FormattersMatchCandidate& candidate : candidates) { - // FIXME: could we do the IsMatch() check first? if (Get(candidate.GetTypeName(),entry)) { if (candidate.IsMatch(entry) == false) @@ -469,4 +451,4 @@ protected: } // namespace lldb_private -#endif // lldb_FormattersContainer_h_ +#endif // lldb_FormattersContainer_h_ diff --git a/include/lldb/DataFormatters/FormattersHelpers.h b/include/lldb/DataFormatters/FormattersHelpers.h new file mode 100644 index 000000000000..4627a61e94f1 --- /dev/null +++ b/include/lldb/DataFormatters/FormattersHelpers.h @@ -0,0 +1,279 @@ +//===-- FormattersHelpers.h --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef lldb_FormattersHelpers_h_ +#define lldb_FormattersHelpers_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-forward.h" +#include "lldb/lldb-enumerations.h" + +#include "lldb/DataFormatters/TypeCategory.h" +#include "lldb/DataFormatters/TypeFormat.h" +#include "lldb/DataFormatters/TypeSummary.h" +#include "lldb/DataFormatters/TypeSynthetic.h" + +namespace lldb_private { + namespace formatters { + void + AddFormat (TypeCategoryImpl::SharedPointer category_sp, + lldb::Format format, + ConstString type_name, + TypeFormatImpl::Flags flags, + bool regex = false); + + void + AddSummary(TypeCategoryImpl::SharedPointer category_sp, + lldb::TypeSummaryImplSP summary_sp, + ConstString type_name, + bool regex = false); + + void + AddStringSummary(TypeCategoryImpl::SharedPointer category_sp, + const char* string, + ConstString type_name, + TypeSummaryImpl::Flags flags, + bool regex = false); + + void + AddOneLineSummary (TypeCategoryImpl::SharedPointer category_sp, + ConstString type_name, + TypeSummaryImpl::Flags flags, + bool regex = false); + +#ifndef LLDB_DISABLE_PYTHON + void + AddCXXSummary (TypeCategoryImpl::SharedPointer category_sp, + CXXFunctionSummaryFormat::Callback funct, + const char* description, + ConstString type_name, + TypeSummaryImpl::Flags flags, + bool regex = false); + + void + AddCXXSynthetic (TypeCategoryImpl::SharedPointer category_sp, + CXXSyntheticChildren::CreateFrontEndCallback generator, + const char* description, + ConstString type_name, + ScriptedSyntheticChildren::Flags flags, + bool regex = false); + + void + AddFilter (TypeCategoryImpl::SharedPointer category_sp, + std::vector<std::string> children, + const char* description, + ConstString type_name, + ScriptedSyntheticChildren::Flags flags, + bool regex = false); +#endif + + StackFrame* + GetViableFrame (ExecutionContext exe_ctx); + + bool + ExtractValueFromObjCExpression (ValueObject &valobj, + const char* target_type, + const char* selector, + uint64_t &value); + + bool + ExtractSummaryFromObjCExpression (ValueObject &valobj, + const char* target_type, + const char* selector, + Stream &stream, + lldb::LanguageType lang_type); + + lldb::ValueObjectSP + CallSelectorOnObject (ValueObject &valobj, + const char* return_type, + const char* selector, + uint64_t index); + + lldb::ValueObjectSP + CallSelectorOnObject (ValueObject &valobj, + const char* return_type, + const char* selector, + const char* key); + + size_t + ExtractIndexFromString (const char* item_name); + + lldb::addr_t + GetArrayAddressOrPointerValue (ValueObject& valobj); + + time_t + GetOSXEpoch (); + + struct InferiorSizedWord { + + InferiorSizedWord(const InferiorSizedWord& word) : ptr_size(word.ptr_size) + { + if (ptr_size == 4) + thirty_two = word.thirty_two; + else + sixty_four = word.sixty_four; + } + + InferiorSizedWord + operator = (const InferiorSizedWord& word) + { + ptr_size = word.ptr_size; + if (ptr_size == 4) + thirty_two = word.thirty_two; + else + sixty_four = word.sixty_four; + return *this; + } + + InferiorSizedWord(uint64_t val, Process& process) : ptr_size(process.GetAddressByteSize()) + { + if (ptr_size == 4) + thirty_two = (uint32_t)val; + else if (ptr_size == 8) + sixty_four = val; + else + assert (false && "new pointer size is unknown"); + } + + bool + IsNegative () const + { + if (ptr_size == 4) + return ((int32_t)thirty_two) < 0; + else + return ((int64_t)sixty_four) < 0; + } + + bool + IsZero () const + { + if (ptr_size == 4) + return thirty_two == 0; + else + return sixty_four == 0; + } + + static InferiorSizedWord + GetMaximum (Process& process) + { + if (process.GetAddressByteSize() == 4) + return InferiorSizedWord(UINT32_MAX,4); + else + return InferiorSizedWord(UINT64_MAX,8); + } + + InferiorSizedWord + operator >> (int rhs) const + { + if (ptr_size == 4) + return InferiorSizedWord(thirty_two >> rhs,4); + return InferiorSizedWord(sixty_four>>rhs,8); + } + + InferiorSizedWord + operator << (int rhs) const + { + if (ptr_size == 4) + return InferiorSizedWord(thirty_two << rhs,4); + return InferiorSizedWord(sixty_four << rhs,8); + } + + InferiorSizedWord + operator & (const InferiorSizedWord& word) const + { + if (ptr_size != word.ptr_size) + return InferiorSizedWord(0,ptr_size); + if (ptr_size == 4) + return InferiorSizedWord(thirty_two & word.thirty_two,4); + return InferiorSizedWord(sixty_four & word.sixty_four,8); + } + + InferiorSizedWord + operator & (int x) const + { + if (ptr_size == 4) + return InferiorSizedWord(thirty_two & x,4); + return InferiorSizedWord(sixty_four & x,8); + } + + size_t + GetBitSize () const + { + return ptr_size << 3; + } + + size_t + GetByteSize () const + { + return ptr_size; + } + + uint64_t + GetValue () const + { + if (ptr_size == 4) + return (uint64_t)thirty_two; + return sixty_four; + } + + InferiorSizedWord + SignExtend () const + { + if (ptr_size == 4) + return InferiorSizedWord ((int32_t)thirty_two,4); + return InferiorSizedWord((int64_t)sixty_four,8); + } + + uint8_t* + CopyToBuffer (uint8_t* buffer) const + { + if (ptr_size == 4) + { + memcpy(buffer, &thirty_two, 4); + return buffer + 4; + } + else + { + memcpy(buffer, &sixty_four, 8); + return buffer + 8; + } + } + + DataExtractor + GetAsData (lldb::ByteOrder byte_order = lldb::eByteOrderInvalid) const + { + if (ptr_size == 4) + return DataExtractor(&thirty_two, 4, byte_order, 4); + else + return DataExtractor(&sixty_four, 8, byte_order, 8); + } + + private: + + InferiorSizedWord(uint64_t val, size_t psz) : ptr_size(psz) + { + if (ptr_size == 4) + thirty_two = (uint32_t)val; + else + sixty_four = val; + } + + size_t ptr_size; + union { + uint32_t thirty_two; + uint64_t sixty_four; + }; + }; + } // namespace formatters +} // namespace lldb_private + +#endif // lldb_FormattersHelpers_h_ diff --git a/include/lldb/DataFormatters/LanguageCategory.h b/include/lldb/DataFormatters/LanguageCategory.h new file mode 100644 index 000000000000..a7040099f213 --- /dev/null +++ b/include/lldb/DataFormatters/LanguageCategory.h @@ -0,0 +1,99 @@ +//===-- LanguageCategory.h----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef lldb_LanguageCategory_h_ +#define lldb_LanguageCategory_h_ + +// C Includes +// C++ Includes + +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-public.h" +#include "lldb/DataFormatters/FormatCache.h" +#include "lldb/DataFormatters/FormatClasses.h" + +#include <memory> + +namespace lldb_private { + +class LanguageCategory +{ +public: + typedef std::unique_ptr<LanguageCategory> UniquePointer; + + LanguageCategory (lldb::LanguageType lang_type); + + bool + Get (FormattersMatchData& match_data, + lldb::TypeFormatImplSP& format_sp); + + bool + Get (FormattersMatchData& match_data, + lldb::TypeSummaryImplSP& format_sp); + + bool + Get (FormattersMatchData& match_data, + lldb::SyntheticChildrenSP& format_sp); + + bool + Get (FormattersMatchData& match_data, + lldb::TypeValidatorImplSP& format_sp); + + bool + GetHardcoded (FormatManager& fmt_mgr, + FormattersMatchData& match_data, + lldb::TypeFormatImplSP& format_sp); + + bool + GetHardcoded (FormatManager& fmt_mgr, + FormattersMatchData& match_data, + lldb::TypeSummaryImplSP& format_sp); + + bool + GetHardcoded (FormatManager& fmt_mgr, + FormattersMatchData& match_data, + lldb::SyntheticChildrenSP& format_sp); + + bool + GetHardcoded (FormatManager& fmt_mgr, + FormattersMatchData& match_data, + lldb::TypeValidatorImplSP& format_sp); + + lldb::TypeCategoryImplSP + GetCategory () const; + + FormatCache& + GetFormatCache (); + + void + Enable (); + + void + Disable (); + + bool + IsEnabled (); + +private: + lldb::TypeCategoryImplSP m_category_sp; + + HardcodedFormatters::HardcodedFormatFinder m_hardcoded_formats; + HardcodedFormatters::HardcodedSummaryFinder m_hardcoded_summaries; + HardcodedFormatters::HardcodedSyntheticFinder m_hardcoded_synthetics; + HardcodedFormatters::HardcodedValidatorFinder m_hardcoded_validators; + + lldb_private::FormatCache m_format_cache; + + bool m_enabled; +}; + +} // namespace lldb_private + +#endif // lldb_LanguageCategory_h_ diff --git a/include/lldb/DataFormatters/StringPrinter.h b/include/lldb/DataFormatters/StringPrinter.h index 48e27ace5d92..a849c4e01109 100644 --- a/include/lldb/DataFormatters/StringPrinter.h +++ b/include/lldb/DataFormatters/StringPrinter.h @@ -10,6 +10,13 @@ #ifndef liblldb_StringPrinter_h_ #define liblldb_StringPrinter_h_ +// C Includes +// C++ Includes +#include <functional> +#include <string> + +// Other libraries and framework includes +// Project includes #include "lldb/lldb-forward.h" #include "lldb/Core/DataExtractor.h" @@ -17,273 +24,505 @@ namespace lldb_private { namespace formatters { - - enum class StringElementType { - ASCII, - UTF8, - UTF16, - UTF32 - }; - - class ReadStringAndDumpToStreamOptions + class StringPrinter { public: - - ReadStringAndDumpToStreamOptions () : - m_location(0), - m_process_sp(), - m_stream(NULL), - m_prefix_token(0), - m_quote('"'), - m_source_size(0), - m_needs_zero_termination(true), - m_escape_non_printables(true), - m_ignore_max_length(false) - { - } - - ReadStringAndDumpToStreamOptions (ValueObject& valobj); - - ReadStringAndDumpToStreamOptions& - SetLocation (uint64_t l) - { - m_location = l; - return *this; - } - - uint64_t - GetLocation () const - { - return m_location; - } - - ReadStringAndDumpToStreamOptions& - SetProcessSP (lldb::ProcessSP p) - { - m_process_sp = p; - return *this; - } - - lldb::ProcessSP - GetProcessSP () const - { - return m_process_sp; - } - - ReadStringAndDumpToStreamOptions& - SetStream (Stream* s) - { - m_stream = s; - return *this; - } - - Stream* - GetStream () const - { - return m_stream; - } - - ReadStringAndDumpToStreamOptions& - SetPrefixToken (char p) - { - m_prefix_token = p; - return *this; - } - - char - GetPrefixToken () const - { - return m_prefix_token; - } - - ReadStringAndDumpToStreamOptions& - SetQuote (char q) - { - m_quote = q; - return *this; - } - - char - GetQuote () const - { - return m_quote; - } - - ReadStringAndDumpToStreamOptions& - SetSourceSize (uint32_t s) - { - m_source_size = s; - return *this; - } - - uint32_t - GetSourceSize () const - { - return m_source_size; - } - - ReadStringAndDumpToStreamOptions& - SetNeedsZeroTermination (bool z) - { - m_needs_zero_termination = z; - return *this; - } - - bool - GetNeedsZeroTermination () const - { - return m_needs_zero_termination; - } - - ReadStringAndDumpToStreamOptions& - SetEscapeNonPrintables (bool e) - { - m_escape_non_printables = e; - return *this; - } - - bool - GetEscapeNonPrintables () const - { - return m_escape_non_printables; - } - - ReadStringAndDumpToStreamOptions& - SetIgnoreMaxLength (bool e) - { - m_ignore_max_length = e; - return *this; - } - - bool - GetIgnoreMaxLength () const - { - return m_ignore_max_length; - } - - private: - uint64_t m_location; - lldb::ProcessSP m_process_sp; - Stream* m_stream; - char m_prefix_token; - char m_quote; - uint32_t m_source_size; - bool m_needs_zero_termination; - bool m_escape_non_printables; - bool m_ignore_max_length; - }; - - class ReadBufferAndDumpToStreamOptions - { - public: - - ReadBufferAndDumpToStreamOptions () : - m_data(), - m_stream(NULL), - m_prefix_token(0), - m_quote('"'), - m_source_size(0), - m_escape_non_printables(true) - { - } - - ReadBufferAndDumpToStreamOptions (ValueObject& valobj); - - ReadBufferAndDumpToStreamOptions& - SetData (DataExtractor d) - { - m_data = d; - return *this; - } - - lldb_private::DataExtractor - GetData () const - { - return m_data; - } - - ReadBufferAndDumpToStreamOptions& - SetStream (Stream* s) - { - m_stream = s; - return *this; - } - - Stream* - GetStream () const - { - return m_stream; - } - - ReadBufferAndDumpToStreamOptions& - SetPrefixToken (char p) - { - m_prefix_token = p; - return *this; - } - - char - GetPrefixToken () const - { - return m_prefix_token; - } - - ReadBufferAndDumpToStreamOptions& - SetQuote (char q) - { - m_quote = q; - return *this; - } - - char - GetQuote () const - { - return m_quote; - } - - ReadBufferAndDumpToStreamOptions& - SetSourceSize (uint32_t s) - { - m_source_size = s; - return *this; - } - - uint32_t - GetSourceSize () const - { - return m_source_size; - } - - ReadBufferAndDumpToStreamOptions& - SetEscapeNonPrintables (bool e) - { - m_escape_non_printables = e; - return *this; - } - - bool - GetEscapeNonPrintables () const - { - return m_escape_non_printables; - } - - private: - DataExtractor m_data; - Stream* m_stream; - char m_prefix_token; - char m_quote; - uint32_t m_source_size; - bool m_escape_non_printables; + enum class StringElementType + { + ASCII, + UTF8, + UTF16, + UTF32 + }; + + enum class GetPrintableElementType + { + ASCII, + UTF8 + }; + + class ReadStringAndDumpToStreamOptions + { + public: + ReadStringAndDumpToStreamOptions () : + m_location(0), + m_process_sp(), + m_stream(nullptr), + m_prefix_token(), + m_suffix_token(), + m_quote('"'), + m_source_size(0), + m_needs_zero_termination(true), + m_escape_non_printables(true), + m_ignore_max_length(false), + m_zero_is_terminator(true), + m_language_type(lldb::eLanguageTypeUnknown) + { + } + + ReadStringAndDumpToStreamOptions (ValueObject& valobj); + + ReadStringAndDumpToStreamOptions& + SetLocation (uint64_t l) + { + m_location = l; + return *this; + } + + uint64_t + GetLocation () const + { + return m_location; + } + + ReadStringAndDumpToStreamOptions& + SetProcessSP (lldb::ProcessSP p) + { + m_process_sp = p; + return *this; + } + + lldb::ProcessSP + GetProcessSP () const + { + return m_process_sp; + } + + ReadStringAndDumpToStreamOptions& + SetStream (Stream* s) + { + m_stream = s; + return *this; + } + + Stream* + GetStream () const + { + return m_stream; + } + + ReadStringAndDumpToStreamOptions& + SetPrefixToken (const std::string& p) + { + m_prefix_token = p; + return *this; + } + + ReadStringAndDumpToStreamOptions& + SetPrefixToken (std::nullptr_t) + { + m_prefix_token.clear(); + return *this; + } + + const char* + GetPrefixToken () const + { + return m_prefix_token.c_str(); + } + + ReadStringAndDumpToStreamOptions& + SetSuffixToken (const std::string& p) + { + m_suffix_token = p; + return *this; + } + + ReadStringAndDumpToStreamOptions& + SetSuffixToken (std::nullptr_t) + { + m_suffix_token.clear(); + return *this; + } + + const char* + GetSuffixToken () const + { + return m_suffix_token.c_str(); + } + + ReadStringAndDumpToStreamOptions& + SetQuote (char q) + { + m_quote = q; + return *this; + } + + char + GetQuote () const + { + return m_quote; + } + + ReadStringAndDumpToStreamOptions& + SetSourceSize (uint32_t s) + { + m_source_size = s; + return *this; + } + + uint32_t + GetSourceSize () const + { + return m_source_size; + } + + ReadStringAndDumpToStreamOptions& + SetNeedsZeroTermination (bool z) + { + m_needs_zero_termination = z; + return *this; + } + + bool + GetNeedsZeroTermination () const + { + return m_needs_zero_termination; + } + + ReadStringAndDumpToStreamOptions& + SetBinaryZeroIsTerminator (bool e) + { + m_zero_is_terminator = e; + return *this; + } + + bool + GetBinaryZeroIsTerminator () const + { + return m_zero_is_terminator; + } + + ReadStringAndDumpToStreamOptions& + SetEscapeNonPrintables (bool e) + { + m_escape_non_printables = e; + return *this; + } + + bool + GetEscapeNonPrintables () const + { + return m_escape_non_printables; + } + + ReadStringAndDumpToStreamOptions& + SetIgnoreMaxLength (bool e) + { + m_ignore_max_length = e; + return *this; + } + + bool + GetIgnoreMaxLength () const + { + return m_ignore_max_length; + } + + ReadStringAndDumpToStreamOptions& + SetLanguage (lldb::LanguageType l) + { + m_language_type = l; + return *this; + } + + lldb::LanguageType + GetLanguage () const + + { + return m_language_type; + } + + private: + uint64_t m_location; + lldb::ProcessSP m_process_sp; + Stream* m_stream; + std::string m_prefix_token; + std::string m_suffix_token; + char m_quote; + uint32_t m_source_size; + bool m_needs_zero_termination; + bool m_escape_non_printables; + bool m_ignore_max_length; + bool m_zero_is_terminator; + lldb::LanguageType m_language_type; + }; + + class ReadBufferAndDumpToStreamOptions + { + public: + ReadBufferAndDumpToStreamOptions () : + m_data(), + m_stream(nullptr), + m_prefix_token(), + m_suffix_token(), + m_quote('"'), + m_source_size(0), + m_escape_non_printables(true), + m_zero_is_terminator(true), + m_is_truncated(false), + m_language_type(lldb::eLanguageTypeUnknown) + { + } + + ReadBufferAndDumpToStreamOptions (ValueObject& valobj); + + ReadBufferAndDumpToStreamOptions (const ReadStringAndDumpToStreamOptions& options); + + ReadBufferAndDumpToStreamOptions& + SetData (DataExtractor d) + { + m_data = d; + return *this; + } + + lldb_private::DataExtractor + GetData () const + { + return m_data; + } + + ReadBufferAndDumpToStreamOptions& + SetStream (Stream* s) + { + m_stream = s; + return *this; + } + + Stream* + GetStream () const + { + return m_stream; + } + + ReadBufferAndDumpToStreamOptions& + SetPrefixToken (const std::string& p) + { + m_prefix_token = p; + return *this; + } + + ReadBufferAndDumpToStreamOptions& + SetPrefixToken (std::nullptr_t) + { + m_prefix_token.clear(); + return *this; + } + + const char* + GetPrefixToken () const + { + return m_prefix_token.c_str(); + } + + ReadBufferAndDumpToStreamOptions& + SetSuffixToken (const std::string& p) + { + m_suffix_token = p; + return *this; + } + + ReadBufferAndDumpToStreamOptions& + SetSuffixToken (std::nullptr_t) + { + m_suffix_token.clear(); + return *this; + } + + const char* + GetSuffixToken () const + { + return m_suffix_token.c_str(); + } + + ReadBufferAndDumpToStreamOptions& + SetQuote (char q) + { + m_quote = q; + return *this; + } + + char + GetQuote () const + { + return m_quote; + } + + ReadBufferAndDumpToStreamOptions& + SetSourceSize (uint32_t s) + { + m_source_size = s; + return *this; + } + + uint32_t + GetSourceSize () const + { + return m_source_size; + } + + ReadBufferAndDumpToStreamOptions& + SetEscapeNonPrintables (bool e) + { + m_escape_non_printables = e; + return *this; + } + + bool + GetEscapeNonPrintables () const + { + return m_escape_non_printables; + } + + ReadBufferAndDumpToStreamOptions& + SetBinaryZeroIsTerminator (bool e) + { + m_zero_is_terminator = e; + return *this; + } + + bool + GetBinaryZeroIsTerminator () const + { + return m_zero_is_terminator; + } + + ReadBufferAndDumpToStreamOptions& + SetIsTruncated (bool t) + { + m_is_truncated = t; + return *this; + } + + bool + GetIsTruncated () const + { + return m_is_truncated; + } + + ReadBufferAndDumpToStreamOptions& + SetLanguage (lldb::LanguageType l) + { + m_language_type = l; + return *this; + } + + lldb::LanguageType + GetLanguage () const + + { + return m_language_type; + } + + private: + DataExtractor m_data; + Stream* m_stream; + std::string m_prefix_token; + std::string m_suffix_token; + char m_quote; + uint32_t m_source_size; + bool m_escape_non_printables; + bool m_zero_is_terminator; + bool m_is_truncated; + lldb::LanguageType m_language_type; + }; + + // I can't use a std::unique_ptr for this because the Deleter is a template argument there + // and I want the same type to represent both pointers I want to free and pointers I don't need + // to free - which is what this class essentially is + // It's very specialized to the needs of this file, and not suggested for general use + template <typename T = uint8_t, typename U = char, typename S = size_t> + struct StringPrinterBufferPointer + { + public: + typedef std::function<void(const T*)> Deleter; + + StringPrinterBufferPointer (std::nullptr_t ptr) : + m_data(nullptr), + m_size(0), + m_deleter() + {} + + StringPrinterBufferPointer(const T* bytes, S size, Deleter deleter = nullptr) : + m_data(bytes), + m_size(size), + m_deleter(deleter) + {} + + StringPrinterBufferPointer(const U* bytes, S size, Deleter deleter = nullptr) : + m_data(reinterpret_cast<const T*>(bytes)), + m_size(size), + m_deleter(deleter) + {} + + StringPrinterBufferPointer(StringPrinterBufferPointer&& rhs) : + m_data(rhs.m_data), + m_size(rhs.m_size), + m_deleter(rhs.m_deleter) + { + rhs.m_data = nullptr; + } + + StringPrinterBufferPointer(const StringPrinterBufferPointer& rhs) : + m_data(rhs.m_data), + m_size(rhs.m_size), + m_deleter(rhs.m_deleter) + { + rhs.m_data = nullptr; // this is why m_data has to be mutable + } + + ~StringPrinterBufferPointer() + { + if (m_data && m_deleter) + m_deleter(m_data); + m_data = nullptr; + } + + const T* + GetBytes () const + { + return m_data; + } + + const S + GetSize () const + { + return m_size; + } + + StringPrinterBufferPointer& + operator = (const StringPrinterBufferPointer& rhs) + { + if (m_data && m_deleter) + m_deleter(m_data); + m_data = rhs.m_data; + m_size = rhs.m_size; + m_deleter = rhs.m_deleter; + rhs.m_data = nullptr; + return *this; + } + + private: + mutable const T* m_data; + size_t m_size; + Deleter m_deleter; + }; + + typedef std::function<StringPrinter::StringPrinterBufferPointer<uint8_t,char,size_t>(uint8_t*, uint8_t*, uint8_t*&)> EscapingHelper; + typedef std::function<EscapingHelper(GetPrintableElementType)> EscapingHelperGenerator; + + static EscapingHelper + GetDefaultEscapingHelper (GetPrintableElementType elem_type); + + template <StringElementType element_type> + static bool + ReadStringAndDumpToStream (const ReadStringAndDumpToStreamOptions& options); + + template <StringElementType element_type> + static bool + ReadBufferAndDumpToStream (const ReadBufferAndDumpToStreamOptions& options); }; - template <StringElementType element_type> - bool - ReadStringAndDumpToStream (ReadStringAndDumpToStreamOptions options); - - template <StringElementType element_type> - bool - ReadBufferAndDumpToStream (ReadBufferAndDumpToStreamOptions options); - } // namespace formatters } // namespace lldb_private diff --git a/include/lldb/DataFormatters/TypeCategory.h b/include/lldb/DataFormatters/TypeCategory.h index e32efa420a55..075d31d1cf6f 100644 --- a/include/lldb/DataFormatters/TypeCategory.h +++ b/include/lldb/DataFormatters/TypeCategory.h @@ -1,4 +1,4 @@ -//===-- TypeCategory.h -------------------------------------------*- C++ -*-===// +//===-- TypeCategory.h ------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -12,6 +12,10 @@ // C Includes // C++ Includes +#include <initializer_list> +#include <memory> +#include <string> +#include <vector> // Other libraries and framework includes // Project includes @@ -38,6 +42,9 @@ namespace lldb_private { typedef typename ExactMatchContainer::SharedPointer ExactMatchContainerSP; typedef typename RegexMatchContainer::SharedPointer RegexMatchContainerSP; + typedef typename ExactMatchContainer::ForEachCallback ExactMatchForEachCallback; + typedef typename RegexMatchContainer::ForEachCallback RegexMatchForEachCallback; + FormatterContainerPair (const char* exact_name, const char* regex_name, IFormatChangeListener* clist) : @@ -60,6 +67,12 @@ namespace lldb_private { return m_regex_sp; } + uint32_t + GetCount () + { + return GetExactMatch()->GetCount() + GetRegexMatch()->GetCount(); + } + private: ExactMatchContainerSP m_exact_sp; RegexMatchContainerSP m_regex_sp; @@ -74,11 +87,10 @@ namespace lldb_private { typedef FormatterContainerPair<TypeValidatorImpl> ValidatorContainer; #ifndef LLDB_DISABLE_PYTHON - typedef FormatterContainerPair<ScriptedSyntheticChildren> SynthContainer; -#endif // #ifndef LLDB_DISABLE_PYTHON + typedef FormatterContainerPair<SyntheticChildren> SynthContainer; +#endif // LLDB_DISABLE_PYTHON public: - typedef uint16_t FormatCategoryItems; static const uint16_t ALL_ITEM_TYPES = UINT16_MAX; @@ -93,13 +105,195 @@ namespace lldb_private { #ifndef LLDB_DISABLE_PYTHON typedef SynthContainer::ExactMatchContainerSP SynthContainerSP; typedef SynthContainer::RegexMatchContainerSP RegexSynthContainerSP; -#endif // #ifndef LLDB_DISABLE_PYTHON +#endif // LLDB_DISABLE_PYTHON typedef ValidatorContainer::ExactMatchContainerSP ValidatorContainerSP; typedef ValidatorContainer::RegexMatchContainerSP RegexValidatorContainerSP; + template <typename T> + class ForEachCallbacks + { + public: + ForEachCallbacks () = default; + ~ForEachCallbacks () = default; + + template<typename U = TypeFormatImpl> + typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type + SetExact (FormatContainer::ExactMatchForEachCallback callback) + { + m_format_exact = callback; + return *this; + } + template<typename U = TypeFormatImpl> + typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type + SetWithRegex (FormatContainer::RegexMatchForEachCallback callback) + { + m_format_regex = callback; + return *this; + } + + template<typename U = TypeSummaryImpl> + typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type + SetExact (SummaryContainer::ExactMatchForEachCallback callback) + { + m_summary_exact = callback; + return *this; + } + template<typename U = TypeSummaryImpl> + typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type + SetWithRegex (SummaryContainer::RegexMatchForEachCallback callback) + { + m_summary_regex = callback; + return *this; + } + + template<typename U = TypeFilterImpl> + typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type + SetExact (FilterContainer::ExactMatchForEachCallback callback) + { + m_filter_exact = callback; + return *this; + } + template<typename U = TypeFilterImpl> + typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type + SetWithRegex (FilterContainer::RegexMatchForEachCallback callback) + { + m_filter_regex = callback; + return *this; + } + +#ifndef LLDB_DISABLE_PYTHON + template<typename U = SyntheticChildren> + typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type + SetExact (SynthContainer::ExactMatchForEachCallback callback) + { + m_synth_exact = callback; + return *this; + } + template<typename U = SyntheticChildren> + typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type + SetWithRegex (SynthContainer::RegexMatchForEachCallback callback) + { + m_synth_regex = callback; + return *this; + } +#endif // LLDB_DISABLE_PYTHON + template<typename U = TypeValidatorImpl> + typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type + SetExact (ValidatorContainer::ExactMatchForEachCallback callback) + { + m_validator_exact = callback; + return *this; + } + template<typename U = TypeValidatorImpl> + typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type + SetWithRegex (ValidatorContainer::RegexMatchForEachCallback callback) + { + m_validator_regex = callback; + return *this; + } + + FormatContainer::ExactMatchForEachCallback + GetFormatExactCallback () const + { + return m_format_exact; + } + FormatContainer::RegexMatchForEachCallback + GetFormatRegexCallback () const + { + return m_format_regex; + } + + SummaryContainer::ExactMatchForEachCallback + GetSummaryExactCallback () const + { + return m_summary_exact; + } + SummaryContainer::RegexMatchForEachCallback + GetSummaryRegexCallback () const + { + return m_summary_regex; + } + + FilterContainer::ExactMatchForEachCallback + GetFilterExactCallback () const + { + return m_filter_exact; + } + FilterContainer::RegexMatchForEachCallback + GetFilterRegexCallback () const + { + return m_filter_regex; + } + +#ifndef LLDB_DISABLE_PYTHON + SynthContainer::ExactMatchForEachCallback + GetSynthExactCallback () const + { + return m_synth_exact; + } + SynthContainer::RegexMatchForEachCallback + GetSynthRegexCallback () const + { + return m_synth_regex; + } +#endif // LLDB_DISABLE_PYTHON + + ValidatorContainer::ExactMatchForEachCallback + GetValidatorExactCallback () const + { + return m_validator_exact; + } + ValidatorContainer::RegexMatchForEachCallback + GetValidatorRegexCallback () const + { + return m_validator_regex; + } + + private: + FormatContainer::ExactMatchForEachCallback m_format_exact; + FormatContainer::RegexMatchForEachCallback m_format_regex; + + SummaryContainer::ExactMatchForEachCallback m_summary_exact; + SummaryContainer::RegexMatchForEachCallback m_summary_regex; + + FilterContainer::ExactMatchForEachCallback m_filter_exact; + FilterContainer::RegexMatchForEachCallback m_filter_regex; + +#ifndef LLDB_DISABLE_PYTHON + SynthContainer::ExactMatchForEachCallback m_synth_exact; + SynthContainer::RegexMatchForEachCallback m_synth_regex; +#endif // LLDB_DISABLE_PYTHON + + ValidatorContainer::ExactMatchForEachCallback m_validator_exact; + ValidatorContainer::RegexMatchForEachCallback m_validator_regex; + }; + TypeCategoryImpl (IFormatChangeListener* clist, - ConstString name); + ConstString name, + std::initializer_list<lldb::LanguageType> langs = {}); + + template <typename T> + void + ForEach (const ForEachCallbacks<T> &foreach) + { + GetTypeFormatsContainer()->ForEach(foreach.GetFormatExactCallback()); + GetRegexTypeFormatsContainer()->ForEach(foreach.GetFormatRegexCallback()); + + GetTypeSummariesContainer()->ForEach(foreach.GetSummaryExactCallback()); + GetRegexTypeSummariesContainer()->ForEach(foreach.GetSummaryRegexCallback()); + + GetTypeFiltersContainer()->ForEach(foreach.GetFilterExactCallback()); + GetRegexTypeFiltersContainer()->ForEach(foreach.GetFilterRegexCallback()); + +#ifndef LLDB_DISABLE_PYTHON + GetTypeSyntheticsContainer()->ForEach(foreach.GetSynthExactCallback()); + GetRegexTypeSyntheticsContainer()->ForEach(foreach.GetSynthRegexCallback()); +#endif // LLDB_DISABLE_PYTHON + + GetTypeValidatorsContainer()->ForEach(foreach.GetValidatorExactCallback()); + GetRegexTypeValidatorsContainer()->ForEach(foreach.GetValidatorRegexCallback()); + } FormatContainerSP GetTypeFormatsContainer () @@ -113,6 +307,12 @@ namespace lldb_private { return m_format_cont.GetRegexMatch(); } + FormatContainer& + GetFormatContainer () + { + return m_format_cont; + } + SummaryContainerSP GetTypeSummariesContainer () { @@ -125,6 +325,12 @@ namespace lldb_private { return m_summary_cont.GetRegexMatch(); } + SummaryContainer& + GetSummaryContainer () + { + return m_summary_cont; + } + FilterContainerSP GetTypeFiltersContainer () { @@ -136,6 +342,12 @@ namespace lldb_private { { return m_filter_cont.GetRegexMatch(); } + + FilterContainer& + GetFilterContainer () + { + return m_filter_cont; + } FormatContainer::MapValueType GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp); @@ -185,12 +397,18 @@ namespace lldb_private { return m_synth_cont.GetRegexMatch(); } + SynthContainer& + GetSyntheticsContainer () + { + return m_synth_cont; + } + SynthContainer::MapValueType GetSyntheticAtIndex (size_t index); lldb::TypeNameSpecifierImplSP GetTypeNameSpecifierForSyntheticAtIndex (size_t index); -#endif // #ifndef LLDB_DISABLE_PYTHON +#endif // LLDB_DISABLE_PYTHON ValidatorContainerSP GetTypeValidatorsContainer () @@ -226,28 +444,28 @@ namespace lldb_private { } bool - Get (ValueObject& valobj, - const FormattersMatchVector& candidates, - lldb::TypeFormatImplSP& entry, - uint32_t* reason = NULL); + Get(ValueObject& valobj, + const FormattersMatchVector& candidates, + lldb::TypeFormatImplSP& entry, + uint32_t* reason = nullptr); bool - Get (ValueObject& valobj, - const FormattersMatchVector& candidates, - lldb::TypeSummaryImplSP& entry, - uint32_t* reason = NULL); + Get(ValueObject& valobj, + const FormattersMatchVector& candidates, + lldb::TypeSummaryImplSP& entry, + uint32_t* reason = nullptr); bool - Get (ValueObject& valobj, - const FormattersMatchVector& candidates, - lldb::SyntheticChildrenSP& entry, - uint32_t* reason = NULL); + Get(ValueObject& valobj, + const FormattersMatchVector& candidates, + lldb::SyntheticChildrenSP& entry, + uint32_t* reason = nullptr); bool - Get (ValueObject& valobj, - const FormattersMatchVector& candidates, - lldb::TypeValidatorImplSP& entry, - uint32_t* reason = NULL); + Get(ValueObject& valobj, + const FormattersMatchVector& candidates, + lldb::TypeValidatorImplSP& entry, + uint32_t* reason = nullptr); void Clear (FormatCategoryItems items = ALL_ITEM_TYPES); @@ -264,13 +482,28 @@ namespace lldb_private { { return m_name.GetCString(); } + + size_t + GetNumLanguages (); + + lldb::LanguageType + GetLanguageAtIndex (size_t idx); + + void + AddLanguage (lldb::LanguageType lang); bool - AnyMatches (ConstString type_name, - FormatCategoryItems items = ALL_ITEM_TYPES, - bool only_enabled = true, - const char** matching_category = NULL, - FormatCategoryItems* matching_type = NULL); + HasLanguage (lldb::LanguageType lang); + + std::string + GetDescription (); + + bool + AnyMatches(ConstString type_name, + FormatCategoryItems items = ALL_ITEM_TYPES, + bool only_enabled = true, + const char** matching_category = nullptr, + FormatCategoryItems* matching_type = nullptr); typedef std::shared_ptr<TypeCategoryImpl> SharedPointer; @@ -280,7 +513,7 @@ namespace lldb_private { FilterContainer m_filter_cont; #ifndef LLDB_DISABLE_PYTHON SynthContainer m_synth_cont; -#endif // #ifndef LLDB_DISABLE_PYTHON +#endif // LLDB_DISABLE_PYTHON ValidatorContainer m_validator_cont; bool m_enabled; @@ -291,6 +524,8 @@ namespace lldb_private { ConstString m_name; + std::vector<lldb::LanguageType> m_languages; + uint32_t m_enabled_position; void @@ -302,6 +537,9 @@ namespace lldb_private { Enable(false, UINT32_MAX); } + bool + IsApplicable (ValueObject& valobj); + uint32_t GetLastEnabledPosition () { @@ -314,6 +552,8 @@ namespace lldb_private { m_enabled_position = p; } + friend class FormatManager; + friend class LanguageCategory; friend class TypeCategoryMap; friend class FormattersContainer<ConstString, TypeFormatImpl>; @@ -328,7 +568,7 @@ namespace lldb_private { #ifndef LLDB_DISABLE_PYTHON friend class FormattersContainer<ConstString, ScriptedSyntheticChildren>; friend class FormattersContainer<lldb::RegularExpressionSP, ScriptedSyntheticChildren>; -#endif // #ifndef LLDB_DISABLE_PYTHON +#endif // LLDB_DISABLE_PYTHON friend class FormattersContainer<ConstString, TypeValidatorImpl>; friend class FormattersContainer<lldb::RegularExpressionSP, TypeValidatorImpl>; @@ -336,4 +576,4 @@ namespace lldb_private { } // namespace lldb_private -#endif // lldb_TypeCategory_h_ +#endif // lldb_TypeCategory_h_ diff --git a/include/lldb/DataFormatters/TypeCategoryMap.h b/include/lldb/DataFormatters/TypeCategoryMap.h index 41b170d5335e..8afeaf87cec5 100644 --- a/include/lldb/DataFormatters/TypeCategoryMap.h +++ b/include/lldb/DataFormatters/TypeCategoryMap.h @@ -1,4 +1,4 @@ -//===-- TypeCategoryMap.h ----------------------------------------*- C++ -*-===// +//===-- TypeCategoryMap.h ---------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -12,6 +12,9 @@ // C Includes // C++ Includes +#include <functional> +#include <list> +#include <map> // Other libraries and framework includes // Project includes @@ -34,7 +37,8 @@ namespace lldb_private { public: typedef std::map<KeyType, ValueSP> MapType; typedef MapType::iterator MapIterator; - typedef bool(*CallbackType)(void*, const ValueSP&); + typedef std::function<bool(const ValueSP&)> ForEachCallback; + typedef uint32_t Position; static const Position First = 0; @@ -82,17 +86,17 @@ namespace lldb_private { ValueSP& entry); void - LoopThrough (CallbackType callback, void* param); + ForEach (ForEachCallback callback); lldb::TypeCategoryImplSP GetAtIndex (uint32_t); bool - AnyMatches (ConstString type_name, - TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES, - bool only_enabled = true, - const char** matching_category = NULL, - TypeCategoryImpl::FormatCategoryItems* matching_type = NULL); + AnyMatches(ConstString type_name, + TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES, + bool only_enabled = true, + const char** matching_category = nullptr, + TypeCategoryImpl::FormatCategoryItems* matching_type = nullptr); uint32_t GetCount () @@ -101,25 +105,20 @@ namespace lldb_private { } lldb::TypeFormatImplSP - GetFormat (ValueObject& valobj, - lldb::DynamicValueType use_dynamic); + GetFormat (FormattersMatchData& match_data); lldb::TypeSummaryImplSP - GetSummaryFormat (ValueObject& valobj, - lldb::DynamicValueType use_dynamic); + GetSummaryFormat (FormattersMatchData& match_data); #ifndef LLDB_DISABLE_PYTHON lldb::SyntheticChildrenSP - GetSyntheticChildren (ValueObject& valobj, - lldb::DynamicValueType use_dynamic); + GetSyntheticChildren (FormattersMatchData& match_data); #endif - lldb::TypeValidatorImplSP - GetValidator (ValueObject& valobj, - lldb::DynamicValueType use_dynamic); + lldb::TypeValidatorImplSP + GetValidator(FormattersMatchData& match_data); private: - class delete_matching_categories { lldb::TypeCategoryImplSP ptr; @@ -159,4 +158,4 @@ namespace lldb_private { }; } // namespace lldb_private -#endif // lldb_TypeCategoryMap_h_ +#endif // lldb_TypeCategoryMap_h_ diff --git a/include/lldb/DataFormatters/TypeFormat.h b/include/lldb/DataFormatters/TypeFormat.h index 8aa7c60b4938..4ed28b692061 100644 --- a/include/lldb/DataFormatters/TypeFormat.h +++ b/include/lldb/DataFormatters/TypeFormat.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes +#include <functional> #include <string> #include <unordered_map> @@ -150,7 +151,6 @@ namespace lldb_private { TypeFormatImpl (const Flags& flags = Flags()); typedef std::shared_ptr<TypeFormatImpl> SharedPointer; - typedef bool(*ValueCallback)(void*, ConstString, const lldb::TypeFormatImplSP&); virtual ~TypeFormatImpl (); @@ -159,16 +159,19 @@ namespace lldb_private { { return m_flags.GetCascades(); } + bool SkipsPointers () const { return m_flags.GetSkipPointers(); } + bool SkipsReferences () const { return m_flags.GetSkipReferences(); } + bool NonCacheable () const { @@ -255,9 +258,8 @@ namespace lldb_private { const TypeFormatImpl::Flags& flags = Flags()); typedef std::shared_ptr<TypeFormatImpl_Format> SharedPointer; - typedef bool(*ValueCallback)(void*, ConstString, const TypeFormatImpl_Format::SharedPointer&); - virtual ~TypeFormatImpl_Format (); + ~TypeFormatImpl_Format() override; lldb::Format GetFormat () const @@ -271,18 +273,18 @@ namespace lldb_private { m_format = fmt; } - virtual TypeFormatImpl::Type - GetType () + TypeFormatImpl::Type + GetType() override { return TypeFormatImpl::Type::eTypeFormat; } - virtual bool - FormatObject (ValueObject *valobj, - std::string& dest) const; + bool + FormatObject(ValueObject *valobj, + std::string& dest) const override; - virtual std::string - GetDescription(); + std::string + GetDescription() override; protected: lldb::Format m_format; @@ -298,9 +300,8 @@ namespace lldb_private { const TypeFormatImpl::Flags& flags = Flags()); typedef std::shared_ptr<TypeFormatImpl_EnumType> SharedPointer; - typedef bool(*ValueCallback)(void*, ConstString, const TypeFormatImpl_EnumType::SharedPointer&); - ~TypeFormatImpl_EnumType (); + ~TypeFormatImpl_EnumType() override; ConstString GetTypeName () @@ -314,26 +315,26 @@ namespace lldb_private { m_enum_type = enum_type; } - virtual TypeFormatImpl::Type - GetType () + TypeFormatImpl::Type + GetType() override { return TypeFormatImpl::Type::eTypeEnum; } - virtual bool - FormatObject (ValueObject *valobj, - std::string& dest) const; + bool + FormatObject(ValueObject *valobj, + std::string& dest) const override; - virtual std::string - GetDescription(); + std::string + GetDescription() override; protected: ConstString m_enum_type; - mutable std::unordered_map<void*,ClangASTType> m_types; + mutable std::unordered_map<void*,CompilerType> m_types; private: DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_EnumType); }; } // namespace lldb_private -#endif // lldb_TypeFormat_h_ +#endif // lldb_TypeFormat_h_ diff --git a/include/lldb/DataFormatters/TypeSummary.h b/include/lldb/DataFormatters/TypeSummary.h index c2838eac27f1..e5bf4ecadfdf 100644 --- a/include/lldb/DataFormatters/TypeSummary.h +++ b/include/lldb/DataFormatters/TypeSummary.h @@ -1,4 +1,4 @@ -//===-- TypeSummary.h --------------------------------------------*- C++ -*-===// +//===-- TypeSummary.h -------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,11 +14,11 @@ #include <stdint.h> // C++ Includes +#include <functional> +#include <memory> #include <string> -#include <vector> // Other libraries and framework includes - // Project includes #include "lldb/lldb-public.h" #include "lldb/lldb-enumerations.h" @@ -26,8 +26,6 @@ #include "lldb/Core/Error.h" #include "lldb/Core/FormatEntity.h" #include "lldb/Core/StructuredData.h" -#include "lldb/Core/ValueObject.h" -#include "lldb/Symbol/Type.h" namespace lldb_private { class TypeSummaryOptions @@ -36,6 +34,8 @@ namespace lldb_private { TypeSummaryOptions (); TypeSummaryOptions (const TypeSummaryOptions& rhs); + ~TypeSummaryOptions() = default; + TypeSummaryOptions& operator = (const TypeSummaryOptions& rhs); @@ -50,8 +50,7 @@ namespace lldb_private { TypeSummaryOptions& SetCapping (lldb::TypeSummaryCapping); - - ~TypeSummaryOptions() = default; + private: lldb::LanguageType m_lang; lldb::TypeSummaryCapping m_capping; @@ -60,10 +59,26 @@ namespace lldb_private { class TypeSummaryImpl { public: + enum class Kind + { + eSummaryString, + eScript, + eCallback, + eInternal + }; + + virtual + ~TypeSummaryImpl() = default; + + Kind + GetKind () const + { + return m_kind; + } + class Flags { public: - Flags () : m_flags (lldb::eTypeOptionCascade) {} @@ -162,6 +177,22 @@ namespace lldb_private { m_flags &= ~lldb::eTypeOptionHideChildren; return *this; } + + bool + GetHideEmptyAggregates () const + { + return (m_flags & lldb::eTypeOptionHideEmptyAggregates) == lldb::eTypeOptionHideEmptyAggregates; + } + + Flags& + SetHideEmptyAggregates (bool value = true) + { + if (value) + m_flags |= lldb::eTypeOptionHideEmptyAggregates; + else + m_flags &= ~lldb::eTypeOptionHideEmptyAggregates; + return *this; + } bool GetDontShowValue () const @@ -243,31 +274,24 @@ namespace lldb_private { uint32_t m_flags; }; - typedef enum Type - { - eTypeUnknown, - eTypeString, - eTypeScript, - eTypeCallback - } Type; - - TypeSummaryImpl (const TypeSummaryImpl::Flags& flags); - bool Cascades () const { return m_flags.GetCascades(); } + bool SkipsPointers () const { return m_flags.GetSkipPointers(); } + bool SkipsReferences () const { return m_flags.GetSkipReferences(); } + bool NonCacheable () const { @@ -279,6 +303,12 @@ namespace lldb_private { { return !m_flags.GetDontShowChildren(); } + + virtual bool + DoesPrintEmptyAggregates () const + { + return !m_flags.GetHideEmptyAggregates(); + } virtual bool DoesPrintValue (ValueObject* valobj) const @@ -358,11 +388,6 @@ namespace lldb_private { m_flags.SetValue(value); } - virtual - ~TypeSummaryImpl () - { - } - // we are using a ValueObject* instead of a ValueObjectSP because we do not need to hold on to this for // extended periods of time and we trust the ValueObject to stay around for as long as it is required // for us to generate its summary @@ -374,12 +399,6 @@ namespace lldb_private { virtual std::string GetDescription () = 0; - virtual bool - IsScripted () = 0; - - virtual Type - GetType () = 0; - uint32_t& GetRevision () { @@ -387,14 +406,16 @@ namespace lldb_private { } typedef std::shared_ptr<TypeSummaryImpl> SharedPointer; - typedef bool(*SummaryCallback)(void*, ConstString, const lldb::TypeSummaryImplSP&); - typedef bool(*RegexSummaryCallback)(void*, lldb::RegularExpressionSP, const lldb::TypeSummaryImplSP&); protected: uint32_t m_my_revision; Flags m_flags; + TypeSummaryImpl (Kind kind, + const TypeSummaryImpl::Flags& flags); + private: + Kind m_kind; DISALLOW_COPY_AND_ASSIGN(TypeSummaryImpl); }; @@ -407,11 +428,8 @@ namespace lldb_private { StringSummaryFormat(const TypeSummaryImpl::Flags& flags, const char* f); - - virtual - ~StringSummaryFormat() - { - } + + ~StringSummaryFormat() override = default; const char* GetSummaryString () const @@ -422,25 +440,17 @@ namespace lldb_private { void SetSummaryString (const char* f); - virtual bool + bool FormatObject(ValueObject *valobj, std::string& dest, - const TypeSummaryOptions& options); - - virtual std::string - GetDescription(); - - virtual bool - IsScripted () - { - return false; - } + const TypeSummaryOptions& options) override; + std::string + GetDescription() override; - virtual Type - GetType () + static bool classof(const TypeSummaryImpl* S) { - return TypeSummaryImpl::eTypeString; + return S->GetKind() == Kind::eSummaryString; } private: @@ -452,9 +462,9 @@ namespace lldb_private { { // we should convert these to SBValue and SBStream if we ever cross // the boundary towards the external world - typedef bool (*Callback)(ValueObject&, - Stream&, - const TypeSummaryOptions&); + typedef std::function<bool(ValueObject&, + Stream&, + const TypeSummaryOptions&)> Callback; Callback m_impl; std::string m_description; @@ -462,7 +472,9 @@ namespace lldb_private { CXXFunctionSummaryFormat (const TypeSummaryImpl::Flags& flags, Callback impl, const char* description); - + + ~CXXFunctionSummaryFormat() override = default; + Callback GetBackendFunction () const { @@ -489,30 +501,18 @@ namespace lldb_private { else m_description.clear(); } + + bool + FormatObject(ValueObject *valobj, + std::string& dest, + const TypeSummaryOptions& options) override; - virtual - ~CXXFunctionSummaryFormat () - { - } - - virtual bool - FormatObject (ValueObject *valobj, - std::string& dest, - const TypeSummaryOptions& options); - - virtual std::string - GetDescription (); - - virtual bool - IsScripted () - { - return false; - } + std::string + GetDescription() override; - virtual Type - GetType () + static bool classof(const TypeSummaryImpl* S) { - return TypeSummaryImpl::eTypeCallback; + return S->GetKind() == Kind::eCallback; } typedef std::shared_ptr<CXXFunctionSummaryFormat> SharedPointer; @@ -521,8 +521,6 @@ namespace lldb_private { DISALLOW_COPY_AND_ASSIGN(CXXFunctionSummaryFormat); }; -#ifndef LLDB_DISABLE_PYTHON - // Python-based summaries, running script code to show data struct ScriptSummaryFormat : public TypeSummaryImpl { @@ -532,8 +530,10 @@ namespace lldb_private { ScriptSummaryFormat(const TypeSummaryImpl::Flags& flags, const char *function_name, - const char* python_script = NULL); - + const char* python_script = nullptr); + + ~ScriptSummaryFormat() override = default; + const char* GetFunctionName () const { @@ -565,38 +565,24 @@ namespace lldb_private { m_python_script.clear(); } - virtual - ~ScriptSummaryFormat () - { - } - - virtual bool - FormatObject (ValueObject *valobj, - std::string& dest, - const TypeSummaryOptions& options); - - virtual std::string - GetDescription (); + bool + FormatObject(ValueObject *valobj, + std::string& dest, + const TypeSummaryOptions& options) override; - virtual bool - IsScripted () - { - return true; - } + std::string + GetDescription() override; - virtual Type - GetType () + static bool classof(const TypeSummaryImpl* S) { - return TypeSummaryImpl::eTypeScript; + return S->GetKind() == Kind::eScript; } typedef std::shared_ptr<ScriptSummaryFormat> SharedPointer; - private: DISALLOW_COPY_AND_ASSIGN(ScriptSummaryFormat); }; -#endif } // namespace lldb_private -#endif // lldb_TypeSummary_h_ +#endif // lldb_TypeSummary_h_ diff --git a/include/lldb/DataFormatters/TypeSynthetic.h b/include/lldb/DataFormatters/TypeSynthetic.h index ff6691c9a1b8..90e5730288c4 100644 --- a/include/lldb/DataFormatters/TypeSynthetic.h +++ b/include/lldb/DataFormatters/TypeSynthetic.h @@ -1,4 +1,4 @@ -//===-- TypeSynthetic.h -------------------------------------------*- C++ -*-===// +//===-- TypeSynthetic.h -----------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,11 +14,13 @@ #include <stdint.h> // C++ Includes +#include <initializer_list> +#include <functional> +#include <memory> #include <string> #include <vector> // Other libraries and framework includes - // Project includes #include "lldb/lldb-public.h" #include "lldb/lldb-enumerations.h" @@ -45,23 +47,27 @@ namespace lldb_private { } public: - SyntheticChildrenFrontEnd (ValueObject &backend) : m_backend(backend), m_valid(true) {} - + virtual - ~SyntheticChildrenFrontEnd () - { - } - + ~SyntheticChildrenFrontEnd() = default; + virtual size_t CalculateNumChildren () = 0; + + virtual size_t + CalculateNumChildren (uint32_t max) + { + auto count = CalculateNumChildren (); + return count <= max ? count : max; + } virtual lldb::ValueObjectSP GetChildAtIndex (size_t idx) = 0; - + virtual size_t GetIndexOfChildWithName (const ConstString &name) = 0; @@ -98,13 +104,13 @@ namespace lldb_private { CreateValueObjectFromAddress (const char* name, uint64_t address, const ExecutionContext& exe_ctx, - ClangASTType type); + CompilerType type); lldb::ValueObjectSP CreateValueObjectFromData (const char* name, const DataExtractor& data, const ExecutionContext& exe_ctx, - ClangASTType type); + CompilerType type); private: bool m_valid; @@ -117,29 +123,26 @@ namespace lldb_private { SyntheticValueProviderFrontEnd (ValueObject &backend) : SyntheticChildrenFrontEnd(backend) {} + + ~SyntheticValueProviderFrontEnd() override = default; + + size_t + CalculateNumChildren() override { return 0; } - virtual - ~SyntheticValueProviderFrontEnd () - { - } - - virtual size_t - CalculateNumChildren () { return 0; } - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx) { return nullptr; } + lldb::ValueObjectSP + GetChildAtIndex(size_t idx) override { return nullptr; } - virtual size_t - GetIndexOfChildWithName (const ConstString &name) { return UINT32_MAX; } + size_t + GetIndexOfChildWithName(const ConstString &name) override { return UINT32_MAX; } - virtual bool - Update () { return false; } + bool + Update() override { return false; } - virtual bool - MightHaveChildren () { return false; } + bool + MightHaveChildren () override { return false; } - virtual lldb::ValueObjectSP - GetSyntheticValue () = 0; + lldb::ValueObjectSP + GetSyntheticValue() override = 0; private: DISALLOW_COPY_AND_ASSIGN(SyntheticValueProviderFrontEnd); @@ -148,7 +151,6 @@ namespace lldb_private { class SyntheticChildren { public: - class Flags { public: @@ -272,27 +274,28 @@ namespace lldb_private { m_flags(flags) { } - + virtual - ~SyntheticChildren () - { - } - + ~SyntheticChildren() = default; + bool Cascades () const { return m_flags.GetCascades(); } + bool SkipsPointers () const { return m_flags.GetSkipPointers(); } + bool SkipsReferences () const { return m_flags.GetSkipReferences(); } + bool NonCacheable () const { @@ -345,7 +348,6 @@ namespace lldb_private { GetFrontEnd (ValueObject &backend) = 0; typedef std::shared_ptr<SyntheticChildren> SharedPointer; - typedef bool(*SyntheticChildrenCallback)(void*, ConstString, const SyntheticChildren::SharedPointer&); uint32_t& GetRevision () @@ -417,69 +419,67 @@ namespace lldb_private { SetExpressionPathAtIndex (size_t i, const std::string& path); bool - IsScripted () + IsScripted() override { return false; } std::string - GetDescription (); + GetDescription() override; class FrontEnd : public SyntheticChildrenFrontEnd { - private: - TypeFilterImpl* filter; public: - FrontEnd(TypeFilterImpl* flt, ValueObject &backend) : SyntheticChildrenFrontEnd(backend), filter(flt) {} - - virtual - ~FrontEnd () - { - } - - virtual size_t - CalculateNumChildren () + + ~FrontEnd() override = default; + + size_t + CalculateNumChildren() override { return filter->GetCount(); } - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx) + lldb::ValueObjectSP + GetChildAtIndex(size_t idx) override { if (idx >= filter->GetCount()) return lldb::ValueObjectSP(); return m_backend.GetSyntheticExpressionPathChild(filter->GetExpressionPathAtIndex(idx), true); } + + bool + Update() override { return false; } - virtual bool - Update() { return false; } - - virtual bool - MightHaveChildren () + bool + MightHaveChildren() override { return filter->GetCount() > 0; } - virtual size_t - GetIndexOfChildWithName (const ConstString &name); + size_t + GetIndexOfChildWithName(const ConstString &name) override; typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer; private: + TypeFilterImpl* filter; + DISALLOW_COPY_AND_ASSIGN(FrontEnd); }; - virtual SyntheticChildrenFrontEnd::AutoPointer - GetFrontEnd(ValueObject &backend) + SyntheticChildrenFrontEnd::AutoPointer + GetFrontEnd(ValueObject &backend) override { return SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(this, backend)); } + typedef std::shared_ptr<TypeFilterImpl> SharedPointer; + private: DISALLOW_COPY_AND_ASSIGN(TypeFilterImpl); }; @@ -487,11 +487,7 @@ namespace lldb_private { class CXXSyntheticChildren : public SyntheticChildren { public: - typedef SyntheticChildrenFrontEnd* (*CreateFrontEndCallback) (CXXSyntheticChildren*, lldb::ValueObjectSP); - protected: - CreateFrontEndCallback m_create_callback; - std::string m_description; - public: + typedef std::function<SyntheticChildrenFrontEnd*(CXXSyntheticChildren*, lldb::ValueObjectSP)> CreateFrontEndCallback; CXXSyntheticChildren (const SyntheticChildren::Flags& flags, const char* description, CreateFrontEndCallback callback) : @@ -502,20 +498,24 @@ namespace lldb_private { } bool - IsScripted () + IsScripted() override { return false; } std::string - GetDescription (); + GetDescription() override; - virtual SyntheticChildrenFrontEnd::AutoPointer - GetFrontEnd (ValueObject &backend) + SyntheticChildrenFrontEnd::AutoPointer + GetFrontEnd(ValueObject &backend) override { return SyntheticChildrenFrontEnd::AutoPointer(m_create_callback(this, backend.GetSP())); } + protected: + CreateFrontEndCallback m_create_callback; + std::string m_description; + private: DISALLOW_COPY_AND_ASSIGN(CXXSyntheticChildren); }; @@ -528,9 +528,9 @@ namespace lldb_private { std::string m_python_code; public: - ScriptedSyntheticChildren (const SyntheticChildren::Flags& flags, - const char* pclass, - const char* pcode = NULL) : + ScriptedSyntheticChildren(const SyntheticChildren::Flags& flags, + const char* pclass, + const char* pcode = nullptr) : SyntheticChildren(flags), m_python_class(), m_python_code() @@ -567,62 +567,63 @@ namespace lldb_private { } std::string - GetDescription (); + GetDescription() override; bool - IsScripted () + IsScripted() override { return true; } class FrontEnd : public SyntheticChildrenFrontEnd { - private: - std::string m_python_class; - StructuredData::ObjectSP m_wrapper_sp; - ScriptInterpreter *m_interpreter; public: - FrontEnd (std::string pclass, ValueObject &backend); + ~FrontEnd() override; + bool IsValid (); - virtual - ~FrontEnd (); - - virtual size_t - CalculateNumChildren (); - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx); + size_t + CalculateNumChildren() override; + + size_t + CalculateNumChildren(uint32_t max) override; - virtual bool - Update (); + lldb::ValueObjectSP + GetChildAtIndex(size_t idx) override; + + bool + Update() override; - virtual bool - MightHaveChildren (); + bool + MightHaveChildren() override; - virtual size_t - GetIndexOfChildWithName (const ConstString &name); + size_t + GetIndexOfChildWithName(const ConstString &name) override; - virtual lldb::ValueObjectSP - GetSyntheticValue (); + lldb::ValueObjectSP + GetSyntheticValue() override; typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer; private: + std::string m_python_class; + StructuredData::ObjectSP m_wrapper_sp; + ScriptInterpreter *m_interpreter; + DISALLOW_COPY_AND_ASSIGN(FrontEnd); }; - virtual SyntheticChildrenFrontEnd::AutoPointer - GetFrontEnd(ValueObject &backend) + SyntheticChildrenFrontEnd::AutoPointer + GetFrontEnd(ValueObject &backend) override { auto synth_ptr = SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(m_python_class, backend)); if (synth_ptr && ((FrontEnd*)synth_ptr.get())->IsValid()) return synth_ptr; - return NULL; + return nullptr; } private: @@ -631,4 +632,4 @@ namespace lldb_private { #endif } // namespace lldb_private -#endif // lldb_TypeSynthetic_h_ +#endif // lldb_TypeSynthetic_h_ diff --git a/include/lldb/DataFormatters/TypeValidator.h b/include/lldb/DataFormatters/TypeValidator.h index d06fac01f824..f1f9a11049db 100644 --- a/include/lldb/DataFormatters/TypeValidator.h +++ b/include/lldb/DataFormatters/TypeValidator.h @@ -13,8 +13,8 @@ // C Includes // C++ Includes -#include <string> #include <functional> +#include <string> // Other libraries and framework includes @@ -150,7 +150,6 @@ public: TypeValidatorImpl (const Flags& flags = Flags()); typedef std::shared_ptr<TypeValidatorImpl> SharedPointer; - typedef bool(*ValueCallback)(void*, ConstString, const lldb::TypeValidatorImplSP&); virtual ~TypeValidatorImpl (); @@ -265,9 +264,8 @@ public: TypeValidatorImpl_CXX (ValidatorFunction f, std::string d, const TypeValidatorImpl::Flags& flags = Flags()); typedef std::shared_ptr<TypeValidatorImpl_CXX> SharedPointer; - typedef bool(*ValueCallback)(void*, ConstString, const TypeValidatorImpl_CXX::SharedPointer&); - virtual ~TypeValidatorImpl_CXX (); + ~TypeValidatorImpl_CXX() override; ValidatorFunction GetValidatorFunction () const @@ -281,17 +279,17 @@ public: m_validator_function = f; } - virtual TypeValidatorImpl::Type - GetType () + TypeValidatorImpl::Type + GetType() override { return TypeValidatorImpl::Type::eTypeCXX; } - virtual ValidationResult - FormatObject (ValueObject *valobj) const; + ValidationResult + FormatObject(ValueObject *valobj) const override; - virtual std::string - GetDescription(); + std::string + GetDescription() override; protected: std::string m_description; @@ -304,4 +302,4 @@ private: } // namespace lldb_private -#endif // lldb_TypeValidator_h_ +#endif // lldb_TypeValidator_h_ diff --git a/include/lldb/DataFormatters/ValueObjectPrinter.h b/include/lldb/DataFormatters/ValueObjectPrinter.h index dc05fd482676..23d7ee2edf50 100644 --- a/include/lldb/DataFormatters/ValueObjectPrinter.h +++ b/include/lldb/DataFormatters/ValueObjectPrinter.h @@ -18,232 +18,15 @@ #include "lldb/lldb-private.h" #include "lldb/lldb-public.h" -#include "lldb/Core/Stream.h" -#include "lldb/Core/ValueObject.h" -#include "lldb/DataFormatters/TypeSummary.h" +#include "lldb/Core/Flags.h" +#include "lldb/DataFormatters/DumpValueObjectOptions.h" +#include "lldb/Symbol/CompilerType.h" -namespace lldb_private { +//#include <functional> +//#include <memory> +//#include <set> -struct DumpValueObjectOptions -{ - uint32_t m_max_ptr_depth = 0; - uint32_t m_max_depth = UINT32_MAX; - lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues; - uint32_t m_omit_summary_depth = 0; - lldb::Format m_format = lldb::eFormatDefault; - lldb::TypeSummaryImplSP m_summary_sp; - std::string m_root_valobj_name; - bool m_use_synthetic : 1; - bool m_scope_already_checked : 1; - bool m_flat_output : 1; - bool m_ignore_cap : 1; - bool m_show_types : 1; - bool m_show_location : 1; - bool m_use_objc : 1; - bool m_hide_root_type : 1; - bool m_hide_name : 1; - bool m_hide_value : 1; - bool m_run_validator : 1; - bool m_use_type_display_name : 1; - bool m_allow_oneliner_mode : 1; - - DumpValueObjectOptions() : - m_summary_sp(), - m_root_valobj_name(), - m_use_synthetic(true), - m_scope_already_checked(false), - m_flat_output(false), - m_ignore_cap(false), - m_show_types(false), - m_show_location(false), - m_use_objc(false), - m_hide_root_type(false), - m_hide_name(false), - m_hide_value(false), - m_run_validator(false), - m_use_type_display_name(true), - m_allow_oneliner_mode(true) - {} - - static const DumpValueObjectOptions - DefaultOptions() - { - static DumpValueObjectOptions g_default_options; - - return g_default_options; - } - - DumpValueObjectOptions (const DumpValueObjectOptions& rhs) = default; - - DumpValueObjectOptions (ValueObject& valobj); - - DumpValueObjectOptions& - SetMaximumPointerDepth(uint32_t depth = 0) - { - m_max_ptr_depth = depth; - return *this; - } - - DumpValueObjectOptions& - SetMaximumDepth(uint32_t depth = 0) - { - m_max_depth = depth; - return *this; - } - - DumpValueObjectOptions& - SetShowTypes(bool show = false) - { - m_show_types = show; - return *this; - } - - DumpValueObjectOptions& - SetShowLocation(bool show = false) - { - m_show_location = show; - return *this; - } - - DumpValueObjectOptions& - SetUseObjectiveC(bool use = false) - { - m_use_objc = use; - return *this; - } - - DumpValueObjectOptions& - SetShowSummary(bool show = true) - { - if (show == false) - SetOmitSummaryDepth(UINT32_MAX); - else - SetOmitSummaryDepth(0); - return *this; - } - - DumpValueObjectOptions& - SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues) - { - m_use_dynamic = dyn; - return *this; - } - - DumpValueObjectOptions& - SetUseSyntheticValue(bool use_synthetic = true) - { - m_use_synthetic = use_synthetic; - return *this; - } - - DumpValueObjectOptions& - SetScopeChecked(bool check = true) - { - m_scope_already_checked = check; - return *this; - } - - DumpValueObjectOptions& - SetFlatOutput(bool flat = false) - { - m_flat_output = flat; - return *this; - } - - DumpValueObjectOptions& - SetOmitSummaryDepth(uint32_t depth = 0) - { - m_omit_summary_depth = depth; - return *this; - } - - DumpValueObjectOptions& - SetIgnoreCap(bool ignore = false) - { - m_ignore_cap = ignore; - return *this; - } - - DumpValueObjectOptions& - SetRawDisplay() - { - SetUseSyntheticValue(false); - SetOmitSummaryDepth(UINT32_MAX); - SetIgnoreCap(true); - SetHideName(false); - SetHideValue(false); - SetUseTypeDisplayName(false); - SetAllowOnelinerMode(false); - return *this; - } - - DumpValueObjectOptions& - SetFormat (lldb::Format format = lldb::eFormatDefault) - { - m_format = format; - return *this; - } - - DumpValueObjectOptions& - SetSummary (lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP()) - { - m_summary_sp = summary; - return *this; - } - - DumpValueObjectOptions& - SetRootValueObjectName (const char* name = NULL) - { - if (name) - m_root_valobj_name.assign(name); - else - m_root_valobj_name.clear(); - return *this; - } - - DumpValueObjectOptions& - SetHideRootType (bool hide_root_type = false) - { - m_hide_root_type = hide_root_type; - return *this; - } - - DumpValueObjectOptions& - SetHideName (bool hide_name = false) - { - m_hide_name = hide_name; - return *this; - } - - DumpValueObjectOptions& - SetHideValue (bool hide_value = false) - { - m_hide_value = hide_value; - return *this; - } - - DumpValueObjectOptions& - SetRunValidator (bool run = true) - { - m_run_validator = run; - return *this; - } - - DumpValueObjectOptions& - SetUseTypeDisplayName (bool dis = false) - { - m_use_type_display_name = dis; - return *this; - } - - DumpValueObjectOptions& - SetAllowOnelinerMode (bool oneliner = false) - { - m_allow_oneliner_mode = oneliner; - return *this; - } - -}; +namespace lldb_private { class ValueObjectPrinter { @@ -262,14 +45,19 @@ public: PrintValueObject (); protected: + typedef std::set<uint64_t> InstancePointersSet; + typedef std::shared_ptr<InstancePointersSet> InstancePointersSetSP; + InstancePointersSetSP m_printed_instance_pointers; + // only this class (and subclasses, if any) should ever be concerned with // the depth mechanism ValueObjectPrinter (ValueObject* valobj, Stream* s, const DumpValueObjectOptions& options, - uint32_t ptr_depth, - uint32_t curr_depth); + const DumpValueObjectOptions::PointerDepth& ptr_depth, + uint32_t curr_depth, + InstancePointersSetSP printed_instance_pointers); // we should actually be using delegating constructors here // but some versions of GCC still have trouble with those @@ -277,8 +65,9 @@ protected: Init (ValueObject* valobj, Stream* s, const DumpValueObjectOptions& options, - uint32_t ptr_depth, - uint32_t curr_depth); + const DumpValueObjectOptions::PointerDepth& ptr_depth, + uint32_t curr_depth, + InstancePointersSetSP printed_instance_pointers); bool GetMostSpecializedValue (); @@ -299,12 +88,18 @@ protected: IsNil (); bool + IsUninitialized (); + + bool IsPtr (); bool IsRef (); bool + IsInstancePointer (); + + bool IsAggregate (); bool @@ -316,17 +111,18 @@ protected: bool PrintLocationIfNeeded (); - bool - PrintTypeIfNeeded (); + void + PrintDecl (); bool - PrintNameIfNeeded (bool show_type); + CheckScopeIfNeeded (); bool - CheckScopeIfNeeded (); + ShouldPrintEmptyBrackets (bool value_printed, + bool summary_printed); TypeSummaryImpl* - GetSummaryFormatter (); + GetSummaryFormatter (bool null_if_omitted = true); void GetValueSummaryError (std::string& value, @@ -343,7 +139,10 @@ protected: bool ShouldPrintChildren (bool is_failed_description, - uint32_t& curr_ptr_depth); + DumpValueObjectOptions::PointerDepth& curr_ptr_depth); + + bool + ShouldExpandEmptyAggregates (); ValueObject* GetValueObjectForChildrenGeneration (); @@ -356,13 +155,15 @@ protected: void PrintChild (lldb::ValueObjectSP child_sp, - uint32_t curr_ptr_depth); + const DumpValueObjectOptions::PointerDepth& curr_ptr_depth); uint32_t GetMaxNumChildrenToPrint (bool& print_dotdotdot); void - PrintChildren (uint32_t curr_ptr_depth); + PrintChildren (bool value_printed, + bool summary_printed, + const DumpValueObjectOptions::PointerDepth& curr_ptr_depth); void PrintChildrenIfNeeded (bool value_printed, @@ -376,20 +177,23 @@ private: ValueObject *m_orig_valobj; ValueObject *m_valobj; Stream *m_stream; - DumpValueObjectOptions options; + DumpValueObjectOptions m_options; Flags m_type_flags; - ClangASTType m_clang_type; - uint32_t m_ptr_depth; + CompilerType m_compiler_type; + DumpValueObjectOptions::PointerDepth m_ptr_depth; uint32_t m_curr_depth; LazyBool m_should_print; LazyBool m_is_nil; + LazyBool m_is_uninit; LazyBool m_is_ptr; LazyBool m_is_ref; LazyBool m_is_aggregate; + LazyBool m_is_instance_ptr; std::pair<TypeSummaryImpl*,bool> m_summary_formatter; std::string m_value; std::string m_summary; std::string m_error; + bool m_val_summary_ok; std::pair<TypeValidatorResult,std::string> m_validation; friend struct StringSummaryFormat; diff --git a/include/lldb/DataFormatters/VectorIterator.h b/include/lldb/DataFormatters/VectorIterator.h new file mode 100644 index 000000000000..3d96ee4c093b --- /dev/null +++ b/include/lldb/DataFormatters/VectorIterator.h @@ -0,0 +1,53 @@ +//===-- VectorIterator.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_VectorIterator_h_ +#define liblldb_VectorIterator_h_ + +#include "lldb/lldb-forward.h" + +#include "lldb/Core/ConstString.h" +#include "lldb/Target/ExecutionContext.h" + +namespace lldb_private { + namespace formatters + { + class VectorIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd + { + public: + VectorIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp, + ConstString item_name); + + size_t + CalculateNumChildren() override; + + lldb::ValueObjectSP + GetChildAtIndex(size_t idx) override; + + bool + Update() override; + + bool + MightHaveChildren() override; + + size_t + GetIndexOfChildWithName(const ConstString &name) override; + + ~VectorIteratorSyntheticFrontEnd() override; + + private: + ExecutionContextRef m_exe_ctx_ref; + ConstString m_item_name; + lldb::ValueObjectSP m_item_sp; + }; + + } // namespace formatters +} // namespace lldb_private + +#endif // liblldb_CF_h_ diff --git a/include/lldb/Expression/ASTDumper.h b/include/lldb/Expression/ASTDumper.h deleted file mode 100644 index 47f7ea460b87..000000000000 --- a/include/lldb/Expression/ASTDumper.h +++ /dev/null @@ -1,43 +0,0 @@ -//===-- ASTDumper.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_ASTDumper_h_ -#define liblldb_ASTDumper_h_ - -#include "clang/AST/DeclVisitor.h" -#include "clang/AST/StmtVisitor.h" -#include "clang/AST/TypeVisitor.h" - -#include "lldb/Core/Stream.h" -#include "llvm/ADT/DenseSet.h" - -namespace lldb_private -{ - -class ASTDumper -{ -public: - ASTDumper (clang::Decl *decl); - ASTDumper (clang::DeclContext *decl_ctx); - ASTDumper (const clang::Type *type); - ASTDumper (clang::QualType type); - ASTDumper (lldb::clang_type_t type); - ASTDumper (const ClangASTType &clang_type); - - const char *GetCString(); - void ToSTDERR(); - void ToLog(Log *log, const char *prefix); - void ToStream(lldb::StreamSP &stream); -private: - std::string m_dump; -}; - -} // namespace lldb_private - -#endif diff --git a/include/lldb/Expression/ASTResultSynthesizer.h b/include/lldb/Expression/ASTResultSynthesizer.h deleted file mode 100644 index 410a862fc12a..000000000000 --- a/include/lldb/Expression/ASTResultSynthesizer.h +++ /dev/null @@ -1,184 +0,0 @@ -//===-- ASTResultSynthesizer.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_ASTResultSynthesizer_h_ -#define liblldb_ASTResultSynthesizer_h_ - -#include "clang/Sema/SemaConsumer.h" -#include "lldb/Core/ClangForward.h" -#include "lldb/Symbol/TaggedASTType.h" - -namespace lldb_private { - -//---------------------------------------------------------------------- -/// @class ASTResultSynthesizer ASTResultSynthesizer.h "lldb/Expression/ASTResultSynthesizer.h" -/// @brief Adds a result variable declaration to the ASTs for an expression. -/// -/// Users expect the expression "i + 3" to return a result, even if a result -/// variable wasn't specifically declared. To fulfil this requirement, LLDB adds -/// a result variable to the expression, transforming it to -/// "int $__lldb_expr_result = i + 3." The IR transformers ensure that the -/// resulting variable is mapped to the right piece of memory. -/// ASTResultSynthesizer's job is to add the variable and its initialization to -/// the ASTs for the expression, and it does so by acting as a SemaConsumer for -/// Clang. -//---------------------------------------------------------------------- -class ASTResultSynthesizer : public clang::SemaConsumer -{ -public: - //---------------------------------------------------------------------- - /// Constructor - /// - /// @param[in] passthrough - /// Since the ASTs must typically go through to the Clang code generator - /// in order to produce LLVM IR, this SemaConsumer must allow them to - /// pass to the next step in the chain after processing. Passthrough is - /// the next ASTConsumer, or NULL if none is required. - /// - /// @param[in] target - /// The target, which contains the persistent variable store and the - /// AST importer. - //---------------------------------------------------------------------- - ASTResultSynthesizer(clang::ASTConsumer *passthrough, - Target &target); - - //---------------------------------------------------------------------- - /// Destructor - //---------------------------------------------------------------------- - ~ASTResultSynthesizer(); - - //---------------------------------------------------------------------- - /// Link this consumer with a particular AST context - /// - /// @param[in] Context - /// This AST context will be used for types and identifiers, and also - /// forwarded to the passthrough consumer, if one exists. - //---------------------------------------------------------------------- - void Initialize(clang::ASTContext &Context); - - //---------------------------------------------------------------------- - /// Examine a list of Decls to find the function $__lldb_expr and - /// transform its code - /// - /// @param[in] D - /// The list of Decls to search. These may contain LinkageSpecDecls, - /// which need to be searched recursively. That job falls to - /// TransformTopLevelDecl. - //---------------------------------------------------------------------- - bool HandleTopLevelDecl(clang::DeclGroupRef D); - - //---------------------------------------------------------------------- - /// Passthrough stub - //---------------------------------------------------------------------- - void HandleTranslationUnit(clang::ASTContext &Ctx); - - //---------------------------------------------------------------------- - /// Passthrough stub - //---------------------------------------------------------------------- - void HandleTagDeclDefinition(clang::TagDecl *D); - - //---------------------------------------------------------------------- - /// Passthrough stub - //---------------------------------------------------------------------- - void CompleteTentativeDefinition(clang::VarDecl *D); - - //---------------------------------------------------------------------- - /// Passthrough stub - //---------------------------------------------------------------------- - void HandleVTable(clang::CXXRecordDecl *RD); - - //---------------------------------------------------------------------- - /// Passthrough stub - //---------------------------------------------------------------------- - void PrintStats(); - - //---------------------------------------------------------------------- - /// Set the Sema object to use when performing transforms, and pass it on - /// - /// @param[in] S - /// The Sema to use. Because Sema isn't externally visible, this class - /// casts it to an Action for actual use. - //---------------------------------------------------------------------- - void InitializeSema(clang::Sema &S); - - //---------------------------------------------------------------------- - /// Reset the Sema to NULL now that transformations are done - //---------------------------------------------------------------------- - void ForgetSema(); -private: - //---------------------------------------------------------------------- - /// Hunt the given Decl for FunctionDecls named $__lldb_expr, recursing - /// as necessary through LinkageSpecDecls, and calling SynthesizeResult on - /// anything that was found - /// - /// @param[in] D - /// The Decl to hunt. - //---------------------------------------------------------------------- - void TransformTopLevelDecl(clang::Decl *D); - - //---------------------------------------------------------------------- - /// Process an Objective-C method and produce the result variable and - /// initialization - /// - /// @param[in] MethodDecl - /// The method to process. - //---------------------------------------------------------------------- - bool SynthesizeObjCMethodResult(clang::ObjCMethodDecl *MethodDecl); - - //---------------------------------------------------------------------- - /// Process a function and produce the result variable and initialization - /// - /// @param[in] FunDecl - /// The function to process. - //---------------------------------------------------------------------- - bool SynthesizeFunctionResult(clang::FunctionDecl *FunDecl); - - //---------------------------------------------------------------------- - /// Process a function body and produce the result variable and - /// initialization - /// - /// @param[in] Body - /// The body of the function. - /// - /// @param[in] DC - /// The DeclContext of the function, into which the result variable - /// is inserted. - //---------------------------------------------------------------------- - bool SynthesizeBodyResult(clang::CompoundStmt *Body, - clang::DeclContext *DC); - - //---------------------------------------------------------------------- - /// Given a DeclContext for a function or method, find all types - /// declared in the context and record any persistent types found. - /// - /// @param[in] FunDeclCtx - /// The context for the function to process. - //---------------------------------------------------------------------- - void RecordPersistentTypes(clang::DeclContext *FunDeclCtx); - - //---------------------------------------------------------------------- - /// Given a TypeDecl, if it declares a type whose name starts with a - /// dollar sign, register it as a pointer type in the target's scratch - /// AST context. - /// - /// @param[in] Body - /// The body of the function. - //---------------------------------------------------------------------- - void MaybeRecordPersistentType(clang::TypeDecl *D); - - clang::ASTContext *m_ast_context; ///< The AST context to use for identifiers and types. - clang::ASTConsumer *m_passthrough; ///< The ASTConsumer down the chain, for passthrough. NULL if it's a SemaConsumer. - clang::SemaConsumer *m_passthrough_sema; ///< The SemaConsumer down the chain, for passthrough. NULL if it's an ASTConsumer. - Target &m_target; ///< The target, which contains the persistent variable store and the - clang::Sema *m_sema; ///< The Sema to use. -}; - -} - -#endif diff --git a/include/lldb/Expression/ASTStructExtractor.h b/include/lldb/Expression/ASTStructExtractor.h deleted file mode 100644 index 25193744c9e0..000000000000 --- a/include/lldb/Expression/ASTStructExtractor.h +++ /dev/null @@ -1,156 +0,0 @@ -//===-- ASTStructExtractor.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_ASTStructExtractor_h_ -#define liblldb_ASTStructExtractor_h_ - -#include "clang/Sema/SemaConsumer.h" -#include "lldb/Core/ClangForward.h" -#include "lldb/Expression/ClangExpressionVariable.h" -#include "lldb/Expression/ClangFunction.h" - -namespace lldb_private { - -//---------------------------------------------------------------------- -/// @class ASTStructExtractor ASTStructExtractor.h "lldb/Expression/ASTStructExtractor.h" -/// @brief Extracts and describes the argument structure for a wrapped function. -/// -/// This pass integrates with ClangFunction, which calls functions with custom -/// sets of arguments. To avoid having to implement the full calling convention -/// for the target's architecture, ClangFunction writes a simple wrapper -/// function that takes a pointer to an argument structure that contains room -/// for the address of the function to be called, the values of all its -/// arguments, and room for the function's return value. -/// -/// The definition of this struct is itself in the body of the wrapper function, -/// so Clang does the structure layout itself. ASTStructExtractor reads through -/// the AST for the wrapper function and finds the struct. -//---------------------------------------------------------------------- -class ASTStructExtractor : public clang::SemaConsumer -{ -public: - //---------------------------------------------------------------------- - /// Constructor - /// - /// @param[in] passthrough - /// Since the ASTs must typically go through to the Clang code generator - /// in order to produce LLVM IR, this SemaConsumer must allow them to - /// pass to the next step in the chain after processing. Passthrough is - /// the next ASTConsumer, or NULL if none is required. - /// - /// @param[in] struct_name - /// The name of the structure to extract from the wrapper function. - /// - /// @param[in] function - /// The caller object whose members should be populated with information - /// about the argument struct. ClangFunction friends ASTStructExtractor - /// for this purpose. - //---------------------------------------------------------------------- - ASTStructExtractor(clang::ASTConsumer *passthrough, - const char *struct_name, - ClangFunction &function); - - //---------------------------------------------------------------------- - /// Destructor - //---------------------------------------------------------------------- - virtual ~ASTStructExtractor(); - - //---------------------------------------------------------------------- - /// Link this consumer with a particular AST context - /// - /// @param[in] Context - /// This AST context will be used for types and identifiers, and also - /// forwarded to the passthrough consumer, if one exists. - //---------------------------------------------------------------------- - void Initialize(clang::ASTContext &Context); - - //---------------------------------------------------------------------- - /// Examine a list of Decls to find the function $__lldb_expr and - /// transform its code - /// - /// @param[in] D - /// The list of Decls to search. These may contain LinkageSpecDecls, - /// which need to be searched recursively. That job falls to - /// TransformTopLevelDecl. - //---------------------------------------------------------------------- - bool HandleTopLevelDecl(clang::DeclGroupRef D); - - //---------------------------------------------------------------------- - /// Passthrough stub - //---------------------------------------------------------------------- - void HandleTranslationUnit(clang::ASTContext &Ctx); - - //---------------------------------------------------------------------- - /// Passthrough stub - //---------------------------------------------------------------------- - void HandleTagDeclDefinition(clang::TagDecl *D); - - //---------------------------------------------------------------------- - /// Passthrough stub - //---------------------------------------------------------------------- - void CompleteTentativeDefinition(clang::VarDecl *D); - - //---------------------------------------------------------------------- - /// Passthrough stub - //---------------------------------------------------------------------- - void HandleVTable(clang::CXXRecordDecl *RD); - - //---------------------------------------------------------------------- - /// Passthrough stub - //---------------------------------------------------------------------- - void PrintStats(); - - //---------------------------------------------------------------------- - /// Set the Sema object to use when performing transforms, and pass it on - /// - /// @param[in] S - /// The Sema to use. Because Sema isn't externally visible, this class - /// casts it to an Action for actual use. - //---------------------------------------------------------------------- - void InitializeSema(clang::Sema &S); - - //---------------------------------------------------------------------- - /// Reset the Sema to NULL now that transformations are done - //---------------------------------------------------------------------- - void ForgetSema(); -private: - //---------------------------------------------------------------------- - /// Hunt the given FunctionDecl for the argument struct and place - /// information about it into m_function - /// - /// @param[in] F - /// The FunctionDecl to hunt. - //---------------------------------------------------------------------- - void - ExtractFromFunctionDecl(clang::FunctionDecl* F); - - //---------------------------------------------------------------------- - /// Hunt the given Decl for FunctionDecls named the same as the wrapper - /// function name, recursing as necessary through LinkageSpecDecls, and - /// calling ExtractFromFunctionDecl on anything that was found - /// - /// @param[in] D - /// The Decl to hunt. - //---------------------------------------------------------------------- - void - ExtractFromTopLevelDecl(clang::Decl* D); - - clang::ASTContext *m_ast_context; ///< The AST context to use for identifiers and types. - clang::ASTConsumer *m_passthrough; ///< The ASTConsumer down the chain, for passthrough. NULL if it's a SemaConsumer. - clang::SemaConsumer *m_passthrough_sema; ///< The SemaConsumer down the chain, for passthrough. NULL if it's an ASTConsumer. - clang::Sema *m_sema; ///< The Sema to use. - clang::Action *m_action; ///< The Sema to use, cast to an Action so it's usable. - - ClangFunction &m_function; ///< The function to populate with information about the argument structure. - std::string m_struct_name; ///< The name of the structure to extract. -}; - -} - -#endif diff --git a/include/lldb/Expression/ClangASTSource.h b/include/lldb/Expression/ClangASTSource.h deleted file mode 100644 index 46140d2f2e64..000000000000 --- a/include/lldb/Expression/ClangASTSource.h +++ /dev/null @@ -1,525 +0,0 @@ -//===-- ClangASTSource.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_ClangASTSource_h_ -#define liblldb_ClangASTSource_h_ - -#include <set> - -#include "clang/Basic/IdentifierTable.h" -#include "lldb/Symbol/ClangExternalASTSourceCommon.h" -#include "lldb/Symbol/ClangASTImporter.h" -#include "lldb/Symbol/ClangASTType.h" -#include "lldb/Target/Target.h" - -#include "llvm/ADT/SmallSet.h" - -namespace lldb_private { - -//---------------------------------------------------------------------- -/// @class ClangASTSource ClangASTSource.h "lldb/Expression/ClangASTSource.h" -/// @brief Provider for named objects defined in the debug info for Clang -/// -/// As Clang parses an expression, it may encounter names that are not -/// defined inside the expression, including variables, functions, and -/// types. Clang knows the name it is looking for, but nothing else. -/// The ExternalSemaSource class provides Decls (VarDecl, FunDecl, TypeDecl) -/// to Clang for these names, consulting the ClangExpressionDeclMap to do -/// the actual lookups. -//---------------------------------------------------------------------- -class ClangASTSource : - public ClangExternalASTSourceCommon, - public ClangASTImporter::MapCompleter -{ -public: - //------------------------------------------------------------------ - /// Constructor - /// - /// Initializes class variables. - /// - /// @param[in] declMap - /// A reference to the LLDB object that handles entity lookup. - //------------------------------------------------------------------ - ClangASTSource (const lldb::TargetSP &target) : - m_import_in_progress (false), - m_lookups_enabled (false), - m_target (target), - m_ast_context (NULL), - m_active_lexical_decls (), - m_active_lookups () - { - m_ast_importer = m_target->GetClangASTImporter(); - } - - //------------------------------------------------------------------ - /// Destructor - //------------------------------------------------------------------ - ~ClangASTSource(); - - //------------------------------------------------------------------ - /// Interface stubs. - //------------------------------------------------------------------ - clang::Decl *GetExternalDecl (uint32_t) override { return NULL; } - clang::Stmt *GetExternalDeclStmt (uint64_t) override { return NULL; } - clang::Selector GetExternalSelector (uint32_t) override { return clang::Selector(); } - uint32_t GetNumExternalSelectors () override { return 0; } - clang::CXXBaseSpecifier *GetExternalCXXBaseSpecifiers (uint64_t Offset) override - { return NULL; } - void MaterializeVisibleDecls (const clang::DeclContext *DC) - { return; } - - void InstallASTContext (clang::ASTContext *ast_context) - { - m_ast_context = ast_context; - m_ast_importer->InstallMapCompleter(ast_context, *this); - } - - // - // APIs for ExternalASTSource - // - - //------------------------------------------------------------------ - /// Look up all Decls that match a particular name. Only handles - /// Identifiers and DeclContexts that are either NamespaceDecls or - /// TranslationUnitDecls. Calls SetExternalVisibleDeclsForName with - /// the result. - /// - /// The work for this function is done by - /// void FindExternalVisibleDecls (NameSearchContext &); - /// - /// @param[in] DC - /// The DeclContext to register the found Decls in. - /// - /// @param[in] Name - /// The name to find entries for. - /// - /// @return - /// Whatever SetExternalVisibleDeclsForName returns. - //------------------------------------------------------------------ - bool FindExternalVisibleDeclsByName(const clang::DeclContext *DC, clang::DeclarationName Name) override; - - //------------------------------------------------------------------ - /// Enumerate all Decls in a given lexical context. - /// - /// @param[in] DC - /// The DeclContext being searched. - /// - /// @param[in] isKindWeWant - /// If non-NULL, a callback function that returns true given the - /// DeclKinds of desired Decls, and false otherwise. - /// - /// @param[in] Decls - /// A vector that is filled in with matching Decls. - //------------------------------------------------------------------ - clang::ExternalLoadResult FindExternalLexicalDecls(const clang::DeclContext *DC, - bool (*isKindWeWant)(clang::Decl::Kind), - llvm::SmallVectorImpl<clang::Decl *> &Decls) override; - - //------------------------------------------------------------------ - /// Specify the layout of the contents of a RecordDecl. - /// - /// @param[in] Record - /// The record (in the parser's AST context) that needs to be - /// laid out. - /// - /// @param[out] Size - /// The total size of the record in bits. - /// - /// @param[out] Alignment - /// The alignment of the record in bits. - /// - /// @param[in] FieldOffsets - /// A map that must be populated with pairs of the record's - /// fields (in the parser's AST context) and their offsets - /// (measured in bits). - /// - /// @param[in] BaseOffsets - /// A map that must be populated with pairs of the record's - /// C++ concrete base classes (in the parser's AST context, - /// and only if the record is a CXXRecordDecl and has base - /// classes) and their offsets (measured in bytes). - /// - /// @param[in] VirtualBaseOffsets - /// A map that must be populated with pairs of the record's - /// C++ virtual base classes (in the parser's AST context, - /// and only if the record is a CXXRecordDecl and has base - /// classes) and their offsets (measured in bytes). - /// - /// @return - /// True <=> the layout is valid. - //----------------------------------------------------------------- - bool layoutRecordType(const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, - llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets, - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &BaseOffsets, - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &VirtualBaseOffsets) override; - - //------------------------------------------------------------------ - /// Complete a TagDecl. - /// - /// @param[in] Tag - /// The Decl to be completed in place. - //------------------------------------------------------------------ - void CompleteType(clang::TagDecl *Tag) override; - - //------------------------------------------------------------------ - /// Complete an ObjCInterfaceDecl. - /// - /// @param[in] Class - /// The Decl to be completed in place. - //------------------------------------------------------------------ - void CompleteType(clang::ObjCInterfaceDecl *Class) override; - - //------------------------------------------------------------------ - /// Called on entering a translation unit. Tells Clang by calling - /// setHasExternalVisibleStorage() and setHasExternalLexicalStorage() - /// that this object has something to say about undefined names. - /// - /// @param[in] ASTConsumer - /// Unused. - //------------------------------------------------------------------ - void StartTranslationUnit(clang::ASTConsumer *Consumer) override; - - // - // APIs for NamespaceMapCompleter - // - - //------------------------------------------------------------------ - /// Look up the modules containing a given namespace and put the - /// appropriate entries in the namespace map. - /// - /// @param[in] namespace_map - /// The map to be completed. - /// - /// @param[in] name - /// The name of the namespace to be found. - /// - /// @param[in] parent_map - /// The map for the namespace's parent namespace, if there is - /// one. - //------------------------------------------------------------------ - void CompleteNamespaceMap(ClangASTImporter::NamespaceMapSP &namespace_map, const ConstString &name, - ClangASTImporter::NamespaceMapSP &parent_map) const override; - - // - // Helper APIs - // - - clang::NamespaceDecl * - AddNamespace (NameSearchContext &context, - ClangASTImporter::NamespaceMapSP &namespace_decls); - - //------------------------------------------------------------------ - /// The worker function for FindExternalVisibleDeclsByName. - /// - /// @param[in] context - /// The NameSearchContext to use when filing results. - //------------------------------------------------------------------ - virtual void FindExternalVisibleDecls (NameSearchContext &context); - - void SetImportInProgress (bool import_in_progress) { m_import_in_progress = import_in_progress; } - bool GetImportInProgress () { return m_import_in_progress; } - - void SetLookupsEnabled (bool lookups_enabled) { m_lookups_enabled = lookups_enabled; } - bool GetLookupsEnabled () { return m_lookups_enabled; } - - //---------------------------------------------------------------------- - /// @class ClangASTSourceProxy ClangASTSource.h "lldb/Expression/ClangASTSource.h" - /// @brief Proxy for ClangASTSource - /// - /// Clang AST contexts like to own their AST sources, so this is a - /// state-free proxy object. - //---------------------------------------------------------------------- - class ClangASTSourceProxy : public ClangExternalASTSourceCommon - { - public: - ClangASTSourceProxy (ClangASTSource &original) : - m_original(original) - { - } - - bool - FindExternalVisibleDeclsByName(const clang::DeclContext *DC, clang::DeclarationName Name) override - { - return m_original.FindExternalVisibleDeclsByName(DC, Name); - } - - clang::ExternalLoadResult - FindExternalLexicalDecls(const clang::DeclContext *DC, bool (*isKindWeWant)(clang::Decl::Kind), - llvm::SmallVectorImpl<clang::Decl *> &Decls) override - { - return m_original.FindExternalLexicalDecls(DC, isKindWeWant, Decls); - } - - void - CompleteType(clang::TagDecl *Tag) override - { - return m_original.CompleteType(Tag); - } - - void - CompleteType(clang::ObjCInterfaceDecl *Class) override - { - return m_original.CompleteType(Class); - } - - bool - layoutRecordType(const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, - llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets, - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &BaseOffsets, - llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &VirtualBaseOffsets) override - { - return m_original.layoutRecordType(Record, - Size, - Alignment, - FieldOffsets, - BaseOffsets, - VirtualBaseOffsets); - } - - void - StartTranslationUnit(clang::ASTConsumer *Consumer) override - { - return m_original.StartTranslationUnit(Consumer); - } - - ClangASTMetadata * - GetMetadata(const void * object) - { - return m_original.GetMetadata(object); - } - - void - SetMetadata(const void * object, ClangASTMetadata &metadata) - { - return m_original.SetMetadata(object, metadata); - } - - bool - HasMetadata(const void * object) - { - return m_original.HasMetadata(object); - } - private: - ClangASTSource &m_original; - }; - - clang::ExternalASTSource *CreateProxy() - { - return new ClangASTSourceProxy(*this); - } - -protected: - //------------------------------------------------------------------ - /// Look for the complete version of an Objective-C interface, and - /// return it if found. - /// - /// @param[in] interface_decl - /// An ObjCInterfaceDecl that may not be the complete one. - /// - /// @return - /// NULL if the complete interface couldn't be found; - /// the complete interface otherwise. - //------------------------------------------------------------------ - clang::ObjCInterfaceDecl * - GetCompleteObjCInterface (clang::ObjCInterfaceDecl *interface_decl); - - //------------------------------------------------------------------ - /// Find all entities matching a given name in a given module, - /// using a NameSearchContext to make Decls for them. - /// - /// @param[in] context - /// The NameSearchContext that can construct Decls for this name. - /// - /// @param[in] module - /// If non-NULL, the module to query. - /// - /// @param[in] namespace_decl - /// If valid and module is non-NULL, the parent namespace. - /// - /// @param[in] current_id - /// The ID for the current FindExternalVisibleDecls invocation, - /// for logging purposes. - /// - /// @return - /// True on success; false otherwise. - //------------------------------------------------------------------ - void - FindExternalVisibleDecls (NameSearchContext &context, - lldb::ModuleSP module, - ClangNamespaceDecl &namespace_decl, - unsigned int current_id); - - //------------------------------------------------------------------ - /// Find all Objective-C methods matching a given selector. - /// - /// @param[in] context - /// The NameSearchContext that can construct Decls for this name. - /// Its m_decl_name contains the selector and its m_decl_context - /// is the containing object. - //------------------------------------------------------------------ - void - FindObjCMethodDecls (NameSearchContext &context); - - //------------------------------------------------------------------ - /// Find all Objective-C properties and ivars with a given name. - /// - /// @param[in] context - /// The NameSearchContext that can construct Decls for this name. - /// Its m_decl_name contains the name and its m_decl_context - /// is the containing object. - //------------------------------------------------------------------ - void - FindObjCPropertyAndIvarDecls (NameSearchContext &context); - - //------------------------------------------------------------------ - /// A wrapper for ClangASTContext: |