diff options
Diffstat (limited to 'lldb/include/lldb/Core')
51 files changed, 1137 insertions, 558 deletions
diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h index 71e50b91d68e..ec393a1871e3 100644 --- a/lldb/include/lldb/Core/Address.h +++ b/lldb/include/lldb/Core/Address.h @@ -14,8 +14,8 @@ #include "lldb/lldb-private-enumerations.h" #include "lldb/lldb-types.h" -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> namespace lldb_private { class Block; @@ -116,7 +116,7 @@ public: /// /// Initialize with a invalid section (NULL) and an invalid offset /// (LLDB_INVALID_ADDRESS). - Address() : m_section_wp(), m_offset(LLDB_INVALID_ADDRESS) {} + Address() : m_section_wp() {} /// Copy constructor /// @@ -487,7 +487,8 @@ public: protected: // Member variables. lldb::SectionWP m_section_wp; ///< The section for the address, can be NULL. - lldb::addr_t m_offset; ///< Offset into section if \a m_section_wp is valid... + lldb::addr_t m_offset = LLDB_INVALID_ADDRESS; ///< Offset into section if \a + ///< m_section_wp is valid... // Returns true if the m_section_wp once had a reference to a valid section // shared pointer, but no longer does. This can happen if we have an address diff --git a/lldb/include/lldb/Core/AddressRange.h b/lldb/include/lldb/Core/AddressRange.h index 8ccf96a436a1..6fbdc35c9168 100644 --- a/lldb/include/lldb/Core/AddressRange.h +++ b/lldb/include/lldb/Core/AddressRange.h @@ -13,7 +13,7 @@ #include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" -#include <stddef.h> +#include <cstddef> namespace lldb_private { class SectionList; @@ -94,8 +94,7 @@ public: /// \return /// Returns \b true if \a so_addr is contained in this range, /// \b false otherwise. - // bool - // Contains (const Address &so_addr) const; + bool Contains(const Address &so_addr) const; /// Check if a section offset address is contained in this range. /// @@ -240,7 +239,7 @@ public: protected: // Member variables Address m_base_addr; ///< The section offset base address of this range. - lldb::addr_t m_byte_size; ///< The size in bytes of this address range. + lldb::addr_t m_byte_size = 0; ///< The size in bytes of this address range. }; // bool operator== (const AddressRange& lhs, const AddressRange& rhs); diff --git a/lldb/include/lldb/Core/AddressResolver.h b/lldb/include/lldb/Core/AddressResolver.h index 9ac058a97cd9..cb571bb5cb60 100644 --- a/lldb/include/lldb/Core/AddressResolver.h +++ b/lldb/include/lldb/Core/AddressResolver.h @@ -13,7 +13,7 @@ #include "lldb/Core/SearchFilter.h" #include "lldb/lldb-defines.h" -#include <stddef.h> +#include <cstddef> #include <vector> namespace lldb_private { diff --git a/lldb/include/lldb/Core/AddressResolverFileLine.h b/lldb/include/lldb/Core/AddressResolverFileLine.h index 46bf4155e865..e768256bf618 100644 --- a/lldb/include/lldb/Core/AddressResolverFileLine.h +++ b/lldb/include/lldb/Core/AddressResolverFileLine.h @@ -11,10 +11,10 @@ #include "lldb/Core/AddressResolver.h" #include "lldb/Core/SearchFilter.h" -#include "lldb/Utility/FileSpec.h" +#include "lldb/Core/SourceLocationSpec.h" #include "lldb/lldb-defines.h" -#include <stdint.h> +#include <cstdint> namespace lldb_private { class Address; @@ -28,8 +28,7 @@ class SymbolContext; class AddressResolverFileLine : public AddressResolver { public: - AddressResolverFileLine(const FileSpec &resolver, uint32_t line_no, - bool check_inlines); + AddressResolverFileLine(SourceLocationSpec location_spec); ~AddressResolverFileLine() override; @@ -42,10 +41,7 @@ public: void GetDescription(Stream *s) override; protected: - FileSpec m_file_spec; // This is the file spec we are looking for. - uint32_t m_line_number; // This is the line number that we are looking for. - bool m_inlines; // This determines whether the resolver looks for inlined - // functions or not. + SourceLocationSpec m_src_location_spec; private: AddressResolverFileLine(const AddressResolverFileLine &) = delete; diff --git a/lldb/include/lldb/Core/AddressResolverName.h b/lldb/include/lldb/Core/AddressResolverName.h deleted file mode 100644 index 0ec1ef05b0ec..000000000000 --- a/lldb/include/lldb/Core/AddressResolverName.h +++ /dev/null @@ -1,63 +0,0 @@ -//===-- AddressResolverName.h -----------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLDB_CORE_ADDRESSRESOLVERNAME_H -#define LLDB_CORE_ADDRESSRESOLVERNAME_H - -#include "lldb/Core/AddressResolver.h" -#include "lldb/Core/SearchFilter.h" -#include "lldb/Utility/ConstString.h" -#include "lldb/Utility/RegularExpression.h" -#include "lldb/lldb-defines.h" - -namespace lldb_private { -class Address; -class Stream; -class SymbolContext; - -/// \class AddressResolverName AddressResolverName.h -/// "lldb/Core/AddressResolverName.h" This class finds addresses for a given -/// function name, either by exact match or by regular expression. - -class AddressResolverName : public AddressResolver { -public: - AddressResolverName(const char *func_name, - AddressResolver::MatchType type = Exact); - - // Creates a function breakpoint by regular expression. Takes over control - // of the lifespan of func_regex. - AddressResolverName(RegularExpression func_regex); - - AddressResolverName(const char *class_name, const char *method, - AddressResolver::MatchType type); - - ~AddressResolverName() override; - - Searcher::CallbackReturn SearchCallback(SearchFilter &filter, - SymbolContext &context, - Address *addr) override; - - lldb::SearchDepth GetDepth() override; - - void GetDescription(Stream *s) override; - -protected: - ConstString m_func_name; - ConstString m_class_name; // FIXME: Not used yet. The idea would be to stop - // on methods of this class. - RegularExpression m_regex; - AddressResolver::MatchType m_match_type; - -private: - AddressResolverName(const AddressResolverName &) = delete; - const AddressResolverName &operator=(const AddressResolverName &) = delete; -}; - -} // namespace lldb_private - -#endif // LLDB_CORE_ADDRESSRESOLVERNAME_H diff --git a/lldb/include/lldb/Core/Architecture.h b/lldb/include/lldb/Core/Architecture.h index 2ea8bd31ebf4..b68bf27ae0df 100644 --- a/lldb/include/lldb/Core/Architecture.h +++ b/lldb/include/lldb/Core/Architecture.h @@ -10,6 +10,7 @@ #define LLDB_CORE_ARCHITECTURE_H #include "lldb/Core/PluginInterface.h" +#include "lldb/Target/MemoryTagManager.h" namespace lldb_private { @@ -97,6 +98,17 @@ public: Target &target) const { return addr; } + + // Returns a pointer to an object that can manage memory tags for this + // Architecture E.g. masking out tags, unpacking tag streams etc. Returns + // nullptr if the architecture does not have a memory tagging extension. + // + // The return pointer being valid does not mean that the current process has + // memory tagging enabled, just that a tagging technology exists for this + // architecture. + virtual const MemoryTagManager *GetMemoryTagManager() const { + return nullptr; + } }; } // namespace lldb_private diff --git a/lldb/include/lldb/Core/Communication.h b/lldb/include/lldb/Core/Communication.h index 354c4bbcc283..930e927f6783 100644 --- a/lldb/include/lldb/Core/Communication.h +++ b/lldb/include/lldb/Core/Communication.h @@ -22,8 +22,8 @@ #include <ratio> #include <string> -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> namespace lldb_private { class Connection; diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 68daae1a3710..f0849c9ac950 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -9,7 +9,7 @@ #ifndef LLDB_CORE_DEBUGGER_H #define LLDB_CORE_DEBUGGER_H -#include <stdint.h> +#include <cstdint> #include <memory> #include <vector> @@ -42,9 +42,9 @@ #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/Threading.h" -#include <assert.h> -#include <stddef.h> -#include <stdio.h> +#include <cassert> +#include <cstddef> +#include <cstdio> namespace llvm { class raw_ostream; @@ -73,6 +73,50 @@ class Debugger : public std::enable_shared_from_this<Debugger>, friend class SourceManager; // For GetSourceFileCache. public: + /// Broadcaster event bits definitions. + enum { + eBroadcastBitProgress = (1 << 0), + }; + + static ConstString GetStaticBroadcasterClass(); + + /// Get the public broadcaster for this debugger. + Broadcaster &GetBroadcaster() { return m_broadcaster; } + const Broadcaster &GetBroadcaster() const { return m_broadcaster; } + + class ProgressEventData : public EventData { + + public: + ProgressEventData(uint64_t progress_id, const std::string &message, + uint64_t completed, uint64_t total, + bool debugger_specific) + : m_message(message), m_id(progress_id), m_completed(completed), + m_total(total), m_debugger_specific(debugger_specific) {} + + static ConstString GetFlavorString(); + + ConstString GetFlavor() const override; + + void Dump(Stream *s) const override; + + static const ProgressEventData * + GetEventDataFromEvent(const Event *event_ptr); + uint64_t GetID() const { return m_id; } + uint64_t GetCompleted() const { return m_completed; } + uint64_t GetTotal() const { return m_total; } + const std::string &GetMessage() const { return m_message; } + bool IsDebuggerSpecific() const { return m_debugger_specific; } + + private: + std::string m_message; + const uint64_t m_id; + uint64_t m_completed; + const uint64_t m_total; + const bool m_debugger_specific; + ProgressEventData(const ProgressEventData &) = delete; + const ProgressEventData &operator=(const ProgressEventData &) = delete; + }; + ~Debugger() override; static lldb::DebuggerSP @@ -246,6 +290,8 @@ public: const FormatEntity::Entry *GetFrameFormatUnique() const; + uint32_t GetStopDisassemblyMaxSize() const; + const FormatEntity::Entry *GetThreadFormat() const; const FormatEntity::Entry *GetThreadStopFormat() const; @@ -344,6 +390,40 @@ public: protected: friend class CommandInterpreter; friend class REPL; + friend class Progress; + + /// Report progress events. + /// + /// Progress events will be delivered to any debuggers that have listeners + /// for the eBroadcastBitProgress. This function is called by the + /// lldb_private::Progress class to deliver the events to any debuggers that + /// qualify. + /// + /// \param [in] progress_id + /// The unique integer identifier for the progress to report. + /// + /// \param[in] message + /// The title of the progress dialog to display in the UI. + /// + /// \param [in] completed + /// The amount of work completed. If \a completed is zero, then this event + /// is a progress started event. If \a completed is equal to \a total, then + /// this event is a progress end event. Otherwise completed indicates the + /// current progress compare to the total value. + /// + /// \param [in] total + /// The total amount of work units that need to be completed. If this value + /// is UINT64_MAX, then an indeterminate progress indicator should be + /// displayed. + /// + /// \param [in] debugger_id + /// If this optional parameter has a value, it indicates the unique + /// debugger identifier that this progress should be delivered to. If this + /// optional parameter does not have a value, the progress will be + /// delivered to all debuggers. + static void ReportProgress(uint64_t progress_id, const std::string &message, + uint64_t completed, uint64_t total, + llvm::Optional<lldb::user_id_t> debugger_id); bool StartEventHandlerThread(); @@ -430,7 +510,8 @@ protected: LoadedPluginsList m_loaded_plugins; HostThread m_event_handler_thread; HostThread m_io_handler_thread; - Broadcaster m_sync_broadcaster; + Broadcaster m_sync_broadcaster; ///< Private debugger synchronization. + Broadcaster m_broadcaster; ///< Public Debugger event broadcaster. lldb::ListenerSP m_forward_listener_sp; llvm::once_flag m_clear_once; lldb::TargetSP m_dummy_target_sp; diff --git a/lldb/include/lldb/Core/Declaration.h b/lldb/include/lldb/Core/Declaration.h new file mode 100644 index 000000000000..f81de21bc8f8 --- /dev/null +++ b/lldb/include/lldb/Core/Declaration.h @@ -0,0 +1,195 @@ +//===-- Declaration.h -------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SYMBOL_DECLARATION_H +#define LLDB_SYMBOL_DECLARATION_H + +#include "lldb/Utility/FileSpec.h" +#include "lldb/lldb-private.h" + +namespace lldb_private { + +/// \class Declaration Declaration.h "lldb/Core/Declaration.h" +/// A class that describes the declaration location of a +/// lldb object. +/// +/// The declarations include the file specification, line number, and the +/// column info and can help track where functions, blocks, inlined functions, +/// types, variables, any many other debug core objects were declared. +class Declaration { +public: + /// Default constructor. + Declaration() : m_file() {} + + /// Construct with file specification, and optional line and column. + /// + /// \param[in] file_spec + /// The file specification that describes where this was + /// declared. + /// + /// \param[in] line + /// The line number that describes where this was declared. Set + /// to zero if there is no line number information. + /// + /// \param[in] column + /// The column number that describes where this was declared. + /// Set to zero if there is no column number information. + Declaration(const FileSpec &file_spec, uint32_t line = 0, + uint16_t column = LLDB_INVALID_COLUMN_NUMBER) + : m_file(file_spec), m_line(line), m_column(column) {} + + /// Construct with a pointer to another Declaration object. + Declaration(const Declaration *decl_ptr) + : m_file(), m_line(0), m_column(LLDB_INVALID_COLUMN_NUMBER) { + if (decl_ptr) + *this = *decl_ptr; + } + + /// Clear the object's state. + /// + /// Sets the file specification to be empty, and the line and column to + /// zero. + void Clear() { + m_file.Clear(); + m_line = 0; + m_column = 0; + } + + /// Compare two declaration objects. + /// + /// Compares the two file specifications from \a lhs and \a rhs. If the file + /// specifications are equal, then continue to compare the line number and + /// column numbers respectively. + /// + /// \param[in] lhs + /// The Left Hand Side const Declaration object reference. + /// + /// \param[in] rhs + /// The Right Hand Side const Declaration object reference. + /// + /// \return + /// -1 if lhs < rhs + /// 0 if lhs == rhs + /// 1 if lhs > rhs + static int Compare(const Declaration &lhs, const Declaration &rhs); + + /// Checks if this object has the same file and line as another declaration + /// object. + /// + /// \param[in] declaration + /// The const Declaration object to compare with. + /// + /// \return + /// Returns \b true if \b declaration is at the same file and + /// line, \b false otherwise. + bool FileAndLineEqual(const Declaration &declaration) const; + + /// Dump a description of this object to a Stream. + /// + /// Dump a description of the contents of this object to the supplied stream + /// \a s. + /// + /// \param[in] s + /// The stream to which to dump the object description. + void Dump(Stream *s, bool show_fullpaths) const; + + bool DumpStopContext(Stream *s, bool show_fullpaths) const; + + /// Get accessor for file specification. + /// + /// \return + /// A reference to the file specification object. + FileSpec &GetFile() { return m_file; } + + /// Get const accessor for file specification. + /// + /// \return + /// A const reference to the file specification object. + const FileSpec &GetFile() const { return m_file; } + + /// Get accessor for the declaration line number. + /// + /// \return + /// Non-zero indicates a valid line number, zero indicates no + /// line information is available. + uint32_t GetLine() const { return m_line; } + + /// Get accessor for the declaration column number. + /// + /// \return + /// Non-zero indicates a valid column number, zero indicates no + /// column information is available. + uint16_t GetColumn() const { return m_column; } + + /// Convert to boolean operator. + /// + /// This allows code to check a Declaration object to see if it + /// contains anything valid using code such as: + /// + /// \code + /// Declaration decl(...); + /// if (decl) + /// { ... + /// \endcode + /// + /// \return + /// A \b true if both the file_spec and the line are valid, + /// \b false otherwise. + explicit operator bool() const { return IsValid(); } + + bool IsValid() const { + return m_file && m_line != 0 && m_line != LLDB_INVALID_LINE_NUMBER; + } + + /// Get the memory cost of this object. + /// + /// \return + /// The number of bytes that this object occupies in memory. + /// The returned value does not include the bytes for any + /// shared string values. + /// + /// \see ConstString::StaticMemorySize () + size_t MemorySize() const; + + /// Set accessor for the declaration file specification. + /// + /// \param[in] file_spec + /// The new declaration file specification. + void SetFile(const FileSpec &file_spec) { m_file = file_spec; } + + /// Set accessor for the declaration line number. + /// + /// \param[in] line + /// Non-zero indicates a valid line number, zero indicates no + /// line information is available. + void SetLine(uint32_t line) { m_line = line; } + + /// Set accessor for the declaration column number. + /// + /// \param[in] column + /// Non-zero indicates a valid column number, zero indicates no + /// column information is available. + void SetColumn(uint16_t column) { m_column = column; } + +protected: + /// The file specification that points to the source file where the + /// declaration occurred. + FileSpec m_file; + /// Non-zero values indicates a valid line number, zero indicates no line + /// number information is available. + uint32_t m_line = 0; + /// Non-zero values indicates a valid column number, zero indicates no column + /// information is available. + uint16_t m_column = LLDB_INVALID_COLUMN_NUMBER; +}; + +bool operator==(const Declaration &lhs, const Declaration &rhs); + +} // namespace lldb_private + +#endif // LLDB_SYMBOL_DECLARATION_H diff --git a/lldb/include/lldb/Core/Disassembler.h b/lldb/include/lldb/Core/Disassembler.h index 9a694de0f60a..622c23ff6492 100644 --- a/lldb/include/lldb/Core/Disassembler.h +++ b/lldb/include/lldb/Core/Disassembler.h @@ -34,9 +34,9 @@ #include <string> #include <vector> -#include <stddef.h> -#include <stdint.h> -#include <stdio.h> +#include <cstddef> +#include <cstdint> +#include <cstdio> namespace llvm { template <typename T> class SmallVectorImpl; @@ -394,10 +394,12 @@ public: lldb::addr_t value; }; - static lldb::DisassemblerSP - DisassembleRange(const ArchSpec &arch, const char *plugin_name, - const char *flavor, Target &target, - const AddressRange &disasm_range, bool prefer_file_cache); + static lldb::DisassemblerSP DisassembleRange(const ArchSpec &arch, + const char *plugin_name, + const char *flavor, + Target &target, + const AddressRange &disasm_range, + bool force_live_memory = false); static lldb::DisassemblerSP DisassembleBytes(const ArchSpec &arch, const char *plugin_name, @@ -426,7 +428,8 @@ public: Stream &strm); size_t ParseInstructions(Target &target, Address address, Limit limit, - Stream *error_strm_ptr, bool prefer_file_cache); + Stream *error_strm_ptr, + bool force_live_memory = false); virtual size_t DecodeInstructions(const Address &base_addr, const DataExtractor &data, @@ -451,10 +454,10 @@ protected: struct SourceLine { FileSpec file; - uint32_t line; - uint32_t column; + uint32_t line = LLDB_INVALID_LINE_NUMBER; + uint32_t column = 0; - SourceLine() : file(), line(LLDB_INVALID_LINE_NUMBER), column(0) {} + SourceLine() : file() {} bool operator==(const SourceLine &rhs) const { return file == rhs.file && line == rhs.line && rhs.column == column; @@ -473,14 +476,12 @@ protected: // index of the "current" source line, if we want to highlight that when // displaying the source lines. (as opposed to the surrounding source // lines provided to give context) - size_t current_source_line; + size_t current_source_line = -1; // Whether to print a blank line at the end of the source lines. - bool print_source_context_end_eol; + bool print_source_context_end_eol = true; - SourceLinesToDisplay() - : lines(), current_source_line(-1), print_source_context_end_eol(true) { - } + SourceLinesToDisplay() : lines() {} }; // Get the function's declaration line number, hopefully a line number diff --git a/lldb/include/lldb/Core/DumpDataExtractor.h b/lldb/include/lldb/Core/DumpDataExtractor.h index 2a9d778e0a6a..12188609e8c0 100644 --- a/lldb/include/lldb/Core/DumpDataExtractor.h +++ b/lldb/include/lldb/Core/DumpDataExtractor.h @@ -12,8 +12,8 @@ #include "lldb/lldb-enumerations.h" #include "lldb/lldb-types.h" -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> namespace lldb_private { class DataExtractor; diff --git a/lldb/include/lldb/Core/EmulateInstruction.h b/lldb/include/lldb/Core/EmulateInstruction.h index a575488ba966..f50fee095a8b 100644 --- a/lldb/include/lldb/Core/EmulateInstruction.h +++ b/lldb/include/lldb/Core/EmulateInstruction.h @@ -21,8 +21,8 @@ #include "lldb/lldb-private-types.h" #include "lldb/lldb-types.h" -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> namespace lldb_private { class OptionValueDictionary; @@ -182,8 +182,8 @@ public: } InfoType; struct Context { - ContextType type; - enum InfoType info_type; + ContextType type = eContextInvalid; + enum InfoType info_type = eInfoTypeNoArgs; union { struct RegisterPlusOffset { RegisterInfo reg; // base register @@ -237,7 +237,7 @@ public: uint32_t isa; } info; - Context() : type(eContextInvalid), info_type(eInfoTypeNoArgs) {} + Context() = default; void SetRegisterPlusOffset(RegisterInfo base_reg, int64_t signed_offset) { info_type = eInfoTypeRegisterPlusOffset; diff --git a/lldb/include/lldb/Core/FileLineResolver.h b/lldb/include/lldb/Core/FileLineResolver.h index 68e252e93bc9..16b1db1b50c4 100644 --- a/lldb/include/lldb/Core/FileLineResolver.h +++ b/lldb/include/lldb/Core/FileLineResolver.h @@ -14,7 +14,7 @@ #include "lldb/Utility/FileSpec.h" #include "lldb/lldb-defines.h" -#include <stdint.h> +#include <cstdint> namespace lldb_private { class Address; @@ -28,8 +28,8 @@ class FileLineResolver : public Searcher { public: FileLineResolver() : m_file_spec(), - m_line_number(UINT32_MAX), // Set this to zero for all lines in a file - m_sc_list(), m_inlines(true) {} + // Set this to zero for all lines in a file + m_sc_list() {} FileLineResolver(const FileSpec &resolver, uint32_t line_no, bool check_inlines); @@ -52,10 +52,11 @@ public: protected: FileSpec m_file_spec; // This is the file spec we are looking for. - uint32_t m_line_number; // This is the line number that we are looking for. + uint32_t m_line_number = + UINT32_MAX; // This is the line number that we are looking for. SymbolContextList m_sc_list; - bool m_inlines; // This determines whether the resolver looks for inlined - // functions or not. + bool m_inlines = true; // This determines whether the resolver looks for + // inlined functions or not. private: FileLineResolver(const FileLineResolver &) = delete; diff --git a/lldb/include/lldb/Core/FileSpecList.h b/lldb/include/lldb/Core/FileSpecList.h index 3e412a7e1a32..cab8e9b9b43f 100644 --- a/lldb/include/lldb/Core/FileSpecList.h +++ b/lldb/include/lldb/Core/FileSpecList.h @@ -14,7 +14,7 @@ #include <vector> -#include <stddef.h> +#include <cstddef> namespace lldb_private { class Stream; diff --git a/lldb/include/lldb/Core/FormatEntity.h b/lldb/include/lldb/Core/FormatEntity.h index 91999f64ab5f..ecae8500df40 100644 --- a/lldb/include/lldb/Core/FormatEntity.h +++ b/lldb/include/lldb/Core/FormatEntity.h @@ -9,26 +9,27 @@ #ifndef LLDB_CORE_FORMATENTITY_H #define LLDB_CORE_FORMATENTITY_H -#include "lldb/Utility/CompletionRequest.h" -#include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/Status.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-types.h" #include <algorithm> -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> #include <string> #include <vector> namespace lldb_private { class Address; +class CompletionRequest; class ExecutionContext; +class FileSpec; +class Status; class Stream; class StringList; class SymbolContext; class ValueObject; } + namespace llvm { class StringRef; } @@ -103,20 +104,51 @@ public: }; struct Definition { + /// The name/string placeholder that corresponds to this definition. const char *name; - const char *string; // Insert this exact string into the output - Entry::Type type; - uint64_t data; - uint32_t num_children; - Definition *children; // An array of "num_children" Definition entries, - bool keep_separator; + /// Insert this exact string into the output + const char *string = nullptr; + /// Entry::Type corresponding to this definition. + const Entry::Type type; + /// Data that is returned as the value of the format string. + const uint64_t data = 0; + /// The number of children of this node in the tree of format strings. + const uint32_t num_children = 0; + /// An array of "num_children" Definition entries. + const Definition *children = nullptr; + /// Whether the separator is kept during parsing or not. It's used + /// for entries with parameters. + const bool keep_separator = false; + + constexpr Definition(const char *name, const FormatEntity::Entry::Type t) + : name(name), type(t) {} + + constexpr Definition(const char *name, const char *string) + : name(name), string(string), type(Entry::Type::EscapeCode) {} + + constexpr Definition(const char *name, const FormatEntity::Entry::Type t, + const uint64_t data) + : name(name), type(t), data(data) {} + + constexpr Definition(const char *name, const FormatEntity::Entry::Type t, + const uint64_t num_children, + const Definition *children, + const bool keep_separator = false) + : name(name), type(t), num_children(num_children), children(children), + keep_separator(keep_separator) {} }; + template <size_t N> + static constexpr Definition + DefinitionWithChildren(const char *name, const FormatEntity::Entry::Type t, + const Definition (&children)[N], + bool keep_separator = false) { + return Definition(name, t, N, children, keep_separator); + } + Entry(Type t = Type::Invalid, const char *s = nullptr, const char *f = nullptr) - : string(s ? s : ""), printf_format(f ? f : ""), children(), - definition(nullptr), type(t), fmt(lldb::eFormatDefault), number(0), - deref(false) {} + : string(s ? s : ""), printf_format(f ? f : ""), children(), type(t) {} Entry(llvm::StringRef s); Entry(char ch); @@ -133,7 +165,6 @@ public: string.clear(); printf_format.clear(); children.clear(); - definition = nullptr; type = Type::Invalid; fmt = lldb::eFormatDefault; number = 0; @@ -157,8 +188,6 @@ public: } if (children != rhs.children) return false; - if (definition != rhs.definition) - return false; if (type != rhs.type) return false; if (fmt != rhs.fmt) @@ -171,11 +200,10 @@ public: std::string string; std::string printf_format; std::vector<Entry> children; - Definition *definition; Type type; - lldb::Format fmt; - lldb::addr_t number; - bool deref; + lldb::Format fmt = lldb::eFormatDefault; + lldb::addr_t number = 0; + bool deref = false; }; static bool Format(const Entry &entry, Stream &s, const SymbolContext *sc, diff --git a/lldb/include/lldb/Core/IOHandler.h b/lldb/include/lldb/Core/IOHandler.h index 2e8f3225fd5f..4a3b788e3ea1 100644 --- a/lldb/include/lldb/Core/IOHandler.h +++ b/lldb/include/lldb/Core/IOHandler.h @@ -26,8 +26,8 @@ #include <string> #include <vector> -#include <stdint.h> -#include <stdio.h> +#include <cstdint> +#include <cstdio> namespace lldb_private { class Debugger; @@ -419,16 +419,14 @@ public: private: #if LLDB_ENABLE_LIBEDIT - static bool IsInputCompleteCallback(Editline *editline, StringList &lines, - void *baton); + bool IsInputCompleteCallback(Editline *editline, StringList &lines); - static int FixIndentationCallback(Editline *editline, const StringList &lines, - int cursor_position, void *baton); + int FixIndentationCallback(Editline *editline, const StringList &lines, + int cursor_position); - static llvm::Optional<std::string> SuggestionCallback(llvm::StringRef line, - void *baton); + llvm::Optional<std::string> SuggestionCallback(llvm::StringRef line); - static void AutoCompleteCallback(CompletionRequest &request, void *baton); + void AutoCompleteCallback(CompletionRequest &request); #endif protected: diff --git a/lldb/include/lldb/Core/LoadedModuleInfoList.h b/lldb/include/lldb/Core/LoadedModuleInfoList.h index 49400f7f4908..ad6da2bd7559 100644 --- a/lldb/include/lldb/Core/LoadedModuleInfoList.h +++ b/lldb/include/lldb/Core/LoadedModuleInfoList.h @@ -101,14 +101,14 @@ public: lldb::addr_t m_dynamic; }; - LoadedModuleInfoList() : m_list(), m_link_map(LLDB_INVALID_ADDRESS) {} + LoadedModuleInfoList() : m_list() {} void add(const LoadedModuleInfo &mod) { m_list.push_back(mod); } void clear() { m_list.clear(); } std::vector<LoadedModuleInfo> m_list; - lldb::addr_t m_link_map; + lldb::addr_t m_link_map = LLDB_INVALID_ADDRESS; }; } // namespace lldb_private diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h index c03fc1eb7599..d11d13b63cfc 100644 --- a/lldb/include/lldb/Core/Mangled.h +++ b/lldb/include/lldb/Core/Mangled.h @@ -17,8 +17,8 @@ #include "llvm/ADT/StringRef.h" +#include <cstddef> #include <memory> -#include <stddef.h> namespace lldb_private { @@ -43,7 +43,8 @@ public: enum ManglingScheme { eManglingSchemeNone = 0, eManglingSchemeMSVC, - eManglingSchemeItanium + eManglingSchemeItanium, + eManglingSchemeRustV0 }; /// Default constructor. diff --git a/lldb/include/lldb/Core/MappedHash.h b/lldb/include/lldb/Core/MappedHash.h index a27ec82b9b86..7bd3c3a78449 100644 --- a/lldb/include/lldb/Core/MappedHash.h +++ b/lldb/include/lldb/Core/MappedHash.h @@ -9,8 +9,8 @@ #ifndef LLDB_CORE_MAPPEDHASH_H #define LLDB_CORE_MAPPEDHASH_H -#include <assert.h> -#include <stdint.h> +#include <cassert> +#include <cstdint> #include <algorithm> #include <functional> @@ -47,19 +47,17 @@ public: uint32_t magic; // HASH_MAGIC or HASH_CIGAM magic value to allow endian detection - uint16_t version; // Version number - uint16_t hash_function; // The hash function enumeration that was used - uint32_t bucket_count; // The number of buckets in this hash table - uint32_t hashes_count; // The total number of unique hash values and hash - // data offsets in this table + uint16_t version = 1; // Version number + uint16_t hash_function = + eHashFunctionDJB; // The hash function enumeration that was used + uint32_t bucket_count = 0; // The number of buckets in this hash table + uint32_t hashes_count = 0; // The total number of unique hash values and + // hash data offsets in this table uint32_t header_data_len; // The size in bytes of the "header_data" template // member below HeaderData header_data; // - Header() - : magic(HASH_MAGIC), version(1), hash_function(eHashFunctionDJB), - bucket_count(0), hashes_count(0), header_data_len(sizeof(T)), - header_data() {} + Header() : magic(HASH_MAGIC), header_data_len(sizeof(T)), header_data() {} virtual ~Header() = default; diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index 9eb7477730c1..dd7100c4616c 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -32,10 +32,10 @@ #include "llvm/Support/Chrono.h" #include <atomic> +#include <cstddef> +#include <cstdint> #include <memory> #include <mutex> -#include <stddef.h> -#include <stdint.h> #include <string> #include <vector> @@ -850,13 +850,10 @@ public: /// \param[in] path /// The original source file path to try and remap. /// - /// \param[out] new_path - /// The newly remapped filespec that is may or may not exist. - /// /// \return - /// /b true if \a path was successfully located and \a new_path - /// is filled in with a new source path, \b false otherwise. - bool RemapSourceFile(llvm::StringRef path, std::string &new_path) const; + /// The newly remapped filespec that is may or may not exist if + /// \a path was successfully located. + llvm::Optional<std::string> RemapSourceFile(llvm::StringRef path) const; bool RemapSourceFile(const char *, std::string &) const = delete; /// Update the ArchSpec to a more specific variant. @@ -885,10 +882,7 @@ public: /// correctly. class LookupInfo { public: - LookupInfo() - : m_name(), m_lookup_name(), m_language(lldb::eLanguageTypeUnknown), - m_name_type_mask(lldb::eFunctionNameTypeNone), - m_match_name_after_lookup(false) {} + LookupInfo() : m_name(), m_lookup_name() {} LookupInfo(ConstString name, lldb::FunctionNameType name_type_mask, lldb::LanguageType language); @@ -917,15 +911,15 @@ public: ConstString m_lookup_name; /// Limit matches to only be for this language - lldb::LanguageType m_language; + lldb::LanguageType m_language = lldb::eLanguageTypeUnknown; /// One or more bits from lldb::FunctionNameType that indicate what kind of /// names we are looking for - lldb::FunctionNameType m_name_type_mask; + lldb::FunctionNameType m_name_type_mask = lldb::eFunctionNameTypeNone; ///< If \b true, then demangled names that match will need to contain ///< "m_name" in order to be considered a match - bool m_match_name_after_lookup; + bool m_match_name_after_lookup = false; }; protected: @@ -952,7 +946,7 @@ protected: ConstString m_object_name; ///< The name an object within this module that is ///selected, or empty of the module is represented ///by \a m_file. - uint64_t m_object_offset; + uint64_t m_object_offset = 0; llvm::sys::TimePoint<> m_object_mod_time; /// DataBuffer containing the module image, if it was provided at diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h index 46a718f08f04..07dddd18357b 100644 --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -27,8 +27,8 @@ #include <mutex> #include <vector> -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> namespace lldb_private { class ConstString; @@ -471,7 +471,7 @@ protected: collection m_modules; ///< The collection of modules. mutable std::recursive_mutex m_modules_mutex; - Notifier *m_notifier; + Notifier *m_notifier = nullptr; public: typedef LockingAdaptedIterable<collection, lldb::ModuleSP, vector_adapter, diff --git a/lldb/include/lldb/Core/ModuleSpec.h b/lldb/include/lldb/Core/ModuleSpec.h index 9dd398a05291..8e5deebbab9a 100644 --- a/lldb/include/lldb/Core/ModuleSpec.h +++ b/lldb/include/lldb/Core/ModuleSpec.h @@ -27,12 +27,11 @@ class ModuleSpec { public: ModuleSpec() : m_file(), m_platform_file(), m_symbol_file(), m_arch(), m_uuid(), - m_object_name(), m_object_offset(0), m_object_size(0), - m_source_mappings() {} + m_object_name(), m_source_mappings() {} - /// If the \param data argument is passed, its contents will be used + /// If the \c data argument is passed, its contents will be used /// as the module contents instead of trying to read them from - /// \param file_spec. + /// \c file_spec . ModuleSpec(const FileSpec &file_spec, const UUID &uuid = UUID(), lldb::DataBufferSP data = lldb::DataBufferSP()) : m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(), @@ -271,8 +270,8 @@ protected: ArchSpec m_arch; UUID m_uuid; ConstString m_object_name; - uint64_t m_object_offset; - uint64_t m_object_size; + uint64_t m_object_offset = 0; + uint64_t m_object_size = 0; llvm::sys::TimePoint<> m_object_mod_time; mutable PathMappingList m_source_mappings; lldb::DataBufferSP m_data = {}; diff --git a/lldb/include/lldb/Core/Opcode.h b/lldb/include/lldb/Core/Opcode.h index a812ae23f6b7..70f2dbdf639f 100644 --- a/lldb/include/lldb/Core/Opcode.h +++ b/lldb/include/lldb/Core/Opcode.h @@ -14,9 +14,9 @@ #include "llvm/Support/SwapByteOrder.h" -#include <assert.h> -#include <stdint.h> -#include <string.h> +#include <cassert> +#include <cstdint> +#include <cstring> namespace lldb { class SBInstruction; @@ -38,7 +38,7 @@ public: eTypeBytes }; - Opcode() : m_byte_order(lldb::eByteOrderInvalid), m_type(eTypeInvalid) {} + Opcode() = default; Opcode(uint8_t inst, lldb::ByteOrder order) : m_byte_order(order), m_type(eType8) { @@ -252,9 +252,9 @@ protected: endian::InlHostByteOrder() == lldb::eByteOrderBig); } - lldb::ByteOrder m_byte_order; + lldb::ByteOrder m_byte_order = lldb::eByteOrderInvalid; - Opcode::Type m_type; + Opcode::Type m_type = eTypeInvalid; union { uint8_t inst8; uint16_t inst16; diff --git a/lldb/include/lldb/Core/PluginManager.h b/lldb/include/lldb/Core/PluginManager.h index 0ac8308d1758..be91929c62e1 100644 --- a/lldb/include/lldb/Core/PluginManager.h +++ b/lldb/include/lldb/Core/PluginManager.h @@ -19,8 +19,8 @@ #include "lldb/lldb-private-interfaces.h" #include "llvm/ADT/StringRef.h" -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> #define LLDB_PLUGIN_DEFINE_ADV(ClassName, PluginName) \ namespace lldb_private { \ @@ -191,7 +191,8 @@ public: GetObjectFileCreateMemoryCallbackForPluginName(ConstString name); static Status SaveCore(const lldb::ProcessSP &process_sp, - const FileSpec &outfile); + const FileSpec &outfile, + lldb::SaveCoreStyle &core_style); // ObjectContainer static bool @@ -331,18 +332,20 @@ public: GetSymbolVendorCreateCallbackAtIndex(uint32_t idx); // Trace - static bool RegisterPlugin(ConstString name, const char *description, - TraceCreateInstance create_callback, - llvm::StringRef schema, - TraceGetStartCommand get_start_command); + static bool RegisterPlugin( + ConstString name, const char *description, + TraceCreateInstanceForSessionFile create_callback_for_session_file, + TraceCreateInstanceForLiveProcess create_callback_for_live_process, + llvm::StringRef schema); - static bool UnregisterPlugin(TraceCreateInstance create_callback); + static bool + UnregisterPlugin(TraceCreateInstanceForSessionFile create_callback); - static TraceCreateInstance GetTraceCreateCallback(ConstString plugin_name); + static TraceCreateInstanceForSessionFile + GetTraceCreateCallback(ConstString plugin_name); - static lldb::CommandObjectSP - GetTraceStartCommand(llvm::StringRef plugin_name, - CommandInterpreter &interpreter); + static TraceCreateInstanceForLiveProcess + GetTraceCreateCallbackForLiveProcess(ConstString plugin_name); /// Get the JSON schema for a trace session file corresponding to the given /// plugin. @@ -366,6 +369,28 @@ public: /// number plugins, otherwise the actual schema is returned. static llvm::StringRef GetTraceSchema(size_t index); + // TraceExporter + + /// \param[in] create_thread_trace_export_command + /// This callback is used to create a CommandObject that will be listed + /// under "thread trace export". Can be \b null. + static bool RegisterPlugin( + ConstString name, const char *description, + TraceExporterCreateInstance create_callback, + ThreadTraceExportCommandCreator create_thread_trace_export_command); + + static TraceExporterCreateInstance + GetTraceExporterCreateCallback(ConstString plugin_name); + + static bool UnregisterPlugin(TraceExporterCreateInstance create_callback); + + static const char *GetTraceExporterPluginNameAtIndex(uint32_t index); + + /// Return the callback used to create the CommandObject that will be listed + /// under "thread trace export". Can be \b null. + static ThreadTraceExportCommandCreator + GetThreadTraceExportCommandCreatorAtIndex(uint32_t index); + // UnwindAssembly static bool RegisterPlugin(ConstString name, const char *description, UnwindAssemblyCreateInstance create_callback); diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h new file mode 100644 index 000000000000..f625d014f268 --- /dev/null +++ b/lldb/include/lldb/Core/Progress.h @@ -0,0 +1,114 @@ +//===-- Progress.h ----------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_CORE_PROGRESS_H +#define LLDB_CORE_PROGRESS_H + +#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-types.h" +#include <atomic> +#include <mutex> + +namespace lldb_private { + +/// A Progress indicator helper class. +/// +/// Any potentially long running sections of code in LLDB should report +/// progress so that clients are aware of delays that might appear during +/// debugging. Delays commonly include indexing debug information, parsing +/// symbol tables for object files, downloading symbols from remote +/// repositories, and many more things. +/// +/// The Progress class helps make sure that progress is correctly reported +/// and will always send an initial progress update, updates when +/// Progress::Increment() is called, and also will make sure that a progress +/// completed update is reported even if the user doesn't explicitly cause one +/// to be sent. +/// +/// The progress is reported via a callback whose type is ProgressCallback: +/// +/// typedef void (*ProgressCallback)(uint64_t progress_id, +/// const char *message, +/// uint64_t completed, +/// uint64_t total, +/// void *baton); +/// +/// This callback will always initially be called with "completed" set to zero +/// and "total" set to the total amount specified in the contructor. This is +/// considered the progress start event. As Progress::Increment() is called, +/// the callback will be called as long as the Progress::m_completed has not +/// yet exceeded the Progress::m_total. When the callback is called with +/// Progress::m_completed == Progress::m_total, that is considered a progress +/// completed event. If Progress::m_completed is non-zero and less than +/// Progress::m_total, then this is considered a progress update event. +/// +/// This callback will be called in the destructor if Progress::m_completed is +/// not equal to Progress::m_total with the "completed" set to +/// Progress::m_total. This ensures we always send a progress completed update +/// even if the user does not. + +class Progress { +public: + /// Construct a progress object that will report information. + /// + /// The constructor will create a unique progress reporting object and + /// immediately send out a progress update by calling the installed callback + /// with completed set to zero out of the specified total. + /// + /// @param [in] title The title of this progress activity. + /// + /// @param [in] total The total units of work to be done if specified, if + /// set to UINT64_MAX then an indeterminate progress indicator should be + /// displayed. + /// + /// @param [in] debugger An optional debugger pointer to specify that this + /// progress is to be reported only to specific debuggers. + Progress(std::string title, uint64_t total = UINT64_MAX, + lldb_private::Debugger *debugger = nullptr); + + /// Destroy the progress object. + /// + /// If the progress has not yet sent a completion update, the destructor + /// will send out a notification where the completed == m_total. This ensures + /// that we always send out a progress complete notification. + ~Progress(); + + /// Increment the progress and send a notification to the intalled callback. + /// + /// If incrementing ends up exceeding m_total, m_completed will be updated + /// to match m_total and no subsequent progress notifications will be sent. + /// If no total was specified in the constructor, this function will not do + /// anything nor send any progress updates. + /// + /// @param [in] amount The amount to increment m_completed by. + void Increment(uint64_t amount = 1); + +private: + void ReportProgress(); + static std::atomic<uint64_t> g_id; + /// The title of the progress activity. + std::string m_title; + std::mutex m_mutex; + /// A unique integer identifier for progress reporting. + const uint64_t m_id; + /// How much work ([0...m_total]) that has been completed. + uint64_t m_completed; + /// Total amount of work, UINT64_MAX for non deterministic progress. + const uint64_t m_total; + /// The optional debugger ID to report progress to. If this has no value then + /// all debuggers will receive this event. + llvm::Optional<lldb::user_id_t> m_debugger_id; + /// Set to true when progress has been reported where m_completed == m_total + /// to ensure that we don't send progress updates after progress has + /// completed. + bool m_complete = false; +}; + +} // namespace lldb_private + +#endif // LLDB_CORE_PROGRESS_H diff --git a/lldb/include/lldb/Core/RichManglingContext.h b/lldb/include/lldb/Core/RichManglingContext.h index 68f80e73b724..48102ec0b1cf 100644 --- a/lldb/include/lldb/Core/RichManglingContext.h +++ b/lldb/include/lldb/Core/RichManglingContext.h @@ -24,12 +24,12 @@ namespace lldb_private { /// providers. See Mangled::DemangleWithRichManglingInfo() class RichManglingContext { public: - RichManglingContext() : m_provider(None), m_ipd_buf_size(2048) { + RichManglingContext() { m_ipd_buf = static_cast<char *>(std::malloc(m_ipd_buf_size)); m_ipd_buf[0] = '\0'; } - ~RichManglingContext() { std::free(m_ipd_buf); } + ~RichManglingContext(); /// Use the ItaniumPartialDemangler to obtain rich mangling information from /// the given mangled name. @@ -70,15 +70,18 @@ private: enum InfoProvider { None, ItaniumPartialDemangler, PluginCxxLanguage }; /// Selects the rich mangling info provider. - InfoProvider m_provider; + InfoProvider m_provider = None; /// Reference to the buffer used for results of ParseXy() operations. llvm::StringRef m_buffer; /// Members for ItaniumPartialDemangler llvm::ItaniumPartialDemangler m_ipd; + /// Note: m_ipd_buf is a raw pointer due to being resized by realloc via + /// ItaniumPartialDemangler. It should be managed with malloc/free, not + /// new/delete. char *m_ipd_buf; - size_t m_ipd_buf_size; + size_t m_ipd_buf_size = 2048; /// Members for PluginCxxLanguage /// Cannot forward declare inner class CPlusPlusLanguage::MethodName. The @@ -86,6 +89,9 @@ private: /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp. llvm::Any m_cxx_method_parser; + /// Clean up memory when using PluginCxxLanguage + void ResetCxxMethodParser(); + /// Clean up memory and set a new info provider for this instance. void ResetProvider(InfoProvider new_provider); diff --git a/lldb/include/lldb/Core/SearchFilter.h b/lldb/include/lldb/Core/SearchFilter.h index 54dc65e4410f..491e3ddc5985 100644 --- a/lldb/include/lldb/Core/SearchFilter.h +++ b/lldb/include/lldb/Core/SearchFilter.h @@ -15,7 +15,7 @@ #include "lldb/Utility/FileSpec.h" #include "lldb/lldb-forward.h" -#include <stdint.h> +#include <cstdint> namespace lldb_private { class Address; diff --git a/lldb/include/lldb/Core/Section.h b/lldb/include/lldb/Core/Section.h index af2bb7896a5b..3d4ab154e743 100644 --- a/lldb/include/lldb/Core/Section.h +++ b/lldb/include/lldb/Core/Section.h @@ -21,8 +21,8 @@ #include <memory> #include <vector> -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> namespace lldb_private { class Address; diff --git a/lldb/include/lldb/Core/SourceLocationSpec.h b/lldb/include/lldb/Core/SourceLocationSpec.h new file mode 100644 index 000000000000..808931186dba --- /dev/null +++ b/lldb/include/lldb/Core/SourceLocationSpec.h @@ -0,0 +1,188 @@ +//===-- SourceLocationSpec.h ------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_UTILITY_SOURCELOCATIONSPEC_H +#define LLDB_UTILITY_SOURCELOCATIONSPEC_H + +#include "lldb/Core/Declaration.h" +#include "lldb/lldb-defines.h" +#include "llvm/ADT/Optional.h" + +#include <string> + +namespace lldb_private { + +/// \class SourceLocationSpec SourceLocationSpec.h +/// "lldb/Core/SourceLocationSpec.h" A source location specifier class. +/// +/// A source location specifier class that holds a Declaration object containing +/// a FileSpec with line and column information. The column line is optional. +/// It also holds search flags that can be fetched by resolvers to look inlined +/// declarations and/or exact matches. +class SourceLocationSpec { +public: + /// Constructor. + /// + /// Takes a \a file_spec with a \a line number and a \a column number. If + /// \a column is null or not provided, it is set to llvm::None. + /// + /// \param[in] file_spec + /// The full or partial path to a file. + /// + /// \param[in] line + /// The line number in the source file. + /// + /// \param[in] column + /// The column number in the line of the source file. + /// + /// \param[in] check_inlines + /// Whether to look for a match in inlined declaration. + /// + /// \param[in] exact_match + /// Whether to look for an exact match. + /// + explicit SourceLocationSpec(FileSpec file_spec, uint32_t line, + llvm::Optional<uint16_t> column = llvm::None, + bool check_inlines = false, + bool exact_match = false); + + SourceLocationSpec() = delete; + + /// Convert to boolean operator. + /// + /// This allows code to check a SourceLocationSpec object to see if it + /// contains anything valid using code such as: + /// + /// \code + /// SourceLocationSpec location_spec(...); + /// if (location_spec) + /// { ... + /// \endcode + /// + /// \return + /// A pointer to this object if both the file_spec and the line are valid, + /// nullptr otherwise. + explicit operator bool() const; + + /// Logical NOT operator. + /// + /// This allows code to check a SourceLocationSpec object to see if it is + /// invalid using code such as: + /// + /// \code + /// SourceLocationSpec location_spec(...); + /// if (!location_spec) + /// { ... + /// \endcode + /// + /// \return + /// Returns \b true if the object has an invalid file_spec or line number, + /// \b false otherwise. + bool operator!() const; + + /// Equal to operator + /// + /// Tests if this object is equal to \a rhs. + /// + /// \param[in] rhs + /// A const SourceLocationSpec object reference to compare this object + /// to. + /// + /// \return + /// \b true if this object is equal to \a rhs, \b false + /// otherwise. + bool operator==(const SourceLocationSpec &rhs) const; + + /// Not equal to operator + /// + /// Tests if this object is not equal to \a rhs. + /// + /// \param[in] rhs + /// A const SourceLocationSpec object reference to compare this object + /// to. + /// + /// \return + /// \b true if this object is equal to \a rhs, \b false + /// otherwise. + bool operator!=(const SourceLocationSpec &rhs) const; + + /// Less than to operator + /// + /// Tests if this object is less than \a rhs. + /// + /// \param[in] rhs + /// A const SourceLocationSpec object reference to compare this object + /// to. + /// + /// \return + /// \b true if this object is less than \a rhs, \b false + /// otherwise. + bool operator<(const SourceLocationSpec &rhs) const; + + /// Compare two SourceLocationSpec objects. + /// + /// If \a full is true, then the file_spec, the line and column must match. + /// If \a full is false, then only the file_spec and line number for \a lhs + /// and \a rhs are compared. This allows a SourceLocationSpec object that have + /// no column information to match a SourceLocationSpec objects that have + /// column information with matching file_spec and line component. + /// + /// \param[in] lhs + /// A const reference to the Left Hand Side object to compare. + /// + /// \param[in] rhs + /// A const reference to the Right Hand Side object to compare. + /// + /// \param[in] full + /// If true, then the file_spec, the line and column must match for a + /// compare to return zero (equal to). If false, then only the file_spec + /// and line number for \a lhs and \a rhs are compared, else a full + /// comparison is done. + /// + /// \return -1 if \a lhs is less than \a rhs, 0 if \a lhs is equal to \a rhs, + /// 1 if \a lhs is greater than \a rhs + static int Compare(const SourceLocationSpec &lhs, + const SourceLocationSpec &rhs); + + static bool Equal(const SourceLocationSpec &lhs, + const SourceLocationSpec &rhs, bool full); + + /// Dump this object to a Stream. + /// + /// Dump the object to the supplied stream \a s, starting with the file name, + /// then the line number and if available the column number. + /// + /// \param[in] s + /// The stream to which to dump the object description. + void Dump(Stream &s) const; + + std::string GetString() const; + + FileSpec GetFileSpec() const { return m_declaration.GetFile(); } + + llvm::Optional<uint32_t> GetLine() const; + + llvm::Optional<uint16_t> GetColumn() const; + + bool GetCheckInlines() const { return m_check_inlines; } + + bool GetExactMatch() const { return m_exact_match; } + +protected: + Declaration m_declaration; + /// Tells if the resolver should look in inlined declaration. + bool m_check_inlines; + /// Tells if the resolver should look for an exact match. + bool m_exact_match; +}; + +/// Dump a SourceLocationSpec object to a stream +Stream &operator<<(Stream &s, const SourceLocationSpec &loc); +} // namespace lldb_private + +#endif // LLDB_UTILITY_SOURCELOCATIONSPEC_H diff --git a/lldb/include/lldb/Core/SourceManager.h b/lldb/include/lldb/Core/SourceManager.h index 7549c308f33a..5f2c1de84652 100644 --- a/lldb/include/lldb/Core/SourceManager.h +++ b/lldb/include/lldb/Core/SourceManager.h @@ -15,10 +15,10 @@ #include "llvm/Support/Chrono.h" +#include <cstddef> #include <cstdint> #include <map> #include <memory> -#include <stddef.h> #include <string> #include <vector> diff --git a/lldb/include/lldb/Core/StreamAsynchronousIO.h b/lldb/include/lldb/Core/StreamAsynchronousIO.h index 949a798955d1..30eff55b2e51 100644 --- a/lldb/include/lldb/Core/StreamAsynchronousIO.h +++ b/lldb/include/lldb/Core/StreamAsynchronousIO.h @@ -13,7 +13,7 @@ #include <string> -#include <stddef.h> +#include <cstddef> namespace lldb_private { class Debugger; diff --git a/lldb/include/lldb/Core/StreamBuffer.h b/lldb/include/lldb/Core/StreamBuffer.h index 9c48ddb44d71..2e61a214302b 100644 --- a/lldb/include/lldb/Core/StreamBuffer.h +++ b/lldb/include/lldb/Core/StreamBuffer.h @@ -11,7 +11,7 @@ #include "lldb/Utility/Stream.h" #include "llvm/ADT/SmallVector.h" -#include <stdio.h> +#include <cstdio> #include <string> namespace lldb_private { @@ -23,7 +23,7 @@ public: StreamBuffer(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order) : Stream(flags, addr_size, byte_order), m_packet() {} - ~StreamBuffer() override {} + ~StreamBuffer() override = default; void Flush() override { // Nothing to do when flushing a buffer based stream... diff --git a/lldb/include/lldb/Core/StreamFile.h b/lldb/include/lldb/Core/StreamFile.h index e71e31eb1d04..dba4042b6ec9 100644 --- a/lldb/include/lldb/Core/StreamFile.h +++ b/lldb/include/lldb/Core/StreamFile.h @@ -14,8 +14,8 @@ #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" -#include <stdint.h> -#include <stdio.h> +#include <cstdint> +#include <cstdio> namespace lldb_private { diff --git a/lldb/include/lldb/Core/ThreadSafeValue.h b/lldb/include/lldb/Core/ThreadSafeValue.h index 38b8034fad53..51820ec9cd9d 100644 --- a/lldb/include/lldb/Core/ThreadSafeValue.h +++ b/lldb/include/lldb/Core/ThreadSafeValue.h @@ -17,12 +17,10 @@ namespace lldb_private { template <class T> class ThreadSafeValue { public: - // Constructors and Destructors - ThreadSafeValue() : m_value(), m_mutex() {} - + ThreadSafeValue() = default; ThreadSafeValue(const T &value) : m_value(value), m_mutex() {} - ~ThreadSafeValue() {} + ~ThreadSafeValue() = default; T GetValue() const { T value; diff --git a/lldb/include/lldb/Core/UserSettingsController.h b/lldb/include/lldb/Core/UserSettingsController.h index f40ad54ac4d6..35555f08c351 100644 --- a/lldb/include/lldb/Core/UserSettingsController.h +++ b/lldb/include/lldb/Core/UserSettingsController.h @@ -17,8 +17,8 @@ #include <vector> -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> namespace lldb_private { class CommandInterpreter; @@ -32,12 +32,12 @@ namespace lldb_private { class Properties { public: - Properties() : m_collection_sp() {} + Properties() = default; Properties(const lldb::OptionValuePropertiesSP &collection_sp) : m_collection_sp(collection_sp) {} - virtual ~Properties() {} + virtual ~Properties() = default; virtual lldb::OptionValuePropertiesSP GetValueProperties() const { // This function is virtual in case subclasses want to lazily implement diff --git a/lldb/include/lldb/Core/Value.h b/lldb/include/lldb/Core/Value.h index 0ff773e59911..1ee4fe639e6e 100644 --- a/lldb/include/lldb/Core/Value.h +++ b/lldb/include/lldb/Core/Value.h @@ -21,8 +21,8 @@ #include <vector> -#include <stdint.h> -#include <string.h> +#include <cstdint> +#include <cstring> namespace lldb_private { class DataExtractor; @@ -37,27 +37,32 @@ 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 { - // m_value contains... - // ============================ - eValueTypeScalar, // raw scalar value - eValueTypeFileAddress, // file address value - eValueTypeLoadAddress, // load address value - eValueTypeHostAddress // host address value (for memory in the process that - // is using liblldb) + /// Type that describes Value::m_value. + enum class ValueType { + Invalid = -1, + // m_value contains: + /// A raw scalar value. + Scalar = 0, + /// A file address value. + FileAddress, + /// A load address value. + LoadAddress, + /// A host address value (for memory in the process that < A is + /// using liblldb). + HostAddress }; - enum ContextType // Type that describes Value::m_context - { - // m_context contains... - // ==================== - eContextTypeInvalid, // undefined - eContextTypeRegisterInfo, // RegisterInfo * (can be a scalar or a vector - // register) - eContextTypeLLDBType, // lldb_private::Type * - eContextTypeVariable // lldb_private::Variable * + /// Type that describes Value::m_context. + enum class ContextType { + // m_context contains: + /// Undefined. + Invalid = -1, + /// RegisterInfo * (can be a scalar or a vector register). + RegisterInfo = 0, + /// lldb_private::Type *. + LLDBType, + /// lldb_private::Variable *. + Variable }; Value(); @@ -85,16 +90,16 @@ public: void ClearContext() { m_context = nullptr; - m_context_type = eContextTypeInvalid; + m_context_type = ContextType::Invalid; } void SetContext(ContextType context_type, void *p) { m_context_type = context_type; m_context = p; - if (m_context_type == eContextTypeRegisterInfo) { + if (m_context_type == ContextType::RegisterInfo) { RegisterInfo *reg_info = GetRegisterInfo(); if (reg_info->encoding == lldb::eEncodingVector) - SetValueType(eValueTypeScalar); + SetValueType(ValueType::Scalar); } } @@ -143,9 +148,9 @@ public: protected: Scalar m_value; CompilerType m_compiler_type; - void *m_context; - ValueType m_value_type; - ContextType m_context_type; + void *m_context = nullptr; + ValueType m_value_type = ValueType::Scalar; + ContextType m_context_type = ContextType::Invalid; DataBufferHeap m_data_buffer; }; diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index a665e7afa0ca..5f1cbc65b320 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -37,8 +37,8 @@ #include <string> #include <utility> -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> namespace lldb_private { class Declaration; @@ -102,7 +102,7 @@ class TypeSummaryOptions; /// Shared Pointer to the contained ValueObject, /// just do so by calling GetSP() on the contained object. -class ValueObject : public UserID { +class ValueObject { public: enum GetExpressionPathFormat { eGetExpressionPathFormatDereferencePointers = 1, @@ -121,55 +121,62 @@ public: }; enum ExpressionPathScanEndReason { - eExpressionPathScanEndReasonEndOfString = 1, // out of data to parse - eExpressionPathScanEndReasonNoSuchChild, // child element not found - eExpressionPathScanEndReasonNoSuchSyntheticChild, // (synthetic) child - // element not found - eExpressionPathScanEndReasonEmptyRangeNotAllowed, // [] only allowed for - // arrays - eExpressionPathScanEndReasonDotInsteadOfArrow, // . used when -> should be - // used - eExpressionPathScanEndReasonArrowInsteadOfDot, // -> used when . should be - // used - eExpressionPathScanEndReasonFragileIVarNotAllowed, // ObjC ivar expansion - // not allowed - eExpressionPathScanEndReasonRangeOperatorNotAllowed, // [] not allowed by - // options - eExpressionPathScanEndReasonRangeOperatorInvalid, // [] not valid on objects - // other than scalars, - // pointers or arrays - eExpressionPathScanEndReasonArrayRangeOperatorMet, // [] is good for arrays, - // but I cannot parse it - eExpressionPathScanEndReasonBitfieldRangeOperatorMet, // [] is good for - // bitfields, but I - // cannot parse after - // it - eExpressionPathScanEndReasonUnexpectedSymbol, // something is malformed in - // the expression - eExpressionPathScanEndReasonTakingAddressFailed, // impossible to apply & - // operator - eExpressionPathScanEndReasonDereferencingFailed, // impossible to apply * - // operator - eExpressionPathScanEndReasonRangeOperatorExpanded, // [] was expanded into a - // VOList - eExpressionPathScanEndReasonSyntheticValueMissing, // getting the synthetic - // children failed + /// Out of data to parse. + eExpressionPathScanEndReasonEndOfString = 1, + /// Child element not found. + eExpressionPathScanEndReasonNoSuchChild, + /// (Synthetic) child element not found. + eExpressionPathScanEndReasonNoSuchSyntheticChild, + /// [] only allowed for arrays. + eExpressionPathScanEndReasonEmptyRangeNotAllowed, + /// . used when -> should be used. + eExpressionPathScanEndReasonDotInsteadOfArrow, + /// -> used when . should be used. + eExpressionPathScanEndReasonArrowInsteadOfDot, + /// ObjC ivar expansion not allowed. + eExpressionPathScanEndReasonFragileIVarNotAllowed, + /// [] not allowed by options. + eExpressionPathScanEndReasonRangeOperatorNotAllowed, + /// [] not valid on objects other than scalars, pointers or arrays. + eExpressionPathScanEndReasonRangeOperatorInvalid, + /// [] is good for arrays, but I cannot parse it. + eExpressionPathScanEndReasonArrayRangeOperatorMet, + /// [] is good for bitfields, but I cannot parse after it. + eExpressionPathScanEndReasonBitfieldRangeOperatorMet, + /// Something is malformed in he expression. + eExpressionPathScanEndReasonUnexpectedSymbol, + /// Impossible to apply & operator. + eExpressionPathScanEndReasonTakingAddressFailed, + /// Impossible to apply * operator. + eExpressionPathScanEndReasonDereferencingFailed, + /// [] was expanded into a VOList. + eExpressionPathScanEndReasonRangeOperatorExpanded, + /// getting the synthetic children failed. + eExpressionPathScanEndReasonSyntheticValueMissing, eExpressionPathScanEndReasonUnknown = 0xFFFF }; enum ExpressionPathEndResultType { - eExpressionPathEndResultTypePlain = 1, // anything but... - eExpressionPathEndResultTypeBitfield, // a bitfield - eExpressionPathEndResultTypeBoundedRange, // a range [low-high] - eExpressionPathEndResultTypeUnboundedRange, // a range [] - eExpressionPathEndResultTypeValueObjectList, // several items in a VOList + /// Anything but... + eExpressionPathEndResultTypePlain = 1, + /// A bitfield. + eExpressionPathEndResultTypeBitfield, + /// A range [low-high]. + eExpressionPathEndResultTypeBoundedRange, + /// A range []. + eExpressionPathEndResultTypeUnboundedRange, + /// Several items in a VOList. + eExpressionPathEndResultTypeValueObjectList, eExpressionPathEndResultTypeInvalid = 0xFFFF }; enum ExpressionPathAftermath { - eExpressionPathAftermathNothing = 1, // just return it - eExpressionPathAftermathDereference, // dereference the target - eExpressionPathAftermathTakeAddress // take target's address + /// Just return it. + eExpressionPathAftermathNothing = 1, + /// Dereference the target. + eExpressionPathAftermathDereference, + /// Take target's address. + eExpressionPathAftermathTakeAddress }; enum ClearUserVisibleDataItems { @@ -265,14 +272,6 @@ public: return m_exe_ctx_ref; } - // Set the EvaluationPoint to the values in exe_scope, Return true if the - // Evaluation Point changed. Since the ExecutionContextScope is always - // going to be valid currently, the Updated Context will also always be - // valid. - - // bool - // SetContext (ExecutionContextScope *exe_scope); - void SetIsConstant() { SetUpdated(); m_mod_id.SetInvalid(); @@ -319,7 +318,7 @@ public: ProcessModID m_mod_id; // This is the stop id when this ValueObject was last // evaluated. ExecutionContextRef m_exe_ctx_ref; - bool m_needs_update; + bool m_needs_update = true; }; virtual ~ValueObject(); @@ -350,10 +349,10 @@ public: void SetNeedsUpdate(); - CompilerType GetCompilerType(); + CompilerType GetCompilerType() { return MaybeCalculateCompleteType(); } // this vends a TypeImpl that is useful at the SB API layer - virtual TypeImpl GetTypeImpl(); + virtual TypeImpl GetTypeImpl() { return TypeImpl(GetCompilerType()); } virtual bool CanProvideValue(); @@ -363,24 +362,32 @@ public: virtual lldb::ValueType GetValueType() const = 0; // Subclasses can implement the functions below. - virtual ConstString GetTypeName(); + virtual ConstString GetTypeName() { return GetCompilerType().GetTypeName(); } - virtual ConstString GetDisplayTypeName(); + virtual ConstString GetDisplayTypeName() { return GetTypeName(); } - virtual ConstString GetQualifiedTypeName(); + virtual ConstString GetQualifiedTypeName() { + return GetCompilerType().GetTypeName(); + } - virtual lldb::LanguageType GetObjectRuntimeLanguage(); + virtual lldb::LanguageType GetObjectRuntimeLanguage() { + return GetCompilerType().GetMinimumLanguage(); + } virtual uint32_t - GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr); + GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr) { + return GetCompilerType().GetTypeInfo(pointee_or_element_compiler_type); + } - virtual bool IsPointerType(); + virtual bool IsPointerType() { return GetCompilerType().IsPointerType(); } - virtual bool IsArrayType(); + virtual bool IsArrayType() { return GetCompilerType().IsArrayType(); } - virtual bool IsScalarType(); + virtual bool IsScalarType() { return GetCompilerType().IsScalarType(); } - virtual bool IsPointerOrReferenceType(); + virtual bool IsPointerOrReferenceType() { + return GetCompilerType().IsPointerOrReferenceType(); + } virtual bool IsPossibleDynamicType(); @@ -394,7 +401,9 @@ public: virtual bool IsDereferenceOfParent() { return false; } - bool IsIntegerType(bool &is_signed); + bool IsIntegerType(bool &is_signed) { + return GetCompilerType().IsIntegerType(is_signed); + } virtual void GetExpressionPath( Stream &s, @@ -420,7 +429,9 @@ public: return (GetBitfieldBitSize() != 0) || (GetBitfieldBitOffset() != 0); } - virtual bool IsArrayItemForPointer() { return m_is_array_item_for_pointer; } + virtual bool IsArrayItemForPointer() { + return m_flags.m_is_array_item_for_pointer; + } virtual const char *GetValueAsCString(); @@ -436,16 +447,16 @@ public: virtual bool SetValueFromCString(const char *value_str, Status &error); - // Return the module associated with this value object in case the value is - // from an executable file and might have its data in sections of the file. - // This can be used for variables. + /// Return the module associated with this value object in case the value is + /// from an executable file and might have its data in sections of the file. + /// This can be used for variables. virtual lldb::ModuleSP GetModule(); ValueObject *GetRoot(); - // Given a ValueObject, loop over itself and its parent, and its parent's - // parent, .. until either the given callback returns false, or you end up at - // a null pointer + /// Given a ValueObject, loop over itself and its parent, and its parent's + /// parent, .. until either the given callback returns false, or you end up at + /// a null pointer ValueObject *FollowParentChain(std::function<bool(ValueObject *)>); virtual bool GetDeclaration(Declaration &decl); @@ -453,7 +464,10 @@ public: // The functions below should NOT be modified by subclasses const Status &GetError(); - ConstString GetName() const; + ConstString GetName() const { return m_name; } + + /// Returns a unique id for this ValueObject. + lldb::user_id_t GetID() const { return m_id.GetID(); } virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create); @@ -480,9 +494,9 @@ public: size_t GetNumChildren(uint32_t max = UINT32_MAX); - const Value &GetValue() const; + const Value &GetValue() const { return m_value; } - Value &GetValue(); + Value &GetValue() { return m_value; } virtual bool ResolveValue(Scalar &scalar); @@ -491,7 +505,9 @@ public: // potentially a few others virtual bool IsLogicalTrue(Status &error); - virtual const char *GetLocationAsCString(); + virtual const char *GetLocationAsCString() { + return GetLocationAsCStringImpl(m_value, m_data); + } const char * GetSummaryAsCString(lldb::LanguageType lang = lldb::eLanguageTypeUnknown); @@ -526,11 +542,11 @@ public: PrintableRepresentationSpecialCases special = PrintableRepresentationSpecialCases::eAllow, bool do_dump_error = true); - bool GetValueIsValid() const; + bool GetValueIsValid() const { return m_flags.m_value_is_valid; } // If you call this on a newly created ValueObject, it will always return // false. - bool GetValueDidChange(); + bool GetValueDidChange() { return m_flags.m_value_did_change; } bool UpdateValueIfNeeded(bool update_format = true); @@ -538,10 +554,10 @@ public: lldb::ValueObjectSP GetSP() { return m_manager->GetSharedPointer(this); } - // Change the name of the current ValueObject. Should *not* be used from a - // synthetic child provider as it would change the name of the non synthetic - // child as well. - void SetName(ConstString name); + /// Change the name of the current ValueObject. Should *not* be used from a + /// synthetic child provider as it would change the name of the non synthetic + /// child as well. + void SetName(ConstString name) { m_name = name; } virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address = true, AddressType *address_type = nullptr); @@ -571,9 +587,9 @@ public: lldb::DynamicValueType GetDynamicValueType(); - virtual lldb::ValueObjectSP GetStaticValue(); + virtual lldb::ValueObjectSP GetStaticValue() { return GetSP(); } - virtual lldb::ValueObjectSP GetNonSyntheticValue(); + virtual lldb::ValueObjectSP GetNonSyntheticValue() { return GetSP(); } lldb::ValueObjectSP GetSyntheticValue(); @@ -589,10 +605,10 @@ public: virtual lldb::ValueObjectSP Dereference(Status &error); - // Creates a copy of the ValueObject with a new name and setting the current - // ValueObject as its parent. It should be used when we want to change the - // name of a ValueObject without modifying the actual ValueObject itself - // (e.g. sythetic child provider). + /// Creates a copy of the ValueObject with a new name and setting the current + /// ValueObject as its parent. It should be used when we want to change the + /// name of a ValueObject without modifying the actual ValueObject itself + /// (e.g. sythetic child provider). virtual lldb::ValueObjectSP Clone(ConstString new_name); virtual lldb::ValueObjectSP AddressOf(Status &error); @@ -611,7 +627,7 @@ public: lldb::TypeSP &type_sp); // The backing bits of this value object were updated, clear any descriptive - // string, so we know we have to refetch them + // string, so we know we have to refetch them. virtual void ValueUpdated() { ClearUserVisibleData(eClearUserVisibleDataItemsValue | eClearUserVisibleDataItemsSummary | @@ -622,9 +638,13 @@ public: virtual bool DoesProvideSyntheticValue() { return false; } - virtual bool IsSyntheticChildrenGenerated(); + virtual bool IsSyntheticChildrenGenerated() { + return m_flags.m_is_synthetic_children_generated; + } - virtual void SetSyntheticChildrenGenerated(bool b); + virtual void SetSyntheticChildrenGenerated(bool b) { + m_flags.m_is_synthetic_children_generated = b; + } virtual SymbolContextScope *GetSymbolContextScope(); @@ -652,14 +672,10 @@ public: CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data, const ExecutionContext &exe_ctx, CompilerType type); - void LogValueObject(Log *log); - - void LogValueObject(Log *log, const DumpValueObjectOptions &options); - lldb::ValueObjectSP Persist(); - // returns true if this is a char* or a char[] if it is a char* and - // check_pointer is true, it also checks that the pointer is valid + /// Returns true if this is a char* or a char[] if it is a char* and + /// check_pointer is true, it also checks that the pointer is valid. bool IsCStringContainer(bool check_pointer = false); std::pair<size_t, bool> @@ -694,7 +710,9 @@ public: virtual lldb::LanguageType GetPreferredDisplayLanguage(); - void SetPreferredDisplayLanguage(lldb::LanguageType); + void SetPreferredDisplayLanguage(lldb::LanguageType lt) { + m_preferred_display_language = lt; + } lldb::TypeSummaryImplSP GetSummaryFormat() { UpdateFormatsIfNeeded(); @@ -744,7 +762,9 @@ public: AddressType GetAddressTypeOfChildren(); - void SetHasCompleteType() { m_did_calculate_complete_objc_class_type = true; } + void SetHasCompleteType() { + m_flags.m_did_calculate_complete_objc_class_type = true; + } /// Find out if a ValueObject might have children. /// @@ -766,16 +786,16 @@ public: virtual bool IsRuntimeSupportValue(); - virtual uint64_t GetLanguageFlags(); + virtual uint64_t GetLanguageFlags() { return m_language_flags; } - virtual void SetLanguageFlags(uint64_t flags); + virtual void SetLanguageFlags(uint64_t flags) { m_language_flags = flags; } protected: typedef ClusterManager<ValueObject> ValueObjectManager; class ChildrenManager { public: - ChildrenManager() : m_mutex(), m_children(), m_children_count(0) {} + ChildrenManager() : m_mutex(), m_children() {} bool HasChildAtIndex(size_t idx) { std::lock_guard<std::recursive_mutex> guard(m_mutex); @@ -811,80 +831,102 @@ protected: typedef ChildrenMap::value_type ChildrenPair; std::recursive_mutex m_mutex; ChildrenMap m_children; - size_t m_children_count; + size_t m_children_count = 0; }; // Classes that inherit from ValueObject can see and modify these - 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. - ConstString m_name; // The name of this object - DataExtractor - m_data; // A data extractor that can be used to extract the value. + + /// The parent value object, or nullptr if this has no parent. + ValueObject *m_parent = nullptr; + /// The root of the hierarchy for this ValueObject (or nullptr if never + /// calculated). + ValueObject *m_root = nullptr; + /// 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. + EvaluationPoint m_update_point; + /// The name of this object. + ConstString m_name; + /// A data extractor that can be used to extract the value. + DataExtractor m_data; Value m_value; - Status - m_error; // An error object that can describe any errors that occur when - // updating values. - std::string m_value_str; // Cached value string that will get cleared if/when - // the value is updated. - std::string m_old_value_str; // Cached old value string from the last time the - // value was gotten - std::string m_location_str; // Cached location string that will get cleared - // if/when the value is updated. - std::string m_summary_str; // Cached summary string that will get cleared - // if/when the value is updated. - std::string m_object_desc_str; // Cached result of the "object printer". This - // differs from the summary - // in that the summary is consed up by us, the object_desc_string is builtin. - - 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 - // dependent objects, and will keep the whole cluster of objects alive as - // long as a shared pointer to any of them has been handed out. Shared - // pointers to value objects must always be made with the GetSP method. + /// An error object that can describe any errors that occur when updating + /// values. + Status m_error; + /// Cached value string that will get cleared if/when the value is updated. + std::string m_value_str; + /// Cached old value string from the last time the value was gotten + std::string m_old_value_str; + /// Cached location string that will get cleared if/when the value is updated. + std::string m_location_str; + /// Cached summary string that will get cleared if/when the value is updated. + std::string m_summary_str; + /// Cached result of the "object printer". This differs from the summary + /// in that the summary is consed up by us, the object_desc_string is builtin. + std::string m_object_desc_str; + /// If the type of the value object should be overridden, the type to impose. + CompilerType m_override_type; + + /// 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 dependent objects, and will keep the whole cluster of + /// objects alive as long as a shared pointer to any of them has been handed + /// out. Shared pointers to value objects must always be made with the GetSP + /// method. + ValueObjectManager *m_manager = nullptr; ChildrenManager m_children; std::map<ConstString, ValueObject *> m_synthetic_children; - ValueObject *m_dynamic_value; - ValueObject *m_synthetic_value; - ValueObject *m_deref_valobj; + ValueObject *m_dynamic_value = nullptr; + ValueObject *m_synthetic_value = nullptr; + ValueObject *m_deref_valobj = nullptr; - lldb::ValueObjectSP m_addr_of_valobj_sp; // We have to hold onto a shared - // pointer to this one because it is - // created - // as an independent ValueObjectConstResult, which isn't managed by us. + /// We have to hold onto a shared pointer to this one because it is created + /// as an independent ValueObjectConstResult, which isn't managed by us. + lldb::ValueObjectSP m_addr_of_valobj_sp; - lldb::Format m_format; - lldb::Format m_last_format; - uint32_t m_last_format_mgr_revision; + lldb::Format m_format = lldb::eFormatDefault; + lldb::Format m_last_format = lldb::eFormatDefault; + uint32_t m_last_format_mgr_revision = 0; lldb::TypeSummaryImplSP m_type_summary_sp; lldb::TypeFormatImplSP m_type_format_sp; lldb::SyntheticChildrenSP m_synthetic_children_sp; ProcessModID m_user_id_of_forced_summary; - AddressType m_address_type_of_ptr_or_ref_children; + AddressType m_address_type_of_ptr_or_ref_children = eAddressTypeInvalid; llvm::SmallVector<uint8_t, 16> m_value_checksum; - 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, - m_old_value_valid : 1, m_is_deref_of_parent : 1, - m_is_array_item_for_pointer : 1, m_is_bitfield_for_scalar : 1, - m_is_child_at_offset : 1, m_is_getting_summary : 1, - m_did_calculate_complete_objc_class_type : 1, - m_is_synthetic_children_generated : 1; + lldb::LanguageType m_preferred_display_language = lldb::eLanguageTypeUnknown; + + uint64_t m_language_flags = 0; + + /// Unique identifier for every value object. + UserID m_id; + + // Utility class for initializing all bitfields in ValueObject's constructors. + // FIXME: This could be done via default initializers once we have C++20. + struct Bitflags { + bool m_value_is_valid : 1, m_value_did_change : 1, + m_children_count_valid : 1, m_old_value_valid : 1, + m_is_deref_of_parent : 1, m_is_array_item_for_pointer : 1, + m_is_bitfield_for_scalar : 1, m_is_child_at_offset : 1, + m_is_getting_summary : 1, m_did_calculate_complete_objc_class_type : 1, + m_is_synthetic_children_generated : 1; + Bitflags() { + m_value_is_valid = false; + m_value_did_change = false; + m_children_count_valid = false; + m_old_value_valid = false; + m_is_deref_of_parent = false; + m_is_array_item_for_pointer = false; + m_is_bitfield_for_scalar = false; + m_is_child_at_offset = false; + m_is_getting_summary = false; + m_did_calculate_complete_objc_class_type = false; + m_is_synthetic_children_generated = false; + } + } m_flags; friend class ValueObjectChild; friend class ExpressionVariable; // For SetName @@ -892,22 +934,13 @@ protected: friend class ValueObjectConstResultImpl; friend class ValueObjectSynthetic; // For ClearUserVisibleData - // Constructors and Destructors - - // Use the no-argument constructor to make a constant variable object (with - // no ExecutionContextScope.) - - ValueObject(); - - // Use this constructor to create a "root variable object". The ValueObject - // will be locked to this context through-out its lifespan. - + /// Use this constructor to create a "root variable object". The ValueObject + /// will be locked to this context through-out its lifespan. ValueObject(ExecutionContextScope *exe_scope, ValueObjectManager &manager, AddressType child_ptr_or_ref_addr_type = eAddressTypeLoad); - // Use this constructor to create a ValueObject owned by another ValueObject. - // It will inherit the ExecutionContext of its parent. - + /// Use this constructor to create a ValueObject owned by another ValueObject. + /// It will inherit the ExecutionContext of its parent. ValueObject(ValueObject &parent); ValueObjectManager *GetManager() { return m_manager; } @@ -928,20 +961,23 @@ protected: virtual void CalculateSyntheticValue(); - // Should only be called by ValueObject::GetChildAtIndex() Returns a - // ValueObject managed by this ValueObject's manager. + /// Should only be called by ValueObject::GetChildAtIndex(). + /// + /// \return A ValueObject managed by this ValueObject's manager. virtual ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index); - // Should only be called by ValueObject::GetNumChildren() + /// Should only be called by ValueObject::GetNumChildren(). virtual size_t CalculateNumChildren(uint32_t max = UINT32_MAX) = 0; void SetNumChildren(size_t num_children); - void SetValueDidChange(bool value_changed); + void SetValueDidChange(bool value_changed) { + m_flags.m_value_did_change = value_changed; + } - void SetValueIsValid(bool valid); + void SetValueIsValid(bool valid) { m_flags.m_value_is_valid = valid; } void ClearUserVisibleData( uint32_t items = ValueObject::eClearUserVisibleDataItemsAllStrings); @@ -959,7 +995,7 @@ protected: const char *GetLocationAsCStringImpl(const Value &value, const DataExtractor &data); - bool IsChecksumEmpty(); + bool IsChecksumEmpty() { return m_value_checksum.empty(); } void SetPreferredDisplayLanguageIfNeeded(lldb::LanguageType); @@ -983,47 +1019,6 @@ private: const ValueObject &operator=(const ValueObject &) = delete; }; -// A value object manager class that is seeded with the static variable value -// and it vends the user facing value object. If the type is dynamic it can -// vend the dynamic type. If this user type also has a synthetic type -// associated with it, it will vend the synthetic type. The class watches the -// process' stop -// ID and will update the user type when needed. -class ValueObjectManager { - // The root value object is the static typed variable object. - lldb::ValueObjectSP m_root_valobj_sp; - // The user value object is the value object the user wants to see. - lldb::ValueObjectSP m_user_valobj_sp; - lldb::DynamicValueType m_use_dynamic; - uint32_t m_stop_id; // The stop ID that m_user_valobj_sp is valid for. - bool m_use_synthetic; - -public: - ValueObjectManager() {} - - ValueObjectManager(lldb::ValueObjectSP in_valobj_sp, - lldb::DynamicValueType use_dynamic, bool use_synthetic); - - bool IsValid() const; - - lldb::ValueObjectSP GetRootSP() const { return m_root_valobj_sp; } - - // Gets the correct value object from the root object for a given process - // stop ID. If dynamic values are enabled, or if synthetic children are - // enabled, the value object that the user wants to see might change while - // debugging. - lldb::ValueObjectSP GetSP(); - - void SetUseDynamic(lldb::DynamicValueType use_dynamic); - void SetUseSynthetic(bool use_synthetic); - lldb::DynamicValueType GetUseDynamic() const { return m_use_dynamic; } - bool GetUseSynthetic() const { return m_use_synthetic; } - lldb::TargetSP GetTargetSP() const; - lldb::ProcessSP GetProcessSP() const; - lldb::ThreadSP GetThreadSP() const; - lldb::StackFrameSP GetFrameSP() const; -}; - } // namespace lldb_private #endif // LLDB_CORE_VALUEOBJECT_H diff --git a/lldb/include/lldb/Core/ValueObjectCast.h b/lldb/include/lldb/Core/ValueObjectCast.h index 342803f8ca63..84cf13353aee 100644 --- a/lldb/include/lldb/Core/ValueObjectCast.h +++ b/lldb/include/lldb/Core/ValueObjectCast.h @@ -15,13 +15,13 @@ #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> namespace lldb_private { class ConstString; -// A ValueObject that represents a given value represented as a different type. +/// A ValueObject that represents a given value represented as a different type. class ValueObjectCast : public ValueObject { public: ~ValueObjectCast() override; diff --git a/lldb/include/lldb/Core/ValueObjectChild.h b/lldb/include/lldb/Core/ValueObjectChild.h index 9a9fd9294261..8a7a7f17bc76 100644 --- a/lldb/include/lldb/Core/ValueObjectChild.h +++ b/lldb/include/lldb/Core/ValueObjectChild.h @@ -20,12 +20,12 @@ #include "llvm/ADT/Optional.h" -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> namespace lldb_private { -// A child of another ValueObject. +/// A child of another ValueObject. class ValueObjectChild : public ValueObject { public: ~ValueObjectChild() override; @@ -71,10 +71,6 @@ protected: bool m_is_deref_of_parent; llvm::Optional<LazyBool> m_can_update_with_invalid_exe_ctx; - // - // void - // ReadValueFromMemory (ValueObject* parent, lldb::addr_t address); - friend class ValueObject; friend class ValueObjectConstResult; friend class ValueObjectConstResultImpl; diff --git a/lldb/include/lldb/Core/ValueObjectConstResult.h b/lldb/include/lldb/Core/ValueObjectConstResult.h index 8d823baa0b7b..58cda6fd6196 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResult.h +++ b/lldb/include/lldb/Core/ValueObjectConstResult.h @@ -21,15 +21,15 @@ #include "lldb/lldb-private-enumerations.h" #include "lldb/lldb-types.h" -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> namespace lldb_private { class DataExtractor; class ExecutionContextScope; class Module; -// A frozen ValueObject copied into host memory +/// A frozen ValueObject copied into host memory. class ValueObjectConstResult : public ValueObject { public: ~ValueObjectConstResult() override; diff --git a/lldb/include/lldb/Core/ValueObjectConstResultCast.h b/lldb/include/lldb/Core/ValueObjectConstResultCast.h index ba81785866c3..5467ce3db403 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResultCast.h +++ b/lldb/include/lldb/Core/ValueObjectConstResultCast.h @@ -17,8 +17,8 @@ #include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> namespace lldb_private { class DataExtractor; diff --git a/lldb/include/lldb/Core/ValueObjectConstResultChild.h b/lldb/include/lldb/Core/ValueObjectConstResultChild.h index b3606bfde0ef..26bd9f337a59 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResultChild.h +++ b/lldb/include/lldb/Core/ValueObjectConstResultChild.h @@ -17,8 +17,8 @@ #include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> namespace lldb_private { class DataExtractor; diff --git a/lldb/include/lldb/Core/ValueObjectConstResultImpl.h b/lldb/include/lldb/Core/ValueObjectConstResultImpl.h index 1316bf66dfdb..2536c51fa574 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResultImpl.h +++ b/lldb/include/lldb/Core/ValueObjectConstResultImpl.h @@ -15,8 +15,8 @@ #include "lldb/lldb-private-enumerations.h" #include "lldb/lldb-types.h" -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> namespace lldb_private { class CompilerType; class DataExtractor; @@ -26,9 +26,9 @@ class ValueObject; namespace lldb_private { -// A class wrapping common implementation details for operations in -// ValueObjectConstResult ( & Child ) that may need to jump from the host -// memory space into the target's memory space +/// A class wrapping common implementation details for operations in +/// ValueObjectConstResult ( & Child ) that may need to jump from the host +/// memory space into the target's memory space. class ValueObjectConstResultImpl { public: ValueObjectConstResultImpl(ValueObject *valobj, diff --git a/lldb/include/lldb/Core/ValueObjectDynamicValue.h b/lldb/include/lldb/Core/ValueObjectDynamicValue.h index 2806857339ef..8822a1d39249 100644 --- a/lldb/include/lldb/Core/ValueObjectDynamicValue.h +++ b/lldb/include/lldb/Core/ValueObjectDynamicValue.h @@ -19,17 +19,17 @@ #include "lldb/lldb-forward.h" #include "lldb/lldb-private-enumerations.h" -#include <assert.h> -#include <stddef.h> -#include <stdint.h> +#include <cassert> +#include <cstddef> +#include <cstdint> namespace lldb_private { class DataExtractor; class Declaration; class Status; -// A ValueObject that represents memory at a given address, viewed as some -// set lldb type. +/// A ValueObject that represents memory at a given address, viewed as some +/// set lldb type. class ValueObjectDynamicValue : public ValueObject { public: ~ValueObjectDynamicValue() override; diff --git a/lldb/include/lldb/Core/ValueObjectList.h b/lldb/include/lldb/Core/ValueObjectList.h index f99fba41aa26..fcb358e21a26 100644 --- a/lldb/include/lldb/Core/ValueObjectList.h +++ b/lldb/include/lldb/Core/ValueObjectList.h @@ -14,12 +14,12 @@ #include <vector> -#include <stddef.h> +#include <cstddef> namespace lldb_private { class ValueObject; -// A collection of ValueObject values that +/// A collection of ValueObject values that. class ValueObjectList { public: const ValueObjectList &operator=(const ValueObjectList &rhs); diff --git a/lldb/include/lldb/Core/ValueObjectMemory.h b/lldb/include/lldb/Core/ValueObjectMemory.h index b5d5e6ecf4c0..83671a794b5f 100644 --- a/lldb/include/lldb/Core/ValueObjectMemory.h +++ b/lldb/include/lldb/Core/ValueObjectMemory.h @@ -18,14 +18,14 @@ #include "lldb/lldb-forward.h" #include "llvm/ADT/StringRef.h" -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> namespace lldb_private { class ExecutionContextScope; -// A ValueObject that represents memory at a given address, viewed as some -// set lldb type. +/// A ValueObject that represents memory at a given address, viewed as some +/// set lldb type. class ValueObjectMemory : public ValueObject { public: ~ValueObjectMemory() override; diff --git a/lldb/include/lldb/Core/ValueObjectRegister.h b/lldb/include/lldb/Core/ValueObjectRegister.h index 3968584ad518..e210b36d2a45 100644 --- a/lldb/include/lldb/Core/ValueObjectRegister.h +++ b/lldb/include/lldb/Core/ValueObjectRegister.h @@ -18,8 +18,8 @@ #include "lldb/lldb-forward.h" #include "lldb/lldb-private-types.h" -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> namespace lldb_private { class DataExtractor; diff --git a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h index 41c461ce13f0..f7a233047cc1 100644 --- a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h +++ b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h @@ -20,18 +20,18 @@ #include <cstdint> #include <memory> -#include <stddef.h> +#include <cstddef> namespace lldb_private { class Declaration; class Status; class SyntheticChildrenFrontEnd; -// A ValueObject that obtains its children from some source other than -// real information -// This is currently used to implement Python-based children and filters but -// you can bind it to any source of synthetic information and have it behave -// accordingly +/// A ValueObject that obtains its children from some source other than +/// real information. +/// This is currently used to implement Python-based children and filters but +/// you can bind it to any source of synthetic information and have it behave +/// accordingly. class ValueObjectSynthetic : public ValueObject { public: ~ValueObjectSynthetic() override; @@ -148,9 +148,9 @@ protected: /// Guarded by m_child_mutex; SyntheticChildrenCache m_synthetic_children_cache; - uint32_t m_synthetic_children_count; // FIXME use the ValueObject's - // ChildrenManager instead of a special - // purpose solution + // FIXME: use the ValueObject's ChildrenManager instead of a special purpose + // solution. + uint32_t m_synthetic_children_count; ConstString m_parent_type_name; diff --git a/lldb/include/lldb/Core/ValueObjectUpdater.h b/lldb/include/lldb/Core/ValueObjectUpdater.h new file mode 100644 index 000000000000..54fcb31076ad --- /dev/null +++ b/lldb/include/lldb/Core/ValueObjectUpdater.h @@ -0,0 +1,43 @@ +//===-- ValueObjectUpdater.h ------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_CORE_VALUEOBJECTUPDATER_H +#define LLDB_CORE_VALUEOBJECTUPDATER_H + +#include "lldb/Core/ValueObject.h" + +namespace lldb_private { + +/// A value object class that is seeded with the static variable value +/// and it vends the user facing value object. If the type is dynamic it can +/// vend the dynamic type. If this user type also has a synthetic type +/// associated with it, it will vend the synthetic type. The class watches the +/// process' stop ID and will update the user type when needed. +class ValueObjectUpdater { + /// The root value object is the static typed variable object. + lldb::ValueObjectSP m_root_valobj_sp; + /// The user value object is the value object the user wants to see. + lldb::ValueObjectSP m_user_valobj_sp; + /// The stop ID that m_user_valobj_sp is valid for. + uint32_t m_stop_id = UINT32_MAX; + +public: + ValueObjectUpdater(lldb::ValueObjectSP in_valobj_sp); + + /// Gets the correct value object from the root object for a given process + /// stop ID. If dynamic values are enabled, or if synthetic children are + /// enabled, the value object that the user wants to see might change while + /// debugging. + lldb::ValueObjectSP GetSP(); + + lldb::ProcessSP GetProcessSP() const; +}; + +} // namespace lldb_private + +#endif // LLDB_CORE_VALUEOBJECTUPDATER_H diff --git a/lldb/include/lldb/Core/ValueObjectVariable.h b/lldb/include/lldb/Core/ValueObjectVariable.h index 23fdedbf5a4a..cbf7e5b52ced 100644 --- a/lldb/include/lldb/Core/ValueObjectVariable.h +++ b/lldb/include/lldb/Core/ValueObjectVariable.h @@ -18,8 +18,8 @@ #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" -#include <stddef.h> -#include <stdint.h> +#include <cstddef> +#include <cstdint> namespace lldb_private { class DataExtractor; @@ -28,8 +28,8 @@ class Status; class ExecutionContextScope; class SymbolContextScope; -// A ValueObject that contains a root variable that may or may not -// have children. +/// A ValueObject that contains a root variable that may or may not +/// have children. class ValueObjectVariable : public ValueObject { public: ~ValueObjectVariable() override; @@ -72,10 +72,11 @@ protected: 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 + /// The variable that this value object is based upon. + lldb::VariableSP m_variable_sp; + ///< The value that DWARFExpression resolves this variable to before we patch + ///< it up. + Value m_resolved_value; private: ValueObjectVariable(ExecutionContextScope *exe_scope, diff --git a/lldb/include/lldb/Core/dwarf.h b/lldb/include/lldb/Core/dwarf.h index cd9cf249bc63..968418e71c2f 100644 --- a/lldb/include/lldb/Core/dwarf.h +++ b/lldb/include/lldb/Core/dwarf.h @@ -10,7 +10,7 @@ #define LLDB_CORE_DWARF_H #include "lldb/Utility/RangeMap.h" -#include <stdint.h> +#include <cstdint> // Get the DWARF constant definitions from llvm #include "llvm/BinaryFormat/Dwarf.h" @@ -38,39 +38,6 @@ typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for any #define DW_EH_PE_MASK_ENCODING 0x0F -//// The following are used only internally within lldb - don't -//// document them in the llvm Dwarf.h header file, we won't see -//// them in executable files anywhere. -//// These constants fit between DW_OP_lo_user (0xe0) and DW_OP_hi_user (0xff). -// -//#define DW_OP_APPLE_array_ref 0xEE // first pops index, then pops array; -//pushes array[index] -//#define DW_OP_APPLE_extern 0xEF // ULEB128 index of external object -//(i.e., an entity from the program that was used in the expression) -#define DW_OP_APPLE_uninit \ - 0xF0 // This is actually generated by some apple compilers in locations lists -//#define DW_OP_APPLE_assign 0xF1 // pops value off and assigns it to -//second item on stack (2nd item must have assignable context) -//#define DW_OP_APPLE_address_of 0xF2 // gets the address of the top stack -//item (top item must be a variable, or have value_type that is an address -//already) -//#define DW_OP_APPLE_value_of 0xF3 // pops the value off the stack and -//pushes the value of that object (top item must be a variable, or expression -//local) -//#define DW_OP_APPLE_deref_type 0xF4 // gets the address of the top stack -//item (top item must be a variable, or a clang type) -//#define DW_OP_APPLE_expr_local 0xF5 // ULEB128 expression local index -//#define DW_OP_APPLE_constf 0xF6 // 1 byte float size, followed by -//constant float data -//#define DW_OP_APPLE_scalar_cast 0xF7 // Cast top of stack to 2nd in stack's -//type leaving all items in place -//#define DW_OP_APPLE_clang_cast 0xF8 // pointer size clang::Type * off the -//stack and cast top stack item to this type -//#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::RangeVector<dw_addr_t, dw_addr_t, 2> DWARFRangeList; #endif // LLDB_CORE_DWARF_H |