diff options
Diffstat (limited to 'include/lldb/Core')
71 files changed, 1868 insertions, 1732 deletions
diff --git a/include/lldb/Core/Address.h b/include/lldb/Core/Address.h index cfa16c30bedb9..0afe55b12be3c 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 9d781f3e85ae9..31e3286cb1108 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 e5fe276e3fb1e..711cc57c14a40 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 ddeb0e0301d2e..5b47379ed18e2 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 afde675a89bbc..cf792f5054e6f 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 0b818a0c71236..13ff436cf08f6 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 6d54b1b431339..8e59a41805ece 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 6c627c2ad3b7e..80abc15f671c1 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 7924ed293d3cf..d29aaca9c2ea9 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 121395c0b23c6..4b3024ebdc576 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 48e62142954e5..d0553699e14ef 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 cfe8ea2db0e12..6e234da0a5957 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 ad73fabe5f1ef..d379c4cf4e866 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 944b975a318a9..9479d4e1a4559 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 7889f4191e507..8b4727eb2de2c 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 e61189b981034..d5cb5e8ba4bc3 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 0d9b90c8919d4..4ca648ca296eb 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 e08e2def4c188..bfa99de81ea4a 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 774d80968ff92..c5e60022fc963 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 1c3eec0359c3e..e8867c0e7e772 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 e1928f1b063d6..f0f7fbdf756f4 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 db4f59132832e..659b696e61fd4 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 b3626882f8432..fbb7bd8b0c1a7 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 b617d8e75f583..3eba1c3cc9d83 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 670c6aa695e1d..0000000000000 --- 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 2dbd2eb436ce8..b11c1644507b0 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 3aa4b4d48e17b..674fdfdfc0b2f 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 a4dd76f112377..ca04c84b21a63 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 4b77ff1ab8fc1..5a52ab2b8b2d5 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 127ddaeb9fd41..35b182aa9801f 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 f4c12cf168ac7..a0dd43263a2c5 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 be7041981a0a7..95de7f375736a 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 57b8077477ced..eac0746baba17 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 af940d788ab03..6f8001fbfd2b1 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 d2c43a5d794d4..b2e3f06f08a9e 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 1b1a71a11c5ac..030b849212c49 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 a58d17b4a794d..b0ece5154ce1d 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 9321e057a397f..b3c2124f447de 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 821a0fb1ae219..a476cd3bd8676 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 bbb7509cedb22..3d5e1fb39b439 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 65d408e298673..8c92f1ba667ef 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 0f65be1bee4b7..5504bafd6b7ef 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 11780aa6ff0fa..f784069894ec6 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 d3b054463fa70..b069cfd496e1e 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 b5fb91c6ce075..e5a9da7512bb8 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 55bb361780a5d..781f0a5994937 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 3fdb6f6e7012f..834f412d0a033 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 1aa46dd80a686..5b6bde7a13c23 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 e2a29a3745534..7ab619b3bb79e 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 c69ed872c30d7..3e341b9940750 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 7da29e48299d7..52f34521ef0eb 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 f5a7ccfb2ffa3..6b2b59b7617c5 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 19c67b65e8c18..e019c70ed5e5b 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 e354d91be4428..ffaeba6fce9b7 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 3bb14421b1e99..88426cfb6c75d 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 972c0d53ea99e..1e50f747f2a8d 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 957cedeb0dcc6..a6d934afd294e 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 cdc507093b289..c066cc7d3661d 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 1538d7a556399..8c7ffe5ec5e26 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 bf8707ea3b05e..13e26c6ab0c10 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 4e05d50132ec8..f63ee83284df7 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 0000000000000..395820dad6c7a --- /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 9063276b0198e..356d175a64aeb 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 e3574e8a4d4e5..36b82f00a2408 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 8d42706be1668..80f37f1047654 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 6565367cc61ce..4f5e7b246fbd5 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 41b43188a46a0..0e12fc7e3f287 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 f7c7683d60bc8..ac76f9e4280bd 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 88824ef4fa546..05bc3781a3cc6 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 0e32d09057dc8..4adb6bad0ada7 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 9fa8816229a96..649a93154b3fe 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_ |