diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2024-01-24 19:17:23 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2024-04-06 20:13:49 +0000 |
commit | 7a6dacaca14b62ca4b74406814becb87a3fefac0 (patch) | |
tree | 273a870ac27484bb1f5ee55e7ef0dc0d061f63e7 /contrib/llvm-project/lldb | |
parent | 46c59ea9b61755455ff6bf9f3e7b834e1af634ea (diff) | |
parent | 4df029cc74e5ec124f14a5682e44999ce4f086df (diff) |
Diffstat (limited to 'contrib/llvm-project/lldb')
89 files changed, 1104 insertions, 731 deletions
diff --git a/contrib/llvm-project/lldb/include/lldb/API/LLDB.h b/contrib/llvm-project/lldb/include/lldb/API/LLDB.h index f652d1bdb835..f5f1b87a046c 100644 --- a/contrib/llvm-project/lldb/include/lldb/API/LLDB.h +++ b/contrib/llvm-project/lldb/include/lldb/API/LLDB.h @@ -33,6 +33,7 @@ #include "lldb/API/SBFile.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBFileSpecList.h" +#include "lldb/API/SBFormat.h" #include "lldb/API/SBFrame.h" #include "lldb/API/SBFunction.h" #include "lldb/API/SBHostOS.h" diff --git a/contrib/llvm-project/lldb/include/lldb/Breakpoint/Breakpoint.h b/contrib/llvm-project/lldb/include/lldb/Breakpoint/Breakpoint.h index 3a8b29aee544..8c4308ab0bc1 100644 --- a/contrib/llvm-project/lldb/include/lldb/Breakpoint/Breakpoint.h +++ b/contrib/llvm-project/lldb/include/lldb/Breakpoint/Breakpoint.h @@ -672,7 +672,7 @@ private: void SendBreakpointChangedEvent(lldb::BreakpointEventType eventKind); - void SendBreakpointChangedEvent(BreakpointEventData *data); + void SendBreakpointChangedEvent(const lldb::EventDataSP &breakpoint_data_sp); Breakpoint(const Breakpoint &) = delete; const Breakpoint &operator=(const Breakpoint &) = delete; diff --git a/contrib/llvm-project/lldb/include/lldb/Breakpoint/BreakpointIDList.h b/contrib/llvm-project/lldb/include/lldb/Breakpoint/BreakpointIDList.h index 6910024695d8..6c57d9bc5079 100644 --- a/contrib/llvm-project/lldb/include/lldb/Breakpoint/BreakpointIDList.h +++ b/contrib/llvm-project/lldb/include/lldb/Breakpoint/BreakpointIDList.h @@ -12,12 +12,13 @@ #include <utility> #include <vector> - -#include "lldb/lldb-enumerations.h" #include "lldb/Breakpoint/BreakpointID.h" #include "lldb/Breakpoint/BreakpointName.h" +#include "lldb/lldb-enumerations.h" #include "lldb/lldb-private.h" +#include "llvm/Support/Error.h" + namespace lldb_private { // class BreakpointIDList @@ -41,8 +42,6 @@ public: bool AddBreakpointID(BreakpointID bp_id); - bool AddBreakpointID(const char *bp_id); - // TODO: This should take a const BreakpointID. bool FindBreakpointID(BreakpointID &bp_id, size_t *position) const; @@ -54,12 +53,10 @@ public: static std::pair<llvm::StringRef, llvm::StringRef> SplitIDRangeExpression(llvm::StringRef in_string); - static void FindAndReplaceIDRanges(Args &old_args, Target *target, - bool allow_locations, - BreakpointName::Permissions - ::PermissionKinds purpose, - CommandReturnObject &result, - Args &new_args); + static llvm::Error + FindAndReplaceIDRanges(Args &old_args, Target *target, bool allow_locations, + BreakpointName::Permissions ::PermissionKinds purpose, + Args &new_args); private: BreakpointIDArray m_breakpoint_ids; diff --git a/contrib/llvm-project/lldb/include/lldb/Breakpoint/Watchpoint.h b/contrib/llvm-project/lldb/include/lldb/Breakpoint/Watchpoint.h index 851162af24c7..22fdfd686c3f 100644 --- a/contrib/llvm-project/lldb/include/lldb/Breakpoint/Watchpoint.h +++ b/contrib/llvm-project/lldb/include/lldb/Breakpoint/Watchpoint.h @@ -235,8 +235,6 @@ private: void SendWatchpointChangedEvent(lldb::WatchpointEventType eventKind); - void SendWatchpointChangedEvent(WatchpointEventData *data); - Watchpoint(const Watchpoint &) = delete; const Watchpoint &operator=(const Watchpoint &) = delete; }; diff --git a/contrib/llvm-project/lldb/include/lldb/Core/Address.h b/contrib/llvm-project/lldb/include/lldb/Core/Address.h index 725b5d9f91d3..9b5874f8b1fb 100644 --- a/contrib/llvm-project/lldb/include/lldb/Core/Address.h +++ b/contrib/llvm-project/lldb/include/lldb/Core/Address.h @@ -9,6 +9,7 @@ #ifndef LLDB_CORE_ADDRESS_H #define LLDB_CORE_ADDRESS_H +#include "lldb/Utility/Stream.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private-enumerations.h" @@ -252,10 +253,11 @@ public: /// in such cases. /// /// \see Address::DumpStyle - bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, - DumpStyle fallback_style = DumpStyleInvalid, - uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false, - llvm::StringRef pattern = "") const; + bool + Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, + DumpStyle fallback_style = DumpStyleInvalid, + uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false, + std::optional<Stream::HighlightSettings> settings = std::nullopt) const; AddressClass GetAddressClass() const; diff --git a/contrib/llvm-project/lldb/include/lldb/Core/DebuggerEvents.h b/contrib/llvm-project/lldb/include/lldb/Core/DebuggerEvents.h index 982b22229701..4a27766e94e3 100644 --- a/contrib/llvm-project/lldb/include/lldb/Core/DebuggerEvents.h +++ b/contrib/llvm-project/lldb/include/lldb/Core/DebuggerEvents.h @@ -20,9 +20,10 @@ class Stream; class ProgressEventData : public EventData { public: - ProgressEventData(uint64_t progress_id, std::string title, std::string update, - uint64_t completed, uint64_t total, bool debugger_specific) - : m_title(std::move(title)), m_details(std::move(update)), + ProgressEventData(uint64_t progress_id, std::string title, + std::string details, uint64_t completed, uint64_t total, + bool debugger_specific) + : m_title(std::move(title)), m_details(std::move(details)), m_id(progress_id), m_completed(completed), m_total(total), m_debugger_specific(debugger_specific) {} diff --git a/contrib/llvm-project/lldb/include/lldb/Core/Progress.h b/contrib/llvm-project/lldb/include/lldb/Core/Progress.h index b2b8781a43b0..65d30ea25cd2 100644 --- a/contrib/llvm-project/lldb/include/lldb/Core/Progress.h +++ b/contrib/llvm-project/lldb/include/lldb/Core/Progress.h @@ -64,12 +64,13 @@ public: /// @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 + /// set to std::nullopt 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, + Progress(std::string title, std::string details = {}, + std::optional<uint64_t> total = std::nullopt, lldb_private::Debugger *debugger = nullptr); /// Destroy the progress object. @@ -89,20 +90,23 @@ public: /// @param [in] amount The amount to increment m_completed by. /// /// @param [in] an optional message associated with this update. - void Increment(uint64_t amount = 1, std::string update = {}); + void Increment(uint64_t amount = 1, + std::optional<std::string> updated_detail = {}); private: - void ReportProgress(std::string update = {}); + void ReportProgress(); static std::atomic<uint64_t> g_id; /// The title of the progress activity. std::string m_title; + std::string m_details; 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; + /// Total amount of work, use a std::nullopt in the constructor for non + /// deterministic progress. + uint64_t m_total; /// The optional debugger ID to report progress to. If this has no value then /// all debuggers will receive this event. std::optional<lldb::user_id_t> m_debugger_id; diff --git a/contrib/llvm-project/lldb/include/lldb/Core/ValueObject.h b/contrib/llvm-project/lldb/include/lldb/Core/ValueObject.h index 3f8005ba696c..4c0b0b2dae6c 100644 --- a/contrib/llvm-project/lldb/include/lldb/Core/ValueObject.h +++ b/contrib/llvm-project/lldb/include/lldb/Core/ValueObject.h @@ -670,8 +670,7 @@ public: std::pair<size_t, bool> ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, Status &error, - uint32_t max_length = 0, bool honor_array = true, - lldb::Format item_format = lldb::eFormatCharArray); + bool honor_array); virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0, uint32_t item_count = 1); diff --git a/contrib/llvm-project/lldb/include/lldb/Host/Config.h.cmake b/contrib/llvm-project/lldb/include/lldb/Host/Config.h.cmake index 14ce46f6559c..3defa454f6d4 100644 --- a/contrib/llvm-project/lldb/include/lldb/Host/Config.h.cmake +++ b/contrib/llvm-project/lldb/include/lldb/Host/Config.h.cmake @@ -55,4 +55,6 @@ #cmakedefine LLDB_GLOBAL_INIT_DIRECTORY R"(${LLDB_GLOBAL_INIT_DIRECTORY})" +#define LLDB_BUG_REPORT_URL "${LLDB_BUG_REPORT_URL}" + #endif // #ifndef LLDB_HOST_CONFIG_H diff --git a/contrib/llvm-project/lldb/include/lldb/Symbol/CompileUnit.h b/contrib/llvm-project/lldb/include/lldb/Symbol/CompileUnit.h index 89e853ab599d..c20a37e32830 100644 --- a/contrib/llvm-project/lldb/include/lldb/Symbol/CompileUnit.h +++ b/contrib/llvm-project/lldb/include/lldb/Symbol/CompileUnit.h @@ -91,7 +91,7 @@ public: /// \param[in] user_data /// User data where the SymbolFile parser can store data. /// - /// \param[in] file_spec + /// \param[in] support_file_sp /// The file specification for the source file of this compile /// unit. /// @@ -116,7 +116,7 @@ public: /// An rvalue list of already parsed support files. /// \see lldb::LanguageType CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, - const FileSpec &file_spec, lldb::user_id_t uid, + lldb::SupportFileSP support_file_sp, lldb::user_id_t uid, lldb::LanguageType language, lldb_private::LazyBool is_optimized, SupportFileList &&support_files = {}); @@ -226,11 +226,15 @@ public: const FileSpec *file_spec_ptr, bool exact, LineEntry *line_entry); - /// Return the primary source file associated with this compile unit. - const FileSpec &GetPrimaryFile() const { return m_file_spec; } + /// Return the primary source spec associated with this compile unit. + const FileSpec &GetPrimaryFile() const { + return m_primary_support_file_sp->GetSpecOnly(); + } /// Return the primary source file associated with this compile unit. - void SetPrimaryFile(const FileSpec &fs) { m_file_spec = fs; } + lldb::SupportFileSP GetPrimarySupportFile() const { + return m_primary_support_file_sp; + } /// Get the line table for the compile unit. /// @@ -419,7 +423,7 @@ protected: /// compile unit. std::vector<SourceModule> m_imported_modules; /// The primary file associated with this compile unit. - FileSpec m_file_spec; + lldb::SupportFileSP m_primary_support_file_sp; /// Files associated with this compile unit's line table and declarations. SupportFileList m_support_files; /// Line table that will get parsed on demand. diff --git a/contrib/llvm-project/lldb/include/lldb/Symbol/LineEntry.h b/contrib/llvm-project/lldb/include/lldb/Symbol/LineEntry.h index 698d89974dc6..c2daba916e3f 100644 --- a/contrib/llvm-project/lldb/include/lldb/Symbol/LineEntry.h +++ b/contrib/llvm-project/lldb/include/lldb/Symbol/LineEntry.h @@ -11,6 +11,7 @@ #include "lldb/Core/AddressRange.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/SupportFile.h" #include "lldb/lldb-private.h" namespace lldb_private { @@ -23,12 +24,6 @@ struct LineEntry { /// Initialize all member variables to invalid values. LineEntry(); - LineEntry(const lldb::SectionSP §ion_sp, lldb::addr_t section_offset, - lldb::addr_t byte_size, const FileSpec &file, uint32_t _line, - uint16_t _column, bool _is_start_of_statement, - bool _is_start_of_basic_block, bool _is_prologue_end, - bool _is_epilogue_begin, bool _is_terminal_entry); - /// Clear the object's state. /// /// Clears all member variables to invalid values. @@ -139,7 +134,8 @@ struct LineEntry { AddressRange range; ///< The section offset address range for this line entry. FileSpec file; ///< The source file, possibly mapped by the target.source-map ///setting - FileSpec original_file; ///< The original source file, from debug info. + lldb::SupportFileSP + original_file_sp; ///< The original source file, from debug info. uint32_t line = LLDB_INVALID_LINE_NUMBER; ///< The source line number, or zero ///< if there is no line number /// information. diff --git a/contrib/llvm-project/lldb/include/lldb/Symbol/Symbol.h b/contrib/llvm-project/lldb/include/lldb/Symbol/Symbol.h index e6c0b495bcf2..e05c845a69f3 100644 --- a/contrib/llvm-project/lldb/include/lldb/Symbol/Symbol.h +++ b/contrib/llvm-project/lldb/include/lldb/Symbol/Symbol.h @@ -13,6 +13,7 @@ #include "lldb/Core/Mangled.h" #include "lldb/Core/Section.h" #include "lldb/Symbol/SymbolContextScope.h" +#include "lldb/Utility/Stream.h" #include "lldb/Utility/UserID.h" #include "lldb/lldb-private.h" #include "llvm/Support/JSON.h" @@ -174,8 +175,9 @@ public: void SetFlags(uint32_t flags) { m_flags = flags; } - void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target, - llvm::StringRef pattern = "") const; + void GetDescription( + Stream *s, lldb::DescriptionLevel level, Target *target, + std::optional<Stream::HighlightSettings> settings = std::nullopt) const; bool IsSynthetic() const { return m_is_synthetic; } diff --git a/contrib/llvm-project/lldb/include/lldb/Symbol/SymbolContext.h b/contrib/llvm-project/lldb/include/lldb/Symbol/SymbolContext.h index 26f3bac09a96..bd33a71b46ca 100644 --- a/contrib/llvm-project/lldb/include/lldb/Symbol/SymbolContext.h +++ b/contrib/llvm-project/lldb/include/lldb/Symbol/SymbolContext.h @@ -17,6 +17,7 @@ #include "lldb/Core/Mangled.h" #include "lldb/Symbol/LineEntry.h" #include "lldb/Utility/Iterable.h" +#include "lldb/Utility/Stream.h" #include "lldb/lldb-private.h" namespace lldb_private { @@ -153,11 +154,11 @@ public: /// /// \return /// \b true if some text was dumped, \b false otherwise. - bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, - const Address &so_addr, bool show_fullpaths, - bool show_module, bool show_inlined_frames, - bool show_function_arguments, bool show_function_name, - llvm::StringRef pattern = "") const; + bool DumpStopContext( + Stream *s, ExecutionContextScope *exe_scope, const Address &so_addr, + bool show_fullpaths, bool show_module, bool show_inlined_frames, + bool show_function_arguments, bool show_function_name, + std::optional<Stream::HighlightSettings> settings = std::nullopt) const; /// Get the address range contained within a symbol context. /// @@ -223,8 +224,9 @@ public: /// The symbol that was found, or \b nullptr if none was found. const Symbol *FindBestGlobalDataSymbol(ConstString name, Status &error); - void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target, - llvm::StringRef pattern = "") const; + void GetDescription( + Stream *s, lldb::DescriptionLevel level, Target *target, + std::optional<Stream::HighlightSettings> settings = std::nullopt) const; uint32_t GetResolvedMask() const; diff --git a/contrib/llvm-project/lldb/include/lldb/Target/Platform.h b/contrib/llvm-project/lldb/include/lldb/Target/Platform.h index 129e4565d9ff..13196ff74d66 100644 --- a/contrib/llvm-project/lldb/include/lldb/Target/Platform.h +++ b/contrib/llvm-project/lldb/include/lldb/Target/Platform.h @@ -288,6 +288,32 @@ public: LocateExecutableScriptingResources(Target *target, Module &module, Stream &feedback_stream); + /// \param[in] module_spec + /// The ModuleSpec of a binary to find. + /// + /// \param[in] process + /// A Process. + /// + /// \param[out] module_sp + /// A Module that matches the ModuleSpec, if one is found. + /// + /// \param[in] module_search_paths_ptr + /// Locations to possibly look for a binary that matches the ModuleSpec. + /// + /// \param[out] old_modules + /// Existing Modules in the Process' Target image list which match + /// the FileSpec. + /// + /// \param[out] did_create_ptr + /// Optional boolean, nullptr may be passed for this argument. + /// If this method is returning a *new* ModuleSP, this + /// will be set to true. + /// If this method is returning a ModuleSP that is already in the + /// Target's image list, it will be false. + /// + /// \return + /// The Status object for any errors found while searching for + /// the binary. virtual Status GetSharedModule( const ModuleSpec &module_spec, Process *process, lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, diff --git a/contrib/llvm-project/lldb/include/lldb/Utility/Broadcaster.h b/contrib/llvm-project/lldb/include/lldb/Utility/Broadcaster.h index 8444c38f6ecc..c8127f0a921d 100644 --- a/contrib/llvm-project/lldb/include/lldb/Utility/Broadcaster.h +++ b/contrib/llvm-project/lldb/include/lldb/Utility/Broadcaster.h @@ -177,8 +177,8 @@ public: m_broadcaster_sp->BroadcastEvent(event_type, event_data_sp); } - void BroadcastEvent(uint32_t event_type, EventData *event_data = nullptr) { - m_broadcaster_sp->BroadcastEvent(event_type, event_data); + void BroadcastEvent(uint32_t event_type) { + m_broadcaster_sp->BroadcastEvent(event_type); } void BroadcastEventIfUnique(uint32_t event_type, @@ -346,7 +346,7 @@ protected: void BroadcastEventIfUnique(lldb::EventSP &event_sp); - void BroadcastEvent(uint32_t event_type, EventData *event_data = nullptr); + void BroadcastEvent(uint32_t event_type); void BroadcastEvent(uint32_t event_type, const lldb::EventDataSP &event_data_sp); diff --git a/contrib/llvm-project/lldb/include/lldb/Utility/FileSpec.h b/contrib/llvm-project/lldb/include/lldb/Utility/FileSpec.h index e4276e8398b4..2e867b2b40b9 100644 --- a/contrib/llvm-project/lldb/include/lldb/Utility/FileSpec.h +++ b/contrib/llvm-project/lldb/include/lldb/Utility/FileSpec.h @@ -13,7 +13,6 @@ #include <optional> #include <string> -#include "lldb/Utility/Checksum.h" #include "lldb/Utility/ConstString.h" #include "llvm/ADT/StringRef.h" @@ -72,12 +71,8 @@ public: /// \param[in] style /// The style of the path /// - /// \param[in] checksum - /// The MD5 checksum of the path. - /// /// \see FileSpec::SetFile (const char *path) - explicit FileSpec(llvm::StringRef path, Style style = Style::native, - const Checksum &checksum = {}); + explicit FileSpec(llvm::StringRef path, Style style = Style::native); explicit FileSpec(llvm::StringRef path, const llvm::Triple &triple); @@ -367,11 +362,7 @@ public: /// /// \param[in] style /// The style for the given path. - /// - /// \param[in] checksum - /// The checksum for the given path. - void SetFile(llvm::StringRef path, Style style, - const Checksum &checksum = {}); + void SetFile(llvm::StringRef path, Style style); /// Change the file specified with a new path. /// @@ -414,19 +405,13 @@ public: /// The lifetime of the StringRefs is tied to the lifetime of the FileSpec. std::vector<llvm::StringRef> GetComponents() const; - /// Return the checksum for this FileSpec or all zeros if there is none. - const Checksum &GetChecksum() const { return m_checksum; }; - protected: // Convenience method for setting the file without changing the style. void SetFile(llvm::StringRef path); /// Called anytime m_directory or m_filename is changed to clear any cached /// state in this object. - void PathWasModified() { - m_checksum = Checksum(); - m_absolute = Absolute::Calculate; - } + void PathWasModified() { m_absolute = Absolute::Calculate; } enum class Absolute : uint8_t { Calculate, @@ -440,9 +425,6 @@ protected: /// The unique'd filename path. ConstString m_filename; - /// The optional MD5 checksum of the file. - Checksum m_checksum; - /// Cache whether this path is absolute. mutable Absolute m_absolute = Absolute::Calculate; diff --git a/contrib/llvm-project/lldb/include/lldb/Utility/FileSpecList.h b/contrib/llvm-project/lldb/include/lldb/Utility/FileSpecList.h index 8cccb1949999..49edc667ddd5 100644 --- a/contrib/llvm-project/lldb/include/lldb/Utility/FileSpecList.h +++ b/contrib/llvm-project/lldb/include/lldb/Utility/FileSpecList.h @@ -10,6 +10,8 @@ #define LLDB_CORE_FILESPECLIST_H #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/SupportFile.h" +#include "lldb/lldb-forward.h" #include <cstddef> #include <vector> @@ -17,28 +19,6 @@ namespace lldb_private { class Stream; -/// Wraps either a FileSpec that represents a local file or a source -/// file whose contents is known (for example because it can be -/// reconstructed from debug info), but that hasn't been written to a -/// file yet. -class SupportFile { -protected: - FileSpec m_file_spec; - -public: - SupportFile(const FileSpec &spec) : m_file_spec(spec) {} - SupportFile(const SupportFile &other) = delete; - SupportFile(SupportFile &&other) = default; - virtual ~SupportFile() = default; - bool operator==(const SupportFile &other) { - return m_file_spec == other.m_file_spec; - } - /// Return the file name only. Useful for resolving breakpoints by file name. - const FileSpec &GetSpecOnly() const { return m_file_spec; }; - /// Materialize the file to disk and return the path to that temporary file. - virtual const FileSpec &Materialize() { return m_file_spec; } -}; - /// A list of support files for a CompileUnit. class SupportFileList { public: @@ -46,21 +26,22 @@ public: SupportFileList(const SupportFileList &) = delete; SupportFileList(SupportFileList &&other) = default; - typedef std::vector<std::unique_ptr<SupportFile>> collection; + typedef std::vector<std::shared_ptr<SupportFile>> collection; typedef collection::const_iterator const_iterator; const_iterator begin() const { return m_files.begin(); } const_iterator end() const { return m_files.end(); } void Append(const FileSpec &file) { - return Append(std::make_unique<SupportFile>(file)); + return Append(std::make_shared<SupportFile>(file)); } - void Append(std::unique_ptr<SupportFile> &&file) { + void Append(std::shared_ptr<SupportFile> &&file) { m_files.push_back(std::move(file)); } // FIXME: Only used by SymbolFilePDB. Replace with a DenseSet at call site. bool AppendIfUnique(const FileSpec &file); size_t GetSize() const { return m_files.size(); } const FileSpec &GetFileSpecAtIndex(size_t idx) const; + lldb::SupportFileSP GetSupportFileAtIndex(size_t idx) const; size_t FindFileIndex(size_t idx, const FileSpec &file, bool full) const; /// Find a compatible file index. /// @@ -90,7 +71,7 @@ public: template <class... Args> void EmplaceBack(Args &&...args) { m_files.push_back( - std::make_unique<SupportFile>(FileSpec(std::forward<Args>(args)...))); + std::make_shared<SupportFile>(std::forward<Args>(args)...)); } protected: diff --git a/contrib/llvm-project/lldb/include/lldb/Utility/Stream.h b/contrib/llvm-project/lldb/include/lldb/Utility/Stream.h index 20c55ac4597a..37bcdc992417 100644 --- a/contrib/llvm-project/lldb/include/lldb/Utility/Stream.h +++ b/contrib/llvm-project/lldb/include/lldb/Utility/Stream.h @@ -33,6 +33,17 @@ public: /// string mode. }; + /// Struct to store information for color highlighting in the stream. + struct HighlightSettings { + llvm::StringRef pattern; ///< Regex pattern for highlighting. + llvm::StringRef prefix; ///< ANSI color code to start colorization. + llvm::StringRef suffix; ///< ANSI color code to end colorization. + + HighlightSettings(llvm::StringRef p, llvm::StringRef pre, + llvm::StringRef suf) + : pattern(p), prefix(pre), suffix(suf) {} + }; + /// Utility class for counting the bytes that were written to a stream in a /// certain time span. /// @@ -260,10 +271,9 @@ public: /// The ANSI color code to end colorization. This is /// environment-dependent. - void PutCStringColorHighlighted(llvm::StringRef text, - llvm::StringRef pattern = "", - llvm::StringRef prefix = "", - llvm::StringRef suffix = ""); + void PutCStringColorHighlighted( + llvm::StringRef text, + std::optional<HighlightSettings> settings = std::nullopt); /// Output and End of Line character to the stream. size_t EOL(); diff --git a/contrib/llvm-project/lldb/include/lldb/Utility/SupportFile.h b/contrib/llvm-project/lldb/include/lldb/Utility/SupportFile.h new file mode 100644 index 000000000000..0ea0ca4e7c97 --- /dev/null +++ b/contrib/llvm-project/lldb/include/lldb/Utility/SupportFile.h @@ -0,0 +1,55 @@ +//===-- SupportFile.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_SUPPORTFILE_H +#define LLDB_UTILITY_SUPPORTFILE_H + +#include "lldb/Utility/Checksum.h" +#include "lldb/Utility/FileSpec.h" + +namespace lldb_private { + +/// Wraps either a FileSpec that represents a local file or a source +/// file whose contents is known (for example because it can be +/// reconstructed from debug info), but that hasn't been written to a +/// file yet. This also stores an optional checksum of the on-disk content. +class SupportFile { +public: + SupportFile() : m_file_spec(), m_checksum() {} + SupportFile(const FileSpec &spec) : m_file_spec(spec), m_checksum() {} + SupportFile(const FileSpec &spec, const Checksum &checksum) + : m_file_spec(spec), m_checksum(checksum) {} + + SupportFile(const SupportFile &other) = delete; + SupportFile(SupportFile &&other) = default; + + virtual ~SupportFile() = default; + + bool operator==(const SupportFile &other) const { + return m_file_spec == other.m_file_spec && m_checksum == other.m_checksum; + } + + bool operator!=(const SupportFile &other) const { return !(*this == other); } + + /// Return the file name only. Useful for resolving breakpoints by file name. + const FileSpec &GetSpecOnly() const { return m_file_spec; }; + + /// Return the checksum or all zeros if there is none. + const Checksum &GetChecksum() const { return m_checksum; }; + + /// Materialize the file to disk and return the path to that temporary file. + virtual const FileSpec &Materialize() { return m_file_spec; } + +protected: + FileSpec m_file_spec; + Checksum m_checksum; +}; + +} // namespace lldb_private + +#endif // LLDB_UTILITY_SUPPORTFILE_H diff --git a/contrib/llvm-project/lldb/include/lldb/Utility/XcodeSDK.h b/contrib/llvm-project/lldb/include/lldb/Utility/XcodeSDK.h index f8528995d549..673ea578ffce 100644 --- a/contrib/llvm-project/lldb/include/lldb/Utility/XcodeSDK.h +++ b/contrib/llvm-project/lldb/include/lldb/Utility/XcodeSDK.h @@ -34,6 +34,8 @@ public: AppleTVOS, WatchSimulator, watchOS, + XRSimulator, + XROS, bridgeOS, Linux, unknown = -1 diff --git a/contrib/llvm-project/lldb/include/lldb/lldb-enumerations.h b/contrib/llvm-project/lldb/include/lldb/lldb-enumerations.h index 99a2f9fe14e2..44a596693e16 100644 --- a/contrib/llvm-project/lldb/include/lldb/lldb-enumerations.h +++ b/contrib/llvm-project/lldb/include/lldb/lldb-enumerations.h @@ -875,6 +875,7 @@ enum TemplateArgumentKind { eTemplateArgumentKindExpression, eTemplateArgumentKindPack, eTemplateArgumentKindNullPtr, + eTemplateArgumentKindStructuralValue, }; /// Type of match to be performed when looking for a formatter for a data type. diff --git a/contrib/llvm-project/lldb/include/lldb/lldb-forward.h b/contrib/llvm-project/lldb/include/lldb/lldb-forward.h index 4e0c62fa26ca..d89ad2151221 100644 --- a/contrib/llvm-project/lldb/include/lldb/lldb-forward.h +++ b/contrib/llvm-project/lldb/include/lldb/lldb-forward.h @@ -212,6 +212,7 @@ class StringList; class StringTableReader; class StructuredDataImpl; class StructuredDataPlugin; +class SupportFile; class Symbol; class SymbolContext; class SymbolContextList; @@ -462,6 +463,7 @@ typedef std::shared_ptr<lldb_private::TypeSummaryImpl> TypeSummaryImplSP; typedef std::shared_ptr<lldb_private::TypeSummaryOptions> TypeSummaryOptionsSP; typedef std::shared_ptr<lldb_private::ScriptedSyntheticChildren> ScriptedSyntheticChildrenSP; +typedef std::shared_ptr<lldb_private::SupportFile> SupportFileSP; typedef std::shared_ptr<lldb_private::UnixSignals> UnixSignalsSP; typedef std::weak_ptr<lldb_private::UnixSignals> UnixSignalsWP; typedef std::shared_ptr<lldb_private::UnwindAssembly> UnwindAssemblySP; diff --git a/contrib/llvm-project/lldb/source/API/SBTypeFilter.cpp b/contrib/llvm-project/lldb/source/API/SBTypeFilter.cpp index 8bbf3a8b526f..f1b5bc952b86 100644 --- a/contrib/llvm-project/lldb/source/API/SBTypeFilter.cpp +++ b/contrib/llvm-project/lldb/source/API/SBTypeFilter.cpp @@ -166,7 +166,7 @@ SBTypeFilter::SBTypeFilter(const lldb::TypeFilterImplSP &typefilter_impl_sp) bool SBTypeFilter::CopyOnWrite_Impl() { if (!IsValid()) return false; - if (m_opaque_sp.unique()) + if (m_opaque_sp.use_count() == 1) return true; TypeFilterImplSP new_sp(new TypeFilterImpl(GetOptions())); diff --git a/contrib/llvm-project/lldb/source/API/SBTypeFormat.cpp b/contrib/llvm-project/lldb/source/API/SBTypeFormat.cpp index 86e11e8b8fde..a0c37de2a73b 100644 --- a/contrib/llvm-project/lldb/source/API/SBTypeFormat.cpp +++ b/contrib/llvm-project/lldb/source/API/SBTypeFormat.cpp @@ -157,7 +157,7 @@ bool SBTypeFormat::CopyOnWrite_Impl(Type type) { if (!IsValid()) return false; - if (m_opaque_sp.unique() && + if (m_opaque_sp.use_count() == 1 && ((type == Type::eTypeKeepSame) || (type == Type::eTypeFormat && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeFormat) || diff --git a/contrib/llvm-project/lldb/source/API/SBTypeSummary.cpp b/contrib/llvm-project/lldb/source/API/SBTypeSummary.cpp index be43aeb48261..a5e87188c9f6 100644 --- a/contrib/llvm-project/lldb/source/API/SBTypeSummary.cpp +++ b/contrib/llvm-project/lldb/source/API/SBTypeSummary.cpp @@ -381,7 +381,7 @@ bool SBTypeSummary::CopyOnWrite_Impl() { if (!IsValid()) return false; - if (m_opaque_sp.unique()) + if (m_opaque_sp.use_count() == 1) return true; TypeSummaryImplSP new_sp; diff --git a/contrib/llvm-project/lldb/source/API/SBTypeSynthetic.cpp b/contrib/llvm-project/lldb/source/API/SBTypeSynthetic.cpp index e2441eea7e10..19a4c53bad6a 100644 --- a/contrib/llvm-project/lldb/source/API/SBTypeSynthetic.cpp +++ b/contrib/llvm-project/lldb/source/API/SBTypeSynthetic.cpp @@ -184,7 +184,7 @@ SBTypeSynthetic::SBTypeSynthetic( bool SBTypeSynthetic::CopyOnWrite_Impl() { if (!IsValid()) return false; - if (m_opaque_sp.unique()) + if (m_opaque_sp.use_count() == 1) return true; ScriptedSyntheticChildrenSP new_sp(new ScriptedSyntheticChildren( diff --git a/contrib/llvm-project/lldb/source/Breakpoint/Breakpoint.cpp b/contrib/llvm-project/lldb/source/Breakpoint/Breakpoint.cpp index 6e6b51b56249..af5dcc9cd88d 100644 --- a/contrib/llvm-project/lldb/source/Breakpoint/Breakpoint.cpp +++ b/contrib/llvm-project/lldb/source/Breakpoint/Breakpoint.cpp @@ -460,17 +460,13 @@ void Breakpoint::ResolveBreakpointInModules(ModuleList &module_list, // If this is not an internal breakpoint, set up to record the new // locations, then dispatch an event with the new locations. if (!IsInternal() && send_event) { - BreakpointEventData *new_locations_event = new BreakpointEventData( - eBreakpointEventTypeLocationsAdded, shared_from_this()); - + std::shared_ptr<BreakpointEventData> new_locations_event = + std::make_shared<BreakpointEventData>( + eBreakpointEventTypeLocationsAdded, shared_from_this()); ResolveBreakpointInModules( module_list, new_locations_event->GetBreakpointLocationCollection()); - - if (new_locations_event->GetBreakpointLocationCollection().GetSize() != - 0) { + if (new_locations_event->GetBreakpointLocationCollection().GetSize() != 0) SendBreakpointChangedEvent(new_locations_event); - } else - delete new_locations_event; } else { ElapsedTime elapsed(m_resolve_time); m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list); @@ -565,12 +561,10 @@ void Breakpoint::ModulesChanged(ModuleList &module_list, bool load, // the module list, then remove their breakpoint sites, and their locations // if asked to. - BreakpointEventData *removed_locations_event; + std::shared_ptr<BreakpointEventData> removed_locations_event; if (!IsInternal()) - removed_locations_event = new BreakpointEventData( + removed_locations_event = std::make_shared<BreakpointEventData>( eBreakpointEventTypeLocationsRemoved, shared_from_this()); - else - removed_locations_event = nullptr; for (ModuleSP module_sp : module_list.Modules()) { if (m_filter_sp->ModulePasses(module_sp)) { @@ -795,31 +789,30 @@ void Breakpoint::ModuleReplaced(ModuleSP old_module_sp, // about telling the world about removing a location we didn't tell them // about adding. - BreakpointEventData *locations_event; + std::shared_ptr<BreakpointEventData> removed_locations_event; if (!IsInternal()) - locations_event = new BreakpointEventData( + removed_locations_event = std::make_shared<BreakpointEventData>( eBreakpointEventTypeLocationsRemoved, shared_from_this()); - else - locations_event = nullptr; for (BreakpointLocationSP loc_sp : locations_to_remove.BreakpointLocations()) { m_locations.RemoveLocation(loc_sp); - if (locations_event) - locations_event->GetBreakpointLocationCollection().Add(loc_sp); + if (removed_locations_event) + removed_locations_event->GetBreakpointLocationCollection().Add(loc_sp); } - SendBreakpointChangedEvent(locations_event); + SendBreakpointChangedEvent(removed_locations_event); // And announce the new ones. if (!IsInternal()) { - locations_event = new BreakpointEventData( - eBreakpointEventTypeLocationsAdded, shared_from_this()); + std::shared_ptr<BreakpointEventData> added_locations_event = + std::make_shared<BreakpointEventData>( + eBreakpointEventTypeLocationsAdded, shared_from_this()); for (BreakpointLocationSP loc_sp : locations_to_announce.BreakpointLocations()) - locations_event->GetBreakpointLocationCollection().Add(loc_sp); + added_locations_event->GetBreakpointLocationCollection().Add(loc_sp); - SendBreakpointChangedEvent(locations_event); + SendBreakpointChangedEvent(added_locations_event); } m_locations.Compact(); } @@ -989,22 +982,22 @@ void Breakpoint::SendBreakpointChangedEvent( if (!m_being_created && !IsInternal() && GetTarget().EventTypeHasListeners( Target::eBroadcastBitBreakpointChanged)) { - BreakpointEventData *data = - new Breakpoint::BreakpointEventData(eventKind, shared_from_this()); + std::shared_ptr<BreakpointEventData> data = + std::make_shared<BreakpointEventData>(eventKind, shared_from_this()); GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged, data); } } -void Breakpoint::SendBreakpointChangedEvent(BreakpointEventData *data) { - if (data == nullptr) +void Breakpoint::SendBreakpointChangedEvent( + const lldb::EventDataSP &breakpoint_data_sp) { + if (!breakpoint_data_sp) return; if (!m_being_created && !IsInternal() && GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged)) - GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged, data); - else - delete data; + GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged, + breakpoint_data_sp); } const char *Breakpoint::BreakpointEventTypeAsCString(BreakpointEventType type) { diff --git a/contrib/llvm-project/lldb/source/Breakpoint/BreakpointIDList.cpp b/contrib/llvm-project/lldb/source/Breakpoint/BreakpointIDList.cpp index 05c461827cad..5ab2c9a8dc38 100644 --- a/contrib/llvm-project/lldb/source/Breakpoint/BreakpointIDList.cpp +++ b/contrib/llvm-project/lldb/source/Breakpoint/BreakpointIDList.cpp @@ -11,9 +11,9 @@ #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" -#include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Target.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/StreamString.h" using namespace lldb; using namespace lldb_private; @@ -48,15 +48,6 @@ bool BreakpointIDList::AddBreakpointID(BreakpointID bp_id) { // return true. } -bool BreakpointIDList::AddBreakpointID(const char *bp_id_str) { - auto bp_id = BreakpointID::ParseCanonicalReference(bp_id_str); - if (!bp_id) - return false; - - m_breakpoint_ids.push_back(*bp_id); - return true; -} - bool BreakpointIDList::FindBreakpointID(BreakpointID &bp_id, size_t *position) const { for (size_t i = 0; i < m_breakpoint_ids.size(); ++i) { @@ -93,12 +84,9 @@ bool BreakpointIDList::FindBreakpointID(const char *bp_id_str, // NEW_ARGS should be a copy of OLD_ARGS, with and ID range specifiers replaced // by the members of the range. -void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target, - bool allow_locations, - BreakpointName::Permissions - ::PermissionKinds purpose, - CommandReturnObject &result, - Args &new_args) { +llvm::Error BreakpointIDList::FindAndReplaceIDRanges( + Args &old_args, Target *target, bool allow_locations, + BreakpointName::Permissions ::PermissionKinds purpose, Args &new_args) { llvm::StringRef range_from; llvm::StringRef range_to; llvm::StringRef current_arg; @@ -109,11 +97,11 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target, current_arg = old_args[i].ref(); if (!allow_locations && current_arg.contains('.')) { - result.AppendErrorWithFormat( + new_args.Clear(); + return llvm::createStringError( + llvm::inconvertibleErrorCode(), "Breakpoint locations not allowed, saw location: %s.", current_arg.str().c_str()); - new_args.Clear(); - return; } Status error; @@ -125,8 +113,8 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target, } else if (BreakpointID::StringIsBreakpointName(current_arg, error)) { if (!error.Success()) { new_args.Clear(); - result.AppendError(error.AsCString()); - return; + return llvm::createStringError(llvm::inconvertibleErrorCode(), + error.AsCString()); } else names_found.insert(std::string(current_arg)); } else if ((i + 2 < old_args.size()) && @@ -152,9 +140,10 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target, breakpoint_sp = target->GetBreakpointByID(bp_id->GetBreakpointID()); if (!breakpoint_sp) { new_args.Clear(); - result.AppendErrorWithFormat("'%d' is not a valid breakpoint ID.\n", - bp_id->GetBreakpointID()); - return; + return llvm::createStringError( + llvm::inconvertibleErrorCode(), + "'%d' is not a valid breakpoint ID.\n", + bp_id->GetBreakpointID()); } const size_t num_locations = breakpoint_sp->GetNumLocations(); for (size_t j = 0; j < num_locations; ++j) { @@ -180,17 +169,17 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target, if (!start_bp || !target->GetBreakpointByID(start_bp->GetBreakpointID())) { new_args.Clear(); - result.AppendErrorWithFormat("'%s' is not a valid breakpoint ID.\n", - range_from.str().c_str()); - return; + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "'%s' is not a valid breakpoint ID.\n", + range_from.str().c_str()); } if (!end_bp || !target->GetBreakpointByID(end_bp->GetBreakpointID())) { new_args.Clear(); - result.AppendErrorWithFormat("'%s' is not a valid breakpoint ID.\n", - range_to.str().c_str()); - return; + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "'%s' is not a valid breakpoint ID.\n", + range_to.str().c_str()); } break_id_t start_bp_id = start_bp->GetBreakpointID(); break_id_t start_loc_id = start_bp->GetLocationID(); @@ -201,11 +190,11 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target, ((start_loc_id != LLDB_INVALID_BREAK_ID) && (end_loc_id == LLDB_INVALID_BREAK_ID))) { new_args.Clear(); - result.AppendError("Invalid breakpoint id range: Either " - "both ends of range must specify" - " a breakpoint location, or neither can " - "specify a breakpoint location."); - return; + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "Invalid breakpoint id range: Either " + "both ends of range must specify" + " a breakpoint location, or neither can " + "specify a breakpoint location."); } // We have valid range starting & ending breakpoint IDs. Go through all @@ -221,13 +210,13 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target, (end_loc_id != LLDB_INVALID_BREAK_ID)) { if (start_bp_id != end_bp_id) { new_args.Clear(); - result.AppendErrorWithFormat( + return llvm::createStringError( + llvm::inconvertibleErrorCode(), "Invalid range: Ranges that specify particular breakpoint " "locations" " must be within the same major breakpoint; you specified two" " different major breakpoints, %d and %d.\n", start_bp_id, end_bp_id); - return; } } @@ -302,8 +291,7 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target, } } } - - result.SetStatus(eReturnStatusSuccessFinishNoResult); + return llvm::Error::success(); } std::pair<llvm::StringRef, llvm::StringRef> diff --git a/contrib/llvm-project/lldb/source/Breakpoint/BreakpointList.cpp b/contrib/llvm-project/lldb/source/Breakpoint/BreakpointList.cpp index f7c2cdb938e6..2c47b3b1263c 100644 --- a/contrib/llvm-project/lldb/source/Breakpoint/BreakpointList.cpp +++ b/contrib/llvm-project/lldb/source/Breakpoint/BreakpointList.cpp @@ -17,9 +17,12 @@ using namespace lldb_private; static void NotifyChange(const BreakpointSP &bp, BreakpointEventType event) { Target &target = bp->GetTarget(); - if (target.EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged)) + if (target.EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged)) { + auto event_data_sp = + std::make_shared<Breakpoint::BreakpointEventData>(event, bp); target.BroadcastEvent(Target::eBroadcastBitBreakpointChanged, - new Breakpoint::BreakpointEventData(event, bp)); + event_data_sp); + } } BreakpointList::BreakpointList(bool is_internal) diff --git a/contrib/llvm-project/lldb/source/Breakpoint/BreakpointLocation.cpp b/contrib/llvm-project/lldb/source/Breakpoint/BreakpointLocation.cpp index 99f94d04bb31..98de059c2e29 100644 --- a/contrib/llvm-project/lldb/source/Breakpoint/BreakpointLocation.cpp +++ b/contrib/llvm-project/lldb/source/Breakpoint/BreakpointLocation.cpp @@ -649,11 +649,11 @@ void BreakpointLocation::SendBreakpointLocationChangedEvent( if (!m_being_created && !m_owner.IsInternal() && m_owner.GetTarget().EventTypeHasListeners( Target::eBroadcastBitBreakpointChanged)) { - Breakpoint::BreakpointEventData *data = new Breakpoint::BreakpointEventData( + auto data_sp = std::make_shared<Breakpoint::BreakpointEventData>( eventKind, m_owner.shared_from_this()); - data->GetBreakpointLocationCollection().Add(shared_from_this()); + data_sp->GetBreakpointLocationCollection().Add(shared_from_this()); m_owner.GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged, - data); + data_sp); } } diff --git a/contrib/llvm-project/lldb/source/Breakpoint/BreakpointResolver.cpp b/contrib/llvm-project/lldb/source/Breakpoint/BreakpointResolver.cpp index 89ea308b1eb0..bc6348716ef4 100644 --- a/contrib/llvm-project/lldb/source/Breakpoint/BreakpointResolver.cpp +++ b/contrib/llvm-project/lldb/source/Breakpoint/BreakpointResolver.cpp @@ -214,7 +214,8 @@ void BreakpointResolver::SetSCMatchesByLine( auto worklist_begin = std::partition( all_scs.begin(), all_scs.end(), [&](const SymbolContext &sc) { if (sc.line_entry.file == match.line_entry.file || - sc.line_entry.original_file == match.line_entry.original_file) { + *sc.line_entry.original_file_sp == + *match.line_entry.original_file_sp) { // When a match is found, keep track of the smallest line number. closest_line = std::min(closest_line, sc.line_entry.line); return false; diff --git a/contrib/llvm-project/lldb/source/Breakpoint/Watchpoint.cpp b/contrib/llvm-project/lldb/source/Breakpoint/Watchpoint.cpp index 4602ce4213b9..1a8ef87c1e67 100644 --- a/contrib/llvm-project/lldb/source/Breakpoint/Watchpoint.cpp +++ b/contrib/llvm-project/lldb/source/Breakpoint/Watchpoint.cpp @@ -462,26 +462,14 @@ const char *Watchpoint::GetConditionText() const { void Watchpoint::SendWatchpointChangedEvent( lldb::WatchpointEventType eventKind) { - if (!m_being_created && - GetTarget().EventTypeHasListeners( - Target::eBroadcastBitWatchpointChanged)) { - WatchpointEventData *data = - new Watchpoint::WatchpointEventData(eventKind, shared_from_this()); - GetTarget().BroadcastEvent(Target::eBroadcastBitWatchpointChanged, data); + if (!m_being_created && GetTarget().EventTypeHasListeners( + Target::eBroadcastBitWatchpointChanged)) { + auto data_sp = + std::make_shared<WatchpointEventData>(eventKind, shared_from_this()); + GetTarget().BroadcastEvent(Target::eBroadcastBitWatchpointChanged, data_sp); } } -void Watchpoint::SendWatchpointChangedEvent(WatchpointEventData *data) { - if (data == nullptr) - return; - - if (!m_being_created && - GetTarget().EventTypeHasListeners(Target::eBroadcastBitWatchpointChanged)) - GetTarget().BroadcastEvent(Target::eBroadcastBitWatchpointChanged, data); - else - delete data; -} - Watchpoint::WatchpointEventData::WatchpointEventData( WatchpointEventType sub_type, const WatchpointSP &new_watchpoint_sp) : m_watchpoint_event(sub_type), m_new_watchpoint_sp(new_watchpoint_sp) {} diff --git a/contrib/llvm-project/lldb/source/Breakpoint/WatchpointList.cpp b/contrib/llvm-project/lldb/source/Breakpoint/WatchpointList.cpp index fc0cc9126d60..f7564483e6f1 100644 --- a/contrib/llvm-project/lldb/source/Breakpoint/WatchpointList.cpp +++ b/contrib/llvm-project/lldb/source/Breakpoint/WatchpointList.cpp @@ -23,10 +23,12 @@ lldb::watch_id_t WatchpointList::Add(const WatchpointSP &wp_sp, bool notify) { m_watchpoints.push_back(wp_sp); if (notify) { if (wp_sp->GetTarget().EventTypeHasListeners( - Target::eBroadcastBitWatchpointChanged)) + Target::eBroadcastBitWatchpointChanged)) { + auto data_sp = std::make_shared<Watchpoint::WatchpointEventData>( + eWatchpointEventTypeAdded, wp_sp); wp_sp->GetTarget().BroadcastEvent(Target::eBroadcastBitWatchpointChanged, - new Watchpoint::WatchpointEventData( - eWatchpointEventTypeAdded, wp_sp)); + data_sp); + } } return wp_sp->GetID(); } @@ -171,11 +173,12 @@ bool WatchpointList::Remove(lldb::watch_id_t watch_id, bool notify) { WatchpointSP wp_sp = *pos; if (notify) { if (wp_sp->GetTarget().EventTypeHasListeners( - Target::eBroadcastBitWatchpointChanged)) + Target::eBroadcastBitWatchpointChanged)) { + auto data_sp = std::make_shared<Watchpoint::WatchpointEventData>( + eWatchpointEventTypeRemoved, wp_sp); wp_sp->GetTarget().BroadcastEvent( - Target::eBroadcastBitWatchpointChanged, - new Watchpoint::WatchpointEventData(eWatchpointEventTypeRemoved, - wp_sp)); + Target::eBroadcastBitWatchpointChanged, data_sp); + } } m_watchpoints.erase(pos); return true; @@ -234,10 +237,10 @@ void WatchpointList::RemoveAll(bool notify) { for (pos = m_watchpoints.begin(); pos != end; ++pos) { if ((*pos)->GetTarget().EventTypeHasListeners( Target::eBroadcastBitBreakpointChanged)) { + auto data_sp = std::make_shared<Watchpoint::WatchpointEventData>( + eWatchpointEventTypeRemoved, *pos); (*pos)->GetTarget().BroadcastEvent( - Target::eBroadcastBitWatchpointChanged, - new Watchpoint::WatchpointEventData(eWatchpointEventTypeRemoved, - *pos)); + Target::eBroadcastBitWatchpointChanged, data_sp); } } } diff --git a/contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp b/contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp index f9ba68eda3ff..1661d5d9b743 100644 --- a/contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/contrib/llvm-project/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -2488,8 +2488,12 @@ void CommandObjectMultiwordBreakpoint::VerifyIDs( // breakpoint ids in the range, and shove all of those breakpoint id strings // into TEMP_ARGS. - BreakpointIDList::FindAndReplaceIDRanges(args, target, allow_locations, - purpose, result, temp_args); + if (llvm::Error err = BreakpointIDList::FindAndReplaceIDRanges( + args, target, allow_locations, purpose, temp_args)) { + result.SetError(std::move(err)); + return; + } + result.SetStatus(eReturnStatusSuccessFinishNoResult); // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual // BreakpointIDList: @@ -2501,33 +2505,31 @@ void CommandObjectMultiwordBreakpoint::VerifyIDs( // At this point, all of the breakpoint ids that the user passed in have // been converted to breakpoint IDs and put into valid_ids. - if (result.Succeeded()) { - // Now that we've converted everything from args into a list of breakpoint - // ids, go through our tentative list of breakpoint id's and verify that - // they correspond to valid/currently set breakpoints. - - const size_t count = valid_ids->GetSize(); - for (size_t i = 0; i < count; ++i) { - BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex(i); - Breakpoint *breakpoint = - target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get(); - if (breakpoint != nullptr) { - const size_t num_locations = breakpoint->GetNumLocations(); - if (static_cast<size_t>(cur_bp_id.GetLocationID()) > num_locations) { - StreamString id_str; - BreakpointID::GetCanonicalReference( - &id_str, cur_bp_id.GetBreakpointID(), cur_bp_id.GetLocationID()); - i = valid_ids->GetSize() + 1; - result.AppendErrorWithFormat( - "'%s' is not a currently valid breakpoint/location id.\n", - id_str.GetData()); - } - } else { + // Now that we've converted everything from args into a list of breakpoint + // ids, go through our tentative list of breakpoint id's and verify that + // they correspond to valid/currently set breakpoints. + + const size_t count = valid_ids->GetSize(); + for (size_t i = 0; i < count; ++i) { + BreakpointID cur_bp_id = valid_ids->GetBreakpointIDAtIndex(i); + Breakpoint *breakpoint = + target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get(); + if (breakpoint != nullptr) { + const size_t num_locations = breakpoint->GetNumLocations(); + if (static_cast<size_t>(cur_bp_id.GetLocationID()) > num_locations) { + StreamString id_str; + BreakpointID::GetCanonicalReference( + &id_str, cur_bp_id.GetBreakpointID(), cur_bp_id.GetLocationID()); i = valid_ids->GetSize() + 1; result.AppendErrorWithFormat( - "'%d' is not a currently valid breakpoint ID.\n", - cur_bp_id.GetBreakpointID()); + "'%s' is not a currently valid breakpoint/location id.\n", + id_str.GetData()); } + } else { + i = valid_ids->GetSize() + 1; + result.AppendErrorWithFormat( + "'%d' is not a currently valid breakpoint ID.\n", + cur_bp_id.GetBreakpointID()); } } } diff --git a/contrib/llvm-project/lldb/source/Commands/CommandObjectFrame.cpp b/contrib/llvm-project/lldb/source/Commands/CommandObjectFrame.cpp index e7cb861c2b01..17a7e858b24e 100644 --- a/contrib/llvm-project/lldb/source/Commands/CommandObjectFrame.cpp +++ b/contrib/llvm-project/lldb/source/Commands/CommandObjectFrame.cpp @@ -494,6 +494,7 @@ protected: case eValueTypeVTableEntry: return false; } + llvm_unreachable("Unexpected scope value"); } /// Finds all the variables in `all_variables` whose name matches `regex`, diff --git a/contrib/llvm-project/lldb/source/Commands/CommandObjectSource.cpp b/contrib/llvm-project/lldb/source/Commands/CommandObjectSource.cpp index cabf6f0436f1..fde74f02aea6 100644 --- a/contrib/llvm-project/lldb/source/Commands/CommandObjectSource.cpp +++ b/contrib/llvm-project/lldb/source/Commands/CommandObjectSource.cpp @@ -747,13 +747,13 @@ protected: bool operator==(const SourceInfo &rhs) const { return function == rhs.function && - line_entry.original_file == rhs.line_entry.original_file && + *line_entry.original_file_sp == *rhs.line_entry.original_file_sp && line_entry.line == rhs.line_entry.line; } bool operator!=(const SourceInfo &rhs) const { return function != rhs.function || - line_entry.original_file != rhs.line_entry.original_file || + *line_entry.original_file_sp != *rhs.line_entry.original_file_sp || line_entry.line != rhs.line_entry.line; } diff --git a/contrib/llvm-project/lldb/source/Commands/CommandObjectTarget.cpp b/contrib/llvm-project/lldb/source/Commands/CommandObjectTarget.cpp index bc8bc51356c8..c3ecdb7700c2 100644 --- a/contrib/llvm-project/lldb/source/Commands/CommandObjectTarget.cpp +++ b/contrib/llvm-project/lldb/source/Commands/CommandObjectTarget.cpp @@ -53,6 +53,7 @@ #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/State.h" +#include "lldb/Utility/Stream.h" #include "lldb/Utility/StructuredData.h" #include "lldb/Utility/Timer.h" #include "lldb/lldb-enumerations.h" @@ -1531,9 +1532,10 @@ static void DumpOsoFilesTable(Stream &strm, }); } -static void DumpAddress(ExecutionContextScope *exe_scope, - const Address &so_addr, bool verbose, bool all_ranges, - Stream &strm, llvm::StringRef pattern = "") { +static void +DumpAddress(ExecutionContextScope *exe_scope, const Address &so_addr, + bool verbose, bool all_ranges, Stream &strm, + std::optional<Stream::HighlightSettings> settings = std::nullopt) { strm.IndentMore(); strm.Indent(" Address: "); so_addr.Dump(&strm, exe_scope, Address::DumpStyleModuleWithFileAddress); @@ -1544,13 +1546,13 @@ static void DumpAddress(ExecutionContextScope *exe_scope, const uint32_t save_indent = strm.GetIndentLevel(); strm.SetIndentLevel(save_indent + 13); so_addr.Dump(&strm, exe_scope, Address::DumpStyleResolvedDescription, - Address::DumpStyleInvalid, UINT32_MAX, false, pattern); + Address::DumpStyleInvalid, UINT32_MAX, false, settings); strm.SetIndentLevel(save_indent); // Print out detailed address information when verbose is enabled if (verbose) { strm.EOL(); so_addr.Dump(&strm, exe_scope, Address::DumpStyleDetailedSymbolContext, - Address::DumpStyleInvalid, UINT32_MAX, all_ranges, pattern); + Address::DumpStyleInvalid, UINT32_MAX, all_ranges, settings); } strm.IndentLess(); } @@ -1615,6 +1617,9 @@ static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter, DumpFullpath(strm, &module->GetFileSpec(), 0); strm.PutCString(":\n"); strm.IndentMore(); + Stream::HighlightSettings settings( + name, interpreter.GetDebugger().GetRegexMatchAnsiPrefix(), + interpreter.GetDebugger().GetRegexMatchAnsiSuffix()); for (uint32_t i = 0; i < num_matches; ++i) { Symbol *symbol = symtab->SymbolAtIndex(match_indexes[i]); if (symbol) { @@ -1622,18 +1627,18 @@ static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter, DumpAddress( interpreter.GetExecutionContext().GetBestExecutionContextScope(), symbol->GetAddressRef(), verbose, all_ranges, strm, - use_color && name_is_regex ? name : nullptr); + use_color && name_is_regex + ? std::optional<Stream::HighlightSettings>{settings} + : std::nullopt); strm.EOL(); } else { strm.IndentMore(); strm.Indent(" Name: "); - llvm::StringRef ansi_prefix = - interpreter.GetDebugger().GetRegexMatchAnsiPrefix(); - llvm::StringRef ansi_suffix = - interpreter.GetDebugger().GetRegexMatchAnsiSuffix(); strm.PutCStringColorHighlighted( symbol->GetDisplayName().GetStringRef(), - use_color ? name : nullptr, ansi_prefix, ansi_suffix); + use_color && name_is_regex + ? std::optional<Stream::HighlightSettings>{settings} + : std::nullopt); strm.EOL(); strm.Indent(" Value: "); strm.Printf("0x%16.16" PRIx64 "\n", symbol->GetRawValue()); @@ -1650,10 +1655,10 @@ static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter, return num_matches; } -static void DumpSymbolContextList(ExecutionContextScope *exe_scope, - Stream &strm, - const SymbolContextList &sc_list, - bool verbose, bool all_ranges) { +static void DumpSymbolContextList( + ExecutionContextScope *exe_scope, Stream &strm, + const SymbolContextList &sc_list, bool verbose, bool all_ranges, + std::optional<Stream::HighlightSettings> settings = std::nullopt) { strm.IndentMore(); bool first_module = true; for (const SymbolContext &sc : sc_list) { @@ -1664,7 +1669,8 @@ static void DumpSymbolContextList(ExecutionContextScope *exe_scope, sc.GetAddressRange(eSymbolContextEverything, 0, true, range); - DumpAddress(exe_scope, range.GetBaseAddress(), verbose, all_ranges, strm); + DumpAddress(exe_scope, range.GetBaseAddress(), verbose, all_ranges, strm, + settings); first_module = false; } strm.IndentLess(); diff --git a/contrib/llvm-project/lldb/source/Core/Address.cpp b/contrib/llvm-project/lldb/source/Core/Address.cpp index 19d34db44ea5..6f5c366ab38a 100644 --- a/contrib/llvm-project/lldb/source/Core/Address.cpp +++ b/contrib/llvm-project/lldb/source/Core/Address.cpp @@ -407,7 +407,8 @@ bool Address::GetDescription(Stream &s, Target &target, bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style, uint32_t addr_size, - bool all_ranges, llvm::StringRef pattern) const { + bool all_ranges, + std::optional<Stream::HighlightSettings> settings) const { // If the section was nullptr, only load address is going to work unless we // are trying to deref a pointer SectionSP section_sp(GetSection()); @@ -516,16 +517,7 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, if (symbol) { const char *symbol_name = symbol->GetName().AsCString(); if (symbol_name) { - llvm::StringRef ansi_prefix; - llvm::StringRef ansi_suffix; - if (target) { - ansi_prefix = - target->GetDebugger().GetRegexMatchAnsiPrefix(); - ansi_suffix = - target->GetDebugger().GetRegexMatchAnsiSuffix(); - } - s->PutCStringColorHighlighted(symbol_name, pattern, - ansi_prefix, ansi_suffix); + s->PutCStringColorHighlighted(symbol_name, settings); addr_t delta = file_Addr - symbol->GetAddressRef().GetFileAddress(); if (delta) @@ -653,7 +645,7 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, pointer_sc.symbol != nullptr) { s->PutCString(": "); pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false, - false, true, true, pattern); + false, true, true, settings); } } } @@ -693,13 +685,13 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, sc.DumpStopContext(s, exe_scope, *this, show_fullpaths, show_module, show_inlined_frames, show_function_arguments, show_function_name, - pattern); + settings); } else { // We found a symbol but it was in a different section so it // isn't the symbol we should be showing, just show the section // name + offset Dump(s, exe_scope, DumpStyleSectionNameOffset, DumpStyleInvalid, - UINT32_MAX, false, pattern); + UINT32_MAX, false, settings); } } } @@ -707,7 +699,7 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, } else { if (fallback_style != DumpStyleInvalid) return Dump(s, exe_scope, fallback_style, DumpStyleInvalid, addr_size, - false, pattern); + false, settings); return false; } break; @@ -728,7 +720,7 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, sc.symbol->GetAddressRef().GetSection() != GetSection()) sc.symbol = nullptr; } - sc.GetDescription(s, eDescriptionLevelBrief, target, pattern); + sc.GetDescription(s, eDescriptionLevelBrief, target, settings); if (sc.block) { bool can_create = true; @@ -777,7 +769,7 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, } else { if (fallback_style != DumpStyleInvalid) return Dump(s, exe_scope, fallback_style, DumpStyleInvalid, addr_size, - false, pattern); + false, settings); return false; } break; diff --git a/contrib/llvm-project/lldb/source/Core/Disassembler.cpp b/contrib/llvm-project/lldb/source/Core/Disassembler.cpp index 166b5fdf22f0..7b07fcb26813 100644 --- a/contrib/llvm-project/lldb/source/Core/Disassembler.cpp +++ b/contrib/llvm-project/lldb/source/Core/Disassembler.cpp @@ -202,7 +202,7 @@ Disassembler::GetFunctionDeclLineEntry(const SymbolContext &sc) { sc.function->GetStartLineSourceInfo(func_decl_file, func_decl_line); if (func_decl_file != prologue_end_line.file && - func_decl_file != prologue_end_line.original_file) + func_decl_file != prologue_end_line.original_file_sp->GetSpecOnly()) return {}; SourceLine decl_line; @@ -407,7 +407,8 @@ void Disassembler::PrintInstructions(Debugger &debugger, const ArchSpec &arch, sc.function->GetStartLineSourceInfo(func_decl_file, func_decl_line); if (func_decl_file == prologue_end_line.file || - func_decl_file == prologue_end_line.original_file) { + func_decl_file == + prologue_end_line.original_file_sp->GetSpecOnly()) { // Add all the lines between the function declaration and // the first non-prologue source line to the list of lines // to print. diff --git a/contrib/llvm-project/lldb/source/Core/FormatEntity.cpp b/contrib/llvm-project/lldb/source/Core/FormatEntity.cpp index 94986457552d..3c665c2eb213 100644 --- a/contrib/llvm-project/lldb/source/Core/FormatEntity.cpp +++ b/contrib/llvm-project/lldb/source/Core/FormatEntity.cpp @@ -1093,6 +1093,19 @@ static void PrettyPrintFunctionNameWithArgs(Stream &out_stream, out_stream.PutChar(')'); } +static void FormatInlinedBlock(Stream &out_stream, Block *block) { + if (!block) + return; + Block *inline_block = block->GetContainingInlinedBlock(); + if (inline_block) { + if (const InlineFunctionInfo *inline_info = + inline_block->GetInlinedFunctionInfo()) { + out_stream.PutCString(" [inlined] "); + inline_info->GetName().Dump(&out_stream); + } + } +} + bool FormatEntity::FormatStringRef(const llvm::StringRef &format_str, Stream &s, const SymbolContext *sc, const ExecutionContext *exe_ctx, @@ -1592,18 +1605,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, if (name) { s.PutCString(name); - - if (sc->block) { - Block *inline_block = sc->block->GetContainingInlinedBlock(); - if (inline_block) { - const InlineFunctionInfo *inline_info = - sc->block->GetInlinedFunctionInfo(); - if (inline_info) { - s.PutCString(" [inlined] "); - inline_info->GetName().Dump(&s); - } - } - } + FormatInlinedBlock(s, sc->block); return true; } } @@ -1638,6 +1640,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, name = sc->symbol->GetNameNoArguments(); if (name) { s.PutCString(name.GetCString()); + FormatInlinedBlock(s, sc->block); return true; } } @@ -1678,7 +1681,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, if (inline_block) { get_function_vars = false; - inline_info = sc->block->GetInlinedFunctionInfo(); + inline_info = inline_block->GetInlinedFunctionInfo(); if (inline_info) variable_list_sp = inline_block->GetBlockVariableList(true); } @@ -1733,14 +1736,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, if (!name) return false; s.PutCString(name); - - if (sc->block && sc->block->GetContainingInlinedBlock()) { - if (const InlineFunctionInfo *inline_info = - sc->block->GetInlinedFunctionInfo()) { - s.PutCString(" [inlined] "); - inline_info->GetName().Dump(&s); - } - } + FormatInlinedBlock(s, sc->block); return true; } case Entry::Type::FunctionAddrOffset: diff --git a/contrib/llvm-project/lldb/source/Core/Module.cpp b/contrib/llvm-project/lldb/source/Core/Module.cpp index 331cf3246641..8ffa35518b3c 100644 --- a/contrib/llvm-project/lldb/source/Core/Module.cpp +++ b/contrib/llvm-project/lldb/source/Core/Module.cpp @@ -971,14 +971,14 @@ void Module::FindTypes(const TypeQuery &query, TypeResults &results) { symbols->FindTypes(query, results); } -static Debugger::DebuggerList +static Debugger::DebuggerList DebuggersOwningModuleRequestingInterruption(Module &module) { - Debugger::DebuggerList requestors - = Debugger::DebuggersRequestingInterruption(); + Debugger::DebuggerList requestors = + Debugger::DebuggersRequestingInterruption(); Debugger::DebuggerList interruptors; if (requestors.empty()) return interruptors; - + for (auto debugger_sp : requestors) { if (!debugger_sp->InterruptRequested()) continue; @@ -993,12 +993,12 @@ SymbolFile *Module::GetSymbolFile(bool can_create, Stream *feedback_strm) { if (!m_did_load_symfile.load()) { std::lock_guard<std::recursive_mutex> guard(m_mutex); if (!m_did_load_symfile.load() && can_create) { - Debugger::DebuggerList interruptors - = DebuggersOwningModuleRequestingInterruption(*this); + Debugger::DebuggerList interruptors = + DebuggersOwningModuleRequestingInterruption(*this); if (!interruptors.empty()) { for (auto debugger_sp : interruptors) { - REPORT_INTERRUPTION(*(debugger_sp.get()), - "Interrupted fetching symbols for module {0}", + REPORT_INTERRUPTION(*(debugger_sp.get()), + "Interrupted fetching symbols for module {0}", this->GetFileSpec()); } return nullptr; diff --git a/contrib/llvm-project/lldb/source/Core/ModuleList.cpp b/contrib/llvm-project/lldb/source/Core/ModuleList.cpp index 2180f29f3694..b7f393636ba2 100644 --- a/contrib/llvm-project/lldb/source/Core/ModuleList.cpp +++ b/contrib/llvm-project/lldb/source/Core/ModuleList.cpp @@ -211,7 +211,29 @@ ModuleList::~ModuleList() = default; void ModuleList::AppendImpl(const ModuleSP &module_sp, bool use_notifier) { if (module_sp) { std::lock_guard<std::recursive_mutex> guard(m_modules_mutex); - m_modules.push_back(module_sp); + // We are required to keep the first element of the Module List as the + // executable module. So check here and if the first module is NOT an + // but the new one is, we insert this module at the beginning, rather than + // at the end. + // We don't need to do any of this if the list is empty: + if (m_modules.empty()) { + m_modules.push_back(module_sp); + } else { + // Since producing the ObjectFile may take some work, first check the 0th + // element, and only if that's NOT an executable look at the incoming + // ObjectFile. That way in the normal case we only look at the element + // 0 ObjectFile. + const bool elem_zero_is_executable + = m_modules[0]->GetObjectFile()->GetType() + == ObjectFile::Type::eTypeExecutable; + lldb_private::ObjectFile *obj = module_sp->GetObjectFile(); + if (!elem_zero_is_executable && obj + && obj->GetType() == ObjectFile::Type::eTypeExecutable) { + m_modules.insert(m_modules.begin(), module_sp); + } else { + m_modules.push_back(module_sp); + } + } if (use_notifier && m_notifier) m_notifier->NotifyModuleAdded(*this, module_sp); } @@ -324,7 +346,7 @@ bool ModuleList::RemoveIfOrphaned(const Module *module_ptr) { collection::iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { if (pos->get() == module_ptr) { - if (pos->unique()) { + if (pos->use_count() == 1) { pos = RemoveImpl(pos); return true; } else @@ -355,7 +377,7 @@ size_t ModuleList::RemoveOrphans(bool mandatory) { made_progress = false; collection::iterator pos = m_modules.begin(); while (pos != m_modules.end()) { - if (pos->unique()) { + if (pos->use_count() == 1) { pos = RemoveImpl(pos); ++remove_count; // We did make progress. diff --git a/contrib/llvm-project/lldb/source/Core/Progress.cpp b/contrib/llvm-project/lldb/source/Core/Progress.cpp index ea3f874916a9..355d6952e53c 100644 --- a/contrib/llvm-project/lldb/source/Core/Progress.cpp +++ b/contrib/llvm-project/lldb/source/Core/Progress.cpp @@ -11,15 +11,22 @@ #include "lldb/Core/Debugger.h" #include "lldb/Utility/StreamString.h" +#include <optional> + using namespace lldb; using namespace lldb_private; std::atomic<uint64_t> Progress::g_id(0); -Progress::Progress(std::string title, uint64_t total, +Progress::Progress(std::string title, std::string details, + std::optional<uint64_t> total, lldb_private::Debugger *debugger) - : m_title(title), m_id(++g_id), m_completed(0), m_total(total) { - assert(total > 0); + : m_title(title), m_details(details), m_id(++g_id), m_completed(0), + m_total(1) { + assert(total == std::nullopt || total > 0); + if (total) + m_total = *total; + if (debugger) m_debugger_id = debugger->GetID(); std::lock_guard<std::mutex> guard(m_mutex); @@ -35,25 +42,28 @@ Progress::~Progress() { ReportProgress(); } -void Progress::Increment(uint64_t amount, std::string update) { +void Progress::Increment(uint64_t amount, + std::optional<std::string> updated_detail) { if (amount > 0) { std::lock_guard<std::mutex> guard(m_mutex); + if (updated_detail) + m_details = std::move(updated_detail.value()); // Watch out for unsigned overflow and make sure we don't increment too // much and exceed m_total. - if (amount > (m_total - m_completed)) + if (m_total && (amount > (m_total - m_completed))) m_completed = m_total; else m_completed += amount; - ReportProgress(update); + ReportProgress(); } } -void Progress::ReportProgress(std::string update) { +void Progress::ReportProgress() { if (!m_complete) { // Make sure we only send one notification that indicates the progress is - // complete. + // complete m_complete = m_completed == m_total; - Debugger::ReportProgress(m_id, m_title, std::move(update), m_completed, - m_total, m_debugger_id); + Debugger::ReportProgress(m_id, m_title, m_details, m_completed, m_total, + m_debugger_id); } } diff --git a/contrib/llvm-project/lldb/source/Core/ValueObject.cpp b/contrib/llvm-project/lldb/source/Core/ValueObject.cpp index b2a6d9412ab4..d58bf2ca763d 100644 --- a/contrib/llvm-project/lldb/source/Core/ValueObject.cpp +++ b/contrib/llvm-project/lldb/source/Core/ValueObject.cpp @@ -813,8 +813,7 @@ static bool CopyStringDataToBufferSP(const StreamString &source, std::pair<size_t, bool> ValueObject::ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, - Status &error, uint32_t max_length, - bool honor_array, Format item_format) { + Status &error, bool honor_array) { bool was_capped = false; StreamString s; ExecutionContext exe_ctx(GetExecutionContextRef()); @@ -827,8 +826,7 @@ ValueObject::ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, return {0, was_capped}; } - if (max_length == 0) - max_length = target->GetMaximumSizeOfStringSummary(); + const auto max_length = target->GetMaximumSizeOfStringSummary(); size_t bytes_read = 0; size_t total_bytes_read = 0; @@ -1149,9 +1147,10 @@ bool ValueObject::DumpPrintableRepresentation( { Status error; lldb::WritableDataBufferSP buffer_sp; - std::pair<size_t, bool> read_string = ReadPointedString( - buffer_sp, error, 0, (custom_format == eFormatVectorOfChar) || - (custom_format == eFormatCharArray)); + std::pair<size_t, bool> read_string = + ReadPointedString(buffer_sp, error, + (custom_format == eFormatVectorOfChar) || + (custom_format == eFormatCharArray)); lldb_private::formatters::StringPrinter:: ReadBufferAndDumpToStreamOptions options(*this); options.SetData(DataExtractor( @@ -1583,62 +1582,64 @@ bool ValueObject::IsUninitializedReference() { ValueObjectSP ValueObject::GetSyntheticArrayMember(size_t index, bool can_create) { - ValueObjectSP synthetic_child_sp; - if (IsPointerType() || IsArrayType()) { - std::string index_str = llvm::formatv("[{0}]", index); - ConstString index_const_str(index_str); - // Check if we have already created a synthetic array member in this valid - // object. If we have we will re-use it. - synthetic_child_sp = GetSyntheticChild(index_const_str); - if (!synthetic_child_sp) { - ValueObject *synthetic_child; - // We haven't made a synthetic array member for INDEX yet, so lets make - // one and cache it for any future reference. - synthetic_child = CreateChildAtIndex(0, true, index); - - // Cache the value if we got one back... - if (synthetic_child) { - AddSyntheticChild(index_const_str, synthetic_child); - synthetic_child_sp = synthetic_child->GetSP(); - synthetic_child_sp->SetName(ConstString(index_str)); - synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true; - } - } - } + if (!IsPointerType() && !IsArrayType()) + return ValueObjectSP(); + + std::string index_str = llvm::formatv("[{0}]", index); + ConstString index_const_str(index_str); + // Check if we have already created a synthetic array member in this valid + // object. If we have we will re-use it. + if (auto existing_synthetic_child = GetSyntheticChild(index_const_str)) + return existing_synthetic_child; + + // We haven't made a synthetic array member for INDEX yet, so lets make + // one and cache it for any future reference. + ValueObject *synthetic_child = CreateChildAtIndex(0, true, index); + + if (!synthetic_child) + return ValueObjectSP(); + + // Cache the synthetic child's value because it's valid. + AddSyntheticChild(index_const_str, synthetic_child); + auto synthetic_child_sp = synthetic_child->GetSP(); + synthetic_child_sp->SetName(ConstString(index_str)); + synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true; return synthetic_child_sp; } ValueObjectSP ValueObject::GetSyntheticBitFieldChild(uint32_t from, uint32_t to, bool can_create) { - ValueObjectSP synthetic_child_sp; - if (IsScalarType()) { - std::string index_str = llvm::formatv("[{0}-{1}]", from, to); - ConstString index_const_str(index_str); - // Check if we have already created a synthetic array member in this valid - // object. If we have we will re-use it. - synthetic_child_sp = GetSyntheticChild(index_const_str); - if (!synthetic_child_sp) { - uint32_t bit_field_size = to - from + 1; - uint32_t bit_field_offset = from; - if (GetDataExtractor().GetByteOrder() == eByteOrderBig) - bit_field_offset = - GetByteSize().value_or(0) * 8 - bit_field_size - bit_field_offset; - // We haven't made a synthetic array member for INDEX yet, so lets make - // one and cache it for any future reference. - ValueObjectChild *synthetic_child = new ValueObjectChild( - *this, GetCompilerType(), index_const_str, GetByteSize().value_or(0), - 0, bit_field_size, bit_field_offset, false, false, - eAddressTypeInvalid, 0); - - // Cache the value if we got one back... - if (synthetic_child) { - AddSyntheticChild(index_const_str, synthetic_child); - synthetic_child_sp = synthetic_child->GetSP(); - synthetic_child_sp->SetName(ConstString(index_str)); - synthetic_child_sp->m_flags.m_is_bitfield_for_scalar = true; - } - } - } + if (!IsScalarType()) + return ValueObjectSP(); + + std::string index_str = llvm::formatv("[{0}-{1}]", from, to); + ConstString index_const_str(index_str); + + // Check if we have already created a synthetic array member in this valid + // object. If we have we will re-use it. + if (auto existing_synthetic_child = GetSyntheticChild(index_const_str)) + return existing_synthetic_child; + + uint32_t bit_field_size = to - from + 1; + uint32_t bit_field_offset = from; + if (GetDataExtractor().GetByteOrder() == eByteOrderBig) + bit_field_offset = + GetByteSize().value_or(0) * 8 - bit_field_size - bit_field_offset; + + // We haven't made a synthetic array member for INDEX yet, so lets make + // one and cache it for any future reference. + ValueObjectChild *synthetic_child = new ValueObjectChild( + *this, GetCompilerType(), index_const_str, GetByteSize().value_or(0), 0, + bit_field_size, bit_field_offset, false, false, eAddressTypeInvalid, 0); + + if (!synthetic_child) + return ValueObjectSP(); + + // Cache the synthetic child's value because it's valid. + AddSyntheticChild(index_const_str, synthetic_child); + auto synthetic_child_sp = synthetic_child->GetSP(); + synthetic_child_sp->SetName(ConstString(index_str)); + synthetic_child_sp->m_flags.m_is_bitfield_for_scalar = true; return synthetic_child_sp; } @@ -1648,9 +1649,8 @@ ValueObjectSP ValueObject::GetSyntheticChildAtOffset( ValueObjectSP synthetic_child_sp; - if (name_const_str.IsEmpty()) { + if (name_const_str.IsEmpty()) name_const_str.SetString("@" + std::to_string(offset)); - } // Check if we have already created a synthetic array member in this valid // object. If we have we will re-use it. @@ -1660,13 +1660,13 @@ ValueObjectSP ValueObject::GetSyntheticChildAtOffset( return synthetic_child_sp; if (!can_create) - return {}; + return ValueObjectSP(); ExecutionContext exe_ctx(GetExecutionContextRef()); std::optional<uint64_t> size = type.GetByteSize(exe_ctx.GetBestExecutionContextScope()); if (!size) - return {}; + return ValueObjectSP(); ValueObjectChild *synthetic_child = new ValueObjectChild(*this, type, name_const_str, *size, offset, 0, 0, false, false, eAddressTypeInvalid, 0); @@ -1700,7 +1700,7 @@ ValueObjectSP ValueObject::GetSyntheticBase(uint32_t offset, return synthetic_child_sp; if (!can_create) - return {}; + return ValueObjectSP(); const bool is_base_class = true; @@ -1708,7 +1708,7 @@ ValueObjectSP ValueObject::GetSyntheticBase(uint32_t offset, std::optional<uint64_t> size = type.GetByteSize(exe_ctx.GetBestExecutionContextScope()); if (!size) - return {}; + return ValueObjectSP(); ValueObjectChild *synthetic_child = new ValueObjectChild(*this, type, name_const_str, *size, offset, 0, 0, is_base_class, false, eAddressTypeInvalid, 0); @@ -1737,30 +1737,30 @@ static const char *SkipLeadingExpressionPathSeparators(const char *expression) { ValueObjectSP ValueObject::GetSyntheticExpressionPathChild(const char *expression, bool can_create) { - ValueObjectSP synthetic_child_sp; ConstString name_const_string(expression); // Check if we have already created a synthetic array member in this valid // object. If we have we will re-use it. - synthetic_child_sp = GetSyntheticChild(name_const_string); - if (!synthetic_child_sp) { - // We haven't made a synthetic array member for expression yet, so lets - // make one and cache it for any future reference. - synthetic_child_sp = GetValueForExpressionPath( - expression, nullptr, nullptr, - GetValueForExpressionPathOptions().SetSyntheticChildrenTraversal( - GetValueForExpressionPathOptions::SyntheticChildrenTraversal:: - None)); - - // Cache the value if we got one back... - if (synthetic_child_sp.get()) { - // FIXME: this causes a "real" child to end up with its name changed to - // the contents of expression - AddSyntheticChild(name_const_string, synthetic_child_sp.get()); - synthetic_child_sp->SetName( - ConstString(SkipLeadingExpressionPathSeparators(expression))); - } - } - return synthetic_child_sp; + if (auto existing_synthetic_child = GetSyntheticChild(name_const_string)) + return existing_synthetic_child; + + // We haven't made a synthetic array member for expression yet, so lets + // make one and cache it for any future reference. + auto path_options = GetValueForExpressionPathOptions(); + path_options.SetSyntheticChildrenTraversal( + GetValueForExpressionPathOptions::SyntheticChildrenTraversal::None); + auto synthetic_child = + GetValueForExpressionPath(expression, nullptr, nullptr, path_options); + + if (!synthetic_child) + return ValueObjectSP(); + + // Cache the synthetic child's value because it's valid. + // FIXME: this causes a "real" child to end up with its name changed to + // the contents of expression + AddSyntheticChild(name_const_string, synthetic_child.get()); + synthetic_child->SetName( + ConstString(SkipLeadingExpressionPathSeparators(expression))); + return synthetic_child; } void ValueObject::CalculateSyntheticValue() { @@ -1957,66 +1957,55 @@ ValueObjectSP ValueObject::GetValueForExpressionPath( const GetValueForExpressionPathOptions &options, ExpressionPathAftermath *final_task_on_target) { - ExpressionPathScanEndReason dummy_reason_to_stop = - ValueObject::eExpressionPathScanEndReasonUnknown; - ExpressionPathEndResultType dummy_final_value_type = - ValueObject::eExpressionPathEndResultTypeInvalid; - ExpressionPathAftermath dummy_final_task_on_target = - ValueObject::eExpressionPathAftermathNothing; - - ValueObjectSP ret_val = GetValueForExpressionPath_Impl( - expression, reason_to_stop ? reason_to_stop : &dummy_reason_to_stop, - final_value_type ? final_value_type : &dummy_final_value_type, options, - final_task_on_target ? final_task_on_target - : &dummy_final_task_on_target); - - if (!final_task_on_target || - *final_task_on_target == ValueObject::eExpressionPathAftermathNothing) - return ret_val; - - if (ret_val.get() && - ((final_value_type ? *final_value_type : dummy_final_value_type) == - eExpressionPathEndResultTypePlain)) // I can only deref and takeaddress - // of plain objects - { - if ((final_task_on_target ? *final_task_on_target - : dummy_final_task_on_target) == - ValueObject::eExpressionPathAftermathDereference) { - Status error; - ValueObjectSP final_value = ret_val->Dereference(error); - if (error.Fail() || !final_value.get()) { - if (reason_to_stop) - *reason_to_stop = - ValueObject::eExpressionPathScanEndReasonDereferencingFailed; - if (final_value_type) - *final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid; - return ValueObjectSP(); - } else { - if (final_task_on_target) - *final_task_on_target = ValueObject::eExpressionPathAftermathNothing; - return final_value; - } - } - if (*final_task_on_target == - ValueObject::eExpressionPathAftermathTakeAddress) { - Status error; - ValueObjectSP final_value = ret_val->AddressOf(error); - if (error.Fail() || !final_value.get()) { - if (reason_to_stop) - *reason_to_stop = - ValueObject::eExpressionPathScanEndReasonTakingAddressFailed; - if (final_value_type) - *final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid; - return ValueObjectSP(); - } else { - if (final_task_on_target) - *final_task_on_target = ValueObject::eExpressionPathAftermathNothing; - return final_value; - } - } + auto dummy_stop_reason = eExpressionPathScanEndReasonUnknown; + auto dummy_value_type = eExpressionPathEndResultTypeInvalid; + auto dummy_final_task = eExpressionPathAftermathNothing; + + auto proxy_stop_reason = reason_to_stop ? reason_to_stop : &dummy_stop_reason; + auto proxy_value_type = + final_value_type ? final_value_type : &dummy_value_type; + auto proxy_final_task = + final_task_on_target ? final_task_on_target : &dummy_final_task; + + auto ret_value = GetValueForExpressionPath_Impl(expression, proxy_stop_reason, + proxy_value_type, options, + proxy_final_task); + + // The caller knows nothing happened if `final_task_on_target` doesn't change. + if (!ret_value || (*proxy_value_type) != eExpressionPathEndResultTypePlain || + !final_task_on_target) + return ValueObjectSP(); + + ExpressionPathAftermath &final_task_on_target_ref = (*final_task_on_target); + ExpressionPathScanEndReason stop_reason_for_error; + Status error; + // The method can only dereference and take the address of plain objects. + switch (final_task_on_target_ref) { + case eExpressionPathAftermathNothing: + return ret_value; + + case eExpressionPathAftermathDereference: + ret_value = ret_value->Dereference(error); + stop_reason_for_error = eExpressionPathScanEndReasonDereferencingFailed; + break; + + case eExpressionPathAftermathTakeAddress: + ret_value = ret_value->AddressOf(error); + stop_reason_for_error = eExpressionPathScanEndReasonTakingAddressFailed; + break; + } + + if (ret_value && error.Success()) { + final_task_on_target_ref = eExpressionPathAftermathNothing; + return ret_value; } - return ret_val; // final_task_on_target will still have its original value, so - // you know I did not do it + + if (reason_to_stop) + *reason_to_stop = stop_reason_for_error; + + if (final_value_type) + *final_value_type = eExpressionPathEndResultTypeInvalid; + return ValueObjectSP(); } ValueObjectSP ValueObject::GetValueForExpressionPath_Impl( @@ -2687,39 +2676,47 @@ ValueObjectSP ValueObject::AddressOf(Status &error) { const bool scalar_is_load_address = false; addr_t addr = GetAddressOf(scalar_is_load_address, &address_type); error.Clear(); - if (addr != LLDB_INVALID_ADDRESS && address_type != eAddressTypeHost) { - switch (address_type) { - case eAddressTypeInvalid: { - StreamString expr_path_strm; - GetExpressionPath(expr_path_strm); - error.SetErrorStringWithFormat("'%s' is not in memory", - expr_path_strm.GetData()); - } break; - case eAddressTypeFile: - case eAddressTypeLoad: { - CompilerType compiler_type = GetCompilerType(); - if (compiler_type) { - std::string name(1, '&'); - name.append(m_name.AsCString("")); - ExecutionContext exe_ctx(GetExecutionContextRef()); - m_addr_of_valobj_sp = ValueObjectConstResult::Create( - exe_ctx.GetBestExecutionContextScope(), - compiler_type.GetPointerType(), ConstString(name.c_str()), addr, - eAddressTypeInvalid, m_data.GetAddressByteSize()); - } - } break; - default: - break; - } - } else { - StreamString expr_path_strm; - GetExpressionPath(expr_path_strm); + StreamString expr_path_strm; + GetExpressionPath(expr_path_strm); + const char *expr_path_str = expr_path_strm.GetData(); + + ExecutionContext exe_ctx(GetExecutionContextRef()); + auto scope = exe_ctx.GetBestExecutionContextScope(); + + if (addr == LLDB_INVALID_ADDRESS) { error.SetErrorStringWithFormat("'%s' doesn't have a valid address", - expr_path_strm.GetData()); + expr_path_str); + return ValueObjectSP(); } - return m_addr_of_valobj_sp; + switch (address_type) { + case eAddressTypeInvalid: + error.SetErrorStringWithFormat("'%s' is not in memory", expr_path_str); + return ValueObjectSP(); + + case eAddressTypeHost: + error.SetErrorStringWithFormat("'%s' is in host process (LLDB) memory", + expr_path_str); + return ValueObjectSP(); + + case eAddressTypeFile: + case eAddressTypeLoad: { + CompilerType compiler_type = GetCompilerType(); + if (!compiler_type) { + error.SetErrorStringWithFormat("'%s' doesn't have a compiler type", + expr_path_str); + return ValueObjectSP(); + } + + std::string name(1, '&'); + name.append(m_name.AsCString("")); + m_addr_of_valobj_sp = ValueObjectConstResult::Create( + scope, compiler_type.GetPointerType(), ConstString(name.c_str()), addr, + eAddressTypeInvalid, m_data.GetAddressByteSize()); + return m_addr_of_valobj_sp; + } + } } ValueObjectSP ValueObject::DoCast(const CompilerType &compiler_type) { diff --git a/contrib/llvm-project/lldb/source/Expression/DiagnosticManager.cpp b/contrib/llvm-project/lldb/source/Expression/DiagnosticManager.cpp index 08977066e333..9a1100df78db 100644 --- a/contrib/llvm-project/lldb/source/Expression/DiagnosticManager.cpp +++ b/contrib/llvm-project/lldb/source/Expression/DiagnosticManager.cpp @@ -46,11 +46,20 @@ static const char *StringForSeverity(DiagnosticSeverity severity) { std::string DiagnosticManager::GetString(char separator) { std::string ret; + llvm::raw_string_ostream stream(ret); for (const auto &diagnostic : Diagnostics()) { - ret.append(StringForSeverity(diagnostic->GetSeverity())); - ret.append(std::string(diagnostic->GetMessage())); - ret.push_back(separator); + llvm::StringRef severity = StringForSeverity(diagnostic->GetSeverity()); + stream << severity; + + llvm::StringRef message = diagnostic->GetMessage(); + std::string searchable_message = message.lower(); + auto severity_pos = message.find(severity); + stream << message.take_front(severity_pos); + + if (severity_pos != llvm::StringRef::npos) + stream << message.drop_front(severity_pos + severity.size()); + stream << separator; } return ret; diff --git a/contrib/llvm-project/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/contrib/llvm-project/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp index ff5c79aa2455..b652ede9b1f5 100644 --- a/contrib/llvm-project/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp @@ -830,6 +830,7 @@ uint32_t EmulateInstructionARM::GetFramePointerRegisterNumber() const { case llvm::Triple::IOS: case llvm::Triple::TvOS: case llvm::Triple::WatchOS: + case llvm::Triple::XROS: // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS: is_apple = true; break; diff --git a/contrib/llvm-project/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/contrib/llvm-project/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index c6937ebca319..f0fe6c9e06d9 100644 --- a/contrib/llvm-project/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -1032,6 +1032,31 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { TypeSummaryImplSP(new StringSummaryFormat( eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__rep_} s"))); + // Chrono time point types + + AddCXXSummary(cpp_category_sp, + lldb_private::formatters::LibcxxChronoSysSecondsSummaryProvider, + "libc++ std::chrono::sys_seconds summary provider", + "^std::__[[:alnum:]]+::chrono::time_point<" + "std::__[[:alnum:]]+::chrono::system_clock, " + "std::__[[:alnum:]]+::chrono::duration<long long, " + "std::__[[:alnum:]]+::ratio<1, 1> " + "> >$", + eTypeOptionHideChildren | eTypeOptionHideValue | + eTypeOptionCascade, + true); + AddCXXSummary(cpp_category_sp, + lldb_private::formatters::LibcxxChronoSysDaysSummaryProvider, + "libc++ std::chrono::sys_seconds summary provider", + "^std::__[[:alnum:]]+::chrono::time_point<" + "std::__[[:alnum:]]+::chrono::system_clock, " + "std::__[[:alnum:]]+::chrono::duration<int, " + "std::__[[:alnum:]]+::ratio<86400, 1> " + "> >$", + eTypeOptionHideChildren | eTypeOptionHideValue | + eTypeOptionCascade, + true); + // Chrono calendar types cpp_category_sp->AddTypeSummary( @@ -1039,6 +1064,7 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | eTypeOptionHideValue, "day=${var.__d_%u}"))); + AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibcxxChronoMonthSummaryProvider, "libc++ std::chrono::month summary provider", @@ -1050,6 +1076,23 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { TypeSummaryImplSP(new StringSummaryFormat( eTypeOptionHideChildren | eTypeOptionHideValue, "year=${var.__y_}"))); + AddCXXSummary(cpp_category_sp, + lldb_private::formatters::LibcxxChronoWeekdaySummaryProvider, + "libc++ std::chrono::weekday summary provider", + "^std::__[[:alnum:]]+::chrono::weekday$", + eTypeOptionHideChildren | eTypeOptionHideValue, true); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::weekday_indexed$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat( + eTypeOptionHideChildren | eTypeOptionHideValue, + "${var.__wd_} index=${var.__idx_%u}"))); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::weekday_last$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | + eTypeOptionHideValue, + "${var.__wd_} index=last"))); cpp_category_sp->AddTypeSummary( "^std::__[[:alnum:]]+::chrono::month_day$", eFormatterMatchRegex, TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | @@ -1060,12 +1103,51 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__m_} day=last"))); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::month_weekday$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | + eTypeOptionHideValue, + "${var.__m_} ${var.__wdi_}"))); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::month_weekday_last$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | + eTypeOptionHideValue, + "${var.__m_} ${var.__wdl_}"))); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::year_month$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | + eTypeOptionHideValue, + "${var.__y_} ${var.__m_}"))); + AddCXXSummary( cpp_category_sp, lldb_private::formatters::LibcxxChronoYearMonthDaySummaryProvider, "libc++ std::chrono::year_month_day summary provider", "^std::__[[:alnum:]]+::chrono::year_month_day$", eTypeOptionHideChildren | eTypeOptionHideValue, true); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::year_month_day_last$", + eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | + eTypeOptionHideValue, + "${var.__y_} ${var.__mdl_}"))); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::year_month_weekday$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat( + eTypeOptionHideChildren | eTypeOptionHideValue, + "${var.__y_} ${var.__m_} ${var.__wdi_}"))); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::year_month_weekday_last$", + eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat( + eTypeOptionHideChildren | eTypeOptionHideValue, + "${var.__y_} ${var.__m_} ${var.__wdl_}"))); } static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { @@ -1589,7 +1671,7 @@ bool CPlusPlusLanguage::GetFunctionDisplayName( if (inline_block) { get_function_vars = false; - inline_info = sc->block->GetInlinedFunctionInfo(); + inline_info = inline_block->GetInlinedFunctionInfo(); if (inline_info) variable_list_sp = inline_block->GetBlockVariableList(true); } diff --git a/contrib/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/contrib/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index f8be4f785dc4..060324e2fcfe 100644 --- a/contrib/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -1073,18 +1073,87 @@ bool lldb_private::formatters::LibcxxWStringViewSummaryProvider( bool success; ValueObjectSP dataobj; size_t size; - std::tie( success, dataobj, size ) = LibcxxExtractStringViewData(valobj); + std::tie(success, dataobj, size) = LibcxxExtractStringViewData(valobj); if (!success) { stream << "Summary Unavailable"; return true; } - return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options, dataobj, size); } +bool lldb_private::formatters::LibcxxChronoSysSecondsSummaryProvider( + ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { + ValueObjectSP ptr_sp = valobj.GetChildMemberWithName("__d_"); + if (!ptr_sp) + return false; + ptr_sp = ptr_sp->GetChildMemberWithName("__rep_"); + if (!ptr_sp) + return false; + + // The date time in the chrono library is valid in the range + // [-32767-01-01T00:00:00Z, 32767-12-31T23:59:59Z]. A 64-bit time_t has a + // larger range, the function strftime is not able to format the entire range + // of time_t. The exact point has not been investigated; it's limited to + // chrono's range. + const std::time_t chrono_timestamp_min = + -1'096'193'779'200; // -32767-01-01T00:00:00Z + const std::time_t chrono_timestamp_max = + 971'890'963'199; // 32767-12-31T23:59:59Z + + const std::time_t seconds = ptr_sp->GetValueAsSigned(0); + if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max) + stream.Printf("timestamp=%ld s", seconds); + else { + std::array<char, 128> str; + std::size_t size = + std::strftime(str.data(), str.size(), "%FT%H:%M:%SZ", gmtime(&seconds)); + if (size == 0) + return false; + + stream.Printf("date/time=%s timestamp=%ld s", str.data(), seconds); + } + + return true; +} + +bool lldb_private::formatters::LibcxxChronoSysDaysSummaryProvider( + ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { + ValueObjectSP ptr_sp = valobj.GetChildMemberWithName("__d_"); + if (!ptr_sp) + return false; + ptr_sp = ptr_sp->GetChildMemberWithName("__rep_"); + if (!ptr_sp) + return false; + + // The date time in the chrono library is valid in the range + // [-32767-01-01Z, 32767-12-31Z]. A 32-bit time_t has a larger range, the + // function strftime is not able to format the entire range of time_t. The + // exact point has not been investigated; it's limited to chrono's range. + const int chrono_timestamp_min = -12'687'428; // -32767-01-01Z + const int chrono_timestamp_max = 11'248'737; // 32767-12-31Z + + const int days = ptr_sp->GetValueAsSigned(0); + if (days < chrono_timestamp_min || days > chrono_timestamp_max) + stream.Printf("timestamp=%d days", days); + + else { + const std::time_t seconds = std::time_t(86400) * days; + + std::array<char, 128> str; + std::size_t size = + std::strftime(str.data(), str.size(), "%FZ", gmtime(&seconds)); + if (size == 0) + return false; + + stream.Printf("date=%s timestamp=%d days", str.data(), days); + } + + return true; +} + bool lldb_private::formatters::LibcxxChronoMonthSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { // FIXME: These are the names used in the C++20 ostream operator. Since LLVM @@ -1106,6 +1175,27 @@ bool lldb_private::formatters::LibcxxChronoMonthSummaryProvider( return true; } +bool lldb_private::formatters::LibcxxChronoWeekdaySummaryProvider( + ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { + // FIXME: These are the names used in the C++20 ostream operator. Since LLVM + // uses C++17 it's not possible to use the ostream operator directly. + static const std::array<std::string_view, 7> weekdays = { + "Sunday", "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday"}; + + ValueObjectSP ptr_sp = valobj.GetChildMemberWithName("__wd_"); + if (!ptr_sp) + return false; + + const unsigned weekday = ptr_sp->GetValueAsUnsigned(0); + if (weekday >= 0 && weekday < 7) + stream << "weekday=" << weekdays[weekday]; + else + stream.Printf("weekday=%u", weekday); + + return true; +} + bool lldb_private::formatters::LibcxxChronoYearMonthDaySummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { ValueObjectSP ptr_sp = valobj.GetChildMemberWithName("__y_"); diff --git a/contrib/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h b/contrib/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h index c252ae382dd9..72da6b2426ef 100644 --- a/contrib/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h +++ b/contrib/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h @@ -261,10 +261,22 @@ SyntheticChildrenFrontEnd * LibcxxStdRangesRefViewSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP); +bool LibcxxChronoSysSecondsSummaryProvider( + ValueObject &valobj, Stream &stream, + const TypeSummaryOptions &options); // libc++ std::chrono::sys_seconds + +bool LibcxxChronoSysDaysSummaryProvider( + ValueObject &valobj, Stream &stream, + const TypeSummaryOptions &options); // libc++ std::chrono::sys_days + bool LibcxxChronoMonthSummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options); // libc++ std::chrono::month +bool LibcxxChronoWeekdaySummaryProvider( + ValueObject &valobj, Stream &stream, + const TypeSummaryOptions &options); // libc++ std::chrono::weekday + bool LibcxxChronoYearMonthDaySummaryProvider( ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options); // libc++ std::chrono::year_month_day diff --git a/contrib/llvm-project/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/contrib/llvm-project/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index dc492ac0f06d..f380d6e7e672 100644 --- a/contrib/llvm-project/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -1893,15 +1893,15 @@ AppleObjCRuntimeV2::DynamicClassInfoExtractor::ComputeHelper( if (loader->IsFullyInitialized()) { switch (exe_ctx.GetTargetRef().GetDynamicClassInfoHelper()) { case eDynamicClassInfoHelperAuto: - [[clang::fallthrough]]; + LLVM_FALLTHROUGH; case eDynamicClassInfoHelperGetRealizedClassList: if (m_runtime.m_has_objc_getRealizedClassList_trylock) return DynamicClassInfoExtractor::objc_getRealizedClassList_trylock; - [[clang::fallthrough]]; + LLVM_FALLTHROUGH; case eDynamicClassInfoHelperCopyRealizedClassList: if (m_runtime.m_has_objc_copyRealizedClassList) return DynamicClassInfoExtractor::objc_copyRealizedClassList; - [[clang::fallthrough]]; + LLVM_FALLTHROUGH; case eDynamicClassInfoHelperRealizedClassesStruct: return DynamicClassInfoExtractor::gdb_objc_realized_classes; } diff --git a/contrib/llvm-project/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/contrib/llvm-project/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 43ab87f08e19..0d95a1c12bde 100644 --- a/contrib/llvm-project/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -2897,9 +2897,8 @@ void ObjectFileELF::ParseSymtab(Symtab &lldb_symtab) { if (!module_sp) return; - Progress progress( - llvm::formatv("Parsing symbol table for {0}", - m_file.GetFilename().AsCString("<Unknown>"))); + Progress progress("Parsing symbol table", + m_file.GetFilename().AsCString("<Unknown>")); ElapsedTime elapsed(module_sp->GetSymtabParseTime()); // We always want to use the main object file so we (hopefully) only have one diff --git a/contrib/llvm-project/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp b/contrib/llvm-project/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp index 9e05737d8e62..3685d6ac72ad 100644 --- a/contrib/llvm-project/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp @@ -98,26 +98,15 @@ RegisterContextPOSIX_mips64::GetRegisterInfoAtIndex(size_t reg) { } size_t RegisterContextPOSIX_mips64::GetRegisterSetCount() { - ArchSpec target_arch = m_register_info_up->GetTargetArchitecture(); - switch (target_arch.GetTriple().getOS()) { - default: { - const auto *context = static_cast<const RegisterContextFreeBSD_mips64 *>( - m_register_info_up.get()); - return context->GetRegisterSetCount(); - } - - } + const auto *context = static_cast<const RegisterContextFreeBSD_mips64 *>( + m_register_info_up.get()); + return context->GetRegisterSetCount(); } const RegisterSet *RegisterContextPOSIX_mips64::GetRegisterSet(size_t set) { - ArchSpec target_arch = m_register_info_up->GetTargetArchitecture(); - switch (target_arch.GetTriple().getOS()) { - default: { - const auto *context = static_cast<const RegisterContextFreeBSD_mips64 *>( - m_register_info_up.get()); - return context->GetRegisterSet(set); - } - } + const auto *context = static_cast<const RegisterContextFreeBSD_mips64 *>( + m_register_info_up.get()); + return context->GetRegisterSet(set); } const char *RegisterContextPOSIX_mips64::GetRegisterName(unsigned reg) { diff --git a/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index ad72b3d121e6..7bb449841851 100644 --- a/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -1180,7 +1180,8 @@ bool GDBRemoteCommunicationClient::GetDefaultThreadId(lldb::tid_t &tid) { static void ParseOSType(llvm::StringRef value, std::string &os_name, std::string &environment) { if (value.equals("iossimulator") || value.equals("tvossimulator") || - value.equals("watchossimulator")) { + value.equals("watchossimulator") || value.equals("xrossimulator") || + value.equals("visionossimulator")) { environment = "simulator"; os_name = value.drop_back(environment.size()).str(); } else if (value.equals("maccatalyst")) { diff --git a/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 316be471df92..eb42b9eb6cb6 100644 --- a/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1089,8 +1089,8 @@ Status ProcessGDBRemote::DoAttachToProcessWithID( const int packet_len = ::snprintf(packet, sizeof(packet), "vAttach;%" PRIx64, attach_pid); SetID(attach_pid); - m_async_broadcaster.BroadcastEvent( - eBroadcastBitAsyncContinue, new EventDataBytes(packet, packet_len)); + auto data_sp = std::make_shared<EventDataBytes>(packet, packet_len); + m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue, data_sp); } else SetExitStatus(-1, error.AsCString()); } @@ -1127,9 +1127,9 @@ Status ProcessGDBRemote::DoAttachToProcessWithName( endian::InlHostByteOrder(), endian::InlHostByteOrder()); - m_async_broadcaster.BroadcastEvent( - eBroadcastBitAsyncContinue, - new EventDataBytes(packet.GetString().data(), packet.GetSize())); + auto data_sp = std::make_shared<EventDataBytes>(packet.GetString().data(), + packet.GetSize()); + m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue, data_sp); } else SetExitStatus(-1, error.AsCString()); @@ -1374,10 +1374,9 @@ Status ProcessGDBRemote::DoResume() { return error; } - m_async_broadcaster.BroadcastEvent( - eBroadcastBitAsyncContinue, - new EventDataBytes(continue_packet.GetString().data(), - continue_packet.GetSize())); + auto data_sp = std::make_shared<EventDataBytes>( + continue_packet.GetString().data(), continue_packet.GetSize()); + m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue, data_sp); if (!listener_sp->GetEvent(event_sp, std::chrono::seconds(5))) { error.SetErrorString("Resume timed out."); @@ -4189,52 +4188,55 @@ static std::vector<RegisterFlags::Field> ParseFlagsFields(XMLNode flags_node, // Note that XML in general requires that each of these attributes only // appears once, so we don't have to handle that here. if (attr_name == "name") { - LLDB_LOG(log, - "ProcessGDBRemote::ParseFlags Found field node name \"{0}\"", - attr_value.data()); + LLDB_LOG( + log, + "ProcessGDBRemote::ParseFlagsFields Found field node name \"{0}\"", + attr_value.data()); name = attr_value; } else if (attr_name == "start") { unsigned parsed_start = 0; if (llvm::to_integer(attr_value, parsed_start)) { if (parsed_start > max_start_bit) { - LLDB_LOG( - log, - "ProcessGDBRemote::ParseFlags Invalid start {0} in field node, " - "cannot be > {1}", - parsed_start, max_start_bit); + LLDB_LOG(log, + "ProcessGDBRemote::ParseFlagsFields Invalid start {0} in " + "field node, " + "cannot be > {1}", + parsed_start, max_start_bit); } else start = parsed_start; } else { - LLDB_LOG(log, - "ProcessGDBRemote::ParseFlags Invalid start \"{0}\" in " - "field node", - attr_value.data()); + LLDB_LOG( + log, + "ProcessGDBRemote::ParseFlagsFields Invalid start \"{0}\" in " + "field node", + attr_value.data()); } } else if (attr_name == "end") { unsigned parsed_end = 0; if (llvm::to_integer(attr_value, parsed_end)) if (parsed_end > max_start_bit) { - LLDB_LOG( - log, - "ProcessGDBRemote::ParseFlags Invalid end {0} in field node, " - "cannot be > {1}", - parsed_end, max_start_bit); + LLDB_LOG(log, + "ProcessGDBRemote::ParseFlagsFields Invalid end {0} in " + "field node, " + "cannot be > {1}", + parsed_end, max_start_bit); } else end = parsed_end; else { - LLDB_LOG( - log, - "ProcessGDBRemote::ParseFlags Invalid end \"{0}\" in field node", - attr_value.data()); + LLDB_LOG(log, + "ProcessGDBRemote::ParseFlagsFields Invalid end \"{0}\" in " + "field node", + attr_value.data()); } } else if (attr_name == "type") { // Type is a known attribute but we do not currently use it and it is // not required. } else { - LLDB_LOG(log, - "ProcessGDBRemote::ParseFlags Ignoring unknown attribute " - "\"{0}\" in field node", - attr_name.data()); + LLDB_LOG( + log, + "ProcessGDBRemote::ParseFlagsFields Ignoring unknown attribute " + "\"{0}\" in field node", + attr_name.data()); } return true; // Walk all attributes of the field. @@ -4242,10 +4244,11 @@ static std::vector<RegisterFlags::Field> ParseFlagsFields(XMLNode flags_node, if (name && start && end) { if (*start > *end) { - LLDB_LOG(log, - "ProcessGDBRemote::ParseFlags Start {0} > end {1} in field " - "\"{2}\", ignoring", - *start, *end, name->data()); + LLDB_LOG( + log, + "ProcessGDBRemote::ParseFlagsFields Start {0} > end {1} in field " + "\"{2}\", ignoring", + *start, *end, name->data()); } else { fields.push_back(RegisterFlags::Field(name->str(), *start, *end)); } diff --git a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp index 47c8074adc5b..b1f7397d6b0f 100644 --- a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp @@ -216,10 +216,11 @@ CompUnitSP SymbolFileBreakpad::ParseCompileUnitAtIndex(uint32_t index) { spec = (*m_files)[record->FileNum]; } - auto cu_sp = std::make_shared<CompileUnit>(m_objfile_sp->GetModule(), - /*user_data*/ nullptr, spec, index, - eLanguageTypeUnknown, - /*is_optimized*/ eLazyBoolNo); + auto cu_sp = std::make_shared<CompileUnit>( + m_objfile_sp->GetModule(), + /*user_data*/ nullptr, std::make_shared<SupportFile>(spec), index, + eLanguageTypeUnknown, + /*is_optimized*/ eLazyBoolNo); SetCompileUnitAtIndex(index, cu_sp); return cu_sp; diff --git a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp index d192944bb9d0..65f5b1a5f1b0 100644 --- a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp @@ -603,6 +603,7 @@ llvm::Expected<TypeSP> SymbolFileCTF::CreateType(CTFType *ctf_type) { ctf_type->uid, ctf_type->name, ctf_type->kind), llvm::inconvertibleErrorCode()); } + llvm_unreachable("Unexpected CTF type kind"); } llvm::Expected<std::unique_ptr<CTFType>> diff --git a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp index 553b6a4c551d..340b9acf80d0 100644 --- a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -191,3 +191,9 @@ DWARFDebugInfo::GetDIE(const DIERef &die_ref) { return cu->GetNonSkeletonUnit().GetDIE(die_ref.die_offset()); return DWARFDIE(); // Not found } + +llvm::StringRef DWARFDebugInfo::PeekDIEName(const DIERef &die_ref) { + if (DWARFUnit *cu = GetUnit(die_ref)) + return cu->GetNonSkeletonUnit().PeekDIEName(die_ref.die_offset()); + return llvm::StringRef(); +} diff --git a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h index d5e48f312ea0..a8b5abc3beed 100644 --- a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -43,6 +43,11 @@ public: bool ContainsTypeUnits(); DWARFDIE GetDIE(const DIERef &die_ref); + /// Returns the AT_Name of this DIE, if it exists, without parsing the entire + /// compile unit. An empty is string is returned upon error or if the + /// attribute is not present. + llvm::StringRef PeekDIEName(const DIERef &die_ref); + enum { eDumpFlag_Verbose = (1 << 0), // Verbose dumping eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type diff --git a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp index 0a7029a55c04..e1f73f1997e3 100644 --- a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -18,8 +18,6 @@ #include "DWARFFormValue.h" #include "DWARFUnit.h" -class DWARFUnit; - using namespace lldb_private; using namespace lldb_private::dwarf; using namespace lldb_private::plugin::dwarf; @@ -502,7 +500,8 @@ dw_addr_t DWARFFormValue::Address() const { &offset, index_size); } -DWARFDIE DWARFFormValue::Reference() const { +std::pair<DWARFUnit *, uint64_t> +DWARFFormValue::ReferencedUnitAndOffset() const { uint64_t value = m_value.value.uval; switch (m_form) { case DW_FORM_ref1: @@ -516,9 +515,9 @@ DWARFDIE DWARFFormValue::Reference() const { if (!m_unit->ContainsDIEOffset(value)) { m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError( "DW_FORM_ref* DIE reference {0:x16} is outside of its CU", value); - return {}; + return {nullptr, 0}; } - return const_cast<DWARFUnit *>(m_unit)->GetDIE(value); + return {const_cast<DWARFUnit *>(m_unit), value}; case DW_FORM_ref_addr: { DWARFUnit *ref_cu = @@ -527,24 +526,29 @@ DWARFDIE DWARFFormValue::Reference() const { if (!ref_cu) { m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError( "DW_FORM_ref_addr DIE reference {0:x16} has no matching CU", value); - return {}; + return {nullptr, 0}; } - return ref_cu->GetDIE(value); + return {ref_cu, value}; } case DW_FORM_ref_sig8: { DWARFTypeUnit *tu = m_unit->GetSymbolFileDWARF().DebugInfo().GetTypeUnitForHash(value); if (!tu) - return {}; - return tu->GetDIE(tu->GetTypeOffset()); + return {nullptr, 0}; + return {tu, tu->GetTypeOffset()}; } default: - return {}; + return {nullptr, 0}; } } +DWARFDIE DWARFFormValue::Reference() const { + auto [unit, offset] = ReferencedUnitAndOffset(); + return unit ? unit->GetDIE(offset) : DWARFDIE(); +} + uint64_t DWARFFormValue::Reference(dw_offset_t base_offset) const { uint64_t value = m_value.value.uval; switch (m_form) { diff --git a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h index 445749a6aac3..fdd5b3c278a4 100644 --- a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h +++ b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h @@ -60,6 +60,12 @@ public: const DWARFUnit *u); std::optional<uint8_t> GetFixedSize() const; DWARFDIE Reference() const; + + /// If this is a reference to another DIE, return the corresponding DWARFUnit + /// and DIE offset such that Unit->GetDIE(offset) produces the desired DIE. + /// Otherwise, a nullptr and unspecified offset are returned. + std::pair<DWARFUnit *, uint64_t> ReferencedUnitAndOffset() const; + uint64_t Reference(dw_offset_t offset) const; bool Boolean() const { return m_value.value.uval != 0; } uint64_t Unsigned() const { return m_value.value.uval; } diff --git a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp index 0e2f4d45543b..7a40361cdede 100644 --- a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -663,6 +663,30 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) { return DWARFDIE(); // Not found } +llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) { + DWARFDebugInfoEntry die; + if (!die.Extract(GetData(), this, &die_offset)) + return llvm::StringRef(); + + // Does die contain a DW_AT_Name? + if (const char *name = + die.GetAttributeValueAsString(this, DW_AT_name, nullptr)) + return name; + + // Does its DW_AT_specification or DW_AT_abstract_origin contain an AT_Name? + for (auto attr : {DW_AT_specification, DW_AT_abstract_origin}) { + DWARFFormValue form_value; + if (!die.GetAttributeValue(this, attr, form_value)) + continue; + auto [unit, offset] = form_value.ReferencedUnitAndOffset(); + if (unit) + if (auto name = unit->PeekDIEName(offset); !name.empty()) + return name; + } + + return llvm::StringRef(); +} + DWARFUnit &DWARFUnit::GetNonSkeletonUnit() { ExtractUnitDIEIfNeeded(); if (m_dwo) diff --git a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h index 3f528e913d8c..bc225a52e1d0 100644 --- a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -187,6 +187,11 @@ public: DWARFDIE GetDIE(dw_offset_t die_offset); + /// Returns the AT_Name of the DIE at `die_offset`, if it exists, without + /// parsing the entire compile unit. An empty is string is returned upon + /// error or if the attribute is not present. + llvm::StringRef PeekDIEName(dw_offset_t die_offset); + DWARFUnit &GetNonSkeletonUnit(); static uint8_t GetAddressByteSize(const DWARFUnit *cu); diff --git a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp index 16ff5f7d4842..92275600f99c 100644 --- a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -75,9 +75,8 @@ void ManualDWARFIndex::Index() { // Include 2 passes per unit to index for extracting DIEs from the unit and // indexing the unit, and then 8 extra entries for finalizing each index set. const uint64_t total_progress = units_to_index.size() * 2 + 8; - Progress progress( - llvm::formatv("Manually indexing DWARF for {0}", module_desc.GetData()), - total_progress); + Progress progress("Manually indexing DWARF", module_desc.GetData(), + total_progress); std::vector<IndexSet> sets(units_to_index.size()); diff --git a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 1a16b70f42fe..fed97858c83f 100644 --- a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -294,7 +294,7 @@ static void ParseSupportFilesFromPrologue( } // Unconditionally add an entry, so the indices match up. - support_files.EmplaceBack(remapped_file, style, checksum); + support_files.EmplaceBack(FileSpec(remapped_file, style), checksum); } } @@ -519,8 +519,6 @@ void SymbolFileDWARF::InitializeObject() { if (apple_names.GetByteSize() > 0 || apple_namespaces.GetByteSize() > 0 || apple_types.GetByteSize() > 0 || apple_objc.GetByteSize() > 0) { - Progress progress(llvm::formatv("Loading Apple DWARF index for {0}", - module_desc.GetData())); m_index = AppleDWARFIndex::Create( *GetObjectFile()->GetModule(), apple_names, apple_namespaces, apple_types, apple_objc, m_context.getOrLoadStrData()); @@ -532,8 +530,7 @@ void SymbolFileDWARF::InitializeObject() { DWARFDataExtractor debug_names; LoadSectionData(eSectionTypeDWARFDebugNames, debug_names); if (debug_names.GetByteSize() > 0) { - Progress progress( - llvm::formatv("Loading DWARF5 index for {0}", module_desc.GetData())); + Progress progress("Loading DWARF5 index", module_desc.GetData()); llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>> index_or = DebugNamesDWARFIndex::Create(*GetObjectFile()->GetModule(), debug_names, @@ -786,12 +783,12 @@ lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) { } else { ModuleSP module_sp(m_objfile_sp->GetModule()); if (module_sp) { - auto initialize_cu = [&](const FileSpec &file_spec, + auto initialize_cu = [&](lldb::SupportFileSP support_file_sp, LanguageType cu_language, SupportFileList &&support_files = {}) { BuildCuTranslationTable(); cu_sp = std::make_shared<CompileUnit>( - module_sp, &dwarf_cu, file_spec, + module_sp, &dwarf_cu, support_file_sp, *GetDWARFUnitIndex(dwarf_cu.GetID()), cu_language, eLazyBoolCalculate, std::move(support_files)); @@ -824,7 +821,7 @@ lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) { return false; if (support_files.GetSize() == 0) return false; - initialize_cu(support_files.GetFileSpecAtIndex(0), + initialize_cu(support_files.GetSupportFileAtIndex(0), eLanguageTypeUnknown, std::move(support_files)); return true; }; @@ -843,7 +840,8 @@ lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) { // case ParseSupportFiles takes care of the remapping. MakeAbsoluteAndRemap(cu_file_spec, dwarf_cu, module_sp); - initialize_cu(cu_file_spec, cu_language); + initialize_cu(std::make_shared<SupportFile>(cu_file_spec), + cu_language); } } } diff --git a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 9094a5e21e69..6dd3eb3677b7 100644 --- a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -598,10 +598,10 @@ CompUnitSP SymbolFileDWARFDebugMap::ParseCompileUnitAtIndex(uint32_t cu_idx) { // User zero as the ID to match the compile unit at offset zero in each // .o file. lldb::user_id_t cu_id = 0; - cu_info.compile_units_sps.push_back( - std::make_shared<CompileUnit>( - m_objfile_sp->GetModule(), nullptr, so_file_spec, cu_id, - eLanguageTypeUnknown, eLazyBoolCalculate)); + cu_info.compile_units_sps.push_back(std::make_shared<CompileUnit>( + m_objfile_sp->GetModule(), nullptr, + std::make_shared<SupportFile>(so_file_spec), cu_id, + eLanguageTypeUnknown, eLazyBoolCalculate)); cu_info.id_to_index_map.insert({0, 0}); SetCompileUnitAtIndex(cu_idx, cu_info.compile_units_sps[0]); // If there's a symbol file also register all the extra compile units. @@ -615,7 +615,8 @@ CompUnitSP SymbolFileDWARFDebugMap::ParseCompileUnitAtIndex(uint32_t cu_idx) { if (dwarf_cu->GetID() == 0) continue; cu_info.compile_units_sps.push_back(std::make_shared<CompileUnit>( - m_objfile_sp->GetModule(), nullptr, so_file_spec, + m_objfile_sp->GetModule(), nullptr, + std::make_shared<SupportFile>(so_file_spec), dwarf_cu->GetID(), eLanguageTypeUnknown, eLazyBoolCalculate)); cu_info.id_to_index_map.insert( {dwarf_cu->GetID(), cu_info.compile_units_sps.size() - 1}); diff --git a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index 9234768323e7..745685a1b31d 100644 --- a/contrib/llvm-project/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -534,9 +534,9 @@ SymbolFileNativePDB::CreateCompileUnit(const CompilandIndexItem &cci) { FileSpec fs(llvm::sys::path::convert_to_slash( source_file_name, llvm::sys::path::Style::windows_backslash)); - CompUnitSP cu_sp = - std::make_shared<CompileUnit>(m_objfile_sp->GetModule(), nullptr, fs, - toOpaqueUid(cci.m_id), lang, optimized); + CompUnitSP cu_sp = std::make_shared<CompileUnit>( + m_objfile_sp->GetModule(), nullptr, std::make_shared<SupportFile>(fs), + toOpaqueUid(cci.m_id), lang, optimized); SetCompileUnitAtIndex(cci.m_id.modi, cu_sp); return cu_sp; diff --git a/contrib/llvm-project/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp b/contrib/llvm-project/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp index 111be6be3652..2cd7bbbb2449 100644 --- a/contrib/llvm-project/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp @@ -9,7 +9,10 @@ #include "SymbolLocatorDebuginfod.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Interpreter/OptionValueString.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" #include "llvm/Debuginfod/Debuginfod.h" #include "llvm/Debuginfod/HTTPClient.h" @@ -54,6 +57,32 @@ public: return urls; } + llvm::Expected<std::string> GetCachePath() { + OptionValueString *s = + m_collection_sp->GetPropertyAtIndexAsOptionValueString( + ePropertySymbolCachePath); + // If we don't have a valid cache location, use the default one. + if (!s || !s->GetCurrentValueAsRef().size()) { + llvm::Expected<std::string> maybeCachePath = + llvm::getDefaultDebuginfodCacheDirectory(); + if (!maybeCachePath) + return maybeCachePath; + return *maybeCachePath; + } + return s->GetCurrentValue(); + } + + std::chrono::milliseconds GetTimeout() const { + std::optional<uint64_t> seconds = + m_collection_sp->GetPropertyAtIndexAs<uint64_t>(ePropertyTimeout); + if (seconds && *seconds != 0) { + return std::chrono::duration_cast<std::chrono::milliseconds>( + std::chrono::seconds(*seconds)); + } else { + return llvm::getDefaultDebuginfodTimeout(); + } + } + private: void ServerURLsChangedCallback() { m_server_urls = GetDebugInfoDURLs(); @@ -112,31 +141,51 @@ SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() { return new SymbolLocatorDebuginfod(); } -static std::optional<FileSpec> GetFileForModule( - const ModuleSpec &module_spec, - std::function<llvm::Expected<std::string>(llvm::object::BuildIDRef)> - PullFromServer) { - if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()) - return {}; +static std::optional<FileSpec> +GetFileForModule(const ModuleSpec &module_spec, + std::function<std::string(llvm::object::BuildID)> UrlBuilder) { const UUID &module_uuid = module_spec.GetUUID(); - if (module_uuid.IsValid() && llvm::canUseDebuginfod()) { - llvm::object::BuildID build_id(module_uuid.GetBytes()); - llvm::Expected<std::string> result = PullFromServer(build_id); - if (result) - return FileSpec(*result); - // An error here should be logged as a failure in the Debuginfod library, - // so just consume it here - consumeError(result.takeError()); - } + // Don't bother if we don't have a valid UUID, Debuginfod isn't available, + // or if the 'symbols.enable-external-lookup' setting is false. + if (!module_uuid.IsValid() || !llvm::canUseDebuginfod() || + !ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()) + return {}; + + // Grab LLDB's Debuginfod overrides from the + // plugin.symbol-locator.debuginfod.* settings. + PluginProperties &plugin_props = GetGlobalPluginProperties(); + llvm::Expected<std::string> cache_path_or_err = plugin_props.GetCachePath(); + // A cache location is *required*. + if (!cache_path_or_err) + return {}; + std::string cache_path = *cache_path_or_err; + llvm::SmallVector<llvm::StringRef> debuginfod_urls = + llvm::getDefaultDebuginfodUrls(); + std::chrono::milliseconds timeout = plugin_props.GetTimeout(); + + // We're ready to ask the Debuginfod library to find our file. + llvm::object::BuildID build_id(module_uuid.GetBytes()); + std::string url_path = UrlBuilder(build_id); + std::string cache_key = llvm::getDebuginfodCacheKey(url_path); + llvm::Expected<std::string> result = llvm::getCachedOrDownloadArtifact( + cache_key, url_path, cache_path, debuginfod_urls, timeout); + if (result) + return FileSpec(*result); + + Log *log = GetLog(LLDBLog::Symbols); + auto err_message = llvm::toString(result.takeError()); + LLDB_LOGV(log, + "Debuginfod failed to download symbol artifact {0} with error {1}", + url_path, err_message); return {}; } std::optional<ModuleSpec> SymbolLocatorDebuginfod::LocateExecutableObjectFile( const ModuleSpec &module_spec) { - return GetFileForModule(module_spec, llvm::getCachedOrDownloadExecutable); + return GetFileForModule(module_spec, llvm::getDebuginfodExecutableUrlPath); } std::optional<FileSpec> SymbolLocatorDebuginfod::LocateExecutableSymbolFile( const ModuleSpec &module_spec, const FileSpecList &default_search_paths) { - return GetFileForModule(module_spec, llvm::getCachedOrDownloadDebuginfo); + return GetFileForModule(module_spec, llvm::getDebuginfodDebuginfoUrlPath); } diff --git a/contrib/llvm-project/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfodProperties.td b/contrib/llvm-project/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfodProperties.td index 1c668b001a16..0ff02674b8ea 100644 --- a/contrib/llvm-project/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfodProperties.td +++ b/contrib/llvm-project/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfodProperties.td @@ -1,7 +1,13 @@ include "../../../../include/lldb/Core/PropertiesBase.td" let Definition = "symbollocatordebuginfod" in { - def ServerURLs : Property<"server_urls", "Array">, + def ServerURLs : Property<"server-urls", "Array">, ElementType<"String">, Desc<"An ordered list of Debuginfod server URLs to query for symbols. This defaults to the contents of the DEBUGINFOD_URLS environment variable.">; + def SymbolCachePath: Property<"cache-path", "String">, + DefaultStringValue<"">, + Desc<"The path where symbol files should be cached. This defaults to LLDB's system cache location.">; + def Timeout : Property<"timeout", "UInt64">, + DefaultUnsignedValue<0>, + Desc<"Timeout (in seconds) for requests made to a DEBUGINFOD server. A value of zero means we use the debuginfod default timeout: DEBUGINFOD_TIMEOUT if the environment variable is set and 90 seconds otherwise.">; } diff --git a/contrib/llvm-project/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp b/contrib/llvm-project/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp index ed014f99fdb5..6f0126b16cdc 100644 --- a/contrib/llvm-project/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp @@ -98,9 +98,9 @@ std::optional<FileSpec> SymbolLocatorDefault::LocateExecutableSymbolFile( FileSystem::Instance().Exists(symbol_file_spec)) return symbol_file_spec; - Progress progress(llvm::formatv( - "Locating external symbol file for {0}", - module_spec.GetFileSpec().GetFilename().AsCString("<Unknown>"))); + Progress progress( + "Locating external symbol file", + module_spec.GetFileSpec().GetFilename().AsCString("<Unknown>")); FileSpecList debug_file_search_paths = default_search_paths; diff --git a/contrib/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/contrib/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 503cbedce982..d6a21ad560c4 100644 --- a/contrib/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/contrib/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -7168,6 +7168,9 @@ TypeSystemClang::GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, case clang::TemplateArgument::Pack: return eTemplateArgumentKindPack; + + case clang::TemplateArgument::StructuralValue: + return eTemplateArgumentKindStructuralValue; } llvm_unreachable("Unhandled clang::TemplateArgument::ArgKind"); } @@ -8353,7 +8356,7 @@ clang::EnumConstantDecl *TypeSystemClang::AddEnumerationValueToEnumerationType( if (name && name[0]) enumerator_decl->setDeclName(&getASTContext().Idents.get(name)); enumerator_decl->setType(clang::QualType(enutype, 0)); - enumerator_decl->setInitVal(value); + enumerator_decl->setInitVal(getASTContext(), value); SetMemberOwningModule(enumerator_decl, enutype->getDecl()); if (!enumerator_decl) diff --git a/contrib/llvm-project/lldb/source/Symbol/CompileUnit.cpp b/contrib/llvm-project/lldb/source/Symbol/CompileUnit.cpp index a6b6c8e57eec..1b3cd23d9400 100644 --- a/contrib/llvm-project/lldb/source/Symbol/CompileUnit.cpp +++ b/contrib/llvm-project/lldb/source/Symbol/CompileUnit.cpp @@ -22,16 +22,19 @@ CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, const lldb::user_id_t cu_sym_id, lldb::LanguageType language, lldb_private::LazyBool is_optimized) - : CompileUnit(module_sp, user_data, FileSpec(pathname), cu_sym_id, language, - is_optimized) {} + : CompileUnit(module_sp, user_data, + std::make_shared<SupportFile>(FileSpec(pathname)), cu_sym_id, + language, is_optimized) {} CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, - const FileSpec &fspec, const lldb::user_id_t cu_sym_id, + lldb::SupportFileSP support_file_sp, + const lldb::user_id_t cu_sym_id, lldb::LanguageType language, lldb_private::LazyBool is_optimized, SupportFileList &&support_files) : ModuleChild(module_sp), UserID(cu_sym_id), m_user_data(user_data), - m_language(language), m_flags(0), m_file_spec(fspec), + m_language(language), m_flags(0), + m_primary_support_file_sp(support_file_sp), m_support_files(std::move(support_files)), m_is_optimized(is_optimized) { if (language != eLanguageTypeUnknown) m_flags.Set(flagsParsedLanguage); diff --git a/contrib/llvm-project/lldb/source/Symbol/LineEntry.cpp b/contrib/llvm-project/lldb/source/Symbol/LineEntry.cpp index 1b2801cd0368..389f8dcb65d8 100644 --- a/contrib/llvm-project/lldb/source/Symbol/LineEntry.cpp +++ b/contrib/llvm-project/lldb/source/Symbol/LineEntry.cpp @@ -17,23 +17,10 @@ LineEntry::LineEntry() : range(), file(), is_start_of_statement(0), is_start_of_basic_block(0), is_prologue_end(0), is_epilogue_begin(0), is_terminal_entry(0) {} -LineEntry::LineEntry(const lldb::SectionSP §ion_sp, - lldb::addr_t section_offset, lldb::addr_t byte_size, - const FileSpec &_file, uint32_t _line, uint16_t _column, - bool _is_start_of_statement, bool _is_start_of_basic_block, - bool _is_prologue_end, bool _is_epilogue_begin, - bool _is_terminal_entry) - : range(section_sp, section_offset, byte_size), file(_file), - original_file(_file), line(_line), column(_column), - is_start_of_statement(_is_start_of_statement), - is_start_of_basic_block(_is_start_of_basic_block), - is_prologue_end(_is_prologue_end), is_epilogue_begin(_is_epilogue_begin), - is_terminal_entry(_is_terminal_entry) {} - void LineEntry::Clear() { range.Clear(); file.Clear(); - original_file.Clear(); + original_file_sp = std::make_shared<SupportFile>(); line = LLDB_INVALID_LINE_NUMBER; column = 0; is_start_of_statement = 0; @@ -195,7 +182,7 @@ AddressRange LineEntry::GetSameLineContiguousAddressRange( // different file / line number. AddressRange complete_line_range = range; auto symbol_context_scope = lldb::eSymbolContextLineEntry; - Declaration start_call_site(original_file, line); + Declaration start_call_site(original_file_sp->GetSpecOnly(), line); if (include_inlined_functions) symbol_context_scope |= lldb::eSymbolContextBlock; @@ -209,7 +196,7 @@ AddressRange LineEntry::GetSameLineContiguousAddressRange( next_line_sc.line_entry.range.GetByteSize() == 0) break; - if (original_file == next_line_sc.line_entry.original_file && + if (*original_file_sp == *next_line_sc.line_entry.original_file_sp && (next_line_sc.line_entry.line == 0 || line == next_line_sc.line_entry.line)) { // Include any line 0 entries - they indicate that this is compiler- @@ -253,8 +240,8 @@ AddressRange LineEntry::GetSameLineContiguousAddressRange( void LineEntry::ApplyFileMappings(lldb::TargetSP target_sp) { if (target_sp) { // Apply any file remappings to our file. - if (auto new_file_spec = - target_sp->GetSourcePathMap().FindFile(original_file)) + if (auto new_file_spec = target_sp->GetSourcePathMap().FindFile( + original_file_sp->GetSpecOnly())) file = *new_file_spec; } } diff --git a/contrib/llvm-project/lldb/source/Symbol/LineTable.cpp b/contrib/llvm-project/lldb/source/Symbol/LineTable.cpp index abe4c98d5928..444135f63bc0 100644 --- a/contrib/llvm-project/lldb/source/Symbol/LineTable.cpp +++ b/contrib/llvm-project/lldb/source/Symbol/LineTable.cpp @@ -290,8 +290,8 @@ bool LineTable::ConvertEntryAtIndexToLineEntry(uint32_t idx, line_entry.file = m_comp_unit->GetSupportFiles().GetFileSpecAtIndex(entry.file_idx); - line_entry.original_file = - m_comp_unit->GetSupportFiles().GetFileSpecAtIndex(entry.file_idx); + line_entry.original_file_sp = + m_comp_unit->GetSupportFiles().GetSupportFileAtIndex(entry.file_idx); line_entry.line = entry.line; line_entry.column = entry.column; line_entry.is_start_of_statement = entry.is_start_of_statement; @@ -357,13 +357,13 @@ void LineTable::Dump(Stream *s, Target *target, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_line_ranges) { const size_t count = m_entries.size(); LineEntry line_entry; - FileSpec prev_file; + SupportFileSP prev_file; for (size_t idx = 0; idx < count; ++idx) { ConvertEntryAtIndexToLineEntry(idx, line_entry); - line_entry.Dump(s, target, prev_file != line_entry.original_file, style, - fallback_style, show_line_ranges); + line_entry.Dump(s, target, *prev_file != *line_entry.original_file_sp, + style, fallback_style, show_line_ranges); s->EOL(); - prev_file = line_entry.original_file; + prev_file = line_entry.original_file_sp; } } diff --git a/contrib/llvm-project/lldb/source/Symbol/Symbol.cpp b/contrib/llvm-project/lldb/source/Symbol/Symbol.cpp index 08900a3ef349..1895f299cc06 100644 --- a/contrib/llvm-project/lldb/source/Symbol/Symbol.cpp +++ b/contrib/llvm-project/lldb/source/Symbol/Symbol.cpp @@ -226,8 +226,9 @@ bool Symbol::IsTrampoline() const { return m_type == eSymbolTypeTrampoline; } bool Symbol::IsIndirect() const { return m_type == eSymbolTypeResolver; } -void Symbol::GetDescription(Stream *s, lldb::DescriptionLevel level, - Target *target, llvm::StringRef pattern) const { +void Symbol::GetDescription( + Stream *s, lldb::DescriptionLevel level, Target *target, + std::optional<Stream::HighlightSettings> settings) const { s->Printf("id = {0x%8.8x}", m_uid); if (m_addr_range.GetBaseAddress().GetSection()) { @@ -254,22 +255,14 @@ void Symbol::GetDescription(Stream *s, lldb::DescriptionLevel level, s->Printf(", value = 0x%16.16" PRIx64, m_addr_range.GetBaseAddress().GetOffset()); } - llvm::StringRef ansi_prefix; - llvm::StringRef ansi_suffix; - if (target) { - ansi_prefix = target->GetDebugger().GetRegexMatchAnsiPrefix(); - ansi_suffix = target->GetDebugger().GetRegexMatchAnsiSuffix(); - } if (ConstString demangled = m_mangled.GetDemangledName()) { s->PutCString(", name=\""); - s->PutCStringColorHighlighted(demangled.GetStringRef(), pattern, - ansi_prefix, ansi_suffix); + s->PutCStringColorHighlighted(demangled.GetStringRef(), settings); s->PutCString("\""); } if (ConstString mangled_name = m_mangled.GetMangledName()) { s->PutCString(", mangled=\""); - s->PutCStringColorHighlighted(mangled_name.GetStringRef(), pattern, - ansi_prefix, ansi_suffix); + s->PutCStringColorHighlighted(mangled_name.GetStringRef(), settings); s->PutCString("\""); } } diff --git a/contrib/llvm-project/lldb/source/Symbol/SymbolContext.cpp b/contrib/llvm-project/lldb/source/Symbol/SymbolContext.cpp index 9fd40b5ca567..3c70b8d8743c 100644 --- a/contrib/llvm-project/lldb/source/Symbol/SymbolContext.cpp +++ b/contrib/llvm-project/lldb/source/Symbol/SymbolContext.cpp @@ -24,6 +24,7 @@ #include "lldb/Target/Target.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" #include "lldb/lldb-enumerations.h" @@ -68,12 +69,11 @@ void SymbolContext::Clear(bool clear_target) { variable = nullptr; } -bool SymbolContext::DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, - const Address &addr, bool show_fullpaths, - bool show_module, bool show_inlined_frames, - bool show_function_arguments, - bool show_function_name, - llvm::StringRef pattern) const { +bool SymbolContext::DumpStopContext( + Stream *s, ExecutionContextScope *exe_scope, const Address &addr, + bool show_fullpaths, bool show_module, bool show_inlined_frames, + bool show_function_arguments, bool show_function_name, + std::optional<Stream::HighlightSettings> settings) const { bool dumped_something = false; if (show_module && module_sp) { if (show_fullpaths) @@ -95,16 +95,8 @@ bool SymbolContext::DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, name = function->GetNameNoArguments(); if (!name) name = function->GetName(); - if (name) { - llvm::StringRef ansi_prefix; - llvm::StringRef ansi_suffix; - if (target_sp) { - ansi_prefix = target_sp->GetDebugger().GetRegexMatchAnsiPrefix(); - ansi_suffix = target_sp->GetDebugger().GetRegexMatchAnsiSuffix(); - } - s->PutCStringColorHighlighted(name.GetStringRef(), pattern, ansi_prefix, - ansi_suffix); - } + if (name) + s->PutCStringColorHighlighted(name.GetStringRef(), settings); } if (addr.IsValid()) { @@ -172,14 +164,7 @@ bool SymbolContext::DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, dumped_something = true; if (symbol->GetType() == eSymbolTypeTrampoline) s->PutCString("symbol stub for: "); - llvm::StringRef ansi_prefix; - llvm::StringRef ansi_suffix; - if (target_sp) { - ansi_prefix = target_sp->GetDebugger().GetRegexMatchAnsiPrefix(); - ansi_suffix = target_sp->GetDebugger().GetRegexMatchAnsiSuffix(); - } - s->PutCStringColorHighlighted(symbol->GetName().GetStringRef(), pattern, - ansi_prefix, ansi_suffix); + s->PutCStringColorHighlighted(symbol->GetName().GetStringRef(), settings); } if (addr.IsValid() && symbol->ValueIsAddress()) { @@ -201,9 +186,9 @@ bool SymbolContext::DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, return dumped_something; } -void SymbolContext::GetDescription(Stream *s, lldb::DescriptionLevel level, - Target *target, - llvm::StringRef pattern) const { +void SymbolContext::GetDescription( + Stream *s, lldb::DescriptionLevel level, Target *target, + std::optional<Stream::HighlightSettings> settings) const { if (module_sp) { s->Indent(" Module: file = \""); module_sp->GetFileSpec().Dump(s->AsRawOstream()); @@ -263,7 +248,7 @@ void SymbolContext::GetDescription(Stream *s, lldb::DescriptionLevel level, if (symbol != nullptr) { s->Indent(" Symbol: "); - symbol->GetDescription(s, level, target, pattern); + symbol->GetDescription(s, level, target, settings); s->EOL(); } @@ -489,8 +474,9 @@ bool SymbolContext::GetParentOfInlinedScope(const Address &curr_frame_pc, next_frame_sc.line_entry.range.GetBaseAddress() = next_frame_pc; next_frame_sc.line_entry.file = curr_inlined_block_inlined_info->GetCallSite().GetFile(); - next_frame_sc.line_entry.original_file = - curr_inlined_block_inlined_info->GetCallSite().GetFile(); + next_frame_sc.line_entry.original_file_sp = + std::make_shared<SupportFile>( + curr_inlined_block_inlined_info->GetCallSite().GetFile()); next_frame_sc.line_entry.line = curr_inlined_block_inlined_info->GetCallSite().GetLine(); next_frame_sc.line_entry.column = diff --git a/contrib/llvm-project/lldb/source/Target/Process.cpp b/contrib/llvm-project/lldb/source/Target/Process.cpp index aa3b04c43cc5..e1c16ca21643 100644 --- a/contrib/llvm-project/lldb/source/Target/Process.cpp +++ b/contrib/llvm-project/lldb/source/Target/Process.cpp @@ -4304,9 +4304,9 @@ void Process::BroadcastAsyncProfileData(const std::string &one_profile_data) { void Process::BroadcastStructuredData(const StructuredData::ObjectSP &object_sp, const StructuredDataPluginSP &plugin_sp) { - BroadcastEvent( - eBroadcastBitStructuredData, - new EventDataStructuredData(shared_from_this(), object_sp, plugin_sp)); + auto data_sp = std::make_shared<EventDataStructuredData>( + shared_from_this(), object_sp, plugin_sp); + BroadcastEvent(eBroadcastBitStructuredData, data_sp); } StructuredDataPluginSP @@ -5694,12 +5694,16 @@ lldb::addr_t Process::GetDataAddressMask() { lldb::addr_t Process::GetHighmemCodeAddressMask() { if (uint32_t num_bits_setting = GetHighmemVirtualAddressableBits()) return ~((1ULL << num_bits_setting) - 1); + if (m_highmem_code_address_mask) + return m_highmem_code_address_mask; return GetCodeAddressMask(); } lldb::addr_t Process::GetHighmemDataAddressMask() { if (uint32_t num_bits_setting = GetHighmemVirtualAddressableBits()) return ~((1ULL << num_bits_setting) - 1); + if (m_highmem_data_address_mask) + return m_highmem_data_address_mask; return GetDataAddressMask(); } diff --git a/contrib/llvm-project/lldb/source/Target/Target.cpp b/contrib/llvm-project/lldb/source/Target/Target.cpp index 302c2bad7021..e969340fdf1e 100644 --- a/contrib/llvm-project/lldb/source/Target/Target.cpp +++ b/contrib/llvm-project/lldb/source/Target/Target.cpp @@ -1704,8 +1704,9 @@ void Target::ModulesDidLoad(ModuleList &module_list) { if (m_process_sp) { m_process_sp->ModulesDidLoad(module_list); } - BroadcastEvent(eBroadcastBitModulesLoaded, - new TargetEventData(this->shared_from_this(), module_list)); + auto data_sp = + std::make_shared<TargetEventData>(shared_from_this(), module_list); + BroadcastEvent(eBroadcastBitModulesLoaded, data_sp); } } @@ -1719,16 +1720,18 @@ void Target::SymbolsDidLoad(ModuleList &module_list) { m_breakpoint_list.UpdateBreakpoints(module_list, true, false); m_internal_breakpoint_list.UpdateBreakpoints(module_list, true, false); - BroadcastEvent(eBroadcastBitSymbolsLoaded, - new TargetEventData(this->shared_from_this(), module_list)); + auto data_sp = + std::make_shared<TargetEventData>(shared_from_this(), module_list); + BroadcastEvent(eBroadcastBitSymbolsLoaded, data_sp); } } void Target::ModulesDidUnload(ModuleList &module_list, bool delete_locations) { if (m_valid && module_list.GetSize()) { UnloadModuleSections(module_list); - BroadcastEvent(eBroadcastBitModulesUnloaded, - new TargetEventData(this->shared_from_this(), module_list)); + auto data_sp = + std::make_shared<TargetEventData>(shared_from_this(), module_list); + BroadcastEvent(eBroadcastBitModulesUnloaded, data_sp); m_breakpoint_list.UpdateBreakpoints(module_list, false, delete_locations); m_internal_breakpoint_list.UpdateBreakpoints(module_list, false, delete_locations); diff --git a/contrib/llvm-project/lldb/source/Target/TargetProperties.td b/contrib/llvm-project/lldb/source/Target/TargetProperties.td index 154a6e5919ab..d2fccdb7b9b3 100644 --- a/contrib/llvm-project/lldb/source/Target/TargetProperties.td +++ b/contrib/llvm-project/lldb/source/Target/TargetProperties.td @@ -95,7 +95,7 @@ let Definition = "target" in { def MaxChildrenDepth: Property<"max-children-depth", "UInt64">, DefaultUnsignedValue<0xFFFFFFFF>, Desc<"Maximum depth to expand children.">; - def MaxSummaryLength: Property<"max-string-summary-length", "SInt64">, + def MaxSummaryLength: Property<"max-string-summary-length", "UInt64">, DefaultUnsignedValue<1024>, Desc<"Maximum number of characters to show when using %s in summary strings.">; def MaxMemReadSize: Property<"max-memory-read-size", "SInt64">, diff --git a/contrib/llvm-project/lldb/source/Target/Thread.cpp b/contrib/llvm-project/lldb/source/Target/Thread.cpp index 865cee97e6d8..8ae2179c1281 100644 --- a/contrib/llvm-project/lldb/source/Target/Thread.cpp +++ b/contrib/llvm-project/lldb/source/Target/Thread.cpp @@ -253,9 +253,11 @@ void Thread::DestroyThread() { } void Thread::BroadcastSelectedFrameChange(StackID &new_frame_id) { - if (EventTypeHasListeners(eBroadcastBitSelectedFrameChanged)) - BroadcastEvent(eBroadcastBitSelectedFrameChanged, - new ThreadEventData(this->shared_from_this(), new_frame_id)); + if (EventTypeHasListeners(eBroadcastBitSelectedFrameChanged)) { + auto data_sp = + std::make_shared<ThreadEventData>(shared_from_this(), new_frame_id); + BroadcastEvent(eBroadcastBitSelectedFrameChanged, data_sp); + } } lldb::StackFrameSP @@ -1507,9 +1509,10 @@ Status Thread::ReturnFromFrame(lldb::StackFrameSP frame_sp, if (copy_success) { thread->DiscardThreadPlans(true); thread->ClearStackFrames(); - if (broadcast && EventTypeHasListeners(eBroadcastBitStackChanged)) - BroadcastEvent(eBroadcastBitStackChanged, - new ThreadEventData(this->shared_from_this())); + if (broadcast && EventTypeHasListeners(eBroadcastBitStackChanged)) { + auto data_sp = std::make_shared<ThreadEventData>(shared_from_this()); + BroadcastEvent(eBroadcastBitStackChanged, data_sp); + } } else { return_error.SetErrorString("Could not reset register values."); } diff --git a/contrib/llvm-project/lldb/source/Target/ThreadList.cpp b/contrib/llvm-project/lldb/source/Target/ThreadList.cpp index 1ba0c435b993..03e8daedff12 100644 --- a/contrib/llvm-project/lldb/source/Target/ThreadList.cpp +++ b/contrib/llvm-project/lldb/source/Target/ThreadList.cpp @@ -726,10 +726,12 @@ bool ThreadList::SetSelectedThreadByIndexID(uint32_t index_id, bool notify) { void ThreadList::NotifySelectedThreadChanged(lldb::tid_t tid) { ThreadSP selected_thread_sp(FindThreadByID(tid)); if (selected_thread_sp->EventTypeHasListeners( - Thread::eBroadcastBitThreadSelected)) - selected_thread_sp->BroadcastEvent( - Thread::eBroadcastBitThreadSelected, - new Thread::ThreadEventData(selected_thread_sp)); + Thread::eBroadcastBitThreadSelected)) { + auto data_sp = + std::make_shared<Thread::ThreadEventData>(selected_thread_sp); + selected_thread_sp->BroadcastEvent(Thread::eBroadcastBitThreadSelected, + data_sp); + } } void ThreadList::Update(ThreadList &rhs) { diff --git a/contrib/llvm-project/lldb/source/Target/ThreadPlanStepOverRange.cpp b/contrib/llvm-project/lldb/source/Target/ThreadPlanStepOverRange.cpp index b1cb070e0a3d..84f282f1de52 100644 --- a/contrib/llvm-project/lldb/source/Target/ThreadPlanStepOverRange.cpp +++ b/contrib/llvm-project/lldb/source/Target/ThreadPlanStepOverRange.cpp @@ -220,8 +220,8 @@ bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) { StackFrameSP frame_sp = thread.GetStackFrameAtIndex(0); sc = frame_sp->GetSymbolContext(eSymbolContextEverything); if (sc.line_entry.IsValid()) { - if (sc.line_entry.original_file != - m_addr_context.line_entry.original_file && + if (*sc.line_entry.original_file_sp != + *m_addr_context.line_entry.original_file_sp && sc.comp_unit == m_addr_context.comp_unit && sc.function == m_addr_context.function) { // Okay, find the next occurrence of this file in the line table: @@ -244,8 +244,8 @@ bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) { LineEntry prev_line_entry; if (line_table->GetLineEntryAtIndex(entry_idx - 1, prev_line_entry) && - prev_line_entry.original_file == - line_entry.original_file) { + *prev_line_entry.original_file_sp == + *line_entry.original_file_sp) { SymbolContext prev_sc; Address prev_address = prev_line_entry.range.GetBaseAddress(); @@ -279,8 +279,8 @@ bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) { if (next_line_function != m_addr_context.function) break; - if (next_line_entry.original_file == - m_addr_context.line_entry.original_file) { + if (*next_line_entry.original_file_sp == + *m_addr_context.line_entry.original_file_sp) { const bool abort_other_plans = false; const RunMode stop_other_threads = RunMode::eAllThreads; lldb::addr_t cur_pc = thread.GetStackFrameAtIndex(0) diff --git a/contrib/llvm-project/lldb/source/Target/ThreadPlanStepRange.cpp b/contrib/llvm-project/lldb/source/Target/ThreadPlanStepRange.cpp index bb92adcae78b..998e76cb65d1 100644 --- a/contrib/llvm-project/lldb/source/Target/ThreadPlanStepRange.cpp +++ b/contrib/llvm-project/lldb/source/Target/ThreadPlanStepRange.cpp @@ -120,8 +120,8 @@ bool ThreadPlanStepRange::InRange() { frame->GetSymbolContext(eSymbolContextEverything)); if (m_addr_context.line_entry.IsValid() && new_context.line_entry.IsValid()) { - if (m_addr_context.line_entry.original_file == - new_context.line_entry.original_file) { + if (*m_addr_context.line_entry.original_file_sp == + *new_context.line_entry.original_file_sp) { if (m_addr_context.line_entry.line == new_context.line_entry.line) { m_addr_context = new_context; const bool include_inlined_functions = diff --git a/contrib/llvm-project/lldb/source/Utility/Broadcaster.cpp b/contrib/llvm-project/lldb/source/Utility/Broadcaster.cpp index 914812d78577..33cd49963e7c 100644 --- a/contrib/llvm-project/lldb/source/Utility/Broadcaster.cpp +++ b/contrib/llvm-project/lldb/source/Utility/Broadcaster.cpp @@ -300,9 +300,8 @@ void Broadcaster::BroadcasterImpl::PrivateBroadcastEvent(EventSP &event_sp, } } -void Broadcaster::BroadcasterImpl::BroadcastEvent(uint32_t event_type, - EventData *event_data) { - auto event_sp = std::make_shared<Event>(event_type, event_data); +void Broadcaster::BroadcasterImpl::BroadcastEvent(uint32_t event_type) { + auto event_sp = std::make_shared<Event>(event_type, /*data = */ nullptr); PrivateBroadcastEvent(event_sp, false); } diff --git a/contrib/llvm-project/lldb/source/Utility/FileSpec.cpp b/contrib/llvm-project/lldb/source/Utility/FileSpec.cpp index 5387be9a681f..4bebbc9ff175 100644 --- a/contrib/llvm-project/lldb/source/Utility/FileSpec.cpp +++ b/contrib/llvm-project/lldb/source/Utility/FileSpec.cpp @@ -68,9 +68,8 @@ void Denormalize(llvm::SmallVectorImpl<char> &path, FileSpec::Style style) { FileSpec::FileSpec() : m_style(GetNativeStyle()) {} // Default constructor that can take an optional full path to a file on disk. -FileSpec::FileSpec(llvm::StringRef path, Style style, const Checksum &checksum) - : m_checksum(checksum), m_style(style) { - SetFile(path, style, checksum); +FileSpec::FileSpec(llvm::StringRef path, Style style) : m_style(style) { + SetFile(path, style); } FileSpec::FileSpec(llvm::StringRef path, const llvm::Triple &triple) @@ -172,11 +171,9 @@ void FileSpec::SetFile(llvm::StringRef pathname) { SetFile(pathname, m_style); } // Update the contents of this object with a new path. The path will be split // up into a directory and filename and stored as uniqued string values for // quick comparison and efficient memory usage. -void FileSpec::SetFile(llvm::StringRef pathname, Style style, - const Checksum &checksum) { +void FileSpec::SetFile(llvm::StringRef pathname, Style style) { Clear(); m_style = (style == Style::native) ? GetNativeStyle() : style; - m_checksum = checksum; if (pathname.empty()) return; diff --git a/contrib/llvm-project/lldb/source/Utility/FileSpecList.cpp b/contrib/llvm-project/lldb/source/Utility/FileSpecList.cpp index 8d2cf81efe5b..7647e04a8204 100644 --- a/contrib/llvm-project/lldb/source/Utility/FileSpecList.cpp +++ b/contrib/llvm-project/lldb/source/Utility/FileSpecList.cpp @@ -41,7 +41,7 @@ bool FileSpecList::AppendIfUnique(const FileSpec &file_spec) { bool SupportFileList::AppendIfUnique(const FileSpec &file_spec) { collection::iterator end = m_files.end(); if (find_if(m_files.begin(), end, - [&](const std::unique_ptr<SupportFile> &support_file) { + [&](const std::shared_ptr<SupportFile> &support_file) { return support_file->GetSpecOnly() == file_spec; }) == end) { Append(file_spec); @@ -176,6 +176,13 @@ const FileSpec &SupportFileList::GetFileSpecAtIndex(size_t idx) const { return g_empty_file_spec; } +std::shared_ptr<SupportFile> +SupportFileList::GetSupportFileAtIndex(size_t idx) const { + if (idx < m_files.size()) + return m_files[idx]; + return {}; +} + // Return the size in bytes that this object takes in memory. This returns the // size in bytes of this object's member variables and any FileSpec objects its // member variables contain, the result doesn't not include the string values diff --git a/contrib/llvm-project/lldb/source/Utility/Stream.cpp b/contrib/llvm-project/lldb/source/Utility/Stream.cpp index 62e061e9d09c..89dce9fb0e1f 100644 --- a/contrib/llvm-project/lldb/source/Utility/Stream.cpp +++ b/contrib/llvm-project/lldb/source/Utility/Stream.cpp @@ -72,23 +72,20 @@ size_t Stream::PutCString(llvm::StringRef str) { return bytes_written; } -void Stream::PutCStringColorHighlighted(llvm::StringRef text, - llvm::StringRef pattern, - llvm::StringRef prefix, - llvm::StringRef suffix) { - // Only apply color formatting when a pattern is present and both prefix and - // suffix are specified. In the absence of these conditions, output the text - // without color formatting. - if (pattern.empty() || (prefix.empty() && suffix.empty())) { +void Stream::PutCStringColorHighlighted( + llvm::StringRef text, std::optional<HighlightSettings> pattern_info) { + // Only apply color formatting when a pattern information is specified. + // Otherwise, output the text without color formatting. + if (!pattern_info.has_value()) { PutCString(text); return; } - llvm::Regex reg_pattern(pattern); + llvm::Regex reg_pattern(pattern_info->pattern); llvm::SmallVector<llvm::StringRef, 1> matches; llvm::StringRef remaining = text; std::string format_str = lldb_private::ansi::FormatAnsiTerminalCodes( - prefix.str() + "%.*s" + suffix.str()); + pattern_info->prefix.str() + "%.*s" + pattern_info->suffix.str()); while (reg_pattern.match(remaining, &matches)) { llvm::StringRef match = matches[0]; size_t match_start_pos = match.data() - remaining.data(); diff --git a/contrib/llvm-project/lldb/source/Utility/XcodeSDK.cpp b/contrib/llvm-project/lldb/source/Utility/XcodeSDK.cpp index d744336373b2..712d611db28f 100644 --- a/contrib/llvm-project/lldb/source/Utility/XcodeSDK.cpp +++ b/contrib/llvm-project/lldb/source/Utility/XcodeSDK.cpp @@ -34,6 +34,10 @@ static llvm::StringRef GetName(XcodeSDK::Type type) { return "WatchSimulator"; case XcodeSDK::watchOS: return "WatchOS"; + case XcodeSDK::XRSimulator: + return "XRSimulator"; + case XcodeSDK::XROS: + return "XROS"; case XcodeSDK::bridgeOS: return "bridgeOS"; case XcodeSDK::Linux: @@ -75,6 +79,10 @@ static XcodeSDK::Type ParseSDKName(llvm::StringRef &name) { return XcodeSDK::WatchSimulator; if (name.consume_front("WatchOS")) return XcodeSDK::watchOS; + if (name.consume_front("XRSimulator")) + return XcodeSDK::XRSimulator; + if (name.consume_front("XROS")) + return XcodeSDK::XROS; if (name.consume_front("bridgeOS")) return XcodeSDK::bridgeOS; if (name.consume_front("Linux")) @@ -183,6 +191,12 @@ std::string XcodeSDK::GetCanonicalName(XcodeSDK::Info info) { case watchOS: name = "watchos"; break; + case XRSimulator: + name = "xrsimulator"; + break; + case XROS: + name = "xros"; + break; case bridgeOS: name = "bridgeos"; break; @@ -212,6 +226,9 @@ bool XcodeSDK::SDKSupportsModules(XcodeSDK::Type sdk_type, case Type::watchOS: case Type::WatchSimulator: return version >= llvm::VersionTuple(6); + case Type::XROS: + case Type::XRSimulator: + return true; default: return false; } @@ -233,6 +250,8 @@ bool XcodeSDK::SupportsSwift() const { case Type::WatchSimulator: case Type::watchOS: return info.version.empty() || info.version >= llvm::VersionTuple(2); + case Type::XROS: + case Type::XRSimulator: case Type::Linux: return true; default: @@ -276,6 +295,10 @@ XcodeSDK::Type XcodeSDK::GetSDKTypeForTriple(const llvm::Triple &triple) { if (triple.getEnvironment() == Triple::Simulator) return XcodeSDK::WatchSimulator; return XcodeSDK::watchOS; + case Triple::XROS: + if (triple.getEnvironment() == Triple::Simulator) + return XcodeSDK::XRSimulator; + return XcodeSDK::XROS; case Triple::Linux: return XcodeSDK::Linux; default: diff --git a/contrib/llvm-project/lldb/tools/driver/Driver.cpp b/contrib/llvm-project/lldb/tools/driver/Driver.cpp index f8058f868d53..c63ff0ff597e 100644 --- a/contrib/llvm-project/lldb/tools/driver/Driver.cpp +++ b/contrib/llvm-project/lldb/tools/driver/Driver.cpp @@ -18,6 +18,7 @@ #include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" #include "lldb/API/SBStructuredData.h" +#include "lldb/Host/Config.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Format.h" @@ -746,6 +747,8 @@ int main(int argc, char const *argv[]) { // Setup LLVM signal handlers and make sure we call llvm_shutdown() on // destruction. llvm::InitLLVM IL(argc, argv, /*InstallPipeSignalExitHandler=*/false); + llvm::setBugReportMsg("PLEASE submit a bug report to " LLDB_BUG_REPORT_URL + " and include the crash backtrace.\n"); // Parse arguments. LLDBOptTable T; diff --git a/contrib/llvm-project/lldb/tools/lldb-server/lldb-server.cpp b/contrib/llvm-project/lldb/tools/lldb-server/lldb-server.cpp index 1808ffc0c979..e2e6bfcd8645 100644 --- a/contrib/llvm-project/lldb/tools/lldb-server/lldb-server.cpp +++ b/contrib/llvm-project/lldb/tools/lldb-server/lldb-server.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "SystemInitializerLLGS.h" +#include "lldb/Host/Config.h" #include "lldb/Initialization/SystemLifetimeManager.h" #include "lldb/Version/Version.h" @@ -50,7 +51,8 @@ static void terminate_debugger() { g_debugger_lifetime->Terminate(); } // main int main(int argc, char *argv[]) { llvm::InitLLVM IL(argc, argv, /*InstallPipeSignalExitHandler=*/false); - llvm::PrettyStackTraceProgram X(argc, argv); + llvm::setBugReportMsg("PLEASE submit a bug report to " LLDB_BUG_REPORT_URL + " and include the crash backtrace.\n"); int option_error = 0; const char *progname = argv[0]; |