diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-07-01 13:24:58 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-07-01 13:24:58 +0000 |
commit | 1b306c26ade71504511d2fa75b03dfaee77f9620 (patch) | |
tree | 2c4c77af2ba9632c24ebf216b9a39989d74f5725 | |
parent | fdea456ad833fbab0d3a296a58250950f11a498c (diff) |
Vendor import of lldb trunk r306956:vendor/lldb/lldb-trunk-r306956
Notes
Notes:
svn path=/vendor/lldb/dist/; revision=320543
svn path=/vendor/lldb/lldb-trunk-r306956/; revision=320544; tag=vendor/lldb/lldb-trunk-r306956
204 files changed, 2330 insertions, 705 deletions
diff --git a/include/lldb/Breakpoint/Breakpoint.h b/include/lldb/Breakpoint/Breakpoint.h index 408647c3b5da..41241334dcf9 100644 --- a/include/lldb/Breakpoint/Breakpoint.h +++ b/include/lldb/Breakpoint/Breakpoint.h @@ -26,8 +26,8 @@ #include "lldb/Breakpoint/Stoppoint.h" #include "lldb/Core/Event.h" #include "lldb/Core/SearchFilter.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Utility/StringList.h" +#include "lldb/Utility/StructuredData.h" namespace lldb_private { diff --git a/include/lldb/Breakpoint/BreakpointOptions.h b/include/lldb/Breakpoint/BreakpointOptions.h index 4ed8469eba3d..420d5915fd44 100644 --- a/include/lldb/Breakpoint/BreakpointOptions.h +++ b/include/lldb/Breakpoint/BreakpointOptions.h @@ -17,9 +17,9 @@ // Other libraries and framework includes // Project includes -#include "lldb/Core/StructuredData.h" #include "lldb/Utility/Baton.h" #include "lldb/Utility/StringList.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/include/lldb/Core/Event.h b/include/lldb/Core/Event.h index 5d297a719e73..f4c7f4769a37 100644 --- a/include/lldb/Core/Event.h +++ b/include/lldb/Core/Event.h @@ -11,9 +11,9 @@ #define liblldb_Event_h_ #include "lldb/Core/Broadcaster.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Host/Predicate.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN #include "lldb/lldb-forward.h" // for EventDataSP, ProcessSP, Struct... diff --git a/include/lldb/Core/SearchFilter.h b/include/lldb/Core/SearchFilter.h index 06fb94d8fbdf..5861afc801cb 100644 --- a/include/lldb/Core/SearchFilter.h +++ b/include/lldb/Core/SearchFilter.h @@ -11,7 +11,7 @@ #define liblldb_SearchFilter_h_ #include "lldb/Core/FileSpecList.h" -#include "lldb/Core/StructuredData.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/Utility/FileSpec.h" // for FileSpec #include "lldb/lldb-forward.h" // for SearchFilterSP, TargetSP, Modu... diff --git a/include/lldb/Core/StructuredDataImpl.h b/include/lldb/Core/StructuredDataImpl.h index 92f0417b354a..819d1d9e5d2f 100644 --- a/include/lldb/Core/StructuredDataImpl.h +++ b/include/lldb/Core/StructuredDataImpl.h @@ -11,10 +11,10 @@ #define liblldb_StructuredDataImpl_h_ #include "lldb/Core/Event.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Target/StructuredDataPlugin.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" #include "llvm/ADT/StringRef.h" diff --git a/include/lldb/DataFormatters/TypeSummary.h b/include/lldb/DataFormatters/TypeSummary.h index a4d51b065480..1bde565aa5c8 100644 --- a/include/lldb/DataFormatters/TypeSummary.h +++ b/include/lldb/DataFormatters/TypeSummary.h @@ -24,8 +24,8 @@ #include "lldb/lldb-public.h" #include "lldb/Core/FormatEntity.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Utility/Status.h" +#include "lldb/Utility/StructuredData.h" namespace lldb_private { class TypeSummaryOptions { diff --git a/include/lldb/DataFormatters/TypeSynthetic.h b/include/lldb/DataFormatters/TypeSynthetic.h index 6f5a8df585b6..59fb6d3fcdbb 100644 --- a/include/lldb/DataFormatters/TypeSynthetic.h +++ b/include/lldb/DataFormatters/TypeSynthetic.h @@ -25,8 +25,8 @@ #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Core/ValueObject.h" +#include "lldb/Utility/StructuredData.h" namespace lldb_private { class SyntheticChildrenFrontEnd { diff --git a/include/lldb/Host/File.h b/include/lldb/Host/File.h index 560a655237f3..1dfa12ea593d 100644 --- a/include/lldb/Host/File.h +++ b/include/lldb/Host/File.h @@ -10,8 +10,8 @@ #ifndef liblldb_File_h_ #define liblldb_File_h_ -#include "lldb/Host/IOObject.h" #include "lldb/Host/PosixApi.h" +#include "lldb/Utility/IOObject.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Host/Host.h b/include/lldb/Host/Host.h index bf48e207f1f2..c41e4796f532 100644 --- a/include/lldb/Host/Host.h +++ b/include/lldb/Host/Host.h @@ -238,6 +238,9 @@ public: uint32_t line_no); static size_t GetEnvironment(StringList &env); + + static std::unique_ptr<Connection> + CreateDefaultConnection(llvm::StringRef url); }; } // namespace lldb_private diff --git a/include/lldb/Host/MainLoopBase.h b/include/lldb/Host/MainLoopBase.h index 39ca9a0f0c9e..a87d262e9452 100644 --- a/include/lldb/Host/MainLoopBase.h +++ b/include/lldb/Host/MainLoopBase.h @@ -10,12 +10,10 @@ #ifndef lldb_Host_posix_MainLoopBase_h_ #define lldb_Host_posix_MainLoopBase_h_ -#include <functional> - -#include "llvm/Support/ErrorHandling.h" - -#include "lldb/Host/IOObject.h" +#include "lldb/Utility/IOObject.h" #include "lldb/Utility/Status.h" +#include "llvm/Support/ErrorHandling.h" +#include <functional> namespace lldb_private { diff --git a/include/lldb/Host/Socket.h b/include/lldb/Host/Socket.h index c4233a233a89..37f468f23ce0 100644 --- a/include/lldb/Host/Socket.h +++ b/include/lldb/Host/Socket.h @@ -15,9 +15,9 @@ #include "lldb/lldb-private.h" -#include "lldb/Host/IOObject.h" #include "lldb/Host/Predicate.h" #include "lldb/Host/SocketAddress.h" +#include "lldb/Utility/IOObject.h" #include "lldb/Utility/Status.h" #ifdef _WIN32 diff --git a/include/lldb/Host/XML.h b/include/lldb/Host/XML.h index 04677625672c..96b5227305e1 100644 --- a/include/lldb/Host/XML.h +++ b/include/lldb/Host/XML.h @@ -24,8 +24,8 @@ #include "llvm/ADT/StringRef.h" // Project includes -#include "lldb/Core/StructuredData.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/include/lldb/Host/common/NativeProcessProtocol.h b/include/lldb/Host/common/NativeProcessProtocol.h index c43299a1df3d..a97540499cd3 100644 --- a/include/lldb/Host/common/NativeProcessProtocol.h +++ b/include/lldb/Host/common/NativeProcessProtocol.h @@ -10,10 +10,10 @@ #ifndef liblldb_NativeProcessProtocol_h_ #define liblldb_NativeProcessProtocol_h_ -#include "lldb/Core/TraceOptions.h" #include "lldb/Host/Host.h" #include "lldb/Host/MainLoop.h" #include "lldb/Utility/Status.h" +#include "lldb/Utility/TraceOptions.h" #include "lldb/lldb-private-forward.h" #include "lldb/lldb-types.h" #include "llvm/ADT/ArrayRef.h" @@ -333,7 +333,7 @@ public: //------------------------------------------------------------------ /// StopTracing API as the name suggests stops a tracing instance. /// - /// @param[in] uid + /// @param[in] traceid /// The user id of the trace intended to be stopped. Now a /// user_id may map to multiple threads in which case this API /// could be used to stop the tracing for a specific thread by @@ -346,7 +346,7 @@ public: /// @return /// Status indicating what went wrong. //------------------------------------------------------------------ - virtual Status StopTrace(lldb::user_id_t uid, + virtual Status StopTrace(lldb::user_id_t traceid, lldb::tid_t thread = LLDB_INVALID_THREAD_ID) { return Status("Not implemented"); } @@ -355,8 +355,8 @@ public: /// This API provides the trace data collected in the form of raw /// data. /// - /// @param[in] uid thread - /// The uid and thread provide the context for the trace + /// @param[in] traceid thread + /// The traceid and thread provide the context for the trace /// instance. /// /// @param[in] buffer @@ -372,7 +372,7 @@ public: /// @return /// The size of the data actually read. //------------------------------------------------------------------ - virtual Status GetData(lldb::user_id_t uid, lldb::tid_t thread, + virtual Status GetData(lldb::user_id_t traceid, lldb::tid_t thread, llvm::MutableArrayRef<uint8_t> &buffer, size_t offset = 0) { return Status("Not implemented"); @@ -382,7 +382,7 @@ public: /// Similar API as above except it aims to provide any extra data /// useful for decoding the actual trace data. //------------------------------------------------------------------ - virtual Status GetMetaData(lldb::user_id_t uid, lldb::tid_t thread, + virtual Status GetMetaData(lldb::user_id_t traceid, lldb::tid_t thread, llvm::MutableArrayRef<uint8_t> &buffer, size_t offset = 0) { return Status("Not implemented"); @@ -391,7 +391,7 @@ public: //------------------------------------------------------------------ /// API to query the TraceOptions for a given user id /// - /// @param[in] uid + /// @param[in] traceid /// The user id of the tracing instance. /// /// @param[in] config @@ -405,7 +405,7 @@ public: /// @param[out] config /// The actual configuration being used for tracing. //------------------------------------------------------------------ - virtual Status GetTraceConfig(lldb::user_id_t uid, TraceOptions &config) { + virtual Status GetTraceConfig(lldb::user_id_t traceid, TraceOptions &config) { return Status("Not implemented"); } diff --git a/include/lldb/Host/linux/Support.h b/include/lldb/Host/linux/Support.h index dae76c78fb4a..8415aa6c4320 100644 --- a/include/lldb/Host/linux/Support.h +++ b/include/lldb/Host/linux/Support.h @@ -22,6 +22,9 @@ getProcFile(::pid_t pid, ::pid_t tid, const llvm::Twine &file); llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> getProcFile(::pid_t pid, const llvm::Twine &file); +llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> +getProcFile(const llvm::Twine &file); + } // namespace lldb_private #endif // #ifndef LLDB_HOST_LINUX_SUPPORT_H diff --git a/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h b/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h index f57c93684002..b7e08eb33af7 100644 --- a/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h +++ b/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h @@ -19,10 +19,10 @@ // Other libraries and framework includes // Project includes -#include "lldb/Core/Connection.h" -#include "lldb/Host/IOObject.h" #include "lldb/Host/Pipe.h" #include "lldb/Host/Predicate.h" +#include "lldb/Utility/Connection.h" +#include "lldb/Utility/IOObject.h" namespace lldb_private { diff --git a/include/lldb/Host/windows/ConnectionGenericFileWindows.h b/include/lldb/Host/windows/ConnectionGenericFileWindows.h index 9309288b8c0a..5907ff16d9c3 100644 --- a/include/lldb/Host/windows/ConnectionGenericFileWindows.h +++ b/include/lldb/Host/windows/ConnectionGenericFileWindows.h @@ -10,8 +10,8 @@ #ifndef liblldb_Host_windows_ConnectionGenericFileWindows_h_ #define liblldb_Host_windows_ConnectionGenericFileWindows_h_ -#include "lldb/Core/Connection.h" #include "lldb/Host/windows/windows.h" +#include "lldb/Utility/Connection.h" #include "lldb/lldb-types.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/ScriptInterpreter.h b/include/lldb/Interpreter/ScriptInterpreter.h index 01b342ae41ca..335231cb29ec 100644 --- a/include/lldb/Interpreter/ScriptInterpreter.h +++ b/include/lldb/Interpreter/ScriptInterpreter.h @@ -19,8 +19,8 @@ #include "lldb/Breakpoint/BreakpointOptions.h" #include "lldb/Core/Broadcaster.h" #include "lldb/Core/PluginInterface.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Utility/Status.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/Host/PseudoTerminal.h" diff --git a/include/lldb/Symbol/DWARFCallFrameInfo.h b/include/lldb/Symbol/DWARFCallFrameInfo.h index 085def8ff0e5..a1bd1bc8b1c9 100644 --- a/include/lldb/Symbol/DWARFCallFrameInfo.h +++ b/include/lldb/Symbol/DWARFCallFrameInfo.h @@ -34,10 +34,11 @@ namespace lldb_private { class DWARFCallFrameInfo { public: - DWARFCallFrameInfo(ObjectFile &objfile, lldb::SectionSP §ion, - lldb::RegisterKind reg_kind, bool is_eh_frame); + enum Type { EH, DWARF }; - ~DWARFCallFrameInfo(); + DWARFCallFrameInfo(ObjectFile &objfile, lldb::SectionSP §ion, Type type); + + ~DWARFCallFrameInfo() = default; // Locate an AddressRange that includes the provided Address in this // object's eh_frame/debug_info @@ -74,12 +75,20 @@ public: private: enum { CFI_AUG_MAX_SIZE = 8, CFI_HEADER_SIZE = 8 }; + enum CFIVersion { + CFI_VERSION1 = 1, // DWARF v.2 + CFI_VERSION3 = 3, // DWARF v.3 + CFI_VERSION4 = 4 // DWARF v.4, v.5 + }; struct CIE { dw_offset_t cie_offset; uint8_t version; char augmentation[CFI_AUG_MAX_SIZE]; // This is typically empty or very // short. + uint8_t address_size = sizeof(uint32_t); // The size of a target address. + uint8_t segment_size = 0; // The size of a segment selector. + uint32_t code_align; int32_t data_align; uint32_t return_addr_reg_num; @@ -134,21 +143,24 @@ private: ObjectFile &m_objfile; lldb::SectionSP m_section_sp; - lldb::RegisterKind m_reg_kind; - Flags m_flags; + Flags m_flags = 0; cie_map_t m_cie_map; DataExtractor m_cfi_data; - bool m_cfi_data_initialized; // only copy the section into the DE once + bool m_cfi_data_initialized = false; // only copy the section into the DE once FDEEntryMap m_fde_index; - bool m_fde_index_initialized; // only scan the section for FDEs once + bool m_fde_index_initialized = false; // only scan the section for FDEs once std::mutex m_fde_index_mutex; // and isolate the thread that does it - bool m_is_eh_frame; + Type m_type; CIESP ParseCIE(const uint32_t cie_offset); + + lldb::RegisterKind GetRegisterKind() const { + return m_type == EH ? lldb::eRegisterKindEHFrame : lldb::eRegisterKindDWARF; + } }; } // namespace lldb_private diff --git a/include/lldb/Symbol/FuncUnwinders.h b/include/lldb/Symbol/FuncUnwinders.h index a5b9b801e033..64c222cce585 100644 --- a/include/lldb/Symbol/FuncUnwinders.h +++ b/include/lldb/Symbol/FuncUnwinders.h @@ -99,6 +99,13 @@ public: Thread &thread, int current_offset); + lldb::UnwindPlanSP GetDebugFrameUnwindPlan(Target &target, + int current_offset); + + lldb::UnwindPlanSP GetDebugFrameAugmentedUnwindPlan(Target &target, + Thread &thread, + int current_offset); + lldb::UnwindPlanSP GetCompactUnwindUnwindPlan(Target &target, int current_offset); @@ -126,10 +133,12 @@ private: lldb::UnwindPlanSP m_unwind_plan_assembly_sp; lldb::UnwindPlanSP m_unwind_plan_eh_frame_sp; - lldb::UnwindPlanSP m_unwind_plan_eh_frame_augmented_sp; // augmented by - // assembly inspection - // so it's valid - // everywhere + lldb::UnwindPlanSP m_unwind_plan_debug_frame_sp; + + // augmented by assembly inspection so it's valid everywhere + lldb::UnwindPlanSP m_unwind_plan_eh_frame_augmented_sp; + lldb::UnwindPlanSP m_unwind_plan_debug_frame_augmented_sp; + std::vector<lldb::UnwindPlanSP> m_unwind_plan_compact_unwind; lldb::UnwindPlanSP m_unwind_plan_arm_unwind_sp; lldb::UnwindPlanSP m_unwind_plan_fast_sp; @@ -139,7 +148,9 @@ private: // Fetching the UnwindPlans can be expensive - if we've already attempted // to get one & failed, don't try again. bool m_tried_unwind_plan_assembly : 1, m_tried_unwind_plan_eh_frame : 1, + m_tried_unwind_plan_debug_frame : 1, m_tried_unwind_plan_eh_frame_augmented : 1, + m_tried_unwind_plan_debug_frame_augmented : 1, m_tried_unwind_plan_compact_unwind : 1, m_tried_unwind_plan_arm_unwind : 1, m_tried_unwind_fast : 1, m_tried_unwind_arch_default : 1, diff --git a/include/lldb/Symbol/UnwindTable.h b/include/lldb/Symbol/UnwindTable.h index e730454b04d1..851d24bea03b 100644 --- a/include/lldb/Symbol/UnwindTable.h +++ b/include/lldb/Symbol/UnwindTable.h @@ -27,6 +27,7 @@ public: ~UnwindTable(); lldb_private::DWARFCallFrameInfo *GetEHFrameInfo(); + lldb_private::DWARFCallFrameInfo *GetDebugFrameInfo(); lldb_private::CompactUnwindInfo *GetCompactUnwindInfo(); @@ -58,6 +59,8 @@ private: void Dump(Stream &s); void Initialize(); + llvm::Optional<AddressRange> GetAddressRange(const Address &addr, + SymbolContext &sc); typedef std::map<lldb::addr_t, lldb::FuncUnwindersSP> collection; typedef collection::iterator iterator; @@ -70,6 +73,7 @@ private: std::mutex m_mutex; std::unique_ptr<DWARFCallFrameInfo> m_eh_frame_up; + std::unique_ptr<DWARFCallFrameInfo> m_debug_frame_up; std::unique_ptr<CompactUnwindInfo> m_compact_unwind_up; std::unique_ptr<ArmUnwindInfo> m_arm_unwind_up; diff --git a/include/lldb/Target/ABI.h b/include/lldb/Target/ABI.h index a8e08e1a800a..0418d683af63 100644 --- a/include/lldb/Target/ABI.h +++ b/include/lldb/Target/ABI.h @@ -92,6 +92,16 @@ protected: virtual lldb::ValueObjectSP GetReturnValueObjectImpl(Thread &thread, llvm::Type &ir_type) const; + //------------------------------------------------------------------ + /// Request to get a Process shared pointer. + /// + /// This ABI object may not have been created with a Process object, + /// or the Process object may no longer be alive. Be sure to handle + /// the case where the shared pointer returned does not have an + /// object inside it. + //------------------------------------------------------------------ + lldb::ProcessSP GetProcessSP() const { return m_process_wp.lock(); } + public: virtual bool CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) = 0; @@ -131,13 +141,18 @@ public: virtual bool GetPointerReturnRegister(const char *&name) { return false; } - static lldb::ABISP FindPlugin(const ArchSpec &arch); + static lldb::ABISP FindPlugin(lldb::ProcessSP process_sp, const ArchSpec &arch); protected: //------------------------------------------------------------------ // Classes that inherit from ABI can see and modify these //------------------------------------------------------------------ - ABI(); + ABI(lldb::ProcessSP process_sp) { + if (process_sp.get()) + m_process_wp = process_sp; + } + + lldb::ProcessWP m_process_wp; private: DISALLOW_COPY_AND_ASSIGN(ABI); diff --git a/include/lldb/Target/InstrumentationRuntime.h b/include/lldb/Target/InstrumentationRuntime.h index a40914d04ea9..21d66d5766a9 100644 --- a/include/lldb/Target/InstrumentationRuntime.h +++ b/include/lldb/Target/InstrumentationRuntime.h @@ -18,7 +18,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/PluginInterface.h" -#include "lldb/Core/StructuredData.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" #include "lldb/lldb-types.h" diff --git a/include/lldb/Target/InstrumentationRuntimeStopInfo.h b/include/lldb/Target/InstrumentationRuntimeStopInfo.h index 0a4a17003d93..b11231960ac1 100644 --- a/include/lldb/Target/InstrumentationRuntimeStopInfo.h +++ b/include/lldb/Target/InstrumentationRuntimeStopInfo.h @@ -16,8 +16,8 @@ // Other libraries and framework includes // Project includes -#include "lldb/Core/StructuredData.h" #include "lldb/Target/StopInfo.h" +#include "lldb/Utility/StructuredData.h" namespace lldb_private { diff --git a/include/lldb/Target/Process.h b/include/lldb/Target/Process.h index dbf6cba09f43..df09570057a1 100644 --- a/include/lldb/Target/Process.h +++ b/include/lldb/Target/Process.h @@ -34,9 +34,7 @@ #include "lldb/Core/Listener.h" #include "lldb/Core/LoadedModuleInfoList.h" #include "lldb/Core/PluginInterface.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Core/ThreadSafeValue.h" -#include "lldb/Core/TraceOptions.h" #include "lldb/Core/UserSettingsController.h" #include "lldb/Host/HostThread.h" #include "lldb/Host/ProcessRunLock.h" @@ -50,6 +48,8 @@ #include "lldb/Target/ThreadList.h" #include "lldb/Utility/NameMatches.h" #include "lldb/Utility/Status.h" +#include "lldb/Utility/StructuredData.h" +#include "lldb/Utility/TraceOptions.h" #include "lldb/lldb-private.h" #include "llvm/ADT/ArrayRef.h" diff --git a/include/lldb/Target/StopInfo.h b/include/lldb/Target/StopInfo.h index 46f34567350d..c99877cbd8ab 100644 --- a/include/lldb/Target/StopInfo.h +++ b/include/lldb/Target/StopInfo.h @@ -16,8 +16,8 @@ // Other libraries and framework includes // Project includes -#include "lldb/Core/StructuredData.h" #include "lldb/Target/Process.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-public.h" namespace lldb_private { diff --git a/include/lldb/Target/StructuredDataPlugin.h b/include/lldb/Target/StructuredDataPlugin.h index a4d2c0382628..5ea265b05420 100644 --- a/include/lldb/Target/StructuredDataPlugin.h +++ b/include/lldb/Target/StructuredDataPlugin.h @@ -11,7 +11,7 @@ #define StructuredDataPlugin_h #include "lldb/Core/PluginInterface.h" -#include "lldb/Core/StructuredData.h" +#include "lldb/Utility/StructuredData.h" namespace lldb_private { diff --git a/include/lldb/Target/SystemRuntime.h b/include/lldb/Target/SystemRuntime.h index f50c9c1b4a56..8c6c2ece967f 100644 --- a/include/lldb/Target/SystemRuntime.h +++ b/include/lldb/Target/SystemRuntime.h @@ -18,10 +18,10 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/PluginInterface.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Target/QueueItem.h" #include "lldb/Target/QueueList.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-private.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/Target/Thread.h b/include/lldb/Target/Thread.h index 954347b5814c..1b0b6ef557e8 100644 --- a/include/lldb/Target/Thread.h +++ b/include/lldb/Target/Thread.h @@ -21,11 +21,11 @@ // Project includes #include "lldb/Core/Broadcaster.h" #include "lldb/Core/Event.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Core/UserSettingsController.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/RegisterCheckpoint.h" #include "lldb/Target/StackFrameList.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/Utility/UserID.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/ThreadPlanPython.h b/include/lldb/Target/ThreadPlanPython.h index 9b7e5d029912..973c935b7c79 100644 --- a/include/lldb/Target/ThreadPlanPython.h +++ b/include/lldb/Target/ThreadPlanPython.h @@ -17,13 +17,13 @@ // Other libraries and framework includes // Project includes -#include "lldb/Core/StructuredData.h" #include "lldb/Target/Process.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" #include "lldb/Target/ThreadPlanTracer.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/Utility/UserID.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/ThreadSpec.h b/include/lldb/Target/ThreadSpec.h index d00172d1763b..34baf8046261 100644 --- a/include/lldb/Target/ThreadSpec.h +++ b/include/lldb/Target/ThreadSpec.h @@ -10,13 +10,9 @@ #ifndef liblldb_ThreadSpec_h_ #define liblldb_ThreadSpec_h_ -// C Includes -// C++ Includes -#include <string> - -// Other libraries and framework includes -// Project includes +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-private.h" +#include <string> namespace lldb_private { diff --git a/include/lldb/Core/Connection.h b/include/lldb/Utility/Connection.h index 27757b2f77e7..be5641d5fa63 100644 --- a/include/lldb/Core/Connection.h +++ b/include/lldb/Utility/Connection.h @@ -31,7 +31,7 @@ template <typename Ratio> class Timeout; namespace lldb_private { //---------------------------------------------------------------------- -/// @class Connection Connection.h "lldb/Core/Connection.h" +/// @class Connection Connection.h "lldb/Utility/Connection.h" /// @brief A communication connection class. /// /// A class that implements that actual communication functions for @@ -48,7 +48,7 @@ public: //------------------------------------------------------------------ /// Default constructor //------------------------------------------------------------------ - Connection(); + Connection() = default; //------------------------------------------------------------------ /// Virtual destructor since this class gets subclassed and handed @@ -56,8 +56,6 @@ public: //------------------------------------------------------------------ virtual ~Connection(); - static Connection *CreateDefaultConnection(const char *url); - //------------------------------------------------------------------ /// Connect using the connect string \a url. /// diff --git a/include/lldb/Host/IOObject.h b/include/lldb/Utility/IOObject.h index 98ad5056de74..61f288183850 100644 --- a/include/lldb/Host/IOObject.h +++ b/include/lldb/Utility/IOObject.h @@ -32,7 +32,7 @@ public: IOObject(FDType type, bool should_close) : m_fd_type(type), m_should_close_fd(should_close) {} - virtual ~IOObject() {} + virtual ~IOObject(); virtual Status Read(void *buf, size_t &num_bytes) = 0; virtual Status Write(const void *buf, size_t &num_bytes) = 0; @@ -51,6 +51,6 @@ protected: private: DISALLOW_COPY_AND_ASSIGN(IOObject); }; -} +} // namespace lldb_private #endif diff --git a/include/lldb/Utility/JSON.h b/include/lldb/Utility/JSON.h index bf8ed9afc008..8bf9c4b37b02 100644 --- a/include/lldb/Utility/JSON.h +++ b/include/lldb/Utility/JSON.h @@ -269,7 +269,7 @@ public: EndOfFile }; - JSONParser(const char *cstr); + JSONParser(llvm::StringRef data); int GetEscapedChar(bool &was_escaped); diff --git a/include/lldb/Core/StructuredData.h b/include/lldb/Utility/StructuredData.h index 39c2f04bb382..2ea5fb98e055 100644 --- a/include/lldb/Core/StructuredData.h +++ b/include/lldb/Utility/StructuredData.h @@ -16,6 +16,9 @@ #include "lldb/Utility/FileSpec.h" // for FileSpec #include "lldb/lldb-enumerations.h" // for StructuredDataType +#include <cassert> // for assert +#include <cstddef> // for size_t +#include <cstdint> // for uint64_t #include <functional> #include <map> #include <memory> @@ -24,10 +27,6 @@ #include <utility> #include <vector> -#include <assert.h> // for assert -#include <stddef.h> // for size_t -#include <stdint.h> // for uint64_t - namespace lldb_private { class Status; } @@ -38,7 +37,7 @@ class Stream; namespace lldb_private { //---------------------------------------------------------------------- -/// @class StructuredData StructuredData.h "lldb/Core/StructuredData.h" +/// @class StructuredData StructuredData.h "lldb/Utility/StructuredData.h" /// @brief A class which can hold structured data /// /// The StructuredData class is designed to hold the data from a JSON @@ -94,10 +93,9 @@ public: } Dictionary *GetAsDictionary() { - return ( - (m_type == lldb::eStructuredDataTypeDictionary) - ? static_cast<Dictionary *>(this) - : nullptr); + return ((m_type == lldb::eStructuredDataTypeDictionary) + ? static_cast<Dictionary *>(this) + : nullptr); } Integer *GetAsInteger() { @@ -302,8 +300,8 @@ public: class Float : public Object { public: - Float(double d = 0.0) : Object(lldb::eStructuredDataTypeFloat), - m_value(d) {} + Float(double d = 0.0) + : Object(lldb::eStructuredDataTypeFloat), m_value(d) {} ~Float() override = default; @@ -319,8 +317,8 @@ public: class Boolean : public Object { public: - Boolean(bool b = false) : Object(lldb::eStructuredDataTypeBoolean), - m_value(b) {} + Boolean(bool b = false) + : Object(lldb::eStructuredDataTypeBoolean), m_value(b) {} ~Boolean() override = default; @@ -338,8 +336,7 @@ public: public: String() : Object(lldb::eStructuredDataTypeString) {} explicit String(llvm::StringRef S) - : Object(lldb::eStructuredDataTypeString), - m_value(S) {} + : Object(lldb::eStructuredDataTypeString), m_value(S) {} void SetValue(llvm::StringRef S) { m_value = S; } @@ -353,8 +350,7 @@ public: class Dictionary : public Object { public: - Dictionary() : Object(lldb::eStructuredDataTypeDictionary), - m_dict() {} + Dictionary() : Object(lldb::eStructuredDataTypeDictionary), m_dict() {} ~Dictionary() override = default; diff --git a/include/lldb/Core/Timer.h b/include/lldb/Utility/Timer.h index 55aab193032e..c06ac17d344d 100644 --- a/include/lldb/Core/Timer.h +++ b/include/lldb/Utility/Timer.h @@ -12,27 +12,15 @@ #include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN #include "llvm/Support/Chrono.h" - #include <atomic> - #include <stdint.h> // for uint32_t namespace lldb_private { class Stream; -} - -namespace lldb_private { //---------------------------------------------------------------------- -/// @class Timer Timer.h "lldb/Core/Timer.h" +/// @class Timer Timer.h "lldb/Utility/Timer.h" /// @brief A timer class that simplifies common timing metrics. -/// -/// A scoped timer class that allows a variety of pthread mutex -/// objects to have a mutex locked when a Timer::Locker -/// object is created, and unlocked when it goes out of scope or -/// when the Timer::Locker::Reset(pthread_mutex_t *) -/// is called. This provides an exception safe way to lock a mutex -/// in a scope. //---------------------------------------------------------------------- class Timer { diff --git a/include/lldb/Core/TraceOptions.h b/include/lldb/Utility/TraceOptions.h index 91f48915c94b..325ff74e6f55 100644 --- a/include/lldb/Core/TraceOptions.h +++ b/include/lldb/Utility/TraceOptions.h @@ -13,7 +13,7 @@ #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" -#include "lldb/Core/StructuredData.h" +#include "lldb/Utility/StructuredData.h" namespace lldb_private { class TraceOptions { diff --git a/include/lldb/lldb-enumerations.h b/include/lldb/lldb-enumerations.h index 3c60873f6796..14bae6ca206d 100644 --- a/include/lldb/lldb-enumerations.h +++ b/include/lldb/lldb-enumerations.h @@ -456,6 +456,7 @@ enum InstrumentationRuntimeType { eInstrumentationRuntimeTypeThreadSanitizer = 0x0001, eInstrumentationRuntimeTypeUndefinedBehaviorSanitizer = 0x0002, eInstrumentationRuntimeTypeMainThreadChecker = 0x0003, + eInstrumentationRuntimeTypeSwiftRuntimeReporting = 0x0004, eNumInstrumentationRuntimeTypes }; diff --git a/include/lldb/lldb-private-interfaces.h b/include/lldb/lldb-private-interfaces.h index 9f25eb1f9a29..806068ece7b6 100644 --- a/include/lldb/lldb-private-interfaces.h +++ b/include/lldb/lldb-private-interfaces.h @@ -21,7 +21,7 @@ #include <set> namespace lldb_private { -typedef lldb::ABISP (*ABICreateInstance)(const ArchSpec &arch); +typedef lldb::ABISP (*ABICreateInstance)(lldb::ProcessSP process_sp, const ArchSpec &arch); typedef Disassembler *(*DisassemblerCreateInstance)(const ArchSpec &arch, const char *flavor); typedef DynamicLoader *(*DynamicLoaderCreateInstance)(Process *process, diff --git a/lldb.xcodeproj/project.pbxproj b/lldb.xcodeproj/project.pbxproj index f4c5c7a0e842..8c59fc888412 100644 --- a/lldb.xcodeproj/project.pbxproj +++ b/lldb.xcodeproj/project.pbxproj @@ -744,7 +744,7 @@ 4CF3D80C15AF4DC800845BF3 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDB919B414F6F10D008FF64B /* Security.framework */; }; 4CF52AF51428291E0051E832 /* SBFileSpecList.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CF52AF41428291E0051E832 /* SBFileSpecList.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4CF52AF8142829390051E832 /* SBFileSpecList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CF52AF7142829390051E832 /* SBFileSpecList.cpp */; }; - 54067BF11DF2041B00749AA5 /* UndefinedBehaviorSanitizerRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 54067BEC1DF2034B00749AA5 /* UndefinedBehaviorSanitizerRuntime.cpp */; }; + 54067BF11DF2041B00749AA5 /* UBSanRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 54067BEC1DF2034B00749AA5 /* UBSanRuntime.cpp */; }; 6D0F61431C80AAAE00A4ECEE /* JavaASTContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D0F61411C80AAAA00A4ECEE /* JavaASTContext.cpp */; }; 6D0F61481C80AAD600A4ECEE /* DWARFASTParserJava.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D0F61441C80AACF00A4ECEE /* DWARFASTParserJava.cpp */; }; 6D0F614E1C80AB0700A4ECEE /* JavaLanguageRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D0F614A1C80AB0400A4ECEE /* JavaLanguageRuntime.cpp */; }; @@ -764,7 +764,7 @@ 6D99A3631BBC2F3200979793 /* ArmUnwindInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D99A3621BBC2F3200979793 /* ArmUnwindInfo.cpp */; }; 6D9AB3DD1BB2B74E003F2289 /* TypeMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D9AB3DC1BB2B74E003F2289 /* TypeMap.cpp */; }; 6DEC6F391BD66D750091ABA6 /* TaskPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6DEC6F381BD66D750091ABA6 /* TaskPool.cpp */; }; - 8C26C4261C3EA5F90031DF7C /* ThreadSanitizerRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C26C4241C3EA4340031DF7C /* ThreadSanitizerRuntime.cpp */; }; + 8C26C4261C3EA5F90031DF7C /* TSanRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C26C4241C3EA4340031DF7C /* TSanRuntime.cpp */; }; 8C2D6A53197A1EAF006989C9 /* MemoryHistory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C2D6A52197A1EAF006989C9 /* MemoryHistory.cpp */; }; 8C2D6A5E197A250F006989C9 /* MemoryHistoryASan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C2D6A5A197A1FDC006989C9 /* MemoryHistoryASan.cpp */; }; 8C3BD9961EF45DA50016C343 /* MainThreadCheckerRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C3BD9951EF45D9B0016C343 /* MainThreadCheckerRuntime.cpp */; }; @@ -772,7 +772,7 @@ 8CCB018219BA4E270009FD44 /* SBThreadCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 8CCB018119BA4E210009FD44 /* SBThreadCollection.h */; settings = {ATTRIBUTES = (Public, ); }; }; 8CCB018319BA51BF0009FD44 /* SBThreadCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CCB017F19BA4DD00009FD44 /* SBThreadCollection.cpp */; }; 8CF02AE919DCC01900B14BE0 /* InstrumentationRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CF02ADF19DCBF3B00B14BE0 /* InstrumentationRuntime.cpp */; }; - 8CF02AEA19DCC02100B14BE0 /* AddressSanitizerRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CF02AE519DCBF8400B14BE0 /* AddressSanitizerRuntime.cpp */; }; + 8CF02AEA19DCC02100B14BE0 /* ASanRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CF02AE519DCBF8400B14BE0 /* ASanRuntime.cpp */; }; 8CF02AEF19DD16B100B14BE0 /* InstrumentationRuntimeStopInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CF02AED19DD15CF00B14BE0 /* InstrumentationRuntimeStopInfo.cpp */; }; 9404957A1BEC497E00926025 /* NSError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 940495781BEC497E00926025 /* NSError.cpp */; }; 9404957B1BEC497E00926025 /* NSException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 940495791BEC497E00926025 /* NSException.cpp */; }; @@ -1262,9 +1262,9 @@ 236102991CF38A2B00B8E0B9 /* LLDBConfig.cmake */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LLDBConfig.cmake; sourceTree = "<group>"; }; 2361029A1CF38A2B00B8E0B9 /* LLDBStandalone.cmake */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LLDBStandalone.cmake; sourceTree = "<group>"; }; 2361029E1CF38A3500B8E0B9 /* Android.cmake */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Android.cmake; sourceTree = "<group>"; }; - 236124A21986B4E2004EFC37 /* IOObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IOObject.cpp; sourceTree = "<group>"; }; + 236124A21986B4E2004EFC37 /* IOObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IOObject.cpp; path = source/Utility/IOObject.cpp; sourceTree = "<group>"; }; 236124A31986B4E2004EFC37 /* Socket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Socket.cpp; sourceTree = "<group>"; }; - 236124A61986B50E004EFC37 /* IOObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = IOObject.h; path = include/lldb/Host/IOObject.h; sourceTree = "<group>"; }; + 236124A61986B50E004EFC37 /* IOObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = IOObject.h; path = include/lldb/Utility/IOObject.h; sourceTree = "<group>"; }; 236124A71986B50E004EFC37 /* Socket.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Socket.h; path = include/lldb/Host/Socket.h; sourceTree = "<group>"; }; 2370A37A1D66C57B000E7BE6 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; }; 2370A37C1D66C587000E7BE6 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; }; @@ -1606,7 +1606,6 @@ 264334381110F63100CDB6C6 /* ValueObjectRegister.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectRegister.cpp; path = source/Core/ValueObjectRegister.cpp; sourceTree = "<group>"; }; 2643343A1110F63C00CDB6C6 /* ValueObjectRegister.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObjectRegister.h; path = include/lldb/Core/ValueObjectRegister.h; sourceTree = "<group>"; }; 264723A511FA076E00DE380C /* CleanUp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CleanUp.h; path = include/lldb/Utility/CleanUp.h; sourceTree = "<group>"; }; - 26474C9E18D0CAEC0073DEBA /* RegisterContext_mips64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContext_mips64.h; path = Utility/RegisterContext_mips64.h; sourceTree = "<group>"; }; 26474C9F18D0CAEC0073DEBA /* RegisterContext_x86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContext_x86.h; path = Utility/RegisterContext_x86.h; sourceTree = "<group>"; }; 26474CA218D0CB070073DEBA /* RegisterContextFreeBSD_i386.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextFreeBSD_i386.cpp; path = Utility/RegisterContextFreeBSD_i386.cpp; sourceTree = "<group>"; }; 26474CA318D0CB070073DEBA /* RegisterContextFreeBSD_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextFreeBSD_i386.h; path = Utility/RegisterContextFreeBSD_i386.h; sourceTree = "<group>"; }; @@ -1630,7 +1629,7 @@ 26474CC518D0CB5B0073DEBA /* RegisterContextPOSIX_mips64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextPOSIX_mips64.h; path = Utility/RegisterContextPOSIX_mips64.h; sourceTree = "<group>"; }; 26474CC618D0CB5B0073DEBA /* RegisterContextPOSIX_x86.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextPOSIX_x86.cpp; path = Utility/RegisterContextPOSIX_x86.cpp; sourceTree = "<group>"; }; 26474CC718D0CB5B0073DEBA /* RegisterContextPOSIX_x86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextPOSIX_x86.h; path = Utility/RegisterContextPOSIX_x86.h; sourceTree = "<group>"; }; - 26474CC818D0CB5B0073DEBA /* RegisterContextPOSIX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextPOSIX.h; path = Utility/RegisterContextPOSIX.h; sourceTree = "<group>"; }; + 26474CC818D0CB5B0073DEBA /* RegisterContextPOSIX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterContextPOSIX.h; sourceTree = "<group>"; }; 26474CD018D0CB700073DEBA /* RegisterInfos_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterInfos_i386.h; path = Utility/RegisterInfos_i386.h; sourceTree = "<group>"; }; 26474CD118D0CB710073DEBA /* RegisterInfos_mips64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterInfos_mips64.h; path = Utility/RegisterInfos_mips64.h; sourceTree = "<group>"; }; 26474CD218D0CB710073DEBA /* RegisterInfos_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterInfos_x86_64.h; path = Utility/RegisterInfos_x86_64.h; sourceTree = "<group>"; }; @@ -1871,11 +1870,9 @@ 267A47F41B1411750021A5BC /* NativeBreakpointList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NativeBreakpointList.h; path = include/lldb/Host/common/NativeBreakpointList.h; sourceTree = "<group>"; }; 267A47F51B14117F0021A5BC /* NativeProcessProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NativeProcessProtocol.h; path = include/lldb/Host/common/NativeProcessProtocol.h; sourceTree = "<group>"; }; 267A47F61B14118F0021A5BC /* NativeRegisterContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NativeRegisterContext.h; path = include/lldb/Host/common/NativeRegisterContext.h; sourceTree = "<group>"; }; - 267A47F71B14119A0021A5BC /* NativeRegisterContextRegisterInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NativeRegisterContextRegisterInfo.h; path = include/lldb/Host/common/NativeRegisterContextRegisterInfo.h; sourceTree = "<group>"; }; 267A47F81B1411A40021A5BC /* NativeThreadProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NativeThreadProtocol.h; path = include/lldb/Host/common/NativeThreadProtocol.h; sourceTree = "<group>"; }; 267A47F91B1411AC0021A5BC /* NativeWatchpointList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NativeWatchpointList.h; path = include/lldb/Host/common/NativeWatchpointList.h; sourceTree = "<group>"; }; 267A47FA1B1411C40021A5BC /* NativeRegisterContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NativeRegisterContext.cpp; path = source/Host/common/NativeRegisterContext.cpp; sourceTree = "<group>"; }; - 267A47FC1B1411CC0021A5BC /* NativeRegisterContextRegisterInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NativeRegisterContextRegisterInfo.cpp; path = source/Host/common/NativeRegisterContextRegisterInfo.cpp; sourceTree = "<group>"; }; 267A47FE1B1411D90021A5BC /* NativeWatchpointList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NativeWatchpointList.cpp; path = source/Host/common/NativeWatchpointList.cpp; sourceTree = "<group>"; }; 267A48001B1411E40021A5BC /* XML.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = XML.cpp; path = source/Host/common/XML.cpp; sourceTree = "<group>"; }; 267A48031B1416080021A5BC /* XML.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = XML.h; path = include/lldb/Host/XML.h; sourceTree = "<group>"; }; @@ -2051,7 +2048,7 @@ 26BC7D5410F1B77400F91463 /* Broadcaster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Broadcaster.h; path = include/lldb/Core/Broadcaster.h; sourceTree = "<group>"; }; 26BC7D5510F1B77400F91463 /* ClangForward.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangForward.h; path = include/lldb/Core/ClangForward.h; sourceTree = "<group>"; }; 26BC7D5610F1B77400F91463 /* Communication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Communication.h; path = include/lldb/Core/Communication.h; sourceTree = "<group>"; }; - 26BC7D5710F1B77400F91463 /* Connection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Connection.h; path = include/lldb/Core/Connection.h; sourceTree = "<group>"; }; + 26BC7D5710F1B77400F91463 /* Connection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Connection.h; path = include/lldb/Utility/Connection.h; sourceTree = "<group>"; }; 26BC7D5E10F1B77400F91463 /* Disassembler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Disassembler.h; path = include/lldb/Core/Disassembler.h; sourceTree = "<group>"; }; 26BC7D5F10F1B77400F91463 /* dwarf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = dwarf.h; path = include/lldb/Core/dwarf.h; sourceTree = "<group>"; }; 26BC7D6110F1B77400F91463 /* Event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Event.h; path = include/lldb/Core/Event.h; sourceTree = "<group>"; }; @@ -2072,7 +2069,7 @@ 26BC7D7710F1B77400F91463 /* State.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = State.h; path = include/lldb/Core/State.h; sourceTree = "<group>"; }; 26BC7D7810F1B77400F91463 /* STLUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STLUtils.h; path = include/lldb/Core/STLUtils.h; sourceTree = "<group>"; }; 26BC7D7A10F1B77400F91463 /* StreamFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StreamFile.h; path = include/lldb/Core/StreamFile.h; sourceTree = "<group>"; }; - 26BC7D7E10F1B77400F91463 /* Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Timer.h; path = include/lldb/Core/Timer.h; sourceTree = "<group>"; }; + 26BC7D7E10F1B77400F91463 /* Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Timer.h; path = include/lldb/Utility/Timer.h; sourceTree = "<group>"; }; 26BC7D8110F1B77400F91463 /* Value.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Value.h; path = include/lldb/Core/Value.h; sourceTree = "<group>"; }; 26BC7D8210F1B77400F91463 /* ValueObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObject.h; path = include/lldb/Core/ValueObject.h; sourceTree = "<group>"; }; 26BC7D8310F1B77400F91463 /* ValueObjectChild.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObjectChild.h; path = include/lldb/Core/ValueObjectChild.h; sourceTree = "<group>"; }; @@ -2080,7 +2077,7 @@ 26BC7D8510F1B77400F91463 /* ValueObjectVariable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObjectVariable.h; path = include/lldb/Core/ValueObjectVariable.h; sourceTree = "<group>"; }; 26BC7DC010F1B79500F91463 /* ClangExpressionHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangExpressionHelper.h; path = ExpressionParser/Clang/ClangExpressionHelper.h; sourceTree = "<group>"; }; 26BC7DC310F1B79500F91463 /* DWARFExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DWARFExpression.h; path = include/lldb/Expression/DWARFExpression.h; sourceTree = "<group>"; }; - 26BC7DD310F1B7D500F91463 /* Endian.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Endian.h; path = include/lldb/Host/Endian.h; sourceTree = "<group>"; }; + 26BC7DD310F1B7D500F91463 /* Endian.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Endian.h; path = include/lldb/Utility/Endian.h; sourceTree = "<group>"; }; 26BC7DD410F1B7D500F91463 /* Host.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Host.h; path = include/lldb/Host/Host.h; sourceTree = "<group>"; }; 26BC7DD610F1B7D500F91463 /* Predicate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Predicate.h; path = include/lldb/Host/Predicate.h; sourceTree = "<group>"; }; 26BC7DE210F1B7F900F91463 /* CommandInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandInterpreter.h; path = include/lldb/Interpreter/CommandInterpreter.h; sourceTree = "<group>"; }; @@ -2134,7 +2131,7 @@ 26BC7E6C10F1B85900F91463 /* Args.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Args.cpp; path = source/Interpreter/Args.cpp; sourceTree = "<group>"; }; 26BC7E6D10F1B85900F91463 /* Broadcaster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Broadcaster.cpp; path = source/Core/Broadcaster.cpp; sourceTree = "<group>"; }; 26BC7E6E10F1B85900F91463 /* Communication.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Communication.cpp; path = source/Core/Communication.cpp; sourceTree = "<group>"; }; - 26BC7E6F10F1B85900F91463 /* Connection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Connection.cpp; path = source/Core/Connection.cpp; sourceTree = "<group>"; }; + 26BC7E6F10F1B85900F91463 /* Connection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Connection.cpp; path = source/Utility/Connection.cpp; sourceTree = "<group>"; }; 26BC7E7410F1B85900F91463 /* lldb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lldb.cpp; path = source/lldb.cpp; sourceTree = "<group>"; }; 26BC7E7610F1B85900F91463 /* Disassembler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Disassembler.cpp; path = source/Core/Disassembler.cpp; sourceTree = "<group>"; }; 26BC7E7710F1B85900F91463 /* DynamicLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DynamicLoader.cpp; path = source/Core/DynamicLoader.cpp; sourceTree = "<group>"; }; @@ -2153,7 +2150,7 @@ 26BC7E8F10F1B85900F91463 /* SourceManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SourceManager.cpp; path = source/Core/SourceManager.cpp; sourceTree = "<group>"; }; 26BC7E9010F1B85900F91463 /* State.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = State.cpp; path = source/Core/State.cpp; sourceTree = "<group>"; }; 26BC7E9210F1B85900F91463 /* StreamFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StreamFile.cpp; path = source/Core/StreamFile.cpp; sourceTree = "<group>"; }; - 26BC7E9610F1B85900F91463 /* Timer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Timer.cpp; path = source/Core/Timer.cpp; sourceTree = "<group>"; }; + 26BC7E9610F1B85900F91463 /* Timer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Timer.cpp; path = source/Utility/Timer.cpp; sourceTree = "<group>"; }; 26BC7E9910F1B85900F91463 /* Value.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Value.cpp; path = source/Core/Value.cpp; sourceTree = "<group>"; }; 26BC7E9A10F1B85900F91463 /* ValueObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObject.cpp; path = source/Core/ValueObject.cpp; sourceTree = "<group>"; }; 26BC7E9B10F1B85900F91463 /* ValueObjectChild.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectChild.cpp; path = source/Core/ValueObjectChild.cpp; sourceTree = "<group>"; }; @@ -2302,7 +2299,7 @@ 26EFC4CB18CFAF0D00865D87 /* ObjectFileJIT.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectFileJIT.h; sourceTree = "<group>"; }; 26F006541B4DD86700B872E5 /* DynamicLoaderWindowsDYLD.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicLoaderWindowsDYLD.cpp; sourceTree = "<group>"; }; 26F006551B4DD86700B872E5 /* DynamicLoaderWindowsDYLD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynamicLoaderWindowsDYLD.h; sourceTree = "<group>"; }; - 26F2F8FD1B156678007857DE /* StructuredData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StructuredData.h; path = include/lldb/Core/StructuredData.h; sourceTree = "<group>"; }; + 26F2F8FD1B156678007857DE /* StructuredData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StructuredData.h; path = include/lldb/Utility/StructuredData.h; sourceTree = "<group>"; }; 26F4A21A13FBA31A0064B613 /* ThreadMemory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadMemory.cpp; path = Utility/ThreadMemory.cpp; sourceTree = "<group>"; }; 26F4A21B13FBA31A0064B613 /* ThreadMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadMemory.h; path = Utility/ThreadMemory.h; sourceTree = "<group>"; }; 26F5C26A10F3D9A4009D5894 /* lldb */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lldb; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -2385,7 +2382,6 @@ 3FDFE56319AF9B77009756A7 /* Config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Config.h; path = include/lldb/Host/linux/Config.h; sourceTree = SOURCE_ROOT; }; 3FDFE56419AF9B77009756A7 /* HostInfoLinux.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostInfoLinux.h; path = include/lldb/Host/linux/HostInfoLinux.h; sourceTree = SOURCE_ROOT; }; 3FDFE56519AF9B77009756A7 /* HostThreadLinux.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HostThreadLinux.h; path = include/lldb/Host/linux/HostThreadLinux.h; sourceTree = SOURCE_ROOT; }; - 3FDFE56619AF9BB2009756A7 /* Config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Config.h; path = include/lldb/Host/macosx/Config.h; sourceTree = "<group>"; }; 3FDFE56719AF9BB2009756A7 /* HostThreadMacOSX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HostThreadMacOSX.h; path = include/lldb/Host/macosx/HostThreadMacOSX.h; sourceTree = "<group>"; }; 3FDFE56A19AF9C44009756A7 /* HostProcessPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HostProcessPosix.cpp; sourceTree = "<group>"; }; 3FDFE56B19AF9C44009756A7 /* HostThreadPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HostThreadPosix.cpp; sourceTree = "<group>"; }; @@ -2578,8 +2574,8 @@ 4CEDAED311754F5E00E875A6 /* ThreadPlanStepUntil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanStepUntil.h; path = include/lldb/Target/ThreadPlanStepUntil.h; sourceTree = "<group>"; }; 4CF52AF41428291E0051E832 /* SBFileSpecList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBFileSpecList.h; path = include/lldb/API/SBFileSpecList.h; sourceTree = "<group>"; }; 4CF52AF7142829390051E832 /* SBFileSpecList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBFileSpecList.cpp; path = source/API/SBFileSpecList.cpp; sourceTree = "<group>"; }; - 54067BEC1DF2034B00749AA5 /* UndefinedBehaviorSanitizerRuntime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = UndefinedBehaviorSanitizerRuntime.cpp; path = UndefinedBehaviorSanitizer/UndefinedBehaviorSanitizerRuntime.cpp; sourceTree = "<group>"; }; - 54067BED1DF2034B00749AA5 /* UndefinedBehaviorSanitizerRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UndefinedBehaviorSanitizerRuntime.h; path = UndefinedBehaviorSanitizer/UndefinedBehaviorSanitizerRuntime.h; sourceTree = "<group>"; }; + 54067BEC1DF2034B00749AA5 /* UBSanRuntime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; path = UBSanRuntime.cpp; sourceTree = "<group>"; }; + 54067BED1DF2034B00749AA5 /* UBSanRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UBSanRuntime.h; sourceTree = "<group>"; }; 69A01E1C1236C5D400C660B5 /* Host.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Host.cpp; sourceTree = "<group>"; }; 69A01E1F1236C5D400C660B5 /* Symbols.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Symbols.cpp; sourceTree = "<group>"; }; 6D0F613C1C80AA8900A4ECEE /* DebugMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DebugMacros.h; path = include/lldb/Symbol/DebugMacros.h; sourceTree = "<group>"; }; @@ -2622,8 +2618,8 @@ 6D9AB3DE1BB2B76B003F2289 /* TypeMap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TypeMap.h; path = include/lldb/Symbol/TypeMap.h; sourceTree = "<group>"; }; 6DEC6F381BD66D750091ABA6 /* TaskPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TaskPool.cpp; path = source/Utility/TaskPool.cpp; sourceTree = "<group>"; }; 6DEC6F3A1BD66D950091ABA6 /* TaskPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TaskPool.h; path = include/lldb/Utility/TaskPool.h; sourceTree = "<group>"; }; - 8C26C4241C3EA4340031DF7C /* ThreadSanitizerRuntime.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadSanitizerRuntime.cpp; path = ThreadSanitizer/ThreadSanitizerRuntime.cpp; sourceTree = "<group>"; }; - 8C26C4251C3EA4340031DF7C /* ThreadSanitizerRuntime.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ThreadSanitizerRuntime.h; path = ThreadSanitizer/ThreadSanitizerRuntime.h; sourceTree = "<group>"; }; + 8C26C4241C3EA4340031DF7C /* TSanRuntime.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = TSanRuntime.cpp; path = TSan/TSanRuntime.cpp; sourceTree = "<group>"; }; + 8C26C4251C3EA4340031DF7C /* TSanRuntime.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TSanRuntime.h; path = TSan/TSanRuntime.h; sourceTree = "<group>"; }; 8C2D6A52197A1EAF006989C9 /* MemoryHistory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MemoryHistory.cpp; path = source/Target/MemoryHistory.cpp; sourceTree = "<group>"; }; 8C2D6A54197A1EBE006989C9 /* MemoryHistory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MemoryHistory.h; path = include/lldb/Target/MemoryHistory.h; sourceTree = "<group>"; }; 8C2D6A5A197A1FDC006989C9 /* MemoryHistoryASan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryHistoryASan.cpp; sourceTree = "<group>"; }; @@ -2637,8 +2633,8 @@ 8CCB018419BA54930009FD44 /* SBThreadCollection.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBThreadCollection.i; sourceTree = "<group>"; }; 8CF02ADF19DCBF3B00B14BE0 /* InstrumentationRuntime.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = InstrumentationRuntime.cpp; path = source/Target/InstrumentationRuntime.cpp; sourceTree = "<group>"; }; 8CF02AE019DCBF3B00B14BE0 /* InstrumentationRuntime.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = InstrumentationRuntime.h; path = include/lldb/Target/InstrumentationRuntime.h; sourceTree = "<group>"; }; - 8CF02AE519DCBF8400B14BE0 /* AddressSanitizerRuntime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AddressSanitizerRuntime.cpp; sourceTree = "<group>"; }; - 8CF02AE619DCBF8400B14BE0 /* AddressSanitizerRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddressSanitizerRuntime.h; sourceTree = "<group>"; }; + 8CF02AE519DCBF8400B14BE0 /* ASanRuntime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ASanRuntime.cpp; sourceTree = "<group>"; }; + 8CF02AE619DCBF8400B14BE0 /* ASanRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASanRuntime.h; sourceTree = "<group>"; }; 8CF02AED19DD15CF00B14BE0 /* InstrumentationRuntimeStopInfo.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = InstrumentationRuntimeStopInfo.cpp; path = source/Target/InstrumentationRuntimeStopInfo.cpp; sourceTree = "<group>"; }; 8CF02AEE19DD15CF00B14BE0 /* InstrumentationRuntimeStopInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = InstrumentationRuntimeStopInfo.h; path = include/lldb/Target/InstrumentationRuntimeStopInfo.h; sourceTree = "<group>"; }; 94005E0313F438DF001EF42D /* python-wrapper.swig */ = {isa = PBXFileReference; lastKnownFileType = text; path = "python-wrapper.swig"; sourceTree = "<group>"; }; @@ -3036,7 +3032,7 @@ AFD65C7F1D9B5B2E00D93120 /* RegisterContextMinidump_x86_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterContextMinidump_x86_64.cpp; sourceTree = "<group>"; }; AFD65C801D9B5B2E00D93120 /* RegisterContextMinidump_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterContextMinidump_x86_64.h; sourceTree = "<group>"; }; AFDFDFD019E34D3400EAE509 /* ConnectionFileDescriptorPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConnectionFileDescriptorPosix.cpp; sourceTree = "<group>"; }; - AFEC3361194A8ABA00FF05C6 /* StructuredData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StructuredData.cpp; path = source/Core/StructuredData.cpp; sourceTree = "<group>"; }; + AFEC3361194A8ABA00FF05C6 /* StructuredData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StructuredData.cpp; path = source/Utility/StructuredData.cpp; sourceTree = "<group>"; }; AFEC5FD51D94F9380076A480 /* Testx86AssemblyInspectionEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Testx86AssemblyInspectionEngine.cpp; path = UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp; sourceTree = "<group>"; }; AFF87C86150FF669000E1742 /* com.apple.debugserver.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = com.apple.debugserver.plist; path = tools/debugserver/source/com.apple.debugserver.plist; sourceTree = "<group>"; }; AFF87C8A150FF677000E1742 /* com.apple.debugserver.applist.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = com.apple.debugserver.applist.plist; path = tools/debugserver/source/com.apple.debugserver.applist.plist; sourceTree = "<group>"; }; @@ -3425,6 +3421,7 @@ children = ( AF3F54B21B3BA5D500186E73 /* POSIXStopInfo.cpp */, AF3F54B31B3BA5D500186E73 /* POSIXStopInfo.h */, + 26474CC818D0CB5B0073DEBA /* RegisterContextPOSIX.h */, AF3F54B81B3BA5D500186E73 /* RegisterContextPOSIXProcessMonitor_arm.cpp */, AF3F54B91B3BA5D500186E73 /* RegisterContextPOSIXProcessMonitor_arm.h */, AF3F54BA1B3BA5D500186E73 /* RegisterContextPOSIXProcessMonitor_arm64.cpp */, @@ -4228,6 +4225,8 @@ 2682F168115ED9C800CCFF99 /* Utility */ = { isa = PBXGroup; children = ( + 26BC7D5710F1B77400F91463 /* Connection.h */, + 26BC7E6F10F1B85900F91463 /* Connection.cpp */, 26FA4315130103F400E71120 /* FileSpec.h */, 26FA43171301048600E71120 /* FileSpec.cpp */, 26CF992414428766001E4138 /* AnsiTerminal.h */, @@ -4248,10 +4247,13 @@ 49CA96F41E6AAC8E00C03FEE /* DataExtractor.h */, 49CA96E91E6AAC6600C03FEE /* DataExtractor.cpp */, 9481FE6B1B5F2D9200DED357 /* Either.h */, + 26BC7DD310F1B7D500F91463 /* Endian.h */, AFC2DCE61E6E2ED000283714 /* FastDemangle.cpp */, AFC2DCED1E6E2F9800283714 /* FastDemangle.h */, AFC2DCF21E6E30CF00283714 /* History.cpp */, AFC2DCF41E6E30D800283714 /* History.h */, + 236124A61986B50E004EFC37 /* IOObject.h */, + 236124A21986B4E2004EFC37 /* IOObject.cpp */, 4C73152119B7D71700F865A4 /* Iterable.h */, 942829541A89614000521B30 /* JSON.h */, 942829551A89614C00521B30 /* JSON.cpp */, @@ -4286,12 +4288,16 @@ 94380B8119940B0A00BFE4A8 /* StringLexer.cpp */, 9A35765E116E76A700E8ED2F /* StringList.h */, 9A35765F116E76B900E8ED2F /* StringList.cpp */, + 26F2F8FD1B156678007857DE /* StructuredData.h */, + AFEC3361194A8ABA00FF05C6 /* StructuredData.cpp */, 94BA8B6E176F8CA0005A91B5 /* Range.h */, 94BA8B6C176F8C9B005A91B5 /* Range.cpp */, 6DEC6F3A1BD66D950091ABA6 /* TaskPool.h */, 6DEC6F381BD66D750091ABA6 /* TaskPool.cpp */, AFF8FF0B1E779D4B003830EF /* TildeExpressionResolver.cpp */, AFF8FF0D1E779D51003830EF /* TildeExpressionResolver.h */, + 26BC7D7E10F1B77400F91463 /* Timer.h */, + 26BC7E9610F1B85900F91463 /* Timer.cpp */, 2654A6911E552F3C00DA1013 /* UriParser.h */, 33064C991A5C7A330033D415 /* UriParser.cpp */, AFC2DCEA1E6E2F7D00283714 /* UserID.cpp */, @@ -4588,7 +4594,6 @@ 26B75B431AD6E29A001F7A57 /* MipsLinuxSignals.h */, AF33B4BC1C1FA441001B28D9 /* NetBSDSignals.cpp */, AF33B4BD1C1FA441001B28D9 /* NetBSDSignals.h */, - 26474C9E18D0CAEC0073DEBA /* RegisterContext_mips64.h */, AF77E0991A033D360096C0EA /* RegisterContext_powerpc.h */, 26474C9F18D0CAEC0073DEBA /* RegisterContext_x86.h */, 26957D9213D381C900670048 /* RegisterContextDarwin_arm.cpp */, @@ -4647,7 +4652,6 @@ 267F68561CC02EAE0086832B /* RegisterContextPOSIX_s390x.h */, 26474CC618D0CB5B0073DEBA /* RegisterContextPOSIX_x86.cpp */, 26474CC718D0CB5B0073DEBA /* RegisterContextPOSIX_x86.h */, - 26474CC818D0CB5B0073DEBA /* RegisterContextPOSIX.h */, 26CA979F172B1FD5005DC71B /* RegisterContextThreadMemory.cpp */, 26CA97A0172B1FD5005DC71B /* RegisterContextThreadMemory.h */, 23EDE3371926AAD500F6A132 /* RegisterInfoInterface.h */, @@ -4731,8 +4735,6 @@ 26BC7D5510F1B77400F91463 /* ClangForward.h */, 26BC7D5610F1B77400F91463 /* Communication.h */, 26BC7E6E10F1B85900F91463 /* Communication.cpp */, - 26BC7D5710F1B77400F91463 /* Connection.h */, - 26BC7E6F10F1B85900F91463 /* Connection.cpp */, 263664941140A4C10075843B /* Debugger.h */, 263664921140A4930075843B /* Debugger.cpp */, 26BC7D5E10F1B77400F91463 /* Disassembler.h */, @@ -4795,13 +4797,9 @@ 2623096E13D0EFFB006381D9 /* StreamBuffer.h */, 26BC7D7A10F1B77400F91463 /* StreamFile.h */, 26BC7E9210F1B85900F91463 /* StreamFile.cpp */, - 26F2F8FD1B156678007857DE /* StructuredData.h */, - AFEC3361194A8ABA00FF05C6 /* StructuredData.cpp */, 26B167A41123BF5500DC7B4F /* ThreadSafeValue.h */, 263FEDA5112CC1DA00E4C208 /* ThreadSafeSTLMap.h */, 940B01FE1D2D82220058795E /* ThreadSafeSTLVector.h */, - 26BC7D7E10F1B77400F91463 /* Timer.h */, - 26BC7E9610F1B85900F91463 /* Timer.cpp */, 94ED54A119C8A822007BE2EA /* ThreadSafeDenseMap.h */, 9449B8031B30E0690019342B /* ThreadSafeDenseSet.h */, 268A813F115B19D000F645B0 /* UniqueCStringMap.h */, @@ -5090,7 +5088,6 @@ 266F5CBB12FC846200DFCE33 /* Config.h */, 3FDFED1E19BA6D55009756A7 /* Debug.h */, 26CFDCA01861638D000E63E5 /* Editline.h */, - 26BC7DD310F1B7D500F91463 /* Endian.h */, 260C6EA013011578005E16B0 /* File.h */, 3FDFDDC0199D34E2009756A7 /* FileCache.h */, 3FDFDDBE199D345E009756A7 /* FileCache.cpp */, @@ -5103,7 +5100,6 @@ 3FDFED2119BA6D55009756A7 /* HostNativeThreadBase.h */, 3FDFE57419AFABFD009756A7 /* HostProcess.h */, 3FDFE57519AFABFD009756A7 /* HostThread.h */, - 236124A61986B50E004EFC37 /* IOObject.h */, 267A47F31B14116E0021A5BC /* NativeBreakpoint.h */, 232CB60B191E00CC00EF39FC /* NativeBreakpoint.cpp */, 267A47F41B1411750021A5BC /* NativeBreakpointList.h */, @@ -5112,8 +5108,6 @@ 232CB60F191E00CC00EF39FC /* NativeProcessProtocol.cpp */, 267A47F61B14118F0021A5BC /* NativeRegisterContext.h */, 267A47FA1B1411C40021A5BC /* NativeRegisterContext.cpp */, - 267A47F71B14119A0021A5BC /* NativeRegisterContextRegisterInfo.h */, - 267A47FC1B1411CC0021A5BC /* NativeRegisterContextRegisterInfo.cpp */, 267A47F81B1411A40021A5BC /* NativeThreadProtocol.h */, 232CB611191E00CC00EF39FC /* NativeThreadProtocol.cpp */, 267A47F91B1411AC0021A5BC /* NativeWatchpointList.h */, @@ -5372,7 +5366,6 @@ 26BC7EE510F1B88100F91463 /* MacOSX */ = { isa = PBXGroup; children = ( - 3FDFE56619AF9BB2009756A7 /* Config.h */, 26BC7EED10F1B8AD00F91463 /* CFCBundle.cpp */, 26BC7EEE10F1B8AD00F91463 /* CFCBundle.h */, 26BC7EEF10F1B8AD00F91463 /* CFCData.cpp */, @@ -5918,13 +5911,13 @@ path = "gdb-remote"; sourceTree = "<group>"; }; - 54067BEA1DF2033700749AA5 /* UndefinedBehaviorSanitizer */ = { + 54067BEA1DF2033700749AA5 /* UBSan */ = { isa = PBXGroup; children = ( - 54067BEC1DF2034B00749AA5 /* UndefinedBehaviorSanitizerRuntime.cpp */, - 54067BED1DF2034B00749AA5 /* UndefinedBehaviorSanitizerRuntime.h */, + 54067BEC1DF2034B00749AA5 /* UBSanRuntime.cpp */, + 54067BED1DF2034B00749AA5 /* UBSanRuntime.h */, ); - name = UndefinedBehaviorSanitizer; + path = UBSan; sourceTree = "<group>"; }; 69A01E1A1236C5D400C660B5 /* common */ = { @@ -5944,7 +5937,6 @@ 3FDFED2419BA6D96009756A7 /* HostNativeThreadBase.cpp */, 3FDFED2C19C257A0009756A7 /* HostProcess.cpp */, 3FDFED2519BA6D96009756A7 /* HostThread.cpp */, - 236124A21986B4E2004EFC37 /* IOObject.cpp */, A36FF33B17D8E94600244D40 /* OptionParser.cpp */, AF37E10917C861F20061E18E /* ProcessRunLock.cpp */, 236124A31986B4E2004EFC37 /* Socket.cpp */, @@ -6000,13 +5992,13 @@ path = Android; sourceTree = "<group>"; }; - 8C26C4221C3EA4050031DF7C /* ThreadSanitizer */ = { + 8C26C4221C3EA4050031DF7C /* TSan */ = { isa = PBXGroup; children = ( - 8C26C4241C3EA4340031DF7C /* ThreadSanitizerRuntime.cpp */, - 8C26C4251C3EA4340031DF7C /* ThreadSanitizerRuntime.h */, + 8C26C4241C3EA4340031DF7C /* TSanRuntime.cpp */, + 8C26C4251C3EA4340031DF7C /* TSanRuntime.h */, ); - name = ThreadSanitizer; + name = TSan; sourceTree = "<group>"; }; 8C2D6A58197A1FB9006989C9 /* MemoryHistory */ = { @@ -6038,21 +6030,21 @@ 8CF02ADD19DCBEC200B14BE0 /* InstrumentationRuntime */ = { isa = PBXGroup; children = ( - 54067BEA1DF2033700749AA5 /* UndefinedBehaviorSanitizer */, - 8C26C4221C3EA4050031DF7C /* ThreadSanitizer */, - 8CF02ADE19DCBEE600B14BE0 /* AddressSanitizer */, + 54067BEA1DF2033700749AA5 /* UBSan */, + 8C26C4221C3EA4050031DF7C /* TSan */, + 8CF02ADE19DCBEE600B14BE0 /* ASan */, 8C3BD9911EF45D9B0016C343 /* MainThreadChecker */, ); path = InstrumentationRuntime; sourceTree = "<group>"; }; - 8CF02ADE19DCBEE600B14BE0 /* AddressSanitizer */ = { + 8CF02ADE19DCBEE600B14BE0 /* ASan */ = { isa = PBXGroup; children = ( - 8CF02AE519DCBF8400B14BE0 /* AddressSanitizerRuntime.cpp */, - 8CF02AE619DCBF8400B14BE0 /* AddressSanitizerRuntime.h */, + 8CF02AE519DCBF8400B14BE0 /* ASanRuntime.cpp */, + 8CF02AE619DCBF8400B14BE0 /* ASanRuntime.h */, ); - path = AddressSanitizer; + path = ASan; sourceTree = "<group>"; }; 942829BA1A89830900521B30 /* argdumper */ = { @@ -7148,7 +7140,7 @@ 2689000713353DB600698AC0 /* BreakpointSite.cpp in Sources */, 2689000913353DB600698AC0 /* BreakpointSiteList.cpp in Sources */, 26474CC918D0CB5B0073DEBA /* RegisterContextMemory.cpp in Sources */, - 8CF02AEA19DCC02100B14BE0 /* AddressSanitizerRuntime.cpp in Sources */, + 8CF02AEA19DCC02100B14BE0 /* ASanRuntime.cpp in Sources */, 26474CB218D0CB180073DEBA /* RegisterContextLinux_i386.cpp in Sources */, 26474CCB18D0CB5B0073DEBA /* RegisterContextPOSIX_mips64.cpp in Sources */, 2689000B13353DB600698AC0 /* Stoppoint.cpp in Sources */, @@ -7625,7 +7617,7 @@ 2642FBAE13D003B400ED6808 /* CommunicationKDP.cpp in Sources */, 2642FBB013D003B400ED6808 /* ProcessKDP.cpp in Sources */, 23D4007E1C210201000C3885 /* DebugMacros.cpp in Sources */, - 8C26C4261C3EA5F90031DF7C /* ThreadSanitizerRuntime.cpp in Sources */, + 8C26C4261C3EA5F90031DF7C /* TSanRuntime.cpp in Sources */, 947CF7711DC7B1EE00EF980B /* ProcessMinidump.cpp in Sources */, 2642FBB213D003B400ED6808 /* ProcessKDPLog.cpp in Sources */, 263641191B34AEE200145B2F /* ABISysV_mips64.cpp in Sources */, @@ -7650,7 +7642,7 @@ 26954EBE1401EE8B00294D09 /* DynamicRegisterInfo.cpp in Sources */, 6D9AB3DD1BB2B74E003F2289 /* TypeMap.cpp in Sources */, 255EFF761AFABA950069F277 /* LockFilePosix.cpp in Sources */, - 54067BF11DF2041B00749AA5 /* UndefinedBehaviorSanitizerRuntime.cpp in Sources */, + 54067BF11DF2041B00749AA5 /* UBSanRuntime.cpp in Sources */, 3FBA69EC1B6067430008F44A /* PythonDataObjects.cpp in Sources */, 26274FA714030F79006BA130 /* DynamicLoaderDarwinKernel.cpp in Sources */, 94FA3DE01405D50400833217 /* ValueObjectConstResultChild.cpp in Sources */, diff --git a/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py b/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py index e476c48d1844..cf435a4aae91 100644 --- a/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py +++ b/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py @@ -31,12 +31,8 @@ class ReturnValueTestCase(TestBase): "<=", "3.6"], archs=["i386"]) - @expectedFailureAll( - bugnumber="llvm.org/pr25785", - hostoslist=["windows"], - compiler="gcc", - archs=["i386"], - triple='.*-android') + @expectedFailureAll(compiler="clang", compiler_version=["<=", "5.0.300080"], + triple='.*-android', archs=["i386"]) @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") @add_test_categories(['pyapi']) def test_with_python(self): @@ -185,12 +181,6 @@ class ReturnValueTestCase(TestBase): "<=", "3.6"], archs=["i386"]) - @expectedFailureAll( - bugnumber="llvm.org/pr25785", - hostoslist=["windows"], - compiler="gcc", - archs=["i386"], - triple='.*-android') @expectedFailureAll(compiler=["gcc"], archs=["x86_64", "i386"]) @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_vector_values(self): diff --git a/packages/Python/lldbsuite/test/make/Android.rules b/packages/Python/lldbsuite/test/make/Android.rules index 058401f425ad..0a725494d354 100644 --- a/packages/Python/lldbsuite/test/make/Android.rules +++ b/packages/Python/lldbsuite/test/make/Android.rules @@ -90,3 +90,7 @@ else ARCH_LDFLAGS += $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/libgnustl_static.a endif + +ifeq "$(ARCH)" "i386" + ARCH_CFLAGS += -mstackrealign +endif diff --git a/scripts/Xcode/build-llvm.py b/scripts/Xcode/build-llvm.py index 36e491ebf065..e2a46de1a16c 100755 --- a/scripts/Xcode/build-llvm.py +++ b/scripts/Xcode/build-llvm.py @@ -43,6 +43,9 @@ def process_repo(r): } def XCODE_REPOSITORIES(): + override = repo.get_override() + if override: + return [process_repo(r) for r in override] identifier = repo.identifier() if identifier == None: identifier = "<invalid>" # repo.find will just use the fallback file diff --git a/scripts/Xcode/repo.py b/scripts/Xcode/repo.py index 7623c503ba9f..2657b6eb0c4e 100644 --- a/scripts/Xcode/repo.py +++ b/scripts/Xcode/repo.py @@ -21,6 +21,17 @@ def identifier(): pass return None +def get_override(): + dir = os.path.dirname(os.path.realpath(__file__)) + repos_dir = os.path.join(dir, "repos") + json_regex = re.compile(r"^.*.json$") + override_path = os.path.join(repos_dir, "OVERRIDE") + if os.path.isfile(override_path): + override_set = json.load(open(override_path)) + return override_set["repos"] + else: + return None + def find(identifier): dir = os.path.dirname(os.path.realpath(__file__)) repos_dir = os.path.join(dir, "repos") diff --git a/scripts/analyze-project-deps.py b/scripts/analyze-project-deps.py index e06d7035d43d..52a880d3b3c8 100644 --- a/scripts/analyze-project-deps.py +++ b/scripts/analyze-project-deps.py @@ -1,3 +1,5 @@ +#! /usr/bin/env python + import argparse import itertools import os @@ -203,4 +205,4 @@ if args.discover_cycles: for (node, inc, outg) in sorted: print " {} [{} in, {} out]".format(node, inc, outg) sys.stdout.flush() -pass
\ No newline at end of file +pass diff --git a/source/API/SBCommunication.cpp b/source/API/SBCommunication.cpp index 8ebc33ca26a6..63b672efe3c0 100644 --- a/source/API/SBCommunication.cpp +++ b/source/API/SBCommunication.cpp @@ -11,6 +11,7 @@ #include "lldb/API/SBBroadcaster.h" #include "lldb/Core/Communication.h" #include "lldb/Host/ConnectionFileDescriptor.h" +#include "lldb/Host/Host.h" #include "lldb/Utility/Log.h" using namespace lldb; @@ -51,7 +52,7 @@ void SBCommunication::SetCloseOnEOF(bool b) { ConnectionStatus SBCommunication::Connect(const char *url) { if (m_opaque) { if (!m_opaque->HasConnection()) - m_opaque->SetConnection(Connection::CreateDefaultConnection(url)); + m_opaque->SetConnection(Host::CreateDefaultConnection(url).release()); return m_opaque->Connect(url, NULL); } return eConnectionStatusNoConnection; diff --git a/source/API/SBStructuredData.cpp b/source/API/SBStructuredData.cpp index 54022390b80f..d506410f6d80 100644 --- a/source/API/SBStructuredData.cpp +++ b/source/API/SBStructuredData.cpp @@ -11,11 +11,11 @@ #include "lldb/API/SBStream.h" #include "lldb/Core/Event.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/Target/StructuredDataPlugin.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" +#include "lldb/Utility/StructuredData.h" using namespace lldb; using namespace lldb_private; diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp index 0ab7375ccc30..c706344ee4a3 100644 --- a/source/API/SBTarget.cpp +++ b/source/API/SBTarget.cpp @@ -2170,7 +2170,7 @@ lldb::addr_t SBTarget::GetStackRedZoneSize() { if (process_sp) abi_sp = process_sp->GetABI(); else - abi_sp = ABI::FindPlugin(target_sp->GetArchitecture()); + abi_sp = ABI::FindPlugin(ProcessSP(), target_sp->GetArchitecture()); if (abi_sp) return abi_sp->GetRedZoneSize(); } diff --git a/source/API/SBThread.cpp b/source/API/SBThread.cpp index d9ce6be3f893..b34489603c8a 100644 --- a/source/API/SBThread.cpp +++ b/source/API/SBThread.cpp @@ -16,7 +16,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Core/ValueObject.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Symbol/CompileUnit.h" @@ -34,6 +33,7 @@ #include "lldb/Target/ThreadPlanStepRange.h" #include "lldb/Target/UnixSignals.h" #include "lldb/Utility/Stream.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBDebugger.h" diff --git a/source/API/SBThreadPlan.cpp b/source/API/SBThreadPlan.cpp index 7537a7645390..a19023f66de2 100644 --- a/source/API/SBThreadPlan.cpp +++ b/source/API/SBThreadPlan.cpp @@ -16,7 +16,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/SymbolContext.h" @@ -33,6 +32,7 @@ #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Target/ThreadPlanStepRange.h" #include "lldb/Utility/Stream.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBDebugger.h" diff --git a/source/API/SBTraceOptions.cpp b/source/API/SBTraceOptions.cpp index 474fa911f7ec..20a8f25a768b 100644 --- a/source/API/SBTraceOptions.cpp +++ b/source/API/SBTraceOptions.cpp @@ -10,9 +10,9 @@ #include "lldb/API/SBTraceOptions.h" #include "lldb/API/SBError.h" #include "lldb/API/SBStructuredData.h" -#include "lldb/Utility/Log.h" #include "lldb/Core/StructuredDataImpl.h" -#include "lldb/Core/TraceOptions.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/TraceOptions.h" using namespace lldb; using namespace lldb_private; diff --git a/source/API/SystemInitializerFull.cpp b/source/API/SystemInitializerFull.cpp index 7be37898c5aa..c505f61e42a6 100644 --- a/source/API/SystemInitializerFull.cpp +++ b/source/API/SystemInitializerFull.cpp @@ -20,7 +20,6 @@ #endif #include "lldb/Core/Debugger.h" -#include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Initialization/SystemInitializerCommon.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -28,6 +27,7 @@ #include "lldb/Symbol/GoASTContext.h" #include "lldb/Symbol/JavaASTContext.h" #include "lldb/Symbol/OCamlASTContext.h" +#include "lldb/Utility/Timer.h" #include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h" #include "Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h" diff --git a/source/Commands/CommandObjectFrame.cpp b/source/Commands/CommandObjectFrame.cpp index 9e1805f2eed6..0bcc35062968 100644 --- a/source/Commands/CommandObjectFrame.cpp +++ b/source/Commands/CommandObjectFrame.cpp @@ -17,7 +17,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/Timer.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectVariable.h" @@ -47,6 +46,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Commands/CommandObjectLog.cpp b/source/Commands/CommandObjectLog.cpp index e545d5679725..ef82d07f15fb 100644 --- a/source/Commands/CommandObjectLog.cpp +++ b/source/Commands/CommandObjectLog.cpp @@ -15,7 +15,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/Timer.h" #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -31,6 +30,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Stream.h" +#include "lldb/Utility/Timer.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp index 343530ea4f35..a80acf19be2d 100644 --- a/source/Commands/CommandObjectTarget.cpp +++ b/source/Commands/CommandObjectTarget.cpp @@ -16,7 +16,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/Section.h" #include "lldb/Core/State.h" -#include "lldb/Core/Timer.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/DataFormatters/ValueObjectPrinter.h" #include "lldb/Host/OptionParser.h" @@ -50,6 +49,7 @@ #include "lldb/Target/StackFrame.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadSpec.h" +#include "lldb/Utility/Timer.h" #include "llvm/Support/FileSystem.h" @@ -3426,6 +3426,23 @@ protected: result.GetOutputStream().Printf("\n"); } + if (UnwindPlanSP plan_sp = + func_unwinders_sp->GetDebugFrameUnwindPlan(*target, 0)) { + result.GetOutputStream().Printf("debug_frame UnwindPlan:\n"); + plan_sp->Dump(result.GetOutputStream(), thread.get(), + LLDB_INVALID_ADDRESS); + result.GetOutputStream().Printf("\n"); + } + + if (UnwindPlanSP plan_sp = + func_unwinders_sp->GetDebugFrameAugmentedUnwindPlan(*target, + *thread, 0)) { + result.GetOutputStream().Printf("debug_frame augmented UnwindPlan:\n"); + plan_sp->Dump(result.GetOutputStream(), thread.get(), + LLDB_INVALID_ADDRESS); + result.GetOutputStream().Printf("\n"); + } + UnwindPlanSP arm_unwind_sp = func_unwinders_sp->GetArmUnwindUnwindPlan(*target, 0); if (arm_unwind_sp) { diff --git a/source/Commands/CommandObjectThread.cpp b/source/Commands/CommandObjectThread.cpp index cfd8fcb7291d..687187b26ccd 100644 --- a/source/Commands/CommandObjectThread.cpp +++ b/source/Commands/CommandObjectThread.cpp @@ -209,7 +209,7 @@ protected: Process *process = m_exe_ctx.GetProcessPtr(); Thread *thread = process->GetThreadList().FindThreadByID(tid).get(); if (thread == nullptr) { - result.AppendErrorWithFormat("Failed to process thread# %lu.\n", tid); + result.AppendErrorWithFormat("Failed to process thread# %llu.\n", tid); result.SetStatus(eReturnStatusFailed); return false; } diff --git a/source/Core/CMakeLists.txt b/source/Core/CMakeLists.txt index 806227793f24..c5105bd9ab12 100644 --- a/source/Core/CMakeLists.txt +++ b/source/Core/CMakeLists.txt @@ -7,7 +7,6 @@ add_lldb_library(lldbCore ArchSpec.cpp Broadcaster.cpp Communication.cpp - Connection.cpp Debugger.cpp Disassembler.cpp DumpDataExtractor.cpp @@ -33,8 +32,6 @@ add_lldb_library(lldbCore State.cpp StreamAsynchronousIO.cpp StreamFile.cpp - StructuredData.cpp - Timer.cpp UserSettingsController.cpp Value.cpp ValueObject.cpp diff --git a/source/Core/Communication.cpp b/source/Core/Communication.cpp index 72873a9510b5..38ab902ab4b7 100644 --- a/source/Core/Communication.cpp +++ b/source/Core/Communication.cpp @@ -9,11 +9,11 @@ #include "lldb/Core/Communication.h" -#include "lldb/Core/Connection.h" #include "lldb/Core/Event.h" #include "lldb/Core/Listener.h" #include "lldb/Host/HostThread.h" #include "lldb/Host/ThreadLauncher.h" +#include "lldb/Utility/Connection.h" #include "lldb/Utility/ConstString.h" // for ConstString #include "lldb/Utility/Log.h" #include "lldb/Utility/Logging.h" // for LogIfAnyCategoriesSet, LIBLLDB... diff --git a/source/Core/Connection.cpp b/source/Core/Connection.cpp deleted file mode 100644 index 60d1221c160c..000000000000 --- a/source/Core/Connection.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===-- Connection.cpp ------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/Core/Connection.h" - -#if defined(_WIN32) -#include "lldb/Host/windows/ConnectionGenericFileWindows.h" -#endif - -#include "lldb/Host/ConnectionFileDescriptor.h" - -#include <string.h> // for strstr - -using namespace lldb_private; - -Connection::Connection() {} - -Connection::~Connection() {} - -Connection *Connection::CreateDefaultConnection(const char *url) { -#if defined(_WIN32) - if (strstr(url, "file://") == url) - return new ConnectionGenericFile(); -#endif - return new ConnectionFileDescriptor(); -} diff --git a/source/Core/Disassembler.cpp b/source/Core/Disassembler.cpp index 0a5d763b6d3f..6d463d552da6 100644 --- a/source/Core/Disassembler.cpp +++ b/source/Core/Disassembler.cpp @@ -17,7 +17,6 @@ #include "lldb/Core/ModuleList.h" // for ModuleList #include "lldb/Core/PluginManager.h" #include "lldb/Core/SourceManager.h" // for SourceManager -#include "lldb/Core/Timer.h" #include "lldb/Host/FileSystem.h" #include "lldb/Interpreter/OptionValue.h" #include "lldb/Interpreter/OptionValueArray.h" @@ -37,8 +36,9 @@ #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Status.h" -#include "lldb/Utility/Stream.h" // for Stream -#include "lldb/Utility/StreamString.h" // for StreamString +#include "lldb/Utility/Stream.h" // for Stream +#include "lldb/Utility/StreamString.h" // for StreamString +#include "lldb/Utility/Timer.h" #include "lldb/lldb-private-enumerations.h" // for InstructionType:... #include "lldb/lldb-private-interfaces.h" // for DisassemblerCrea... #include "lldb/lldb-private-types.h" // for RegisterInfo diff --git a/source/Core/FormatEntity.cpp b/source/Core/FormatEntity.cpp index e3c346f79d6b..6002efe9244d 100644 --- a/source/Core/FormatEntity.cpp +++ b/source/Core/FormatEntity.cpp @@ -14,8 +14,7 @@ #include "lldb/Core/ArchSpec.h" // for ArchSpec #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" -#include "lldb/Core/RegisterValue.h" // for RegisterValue -#include "lldb/Core/StructuredData.h" // for StructuredData::O... +#include "lldb/Core/RegisterValue.h" // for RegisterValue #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/DataFormatters/DataVisualization.h" @@ -50,9 +49,10 @@ #include "lldb/Utility/SharingPtr.h" // for SharingPtr #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" -#include "lldb/Utility/StringList.h" // for StringList -#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS -#include "lldb/lldb-forward.h" // for ValueObjectSP +#include "lldb/Utility/StringList.h" // for StringList +#include "lldb/Utility/StructuredData.h" // for StructuredData::O... +#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS +#include "lldb/lldb-forward.h" // for ValueObjectSP #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" // for Triple, Triple::O... diff --git a/source/Core/Mangled.cpp b/source/Core/Mangled.cpp index 4dac0b8f3bf1..211a0c32cee7 100644 --- a/source/Core/Mangled.cpp +++ b/source/Core/Mangled.cpp @@ -27,12 +27,12 @@ #include <cxxabi.h> #endif -#include "lldb/Core/Timer.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Logging.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Stream.h" +#include "lldb/Utility/Timer.h" #include "lldb/lldb-enumerations.h" // for LanguageType #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h" diff --git a/source/Core/Module.cpp b/source/Core/Module.cpp index 1b510d2ff7b2..aaae4700db35 100644 --- a/source/Core/Module.cpp +++ b/source/Core/Module.cpp @@ -17,7 +17,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/SearchFilter.h" // for SearchFilt... #include "lldb/Core/Section.h" -#include "lldb/Core/Timer.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -45,6 +44,7 @@ #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" // for Stream #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" #if defined(LLVM_ON_WIN32) #include "lldb/Host/windows/PosixApi.h" // for PATH_MAX diff --git a/source/Host/CMakeLists.txt b/source/Host/CMakeLists.txt index b9079ce26a2c..73d030e198af 100644 --- a/source/Host/CMakeLists.txt +++ b/source/Host/CMakeLists.txt @@ -13,7 +13,6 @@ add_host_subdirectory(common common/HostNativeThreadBase.cpp common/HostProcess.cpp common/HostThread.cpp - common/IOObject.cpp common/LockFileBase.cpp common/MainLoop.cpp common/MonitoringProcessLauncher.cpp diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp index af0b57248922..29e5991d31aa 100644 --- a/source/Host/common/Host.cpp +++ b/source/Host/common/Host.cpp @@ -58,6 +58,7 @@ #include "lldb/Host/Predicate.h" #include "lldb/Host/ProcessLauncher.h" #include "lldb/Host/ThreadLauncher.h" +#include "lldb/Host/posix/ConnectionFileDescriptorPosix.h" #include "lldb/Target/FileAction.h" #include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/UnixSignals.h" @@ -73,6 +74,7 @@ #include "llvm/Support/FileSystem.h" #if defined(_WIN32) +#include "lldb/Host/windows/ConnectionGenericFileWindows.h" #include "lldb/Host/windows/ProcessLauncherWindows.h" #else #include "lldb/Host/posix/ProcessLauncherPosixFork.h" @@ -624,6 +626,14 @@ const UnixSignalsSP &Host::GetUnixSignals() { return s_unix_signals_sp; } +std::unique_ptr<Connection> Host::CreateDefaultConnection(llvm::StringRef url) { +#if defined(_WIN32) + if (url.startswith("file://")) + return std::unique_ptr<Connection>(new ConnectionGenericFile()); +#endif + return std::unique_ptr<Connection>(new ConnectionFileDescriptor()); +} + #if defined(LLVM_ON_UNIX) WaitStatus WaitStatus::Decode(int wstatus) { if (WIFEXITED(wstatus)) diff --git a/source/Host/common/Symbols.cpp b/source/Host/common/Symbols.cpp index fe29b9e78990..e7bdf084d385 100644 --- a/source/Host/common/Symbols.cpp +++ b/source/Host/common/Symbols.cpp @@ -11,7 +11,6 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/Timer.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/Target.h" #include "lldb/Utility/DataBuffer.h" @@ -19,6 +18,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/SafeMachO.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" #include "lldb/Utility/UUID.h" #include "llvm/Support/FileSystem.h" diff --git a/source/Host/freebsd/Host.cpp b/source/Host/freebsd/Host.cpp index bd547bbeb9c5..037dfc7f5e03 100644 --- a/source/Host/freebsd/Host.cpp +++ b/source/Host/freebsd/Host.cpp @@ -27,22 +27,19 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Module.h" -#include "lldb/Core/StreamFile.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" +#include "lldb/Utility/CleanUp.h" +#include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/NameMatches.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" -#include "lldb/Utility/CleanUp.h" -#include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/DataExtractor.h" -#include "lldb/Utility/NameMatches.h" - #include "llvm/Support/Host.h" extern "C" { diff --git a/source/Host/linux/Support.cpp b/source/Host/linux/Support.cpp index 8fbb60052e3f..31808401ea61 100644 --- a/source/Host/linux/Support.cpp +++ b/source/Host/linux/Support.cpp @@ -32,3 +32,13 @@ lldb_private::getProcFile(::pid_t pid, const llvm::Twine &file) { LLDB_LOG(log, "Failed to open {0}: {1}", File, Ret.getError().message()); return Ret; } + +llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> +lldb_private::getProcFile(const llvm::Twine &file) { + Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); + std::string File = ("/proc/" + file).str(); + auto Ret = llvm::MemoryBuffer::getFileAsStream(File); + if (!Ret) + LLDB_LOG(log, "Failed to open {0}: {1}", File, Ret.getError().message()); + return Ret; +} diff --git a/source/Host/macosx/Host.mm b/source/Host/macosx/Host.mm index 919b35624e60..bbf70cd4c4b3 100644 --- a/source/Host/macosx/Host.mm +++ b/source/Host/macosx/Host.mm @@ -58,8 +58,6 @@ #include "lldb/Core/Communication.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/StreamFile.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/ThreadLauncher.h" @@ -73,6 +71,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/NameMatches.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/StructuredData.h" #include "llvm/Support/FileSystem.h" diff --git a/source/Host/macosx/Symbols.cpp b/source/Host/macosx/Symbols.cpp index 20508a658563..9d1e8fe96ae9 100644 --- a/source/Host/macosx/Symbols.cpp +++ b/source/Host/macosx/Symbols.cpp @@ -26,7 +26,6 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/CleanUp.h" @@ -35,6 +34,7 @@ #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" #include "lldb/Utility/UUID.h" #include "mach/machine.h" diff --git a/source/Host/netbsd/Host.cpp b/source/Host/netbsd/Host.cpp index bbe34a83d999..d927f95f0675 100644 --- a/source/Host/netbsd/Host.cpp +++ b/source/Host/netbsd/Host.cpp @@ -26,22 +26,19 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Module.h" -#include "lldb/Core/StreamFile.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" +#include "lldb/Utility/CleanUp.h" +#include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/NameMatches.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" -#include "lldb/Utility/CleanUp.h" -#include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/DataExtractor.h" -#include "lldb/Utility/NameMatches.h" - #include "llvm/Support/Host.h" extern "C" { diff --git a/source/Host/openbsd/Host.cpp b/source/Host/openbsd/Host.cpp index 7e4a64fbd9ae..0535256b9aa1 100644 --- a/source/Host/openbsd/Host.cpp +++ b/source/Host/openbsd/Host.cpp @@ -23,22 +23,19 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Module.h" -#include "lldb/Core/StreamFile.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" +#include "lldb/Utility/CleanUp.h" +#include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/NameMatches.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" -#include "lldb/Utility/CleanUp.h" -#include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/DataExtractor.h" -#include "lldb/Utility/NameMatches.h" - #include "llvm/Support/Host.h" extern "C" { diff --git a/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/source/Host/posix/ConnectionFileDescriptorPosix.cpp index c3b237a87302..6b0f069c35a9 100644 --- a/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -16,10 +16,10 @@ #include "lldb/Host/posix/ConnectionFileDescriptorPosix.h" #include "lldb/Host/Config.h" -#include "lldb/Host/IOObject.h" #include "lldb/Host/Socket.h" #include "lldb/Host/SocketAddress.h" #include "lldb/Utility/SelectHelper.h" +#include "lldb/Utility/Timeout.h" // C Includes #include <errno.h> @@ -42,13 +42,12 @@ #include "llvm/ADT/SmallVector.h" #endif // Project includes -#include "lldb/Core/Communication.h" -#include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Host/Socket.h" #include "lldb/Host/common/TCPSocket.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Host/windows/Host.cpp b/source/Host/windows/Host.cpp index 69a7c2ef4f74..4458ce25e607 100644 --- a/source/Host/windows/Host.cpp +++ b/source/Host/windows/Host.cpp @@ -15,16 +15,14 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Target/Process.h" -#include "lldb/Utility/Log.h" -#include "lldb/Utility/Status.h" - -#include "lldb/Core/StreamFile.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" +#include "lldb/Target/Process.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/StructuredData.h" #include "llvm/Support/ConvertUTF.h" diff --git a/source/Initialization/SystemInitializerCommon.cpp b/source/Initialization/SystemInitializerCommon.cpp index 77869807c79c..e76ba4122bb6 100644 --- a/source/Initialization/SystemInitializerCommon.cpp +++ b/source/Initialization/SystemInitializerCommon.cpp @@ -17,10 +17,10 @@ #include "Plugins/ObjectFile/ELF/ObjectFileELF.h" #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h" #include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h" -#include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Timer.h" #if defined(__APPLE__) #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h" diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp index a1d8eded09f5..075f2e7b7bd1 100644 --- a/source/Interpreter/CommandInterpreter.cpp +++ b/source/Interpreter/CommandInterpreter.cpp @@ -45,9 +45,9 @@ #include "lldb/Core/PluginManager.h" #include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/Timer.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" +#include "lldb/Utility/Timer.h" #ifndef LLDB_DISABLE_LIBEDIT #include "lldb/Host/Editline.h" diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp index 06b1c7054c1f..fd5ee6ede4c3 100644 --- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp +++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp @@ -1326,7 +1326,7 @@ size_t ABIMacOSX_arm::GetRedZoneSize() const { return 0; } //------------------------------------------------------------------ ABISP -ABIMacOSX_arm::CreateInstance(const ArchSpec &arch) { +ABIMacOSX_arm::CreateInstance(ProcessSP process_sp, const ArchSpec &arch) { static ABISP g_abi_sp; const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); const llvm::Triple::VendorType vendor_type = arch.GetTriple().getVendor(); @@ -1335,7 +1335,7 @@ ABIMacOSX_arm::CreateInstance(const ArchSpec &arch) { if ((arch_type == llvm::Triple::arm) || (arch_type == llvm::Triple::thumb)) { if (!g_abi_sp) - g_abi_sp.reset(new ABIMacOSX_arm); + g_abi_sp.reset(new ABIMacOSX_arm(process_sp)); return g_abi_sp; } } @@ -1546,16 +1546,14 @@ bool ABIMacOSX_arm::GetArgumentValues(Thread &thread, ValueList &values) const { return true; } -bool ABIMacOSX_arm::IsArmv7kProcess(Thread *thread) const { +bool ABIMacOSX_arm::IsArmv7kProcess() const { bool is_armv7k = false; - if (thread) { - ProcessSP process_sp(thread->GetProcess()); - if (process_sp) { - const ArchSpec &arch(process_sp->GetTarget().GetArchitecture()); - const ArchSpec::Core system_core = arch.GetCore(); - if (system_core == ArchSpec::eCore_arm_armv7k) { - is_armv7k = true; - } + ProcessSP process_sp(GetProcessSP()); + if (process_sp) { + const ArchSpec &arch(process_sp->GetTarget().GetArchitecture()); + const ArchSpec::Core system_core = arch.GetCore(); + if (system_core == ArchSpec::eCore_arm_armv7k) { + is_armv7k = true; } } return is_armv7k; @@ -1588,7 +1586,7 @@ ValueObjectSP ABIMacOSX_arm::GetReturnValueObjectImpl( default: return return_valobj_sp; case 128: - if (IsArmv7kProcess(&thread)) { + if (IsArmv7kProcess()) { // "A composite type not larger than 16 bytes is returned in r0-r3. The // format is // as if the result had been stored in memory at a word-aligned address @@ -1755,8 +1753,7 @@ Status ABIMacOSX_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, set_it_simple = true; } } - } else if (num_bytes <= 16 && - IsArmv7kProcess(frame_sp->GetThread().get())) { + } else if (num_bytes <= 16 && IsArmv7kProcess()) { // "A composite type not larger than 16 bytes is returned in r0-r3. The // format is // as if the result had been stored in memory at a word-aligned address diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h index 5aa817c20ec2..d3c20e1e618f 100644 --- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h +++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h @@ -66,7 +66,7 @@ public: const lldb_private::RegisterInfo * GetRegisterInfoArray(uint32_t &count) override; - bool IsArmv7kProcess(lldb_private::Thread *thread) const; + bool IsArmv7kProcess() const; //------------------------------------------------------------------ // Static Functions @@ -76,7 +76,7 @@ public: static void Terminate(); - static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch); static lldb_private::ConstString GetPluginNameStatic(); @@ -94,7 +94,7 @@ protected: lldb_private::CompilerType &ast_type) const override; private: - ABIMacOSX_arm() : lldb_private::ABI() { + ABIMacOSX_arm(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) { // Call CreateInstance instead. } }; diff --git a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp index a545dfc837da..e301b21d542a 100644 --- a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp +++ b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp @@ -1666,7 +1666,7 @@ size_t ABIMacOSX_arm64::GetRedZoneSize() const { return 128; } //------------------------------------------------------------------ ABISP -ABIMacOSX_arm64::CreateInstance(const ArchSpec &arch) { +ABIMacOSX_arm64::CreateInstance(ProcessSP process_sp, const ArchSpec &arch) { static ABISP g_abi_sp; const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); const llvm::Triple::VendorType vendor_type = arch.GetTriple().getVendor(); @@ -1674,7 +1674,7 @@ ABIMacOSX_arm64::CreateInstance(const ArchSpec &arch) { if (vendor_type == llvm::Triple::Apple) { if (arch_type == llvm::Triple::aarch64) { if (!g_abi_sp) - g_abi_sp.reset(new ABIMacOSX_arm64); + g_abi_sp.reset(new ABIMacOSX_arm64(process_sp)); return g_abi_sp; } } diff --git a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h index 589e2ea468ef..2dd7337542db 100644 --- a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h +++ b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h @@ -78,7 +78,7 @@ public: static void Terminate(); - static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch); //------------------------------------------------------------------ // PluginInterface protocol @@ -102,7 +102,7 @@ protected: lldb_private::CompilerType &ast_type) const override; private: - ABIMacOSX_arm64() : lldb_private::ABI() { + ABIMacOSX_arm64(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) { // Call CreateInstance instead. } }; diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp index c393ac9c916b..716a73b854b3 100644 --- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp +++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp @@ -713,13 +713,13 @@ size_t ABIMacOSX_i386::GetRedZoneSize() const { return 0; } //------------------------------------------------------------------ ABISP -ABIMacOSX_i386::CreateInstance(const ArchSpec &arch) { +ABIMacOSX_i386::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) { static ABISP g_abi_sp; if ((arch.GetTriple().getArch() == llvm::Triple::x86) && (arch.GetTriple().isMacOSX() || arch.GetTriple().isiOS() || arch.GetTriple().isWatchOS())) { if (!g_abi_sp) - g_abi_sp.reset(new ABIMacOSX_i386); + g_abi_sp.reset(new ABIMacOSX_i386(process_sp)); return g_abi_sp; } return ABISP(); diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h index 88fb6ffd7a40..e026e3248672 100644 --- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h +++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h @@ -81,7 +81,7 @@ public: static void Terminate(); - static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch); //------------------------------------------------------------------ // PluginInterface protocol @@ -101,7 +101,7 @@ protected: bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABIMacOSX_i386() : lldb_private::ABI() { + ABIMacOSX_i386(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) { // Call CreateInstance instead. } }; diff --git a/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp b/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp index 614c6e893806..882d5cd23e58 100644 --- a/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp +++ b/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp @@ -1327,7 +1327,7 @@ size_t ABISysV_arm::GetRedZoneSize() const { return 0; } //------------------------------------------------------------------ ABISP -ABISysV_arm::CreateInstance(const ArchSpec &arch) { +ABISysV_arm::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) { static ABISP g_abi_sp; const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); const llvm::Triple::VendorType vendor_type = arch.GetTriple().getVendor(); @@ -1336,7 +1336,7 @@ ABISysV_arm::CreateInstance(const ArchSpec &arch) { if ((arch_type == llvm::Triple::arm) || (arch_type == llvm::Triple::thumb)) { if (!g_abi_sp) - g_abi_sp.reset(new ABISysV_arm); + g_abi_sp.reset(new ABISysV_arm(process_sp)); return g_abi_sp; } } diff --git a/source/Plugins/ABI/SysV-arm/ABISysV_arm.h b/source/Plugins/ABI/SysV-arm/ABISysV_arm.h index 81f1277419a6..f046968c213d 100644 --- a/source/Plugins/ABI/SysV-arm/ABISysV_arm.h +++ b/source/Plugins/ABI/SysV-arm/ABISysV_arm.h @@ -76,7 +76,7 @@ public: static void Terminate(); - static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch); static lldb_private::ConstString GetPluginNameStatic(); @@ -94,7 +94,7 @@ protected: lldb_private::CompilerType &ast_type) const override; private: - ABISysV_arm() : lldb_private::ABI() { + ABISysV_arm(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) { // Call CreateInstance instead. } }; diff --git a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp index ce8f8a65e3e3..f91ed851a3e5 100644 --- a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp +++ b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp @@ -1670,7 +1670,7 @@ size_t ABISysV_arm64::GetRedZoneSize() const { return 128; } //------------------------------------------------------------------ ABISP -ABISysV_arm64::CreateInstance(const ArchSpec &arch) { +ABISysV_arm64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) { static ABISP g_abi_sp; const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); const llvm::Triple::VendorType vendor_type = arch.GetTriple().getVendor(); @@ -1678,7 +1678,7 @@ ABISysV_arm64::CreateInstance(const ArchSpec &arch) { if (vendor_type != llvm::Triple::Apple) { if (arch_type == llvm::Triple::aarch64) { if (!g_abi_sp) - g_abi_sp.reset(new ABISysV_arm64); + g_abi_sp.reset(new ABISysV_arm64(process_sp)); return g_abi_sp; } } diff --git a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h index c048e8634ae5..8d23c2419bab 100644 --- a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h +++ b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h @@ -83,7 +83,7 @@ public: static void Terminate(); - static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch); static lldb_private::ConstString GetPluginNameStatic(); @@ -101,7 +101,7 @@ protected: lldb_private::CompilerType &ast_type) const override; private: - ABISysV_arm64() : lldb_private::ABI() { + ABISysV_arm64(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) { // Call CreateInstance instead. } }; diff --git a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp index 425bf2ce0bf6..74274f08b24f 100644 --- a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp +++ b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp @@ -1019,11 +1019,11 @@ size_t ABISysV_hexagon::GetRedZoneSize() const { return 0; } //------------------------------------------------------------------ ABISP -ABISysV_hexagon::CreateInstance(const ArchSpec &arch) { +ABISysV_hexagon::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) { static ABISP g_abi_sp; if (arch.GetTriple().getArch() == llvm::Triple::hexagon) { if (!g_abi_sp) - g_abi_sp.reset(new ABISysV_hexagon); + g_abi_sp.reset(new ABISysV_hexagon(process_sp)); return g_abi_sp; } return ABISP(); diff --git a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h index 5f808291eac0..5a6809371d9f 100644 --- a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h +++ b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h @@ -84,7 +84,7 @@ public: static void Terminate(); - static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch); static lldb_private::ConstString GetPluginNameStatic(); @@ -106,7 +106,7 @@ protected: bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABISysV_hexagon() : lldb_private::ABI() { + ABISysV_hexagon(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) { // Call CreateInstance instead. } }; diff --git a/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp b/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp index cb3644d46af4..63da5a77b48f 100644 --- a/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp +++ b/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp @@ -203,12 +203,12 @@ ABISysV_i386::GetRegisterInfoArray(uint32_t &count) { //------------------------------------------------------------------ ABISP -ABISysV_i386::CreateInstance(const ArchSpec &arch) { +ABISysV_i386::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) { static ABISP g_abi_sp; if ((arch.GetTriple().getArch() == llvm::Triple::x86) && arch.GetTriple().isOSLinux()) { if (!g_abi_sp) - g_abi_sp.reset(new ABISysV_i386); + g_abi_sp.reset(new ABISysV_i386(process_sp)); return g_abi_sp; } return ABISP(); diff --git a/source/Plugins/ABI/SysV-i386/ABISysV_i386.h b/source/Plugins/ABI/SysV-i386/ABISysV_i386.h index 038bf656b1f1..4dce54c4f073 100644 --- a/source/Plugins/ABI/SysV-i386/ABISysV_i386.h +++ b/source/Plugins/ABI/SysV-i386/ABISysV_i386.h @@ -89,7 +89,7 @@ public: static void Terminate(); - static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch); //------------------------------------------------------------------ // PluginInterface protocol @@ -109,7 +109,7 @@ protected: bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABISysV_i386() : lldb_private::ABI() { + ABISysV_i386(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) { // Call CreateInstance instead. } }; diff --git a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp index a77252a20499..95e2a7b0afeb 100644 --- a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp +++ b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp @@ -559,13 +559,13 @@ size_t ABISysV_mips::GetRedZoneSize() const { return 0; } //------------------------------------------------------------------ ABISP -ABISysV_mips::CreateInstance(const ArchSpec &arch) { +ABISysV_mips::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) { static ABISP g_abi_sp; const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); if ((arch_type == llvm::Triple::mips) || (arch_type == llvm::Triple::mipsel)) { if (!g_abi_sp) - g_abi_sp.reset(new ABISysV_mips); + g_abi_sp.reset(new ABISysV_mips(process_sp)); return g_abi_sp; } return ABISP(); diff --git a/source/Plugins/ABI/SysV-mips/ABISysV_mips.h b/source/Plugins/ABI/SysV-mips/ABISysV_mips.h index 980553c506bd..0de8e7751fce 100644 --- a/source/Plugins/ABI/SysV-mips/ABISysV_mips.h +++ b/source/Plugins/ABI/SysV-mips/ABISysV_mips.h @@ -74,7 +74,7 @@ public: static void Terminate(); - static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch); static lldb_private::ConstString GetPluginNameStatic(); @@ -96,7 +96,7 @@ protected: bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABISysV_mips() : lldb_private::ABI() { + ABISysV_mips(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) { // Call CreateInstance instead. } }; diff --git a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp index baa478ea1106..749e170fa17d 100644 --- a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp +++ b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp @@ -559,13 +559,13 @@ size_t ABISysV_mips64::GetRedZoneSize() const { return 0; } //------------------------------------------------------------------ ABISP -ABISysV_mips64::CreateInstance(const ArchSpec &arch) { +ABISysV_mips64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) { static ABISP g_abi_sp; const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch(); if ((arch_type == llvm::Triple::mips64) || (arch_type == llvm::Triple::mips64el)) { if (!g_abi_sp) - g_abi_sp.reset(new ABISysV_mips64); + g_abi_sp.reset(new ABISysV_mips64(process_sp)); return g_abi_sp; } return ABISP(); diff --git a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h index ac7d9b871946..6258c08e35f9 100644 --- a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h +++ b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h @@ -87,7 +87,7 @@ public: static void Terminate(); - static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch); static lldb_private::ConstString GetPluginNameStatic(); @@ -109,7 +109,7 @@ protected: bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABISysV_mips64() : lldb_private::ABI() { + ABISysV_mips64(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) { // Call CreateInstance instead. } }; diff --git a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp index 00adfe1be82d..06a8ce932fda 100644 --- a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp +++ b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp @@ -223,11 +223,11 @@ size_t ABISysV_ppc::GetRedZoneSize() const { return 224; } //------------------------------------------------------------------ ABISP -ABISysV_ppc::CreateInstance(const ArchSpec &arch) { +ABISysV_ppc::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) { static ABISP g_abi_sp; if (arch.GetTriple().getArch() == llvm::Triple::ppc) { if (!g_abi_sp) - g_abi_sp.reset(new ABISysV_ppc); + g_abi_sp.reset(new ABISysV_ppc(process_sp)); return g_abi_sp; } return ABISP(); diff --git a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h index 8cb9bf24881f..df3ebe83faf8 100644 --- a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h +++ b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h @@ -83,7 +83,7 @@ public: static void Terminate(); - static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch); static lldb_private::ConstString GetPluginNameStatic(); @@ -105,7 +105,7 @@ protected: bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABISysV_ppc() : lldb_private::ABI() { + ABISysV_ppc(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) { // Call CreateInstance instead. } }; diff --git a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp index 449990d71304..c090f01ccb1c 100644 --- a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp +++ b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp @@ -223,11 +223,11 @@ size_t ABISysV_ppc64::GetRedZoneSize() const { return 224; } //------------------------------------------------------------------ ABISP -ABISysV_ppc64::CreateInstance(const ArchSpec &arch) { +ABISysV_ppc64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) { static ABISP g_abi_sp; if (arch.GetTriple().getArch() == llvm::Triple::ppc64) { if (!g_abi_sp) - g_abi_sp.reset(new ABISysV_ppc64); + g_abi_sp.reset(new ABISysV_ppc64(process_sp)); return g_abi_sp; } return ABISP(); diff --git a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h index 29237a68fc9e..21608a5c1cdd 100644 --- a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h +++ b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h @@ -83,7 +83,7 @@ public: static void Terminate(); - static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch); static lldb_private::ConstString GetPluginNameStatic(); @@ -105,7 +105,7 @@ protected: bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABISysV_ppc64() : lldb_private::ABI() { + ABISysV_ppc64(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) { // Call CreateInstance instead. } }; diff --git a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp index 7f76d49bfb0f..967e407188fa 100644 --- a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp +++ b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp @@ -205,11 +205,11 @@ size_t ABISysV_s390x::GetRedZoneSize() const { return 0; } //------------------------------------------------------------------ ABISP -ABISysV_s390x::CreateInstance(const ArchSpec &arch) { +ABISysV_s390x::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) { static ABISP g_abi_sp; if (arch.GetTriple().getArch() == llvm::Triple::systemz) { if (!g_abi_sp) - g_abi_sp.reset(new ABISysV_s390x); + g_abi_sp.reset(new ABISysV_s390x(process_sp)); return g_abi_sp; } return ABISP(); diff --git a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h index e233a900e395..5e3d20d7898b 100644 --- a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h +++ b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h @@ -77,7 +77,7 @@ public: static void Terminate(); - static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch); static lldb_private::ConstString GetPluginNameStatic(); @@ -99,7 +99,7 @@ protected: bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABISysV_s390x() : lldb_private::ABI() { + ABISysV_s390x(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) { // Call CreateInstance instead. } }; diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp index deccca8c29e9..10bbae566491 100644 --- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp +++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp @@ -1093,11 +1093,11 @@ size_t ABISysV_x86_64::GetRedZoneSize() const { return 128; } //------------------------------------------------------------------ ABISP -ABISysV_x86_64::CreateInstance(const ArchSpec &arch) { +ABISysV_x86_64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) { static ABISP g_abi_sp; if (arch.GetTriple().getArch() == llvm::Triple::x86_64) { if (!g_abi_sp) - g_abi_sp.reset(new ABISysV_x86_64); + g_abi_sp.reset(new ABISysV_x86_64(process_sp)); return g_abi_sp; } return ABISP(); diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h index 8d420e88167c..5b67e8656d36 100644 --- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h +++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h @@ -85,7 +85,7 @@ public: static void Terminate(); - static lldb::ABISP CreateInstance(const lldb_private::ArchSpec &arch); + static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch); static lldb_private::ConstString GetPluginNameStatic(); @@ -107,7 +107,7 @@ protected: bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info); private: - ABISysV_x86_64() : lldb_private::ABI() { + ABISysV_x86_64(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) { // Call CreateInstance instead. } }; diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h index fdfe45b663c1..a02d1ad9bee3 100644 --- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h +++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h @@ -18,11 +18,11 @@ // Other libraries and framework includes // Project includes -#include "lldb/Core/StructuredData.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Process.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/SafeMachO.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/Utility/UUID.h" #include "llvm/ADT/Triple.h" diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h index dd42686195b1..db90966e5615 100644 --- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h +++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h @@ -25,11 +25,11 @@ // Other libraries and framework includes // Project includes -#include "lldb/Core/StructuredData.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Process.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/SafeMachO.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/Utility/UUID.h" #include "DynamicLoaderDarwin.h" diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h index 81c2fcfb194f..8b5052e4e230 100644 --- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h +++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h @@ -28,11 +28,11 @@ // Other libraries and framework includes // Project includes -#include "lldb/Core/StructuredData.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Process.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/SafeMachO.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/Utility/UUID.h" #include "DynamicLoaderDarwin.h" diff --git a/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h b/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h index 9fd21c06f30c..e9af5a6cdc74 100644 --- a/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h +++ b/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h @@ -14,9 +14,9 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Core/StructuredData.h" #include "lldb/Target/InstrumentationRuntime.h" #include "lldb/Target/Process.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h b/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h index 87440a2489e6..516d9fef5e8e 100644 --- a/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h +++ b/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h @@ -10,9 +10,9 @@ #ifndef liblldb_MainThreadCheckerRuntime_h_ #define liblldb_MainThreadCheckerRuntime_h_ -#include "lldb/Core/StructuredData.h" #include "lldb/Target/ABI.h" #include "lldb/Target/InstrumentationRuntime.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h b/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h index 2a10582b65d2..dc737d22a67a 100644 --- a/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h +++ b/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h @@ -14,9 +14,9 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Core/StructuredData.h" #include "lldb/Target/ABI.h" #include "lldb/Target/InstrumentationRuntime.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h b/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h index 0c478bd57e82..8f138fc12073 100644 --- a/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h +++ b/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h @@ -10,9 +10,9 @@ #ifndef liblldb_UndefinedBehaviorSanitizerRuntime_h_ #define liblldb_UndefinedBehaviorSanitizerRuntime_h_ -#include "lldb/Core/StructuredData.h" #include "lldb/Target/ABI.h" #include "lldb/Target/InstrumentationRuntime.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/source/Plugins/Language/ObjC/Cocoa.cpp b/source/Plugins/Language/ObjC/Cocoa.cpp index 6aaf66cbb486..2ba005e02ad4 100644 --- a/source/Plugins/Language/ObjC/Cocoa.cpp +++ b/source/Plugins/Language/ObjC/Cocoa.cpp @@ -517,11 +517,11 @@ bool lldb_private::formatters::NSNumberSummaryProvider( bool is_preserved_number = cfinfoa & 0x8; if (is_preserved_number) { - lldbassert(!"We should handle preserved numbers!"); + lldbassert(!static_cast<bool>("We should handle preserved numbers!")); return false; } - type_code = (TypeCodes)(cfinfoa & 0x7); + type_code = static_cast<TypeCodes>(cfinfoa & 0x7); } else { uint8_t data_type = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, 1, diff --git a/source/Plugins/Language/ObjC/NSSet.cpp b/source/Plugins/Language/ObjC/NSSet.cpp index b6f6ff7af19d..2f3398775169 100644 --- a/source/Plugins/Language/ObjC/NSSet.cpp +++ b/source/Plugins/Language/ObjC/NSSet.cpp @@ -13,6 +13,7 @@ // Project includes #include "NSSet.h" +#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/DataFormatters/FormattersHelpers.h" @@ -84,11 +85,12 @@ private: std::vector<SetItemDescriptor> m_children; }; -class NSSetMSyntheticFrontEnd : public SyntheticChildrenFrontEnd { +template <typename D32, typename D64> +class GenericNSSetMSyntheticFrontEnd : public SyntheticChildrenFrontEnd { public: - NSSetMSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); + GenericNSSetMSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); - ~NSSetMSyntheticFrontEnd() override; + ~GenericNSSetMSyntheticFrontEnd() override; size_t CalculateNumChildren() override; @@ -101,32 +103,57 @@ public: size_t GetIndexOfChildWithName(const ConstString &name) override; private: + + struct SetItemDescriptor { + lldb::addr_t item_ptr; + lldb::ValueObjectSP valobj_sp; + }; + + ExecutionContextRef m_exe_ctx_ref; + uint8_t m_ptr_size; + D32 *m_data_32; + D64 *m_data_64; + std::vector<SetItemDescriptor> m_children; +}; + +namespace Foundation1300 { struct DataDescriptor_32 { uint32_t _used : 26; uint32_t _size; uint32_t _mutations; uint32_t _objs_addr; }; - + struct DataDescriptor_64 { uint64_t _used : 58; uint64_t _size; uint64_t _mutations; uint64_t _objs_addr; }; - - struct SetItemDescriptor { - lldb::addr_t item_ptr; - lldb::ValueObjectSP valobj_sp; + + using NSSetMSyntheticFrontEnd = + GenericNSSetMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>; +} + +namespace Foundation1400 { + struct DataDescriptor_32 { + uint32_t _used : 26; + uint32_t _size; + uint32_t _objs_addr; + uint32_t _mutations; }; - - ExecutionContextRef m_exe_ctx_ref; - uint8_t m_ptr_size; - DataDescriptor_32 *m_data_32; - DataDescriptor_64 *m_data_64; - std::vector<SetItemDescriptor> m_children; -}; - + + struct DataDescriptor_64 { + uint64_t _used : 58; + uint64_t _size; + uint64_t _objs_addr; + uint64_t _mutations; + }; + + using NSSetMSyntheticFrontEnd = + GenericNSSetMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>; +} + class NSSetCodeRunningSyntheticFrontEnd : public SyntheticChildrenFrontEnd { public: NSSetCodeRunningSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp); @@ -283,7 +310,12 @@ lldb_private::formatters::NSSetSyntheticFrontEndCreator( if (!strcmp(class_name, "__NSSetI")) { return (new NSSetISyntheticFrontEnd(valobj_sp)); } else if (!strcmp(class_name, "__NSSetM")) { - return (new NSSetMSyntheticFrontEnd(valobj_sp)); + AppleObjCRuntime *apple_runtime = + llvm::dyn_cast_or_null<AppleObjCRuntime>(runtime); + if (apple_runtime && apple_runtime->GetFoundationVersion() >= 1400) + return (new Foundation1400::NSSetMSyntheticFrontEnd(valobj_sp)); + else + return (new Foundation1300::NSSetMSyntheticFrontEnd(valobj_sp)); } else { auto &map(NSSet_Additionals::GetAdditionalSynthetics()); auto iter = map.find(class_name_cs), end = map.end(); @@ -442,7 +474,9 @@ lldb_private::formatters::NSSetISyntheticFrontEnd::GetChildAtIndex(size_t idx) { return set_item.valobj_sp; } -lldb_private::formatters::NSSetMSyntheticFrontEnd::NSSetMSyntheticFrontEnd( +template <typename D32, typename D64> +lldb_private::formatters:: + GenericNSSetMSyntheticFrontEnd<D32, D64>::GenericNSSetMSyntheticFrontEnd( lldb::ValueObjectSP valobj_sp) : SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_ptr_size(8), m_data_32(nullptr), m_data_64(nullptr) { @@ -450,15 +484,19 @@ lldb_private::formatters::NSSetMSyntheticFrontEnd::NSSetMSyntheticFrontEnd( Update(); } -lldb_private::formatters::NSSetMSyntheticFrontEnd::~NSSetMSyntheticFrontEnd() { +template <typename D32, typename D64> +lldb_private::formatters:: + GenericNSSetMSyntheticFrontEnd<D32, D64>::~GenericNSSetMSyntheticFrontEnd() { delete m_data_32; m_data_32 = nullptr; delete m_data_64; m_data_64 = nullptr; } +template <typename D32, typename D64> size_t -lldb_private::formatters::NSSetMSyntheticFrontEnd::GetIndexOfChildWithName( +lldb_private::formatters:: + GenericNSSetMSyntheticFrontEnd<D32, D64>::GetIndexOfChildWithName( const ConstString &name) { const char *item_name = name.GetCString(); uint32_t idx = ExtractIndexFromString(item_name); @@ -467,14 +505,19 @@ lldb_private::formatters::NSSetMSyntheticFrontEnd::GetIndexOfChildWithName( return idx; } +template <typename D32, typename D64> size_t -lldb_private::formatters::NSSetMSyntheticFrontEnd::CalculateNumChildren() { +lldb_private::formatters:: + GenericNSSetMSyntheticFrontEnd<D32, D64>::CalculateNumChildren() { if (!m_data_32 && !m_data_64) return 0; return (m_data_32 ? m_data_32->_used : m_data_64->_used); } -bool lldb_private::formatters::NSSetMSyntheticFrontEnd::Update() { +template <typename D32, typename D64> +bool +lldb_private::formatters:: + GenericNSSetMSyntheticFrontEnd<D32, D64>::Update() { m_children.clear(); ValueObjectSP valobj_sp = m_backend.GetSP(); m_ptr_size = 0; @@ -500,12 +543,12 @@ bool lldb_private::formatters::NSSetMSyntheticFrontEnd::Update() { m_ptr_size = process_sp->GetAddressByteSize(); uint64_t data_location = valobj_sp->GetAddressOf() + m_ptr_size; if (m_ptr_size == 4) { - m_data_32 = new DataDescriptor_32(); - process_sp->ReadMemory(data_location, m_data_32, sizeof(DataDescriptor_32), + m_data_32 = new D32(); + process_sp->ReadMemory(data_location, m_data_32, sizeof(D32), error); } else { - m_data_64 = new DataDescriptor_64(); - process_sp->ReadMemory(data_location, m_data_64, sizeof(DataDescriptor_64), + m_data_64 = new D64(); + process_sp->ReadMemory(data_location, m_data_64, sizeof(D64), error); } if (error.Fail()) @@ -513,12 +556,17 @@ bool lldb_private::formatters::NSSetMSyntheticFrontEnd::Update() { return false; } -bool lldb_private::formatters::NSSetMSyntheticFrontEnd::MightHaveChildren() { +template <typename D32, typename D64> +bool +lldb_private::formatters:: + GenericNSSetMSyntheticFrontEnd<D32, D64>::MightHaveChildren() { return true; } +template <typename D32, typename D64> lldb::ValueObjectSP -lldb_private::formatters::NSSetMSyntheticFrontEnd::GetChildAtIndex(size_t idx) { +lldb_private::formatters:: + GenericNSSetMSyntheticFrontEnd<D32, D64>::GetChildAtIndex(size_t idx) { lldb::addr_t m_objs_addr = (m_data_32 ? m_data_32->_objs_addr : m_data_64->_objs_addr); diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index f15bcaa13844..2a7735959a91 100644 --- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -30,7 +30,6 @@ #include "lldb/Core/PluginManager.h" #include "lldb/Core/Scalar.h" #include "lldb/Core/Section.h" -#include "lldb/Core/Timer.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/Expression/DiagnosticManager.h" #include "lldb/Expression/FunctionCaller.h" @@ -55,6 +54,7 @@ #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" #include "AppleObjCClassDescriptorV2.h" #include "AppleObjCDeclVendor.h" diff --git a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp index 8a388a667372..25bfce7a2b83 100644 --- a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp +++ b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp @@ -31,11 +31,11 @@ typedef struct ar_hdr { #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Timer.h" #include "lldb/Host/FileSystem.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/Stream.h" +#include "lldb/Utility/Timer.h" #include "llvm/Support/MemoryBuffer.h" diff --git a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 20e9a930b486..3b33cf1601fb 100644 --- a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -19,7 +19,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/Timer.h" #include "lldb/Symbol/DWARFCallFrameInfo.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/SectionLoadList.h" @@ -28,6 +27,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" +#include "lldb/Utility/Timer.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/StringRef.h" diff --git a/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp b/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp index 055a8219f154..06406c6f1655 100644 --- a/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp +++ b/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp @@ -20,7 +20,6 @@ #include "lldb/Core/RangeMap.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/Platform.h" @@ -32,6 +31,7 @@ #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" #include "lldb/Utility/UUID.h" #ifndef __APPLE__ diff --git a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 1a4ae1a21aec..9bc171e454c9 100644 --- a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -27,7 +27,6 @@ #include "lldb/Core/RegisterValue.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/DWARFCallFrameInfo.h" #include "lldb/Symbol/ObjectFile.h" @@ -44,6 +43,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" #include "lldb/Utility/UUID.h" #include "lldb/Utility/SafeMachO.h" @@ -2502,7 +2502,7 @@ size_t ObjectFileMachO::ParseSymtab() { if (text_section_sp.get() && eh_frame_section_sp.get() && m_type != eTypeDebugInfo) { DWARFCallFrameInfo eh_frame(*this, eh_frame_section_sp, - eRegisterKindEHFrame, true); + DWARFCallFrameInfo::EH); DWARFCallFrameInfo::FunctionAddressAndSizeVector functions; eh_frame.GetFunctionAddressAndSizeVector(functions); addr_t text_base_addr = text_section_sp->GetFileAddress(); diff --git a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp index 4739a4934aa6..5607a71ad5aa 100644 --- a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -19,7 +19,6 @@ #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/Timer.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/Process.h" #include "lldb/Target/SectionLoadList.h" @@ -28,6 +27,7 @@ #include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" #include "lldb/Utility/UUID.h" #include "llvm/Support/MemoryBuffer.h" diff --git a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp index 14bf0784dc2c..588f3f7aec64 100644 --- a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp +++ b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp @@ -22,7 +22,6 @@ #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/RegisterValue.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/ScriptInterpreter.h" @@ -35,6 +34,7 @@ #include "lldb/Target/ThreadList.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/StructuredData.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h index 1eec30ef38c7..2e1680410962 100644 --- a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h +++ b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h @@ -16,8 +16,8 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Core/StructuredData.h" #include "lldb/Target/OperatingSystem.h" +#include "lldb/Utility/StructuredData.h" class DynamicRegisterInfo; diff --git a/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index a29cc9e1ed86..f87852ed7f44 100644 --- a/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -24,7 +24,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/Symbols.h" @@ -39,6 +38,7 @@ #include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" +#include "lldb/Utility/Timer.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Threading.h" diff --git a/source/Plugins/Process/Linux/CMakeLists.txt b/source/Plugins/Process/Linux/CMakeLists.txt index 8a46d730caff..8330cac160e6 100644 --- a/source/Plugins/Process/Linux/CMakeLists.txt +++ b/source/Plugins/Process/Linux/CMakeLists.txt @@ -11,6 +11,7 @@ add_lldb_library(lldbPluginProcessLinux PLUGIN NativeRegisterContextLinux_mips64.cpp NativeRegisterContextLinux_s390x.cpp NativeThreadLinux.cpp + ProcessorTrace.cpp SingleStepCheck.cpp LINK_LIBS diff --git a/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/source/Plugins/Process/Linux/NativeProcessLinux.cpp index e39a1788fc00..8e378802de9c 100644 --- a/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -289,7 +289,8 @@ Status NativeProcessProtocol::Attach( NativeProcessLinux::NativeProcessLinux() : NativeProcessProtocol(LLDB_INVALID_PROCESS_ID), m_arch(), m_supports_mem_region(eLazyBoolCalculate), m_mem_region_cache(), - m_pending_notification_tid(LLDB_INVALID_THREAD_ID) {} + m_pending_notification_tid(LLDB_INVALID_THREAD_ID), + m_pt_proces_trace_id(LLDB_INVALID_UID) {} void NativeProcessLinux::AttachToInferior(MainLoop &mainloop, lldb::pid_t pid, Status &error) { @@ -580,6 +581,7 @@ void NativeProcessLinux::MonitorCallback(lldb::pid_t pid, bool exited, info.si_pid); auto thread_sp = AddThread(pid); + // Resume the newly created thread. ResumeThread(*thread_sp, eStateRunning, LLDB_INVALID_SIGNAL_NUMBER); ThreadWasCreated(*thread_sp); @@ -691,6 +693,7 @@ void NativeProcessLinux::WaitForNewThread(::pid_t tid) { LLDB_LOG(log, "pid = {0}: tracking new thread tid {1}", GetID(), tid); new_thread_sp = AddThread(tid); + ResumeThread(*new_thread_sp, eStateRunning, LLDB_INVALID_SIGNAL_NUMBER); ThreadWasCreated(*new_thread_sp); } @@ -1301,6 +1304,9 @@ Status NativeProcessLinux::Detach() { e; // Save the error, but still attempt to detach from other threads. } + m_processor_trace_monitor.clear(); + m_pt_proces_trace_id = LLDB_INVALID_UID; + return error; } @@ -2089,6 +2095,8 @@ bool NativeProcessLinux::StopTrackingThread(lldb::tid_t thread_id) { } } + if (found) + StopTracingForThread(thread_id); SignalIfAllThreadsStopped(); return found; } @@ -2106,6 +2114,21 @@ NativeThreadLinuxSP NativeProcessLinux::AddThread(lldb::tid_t thread_id) { auto thread_sp = std::make_shared<NativeThreadLinux>(this, thread_id); m_threads.push_back(thread_sp); + + if (m_pt_proces_trace_id != LLDB_INVALID_UID) { + auto traceMonitor = ProcessorTraceMonitor::Create( + GetID(), thread_id, m_pt_process_trace_config, true); + if (traceMonitor) { + m_pt_traced_thread_group.insert(thread_id); + m_processor_trace_monitor.insert( + std::make_pair(thread_id, std::move(*traceMonitor))); + } else { + LLDB_LOG(log, "failed to start trace on thread {0}", thread_id); + Status error(traceMonitor.takeError()); + LLDB_LOG(log, "error {0}", error); + } + } + return thread_sp; } @@ -2405,3 +2428,258 @@ Status NativeProcessLinux::PtraceWrapper(int req, lldb::pid_t pid, void *addr, return error; } + +llvm::Expected<ProcessorTraceMonitor &> +NativeProcessLinux::LookupProcessorTraceInstance(lldb::user_id_t traceid, + lldb::tid_t thread) { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); + if (thread == LLDB_INVALID_THREAD_ID && traceid == m_pt_proces_trace_id) { + LLDB_LOG(log, "thread not specified: {0}", traceid); + return Status("tracing not active thread not specified").ToError(); + } + + for (auto& iter : m_processor_trace_monitor) { + if (traceid == iter.second->GetTraceID() && + (thread == iter.first || thread == LLDB_INVALID_THREAD_ID)) + return *(iter.second); + } + + LLDB_LOG(log, "traceid not being traced: {0}", traceid); + return Status("tracing not active for this thread").ToError(); +} + +Status NativeProcessLinux::GetMetaData(lldb::user_id_t traceid, + lldb::tid_t thread, + llvm::MutableArrayRef<uint8_t> &buffer, + size_t offset) { + TraceOptions trace_options; + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); + Status error; + + LLDB_LOG(log, "traceid {0}", traceid); + + auto perf_monitor = LookupProcessorTraceInstance(traceid, thread); + if (!perf_monitor) { + LLDB_LOG(log, "traceid not being traced: {0}", traceid); + buffer = buffer.slice(buffer.size()); + error = perf_monitor.takeError(); + return error; + } + return (*perf_monitor).ReadPerfTraceData(buffer, offset); +} + +Status NativeProcessLinux::GetData(lldb::user_id_t traceid, lldb::tid_t thread, + llvm::MutableArrayRef<uint8_t> &buffer, + size_t offset) { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); + Status error; + + LLDB_LOG(log, "traceid {0}", traceid); + + auto perf_monitor = LookupProcessorTraceInstance(traceid, thread); + if (!perf_monitor) { + LLDB_LOG(log, "traceid not being traced: {0}", traceid); + buffer = buffer.slice(buffer.size()); + error = perf_monitor.takeError(); + return error; + } + return (*perf_monitor).ReadPerfTraceAux(buffer, offset); +} + +Status NativeProcessLinux::GetTraceConfig(lldb::user_id_t traceid, + TraceOptions &config) { + Status error; + if (config.getThreadID() == LLDB_INVALID_THREAD_ID && + m_pt_proces_trace_id == traceid) { + if (m_pt_proces_trace_id == LLDB_INVALID_UID) { + error.SetErrorString("tracing not active for this process"); + return error; + } + config = m_pt_process_trace_config; + } else { + auto perf_monitor = + LookupProcessorTraceInstance(traceid, config.getThreadID()); + if (!perf_monitor) { + error = perf_monitor.takeError(); + return error; + } + error = (*perf_monitor).GetTraceConfig(config); + } + return error; +} + +lldb::user_id_t +NativeProcessLinux::StartTraceGroup(const TraceOptions &config, + Status &error) { + + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); + if (config.getType() != TraceType::eTraceTypeProcessorTrace) + return LLDB_INVALID_UID; + + if (m_pt_proces_trace_id != LLDB_INVALID_UID) { + error.SetErrorString("tracing already active on this process"); + return m_pt_proces_trace_id; + } + + for (const auto &thread_sp : m_threads) { + if (auto traceInstance = ProcessorTraceMonitor::Create( + GetID(), thread_sp->GetID(), config, true)) { + m_pt_traced_thread_group.insert(thread_sp->GetID()); + m_processor_trace_monitor.insert( + std::make_pair(thread_sp->GetID(), std::move(*traceInstance))); + } + } + + m_pt_process_trace_config = config; + error = ProcessorTraceMonitor::GetCPUType(m_pt_process_trace_config); + + // Trace on Complete process will have traceid of 0 + m_pt_proces_trace_id = 0; + + LLDB_LOG(log, "Process Trace ID {0}", m_pt_proces_trace_id); + return m_pt_proces_trace_id; +} + +lldb::user_id_t NativeProcessLinux::StartTrace(const TraceOptions &config, + Status &error) { + if (config.getType() != TraceType::eTraceTypeProcessorTrace) + return NativeProcessProtocol::StartTrace(config, error); + + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); + + lldb::tid_t threadid = config.getThreadID(); + + if (threadid == LLDB_INVALID_THREAD_ID) + return StartTraceGroup(config, error); + + auto thread_sp = GetThreadByID(threadid); + if (!thread_sp) { + // Thread not tracked by lldb so don't trace. + error.SetErrorString("invalid thread id"); + return LLDB_INVALID_UID; + } + + const auto &iter = m_processor_trace_monitor.find(threadid); + if (iter != m_processor_trace_monitor.end()) { + LLDB_LOG(log, "Thread already being traced"); + error.SetErrorString("tracing already active on this thread"); + return LLDB_INVALID_UID; + } + + auto traceMonitor = + ProcessorTraceMonitor::Create(GetID(), threadid, config, false); + if (!traceMonitor) { + error = traceMonitor.takeError(); + LLDB_LOG(log, "error {0}", error); + return LLDB_INVALID_UID; + } + lldb::user_id_t ret_trace_id = (*traceMonitor)->GetTraceID(); + m_processor_trace_monitor.insert( + std::make_pair(threadid, std::move(*traceMonitor))); + return ret_trace_id; +} + +Status NativeProcessLinux::StopTracingForThread(lldb::tid_t thread) { + Status error; + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); + LLDB_LOG(log, "Thread {0}", thread); + + const auto& iter = m_processor_trace_monitor.find(thread); + if (iter == m_processor_trace_monitor.end()) { + error.SetErrorString("tracing not active for this thread"); + return error; + } + + if (iter->second->GetTraceID() == m_pt_proces_trace_id) { + // traceid maps to the whole process so we have to erase it from the + // thread group. + LLDB_LOG(log, "traceid maps to process"); + m_pt_traced_thread_group.erase(thread); + } + m_processor_trace_monitor.erase(iter); + + return error; +} + +Status NativeProcessLinux::StopTrace(lldb::user_id_t traceid, + lldb::tid_t thread) { + Status error; + + TraceOptions trace_options; + trace_options.setThreadID(thread); + error = NativeProcessLinux::GetTraceConfig(traceid, trace_options); + + if (error.Fail()) + return error; + + switch (trace_options.getType()) { + case lldb::TraceType::eTraceTypeProcessorTrace: + if (traceid == m_pt_proces_trace_id && + thread == LLDB_INVALID_THREAD_ID) + StopProcessorTracingOnProcess(); + else + error = StopProcessorTracingOnThread(traceid, thread); + break; + default: + error.SetErrorString("trace not supported"); + break; + } + + return error; +} + +void NativeProcessLinux::StopProcessorTracingOnProcess() { + for (auto thread_id_iter : m_pt_traced_thread_group) + m_processor_trace_monitor.erase(thread_id_iter); + m_pt_traced_thread_group.clear(); + m_pt_proces_trace_id = LLDB_INVALID_UID; +} + +Status NativeProcessLinux::StopProcessorTracingOnThread(lldb::user_id_t traceid, + lldb::tid_t thread) { + Status error; + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); + + if (thread == LLDB_INVALID_THREAD_ID) { + for (auto& iter : m_processor_trace_monitor) { + if (iter.second->GetTraceID() == traceid) { + // Stopping a trace instance for an individual thread + // hence there will only be one traceid that can match. + m_processor_trace_monitor.erase(iter.first); + return error; + } + LLDB_LOG(log, "Trace ID {0}", iter.second->GetTraceID()); + } + + LLDB_LOG(log, "Invalid TraceID"); + error.SetErrorString("invalid trace id"); + return error; + } + + // thread is specified so we can use find function on the map. + const auto& iter = m_processor_trace_monitor.find(thread); + if (iter == m_processor_trace_monitor.end()) { + // thread not found in our map. + LLDB_LOG(log, "thread not being traced"); + error.SetErrorString("tracing not active for this thread"); + return error; + } + if (iter->second->GetTraceID() != traceid) { + // traceid did not match so it has to be invalid. + LLDB_LOG(log, "Invalid TraceID"); + error.SetErrorString("invalid trace id"); + return error; + } + + LLDB_LOG(log, "UID - {0} , Thread -{1}", traceid, thread); + + if (traceid == m_pt_proces_trace_id) { + // traceid maps to the whole process so we have to erase it from the + // thread group. + LLDB_LOG(log, "traceid maps to process"); + m_pt_traced_thread_group.erase(thread); + } + m_processor_trace_monitor.erase(iter); + + return error; +} diff --git a/source/Plugins/Process/Linux/NativeProcessLinux.h b/source/Plugins/Process/Linux/NativeProcessLinux.h index aa6fe4412068..6bf093f6a39a 100644 --- a/source/Plugins/Process/Linux/NativeProcessLinux.h +++ b/source/Plugins/Process/Linux/NativeProcessLinux.h @@ -23,6 +23,7 @@ #include "lldb/lldb-types.h" #include "NativeThreadLinux.h" +#include "ProcessorTrace.h" #include "lldb/Host/common/NativeProcessProtocol.h" namespace lldb_private { @@ -105,6 +106,22 @@ public: return getProcFile(GetID(), "auxv"); } + lldb::user_id_t StartTrace(const TraceOptions &config, + Status &error) override; + + Status StopTrace(lldb::user_id_t traceid, + lldb::tid_t thread) override; + + Status GetData(lldb::user_id_t traceid, lldb::tid_t thread, + llvm::MutableArrayRef<uint8_t> &buffer, + size_t offset = 0) override; + + Status GetMetaData(lldb::user_id_t traceid, lldb::tid_t thread, + llvm::MutableArrayRef<uint8_t> &buffer, + size_t offset = 0) override; + + Status GetTraceConfig(lldb::user_id_t traceid, TraceOptions &config) override; + // --------------------------------------------------------------------- // Interface used by NativeRegisterContext-derived classes. // --------------------------------------------------------------------- @@ -228,6 +245,43 @@ private: void SigchldHandler(); Status PopulateMemoryRegionCache(); + + lldb::user_id_t StartTraceGroup(const TraceOptions &config, + Status &error); + + // This function is intended to be used to stop tracing + // on a thread that exited. + Status StopTracingForThread(lldb::tid_t thread); + + // The below function as the name suggests, looks up a ProcessorTrace + // instance from the m_processor_trace_monitor map. In the case of + // process tracing where the traceid passed would map to the complete + // process, it is mandatory to provide a threadid to obtain a trace + // instance (since ProcessorTrace is tied to a thread). In the other + // scenario that an individual thread is being traced, just the traceid + // is sufficient to obtain the actual ProcessorTrace instance. + llvm::Expected<ProcessorTraceMonitor &> + LookupProcessorTraceInstance(lldb::user_id_t traceid, lldb::tid_t thread); + + // Stops tracing on individual threads being traced. Not intended + // to be used to stop tracing on complete process. + Status StopProcessorTracingOnThread(lldb::user_id_t traceid, + lldb::tid_t thread); + + // Intended to stop tracing on complete process. + // Should not be used for stopping trace on + // individual threads. + void StopProcessorTracingOnProcess(); + + llvm::DenseMap<lldb::tid_t, ProcessorTraceMonitorUP> + m_processor_trace_monitor; + + // Set for tracking threads being traced under + // same process user id. + llvm::DenseSet<lldb::tid_t> m_pt_traced_thread_group; + + lldb::user_id_t m_pt_proces_trace_id; + TraceOptions m_pt_process_trace_config; }; } // namespace process_linux diff --git a/source/Plugins/Process/Linux/ProcessorTrace.cpp b/source/Plugins/Process/Linux/ProcessorTrace.cpp new file mode 100644 index 000000000000..7043d50256e6 --- /dev/null +++ b/source/Plugins/Process/Linux/ProcessorTrace.cpp @@ -0,0 +1,400 @@ +//===-- ProcessorTrace.cpp ------------------------------------ -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <algorithm> +#include <fstream> + +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/MathExtras.h" + +#include "Plugins/Process/POSIX/ProcessPOSIXLog.h" +#include "ProcessorTrace.h" +#include "lldb/Host/linux/Support.h" + +#include <sys/syscall.h> + +using namespace lldb; +using namespace lldb_private; +using namespace process_linux; +using namespace llvm; + +lldb::user_id_t ProcessorTraceMonitor::m_trace_num = 1; + +Status ProcessorTraceMonitor::GetTraceConfig(TraceOptions &config) const { +#ifndef PERF_ATTR_SIZE_VER5 + llvm_unreachable("perf event not supported"); +#else + Status error; + + config.setType(lldb::TraceType::eTraceTypeProcessorTrace); + config.setMetaDataBufferSize(m_mmap_meta->data_size); + + config.setTraceBufferSize(m_mmap_meta->aux_size); + + error = GetCPUType(config); + + return error; +#endif +} + +Status ProcessorTraceMonitor::StartTrace(lldb::pid_t pid, lldb::tid_t tid, + const TraceOptions &config) { + Status error; + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); + LLDB_LOG(log, "{0}", config.getThreadID()); + +#ifndef PERF_ATTR_SIZE_VER5 + llvm_unreachable("perf event not supported"); +#else + + LLDB_LOG(log, "called thread id {0}", tid); + uint64_t page_size = getpagesize(); + uint64_t bufsize = config.getTraceBufferSize(); + uint64_t metabufsize = config.getMetaDataBufferSize(); + + uint64_t numpages = static_cast<uint64_t>( + llvm::PowerOf2Floor((bufsize + page_size - 1) / page_size)); + numpages = std::max(1ul, numpages); + bufsize = page_size * numpages; + + numpages = static_cast<uint64_t>( + llvm::PowerOf2Floor((metabufsize + page_size - 1) / page_size)); + numpages = std::max(0ul, numpages); + metabufsize = page_size * numpages; + + perf_event_attr attr; + memset(&attr, 0, sizeof(attr)); + attr.size = sizeof(attr); + attr.exclude_kernel = 1; + attr.sample_type = PERF_SAMPLE_TIME; + attr.sample_id_all = 1; + attr.exclude_hv = 1; + attr.exclude_idle = 1; + attr.mmap = 1; + + int intel_pt_type = 0; + + auto ret = llvm::MemoryBuffer::getFileAsStream( + "/sys/bus/event_source/devices/intel_pt/type"); + if (!ret) { + LLDB_LOG(log, "failed to open Config file"); + return ret.getError(); + } + + StringRef rest = ret.get()->getBuffer(); + if (rest.empty() || rest.trim().getAsInteger(10, intel_pt_type)) { + LLDB_LOG(log, "failed to read Config file"); + error.SetErrorString("invalid file"); + return error; + } + + rest.trim().getAsInteger(10, intel_pt_type); + LLDB_LOG(log, "intel pt type {0}", intel_pt_type); + attr.type = intel_pt_type; + + LLDB_LOG(log, "meta buffer size {0}", metabufsize); + LLDB_LOG(log, "buffer size {0} ", bufsize); + + if (error.Fail()) { + LLDB_LOG(log, "Status in custom config"); + + return error; + } + + errno = 0; + auto fd = + syscall(SYS_perf_event_open, &attr, static_cast<::tid_t>(tid), -1, -1, 0); + if (fd == -1) { + LLDB_LOG(log, "syscall error {0}", errno); + error.SetErrorString("perf event syscall Failed"); + return error; + } + + m_fd = std::move(std::unique_ptr<int, file_close>(new int(fd), file_close())); + + errno = 0; + auto base = + mmap(NULL, (metabufsize + page_size), PROT_WRITE, MAP_SHARED, fd, 0); + + if (base == MAP_FAILED) { + LLDB_LOG(log, "mmap base error {0}", errno); + error.SetErrorString("Meta buffer allocation failed"); + return error; + } + + m_mmap_meta = std::move(std::unique_ptr<perf_event_mmap_page, munmap_delete>( + reinterpret_cast<perf_event_mmap_page *>(base), + munmap_delete(metabufsize + page_size))); + + m_mmap_meta->aux_offset = m_mmap_meta->data_offset + m_mmap_meta->data_size; + m_mmap_meta->aux_size = bufsize; + + errno = 0; + auto mmap_aux = mmap(NULL, bufsize, PROT_READ, MAP_SHARED, fd, + static_cast<long int>(m_mmap_meta->aux_offset)); + + if (mmap_aux == MAP_FAILED) { + LLDB_LOG(log, "second mmap done {0}", errno); + error.SetErrorString("Trace buffer allocation failed"); + return error; + } + m_mmap_aux = std::move(std::unique_ptr<uint8_t, munmap_delete>( + reinterpret_cast<uint8_t *>(mmap_aux), munmap_delete(bufsize))); +#endif + return error; +} + +llvm::MutableArrayRef<uint8_t> ProcessorTraceMonitor::GetDataBuffer() { +#ifndef PERF_ATTR_SIZE_VER5 + llvm_unreachable("perf event not supported"); +#else + return MutableArrayRef<uint8_t>( + (reinterpret_cast<uint8_t *>(m_mmap_meta.get()) + + m_mmap_meta->data_offset), + m_mmap_meta->data_size); +#endif +} + +llvm::MutableArrayRef<uint8_t> ProcessorTraceMonitor::GetAuxBuffer() { +#ifndef PERF_ATTR_SIZE_VER5 + llvm_unreachable("perf event not supported"); +#else + return MutableArrayRef<uint8_t>(m_mmap_aux.get(), m_mmap_meta->aux_size); +#endif +} + +Status ProcessorTraceMonitor::GetCPUType(TraceOptions &config) { + + Status error; + uint64_t cpu_family = -1; + uint64_t model = -1; + uint64_t stepping = -1; + std::string vendor_id; + + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); + + auto BufferOrError = getProcFile("cpuinfo"); + if (!BufferOrError) + return BufferOrError.getError(); + + LLDB_LOG(log, "GetCPUType Function"); + + StringRef Rest = BufferOrError.get()->getBuffer(); + while (!Rest.empty()) { + StringRef Line; + std::tie(Line, Rest) = Rest.split('\n'); + + SmallVector<StringRef, 2> columns; + Line.split(columns, StringRef(":"), -1, false); + + if (columns.size() < 2) + continue; // continue searching + + columns[1] = columns[1].trim(" "); + if (columns[0].contains("cpu family") && + columns[1].getAsInteger(10, cpu_family)) + continue; + + else if (columns[0].contains("model") && columns[1].getAsInteger(10, model)) + continue; + + else if (columns[0].contains("stepping") && + columns[1].getAsInteger(10, stepping)) + continue; + + else if (columns[0].contains("vendor_id")) { + vendor_id = columns[1].str(); + if (!vendor_id.empty()) + continue; + } + LLDB_LOG(log, "{0}:{1}:{2}:{3}", cpu_family, model, stepping, vendor_id); + + if ((cpu_family != static_cast<uint64_t>(-1)) && + (model != static_cast<uint64_t>(-1)) && + (stepping != static_cast<uint64_t>(-1)) && (!vendor_id.empty())) { + auto params_dict = std::make_shared<StructuredData::Dictionary>(); + params_dict->AddIntegerItem("cpu_family", cpu_family); + params_dict->AddIntegerItem("cpu_model", model); + params_dict->AddIntegerItem("cpu_stepping", stepping); + params_dict->AddStringItem("cpu_vendor", vendor_id); + + llvm::StringRef intel_custom_params_key("intel-pt"); + + auto intel_custom_params = std::make_shared<StructuredData::Dictionary>(); + intel_custom_params->AddItem( + intel_custom_params_key, + StructuredData::ObjectSP(std::move(params_dict))); + + config.setTraceParams(intel_custom_params); + return error; // we are done + } + } + + error.SetErrorString("cpu info not found"); + return error; +} + +llvm::Expected<ProcessorTraceMonitorUP> +ProcessorTraceMonitor::Create(lldb::pid_t pid, lldb::tid_t tid, + const TraceOptions &config, + bool useProcessSettings) { + + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); + + Status error; + if (tid == LLDB_INVALID_THREAD_ID) { + error.SetErrorString("thread not specified"); + return std::move(error.ToError()); + } + + ProcessorTraceMonitorUP pt_monitor_up(new ProcessorTraceMonitor); + + error = pt_monitor_up->StartTrace(pid, tid, config); + if (error.Fail()) + return std::move(error.ToError()); + + pt_monitor_up->SetThreadID(tid); + + if (useProcessSettings) { + pt_monitor_up->SetTraceID(0); + } else { + pt_monitor_up->SetTraceID(m_trace_num++); + LLDB_LOG(log, "Trace ID {0}", m_trace_num); + } + return std::move(pt_monitor_up); +} + +Status +ProcessorTraceMonitor::ReadPerfTraceAux(llvm::MutableArrayRef<uint8_t> &buffer, + size_t offset) { + + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); + Status error; + +#ifndef PERF_ATTR_SIZE_VER5 + llvm_unreachable("perf event not supported"); +#else + uint64_t head = m_mmap_meta->aux_head; + + LLDB_LOG(log, "Aux size -{0} , Head - {1}", m_mmap_meta->aux_size, head); + + /** + * When configured as ring buffer, the aux buffer keeps wrapping around + * the buffer and its not possible to detect how many times the buffer + * wrapped. Initially the buffer is filled with zeros,as shown below + * so in order to get complete buffer we first copy firstpartsize, followed + * by any left over part from beginning to aux_head + * + * aux_offset [d,d,d,d,d,d,d,d,0,0,0,0,0,0,0,0,0,0,0] aux_size + * aux_head->||<- firstpartsize ->| + * + * */ + + ReadCyclicBuffer(buffer, GetAuxBuffer(), static_cast<size_t>(head), offset); + LLDB_LOG(log, "ReadCyclic BUffer Done"); + return error; +#endif +} + +Status +ProcessorTraceMonitor::ReadPerfTraceData(llvm::MutableArrayRef<uint8_t> &buffer, + size_t offset) { + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); + uint64_t bytes_remaining = buffer.size(); + Status error; +#ifndef PERF_ATTR_SIZE_VER5 + llvm_unreachable("perf event not supported"); +#else + + uint64_t head = m_mmap_meta->data_head; + + /* + * The data buffer and aux buffer have different implementations + * with respect to their definition of head pointer. In the case + * of Aux data buffer the head always wraps around the aux buffer + * and we don't need to care about it, whereas the data_head keeps + * increasing and needs to be wrapped by modulus operator + */ + + LLDB_LOG(log, "bytes_remaining - {0}", bytes_remaining); + + auto data_buffer = GetDataBuffer(); + + if (head > data_buffer.size()) { + head = head % data_buffer.size(); + LLDB_LOG(log, "Data size -{0} Head - {1}", m_mmap_meta->data_size, head); + + ReadCyclicBuffer(buffer, data_buffer, static_cast<size_t>(head), offset); + bytes_remaining -= buffer.size(); + } else { + LLDB_LOG(log, "Head - {0}", head); + if (offset >= head) { + LLDB_LOG(log, "Invalid Offset "); + error.SetErrorString("invalid offset"); + buffer = buffer.slice(buffer.size()); + return error; + } + + auto data = data_buffer.slice(offset, (head - offset)); + auto remaining = std::copy(data.begin(), data.end(), buffer.begin()); + bytes_remaining -= (remaining - buffer.begin()); + } + buffer = buffer.drop_back(bytes_remaining); + return error; +#endif +} + +void ProcessorTraceMonitor::ReadCyclicBuffer( + llvm::MutableArrayRef<uint8_t> &dst, llvm::MutableArrayRef<uint8_t> src, + size_t src_cyc_index, size_t offset) { + + Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); + + if (dst.empty() || src.empty()) { + dst = dst.drop_back(dst.size()); + return; + } + + if (dst.data() == nullptr || src.data() == nullptr) { + dst = dst.drop_back(dst.size()); + return; + } + + if (src_cyc_index > src.size()) { + dst = dst.drop_back(dst.size()); + return; + } + + if (offset >= src.size()) { + LLDB_LOG(log, "Too Big offset "); + dst = dst.drop_back(dst.size()); + return; + } + + llvm::SmallVector<MutableArrayRef<uint8_t>, 2> parts = { + src.slice(src_cyc_index), src.take_front(src_cyc_index)}; + + if (offset > parts[0].size()) { + parts[1] = parts[1].slice(offset - parts[0].size()); + parts[0] = parts[0].drop_back(parts[0].size()); + } else if (offset == parts[0].size()) { + parts[0] = parts[0].drop_back(parts[0].size()); + } else { + parts[0] = parts[0].slice(offset); + } + auto next = dst.begin(); + auto bytes_left = dst.size(); + for (auto part : parts) { + size_t chunk_size = std::min(part.size(), bytes_left); + next = std::copy_n(part.begin(), chunk_size, next); + bytes_left -= chunk_size; + } + dst = dst.drop_back(bytes_left); +} diff --git a/source/Plugins/Process/Linux/ProcessorTrace.h b/source/Plugins/Process/Linux/ProcessorTrace.h new file mode 100644 index 000000000000..ddcaf0f842b5 --- /dev/null +++ b/source/Plugins/Process/Linux/ProcessorTrace.h @@ -0,0 +1,140 @@ +//===-- ProcessorTrace.h -------------------------------------- -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_ProcessorTrace_H_ +#define liblldb_ProcessorTrace_H_ + +#include "lldb/Utility/Status.h" +#include "lldb/Utility/TraceOptions.h" +#include "lldb/lldb-types.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/DenseSet.h" + +#include <linux/perf_event.h> +#include <sys/mman.h> + +namespace lldb_private { + +namespace process_linux { + +// --------------------------------------------------------------------- +// This class keeps track of one tracing instance of +// Intel(R) Processor Trace on Linux OS. There is a map keeping track +// of different tracing instances on each thread, which enables trace +// gathering on a per thread level. +// +// The tracing instance is linked with a trace id. The trace id acts like +// a key to the tracing instance and trace manipulations could be +// performed using the trace id. +// +// The traace id could map to trace instances for a group of threads +// (spanning to all the threads in the process) or a single thread. +// The kernel interface for us is the perf_event_open. +// --------------------------------------------------------------------- + +class ProcessorTraceMonitor; +typedef std::unique_ptr<ProcessorTraceMonitor> ProcessorTraceMonitorUP; + +class ProcessorTraceMonitor { + + class munmap_delete { + size_t m_length; + + public: + munmap_delete(size_t length) : m_length(length) {} + void operator()(void *ptr) { + if (m_length) + munmap(ptr, m_length); + } + }; + + class file_close { + + public: + file_close() = default; + void operator()(int *ptr) { + if (ptr == nullptr) + return; + if (*ptr == -1) + return; + close(*ptr); + std::default_delete<int>()(ptr); + } + }; + + std::unique_ptr<perf_event_mmap_page, munmap_delete> m_mmap_meta; + std::unique_ptr<uint8_t, munmap_delete> m_mmap_aux; + std::unique_ptr<int, file_close> m_fd; + + // perf_event_mmap_page *m_mmap_base; + lldb::user_id_t m_traceid; + lldb::tid_t m_thread_id; + + // Counter to track trace instances. + static lldb::user_id_t m_trace_num; + + void SetTraceID(lldb::user_id_t traceid) { m_traceid = traceid; } + + Status StartTrace(lldb::pid_t pid, lldb::tid_t tid, + const TraceOptions &config); + + llvm::MutableArrayRef<uint8_t> GetAuxBuffer(); + llvm::MutableArrayRef<uint8_t> GetDataBuffer(); + + ProcessorTraceMonitor() + : m_mmap_meta(nullptr, munmap_delete(0)), + m_mmap_aux(nullptr, munmap_delete(0)), m_fd(nullptr, file_close()), + m_traceid(LLDB_INVALID_UID), m_thread_id(LLDB_INVALID_THREAD_ID){}; + + void SetThreadID(lldb::tid_t tid) { m_thread_id = tid; } + +public: + static Status GetCPUType(TraceOptions &config); + + static llvm::Expected<ProcessorTraceMonitorUP> + Create(lldb::pid_t pid, lldb::tid_t tid, const TraceOptions &config, + bool useProcessSettings); + + Status ReadPerfTraceAux(llvm::MutableArrayRef<uint8_t> &buffer, + size_t offset = 0); + + Status ReadPerfTraceData(llvm::MutableArrayRef<uint8_t> &buffer, + size_t offset = 0); + + ~ProcessorTraceMonitor() = default; + + lldb::tid_t GetThreadID() const { return m_thread_id; } + + lldb::user_id_t GetTraceID() const { return m_traceid; } + + Status GetTraceConfig(TraceOptions &config) const; + + // --------------------------------------------------------------------- + /// Read data from a cyclic buffer + /// + /// @param[in] [out] buf + /// Destination buffer, the buffer will be truncated to written size. + /// + /// @param[in] src + /// Source buffer which must be a cyclic buffer. + /// + /// @param[in] src_cyc_index + /// The index pointer (start of the valid data in the cyclic + /// buffer). + /// + /// @param[in] offset + /// The offset to begin reading the data in the cyclic buffer. + // --------------------------------------------------------------------- + static void ReadCyclicBuffer(llvm::MutableArrayRef<uint8_t> &dst, + llvm::MutableArrayRef<uint8_t> src, + size_t src_cyc_index, size_t offset); +}; +} // namespace process_linux +} // namespace lldb_private +#endif diff --git a/source/Plugins/Process/POSIX/CMakeLists.txt b/source/Plugins/Process/POSIX/CMakeLists.txt index 66fb7aa155b4..d9a4508df0a3 100644 --- a/source/Plugins/Process/POSIX/CMakeLists.txt +++ b/source/Plugins/Process/POSIX/CMakeLists.txt @@ -7,7 +7,6 @@ add_lldb_library(lldbPluginProcessPOSIX PLUGIN ProcessPOSIXLog.cpp LINK_LIBS - lldbCore lldbInterpreter LINK_COMPONENTS Support diff --git a/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp b/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp index 0bd90dbf7620..1a4511a82230 100644 --- a/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp +++ b/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp @@ -15,11 +15,11 @@ // Project includes #include "lldb/Core/ArchSpec.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/StructuredData.h" #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Host/StringConvert.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/StringExtractor.h" +#include "lldb/Utility/StructuredData.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Plugins/Process/Utility/DynamicRegisterInfo.h b/source/Plugins/Process/Utility/DynamicRegisterInfo.h index a30bfa1e1f16..228acfbed4ee 100644 --- a/source/Plugins/Process/Utility/DynamicRegisterInfo.h +++ b/source/Plugins/Process/Utility/DynamicRegisterInfo.h @@ -17,8 +17,8 @@ // Other libraries and framework includes // Project includes -#include "lldb/Core/StructuredData.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-private.h" class DynamicRegisterInfo { diff --git a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp index bce77d7e0a32..bd73a29e0871 100644 --- a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -297,6 +297,14 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { return; } + ExecutionContext exe_ctx(m_thread.shared_from_this()); + Process *process = exe_ctx.GetProcessPtr(); + // Let ABIs fixup code addresses to make sure they are valid. In ARM ABIs + // this will strip bit zero in case we read a PC from memory or from the LR. + ABI *abi = process->GetABI().get(); + if (abi) + pc = abi->FixCodeAddress(pc); + if (log) { UnwindLogMsg("pc = 0x%" PRIx64, pc); addr_t reg_val; @@ -321,14 +329,6 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { } } - ExecutionContext exe_ctx(m_thread.shared_from_this()); - Process *process = exe_ctx.GetProcessPtr(); - // Let ABIs fixup code addresses to make sure they are valid. In ARM ABIs - // this will strip bit zero in case we read a PC from memory or from the LR. - ABI *abi = process->GetABI().get(); - if (abi) - pc = abi->FixCodeAddress(pc); - const bool allow_section_end = true; m_current_pc.SetLoadAddress(pc, &process->GetTarget(), allow_section_end); @@ -2054,11 +2054,6 @@ bool RegisterContextLLDB::ReadPC(addr_t &pc) { // unwind past that frame to help // find the bug. - if (m_all_registers_available == false && above_trap_handler == false && - (pc == 0 || pc == 1)) { - return false; - } - ProcessSP process_sp (m_thread.GetProcess()); if (process_sp) { @@ -2066,6 +2061,12 @@ bool RegisterContextLLDB::ReadPC(addr_t &pc) { if (abi) pc = abi->FixCodeAddress(pc); } + + if (m_all_registers_available == false && above_trap_handler == false && + (pc == 0 || pc == 1)) { + return false; + } + return true; } else { return false; diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h index 6306651da7a1..a38110faaec6 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h @@ -23,9 +23,9 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/ArchSpec.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Target/Process.h" #include "lldb/Utility/StreamGDBRemote.h" +#include "lldb/Utility/StructuredData.h" #include "llvm/ADT/Optional.h" diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index d34a79453fed..7523260c13e4 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -1250,9 +1250,9 @@ GDBRemoteCommunicationServerLLGS::Handle_jTraceRead( lldb::user_id_t uid = LLDB_INVALID_UID; - size_t byte_count = std::numeric_limits<size_t>::max(); + uint64_t byte_count = std::numeric_limits<uint64_t>::max(); lldb::tid_t tid = LLDB_INVALID_THREAD_ID; - size_t offset = std::numeric_limits<size_t>::max(); + uint64_t offset = std::numeric_limits<uint64_t>::max(); auto json_object = StructuredData::ParseJSON(packet.Peek()); @@ -1286,8 +1286,8 @@ GDBRemoteCommunicationServerLLGS::Handle_jTraceRead( if (error.Fail()) return SendErrorResponse(error.GetError()); - for (size_t i = 0; i < buf.size(); ++i) - response.PutHex8(buf[i]); + for (auto i : buf) + response.PutHex8(i); StreamGDBRemote escaped_response; escaped_response.PutEscapedBytes(response.GetData(), response.GetSize()); diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp index 73e3732df3ef..977c34c2a69b 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -22,7 +22,6 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/Threading.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Host/Config.h" #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/Host.h" @@ -35,6 +34,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamGDBRemote.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/Utility/UriParser.h" // Project includes diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index aeb7c742b4f4..042c96111bb3 100644 --- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -35,7 +35,6 @@ #include "lldb/Core/PluginManager.h" #include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/Timer.h" #include "lldb/Core/Value.h" #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Host/ConnectionFileDescriptor.h" @@ -66,6 +65,7 @@ #include "lldb/Utility/CleanUp.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" // Project includes #include "GDBRemoteRegisterContext.h" @@ -599,7 +599,7 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) { // gets called in DidAttach, when the target architecture (and // consequently the ABI we'll get from // the process) may be wrong. - ABISP abi_to_use = ABI::FindPlugin(arch_to_use); + ABISP abi_to_use = ABI::FindPlugin(shared_from_this(), arch_to_use); AugmentRegisterInfoViaABI(reg_info, reg_name, abi_to_use); @@ -4419,7 +4419,7 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec &arch_to_use) { // that context we haven't // set the Target's architecture yet, so the ABI is also potentially // incorrect. - ABISP abi_to_use_sp = ABI::FindPlugin(arch_to_use); + ABISP abi_to_use_sp = ABI::FindPlugin(shared_from_this(), arch_to_use); if (feature_node) { ParseRegisters(feature_node, target_info, this->m_register_info, abi_to_use_sp, cur_reg_num, reg_offset); diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index d7a4e961b540..54a472d7332e 100644 --- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -24,7 +24,6 @@ #include "lldb/Core/Broadcaster.h" #include "lldb/Core/LoadedModuleInfoList.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Core/ThreadSafeValue.h" #include "lldb/Host/HostThread.h" #include "lldb/Target/Process.h" @@ -35,6 +34,7 @@ #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StringExtractor.h" #include "lldb/Utility/StringList.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-private-forward.h" #include "GDBRemoteCommunicationClient.h" diff --git a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h index 27caf42fc4a5..1a5b60aea288 100644 --- a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h +++ b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h @@ -16,9 +16,9 @@ // Other libraries and framework includes // Project includes -#include "lldb/Core/StructuredData.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/StructuredData.h" class StringExtractor; diff --git a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h index e613e3d6aa6c..beeb64782367 100644 --- a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h +++ b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h @@ -21,10 +21,10 @@ // Project includes #include "lldb/Utility/Flags.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Host/File.h" #include "lldb/Interpreter/OptionValue.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/lldb-defines.h" #include "llvm/ADT/ArrayRef.h" diff --git a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index d6d695fc2e74..b7fbd7347d08 100644 --- a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -33,7 +33,6 @@ #include "lldb/Core/Communication.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Timer.h" #include "lldb/Core/ValueObject.h" #include "lldb/DataFormatters/TypeSummary.h" #include "lldb/Host/ConnectionFileDescriptor.h" @@ -44,6 +43,7 @@ #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" +#include "lldb/Utility/Timer.h" #if defined(_WIN32) #include "lldb/Host/windows/ConnectionGenericFileWindows.h" diff --git a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp index fc97a76de59b..79b2acc4b4f3 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp @@ -13,13 +13,13 @@ #include "lldb/Core/DumpDataExtractor.h" #include "lldb/Core/Mangled.h" #include "lldb/Core/Module.h" -#include "lldb/Core/Timer.h" #include "lldb/Host/StringConvert.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/LineTable.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" #include "DWARFDIECollection.h" #include "DWARFDebugAbbrev.h" diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp index e923225f1d98..13c2d8726821 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp @@ -14,9 +14,9 @@ #include <algorithm> -#include "lldb/Core/Timer.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" +#include "lldb/Utility/Timer.h" #include "DWARFCompileUnit.h" #include "DWARFDebugInfo.h" diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp index 67d8828c4516..694d34fc211c 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp @@ -14,9 +14,9 @@ #include "lldb/Core/FileSpecList.h" #include "lldb/Core/Module.h" -#include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Timer.h" #include "LogChannelDWARF.h" #include "SymbolFileDWARF.h" diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp index 04bc2f497075..766899c497b0 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp @@ -9,8 +9,8 @@ #include "DWARFDebugPubnames.h" -#include "lldb/Core/Timer.h" #include "lldb/Utility/Stream.h" +#include "lldb/Utility/Timer.h" #include "DWARFCompileUnit.h" #include "DWARFDIECollection.h" diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 252a9807a3b5..ef18c2b5d3ba 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -21,10 +21,10 @@ #include "lldb/Core/Scalar.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/Timer.h" #include "lldb/Core/Value.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" #include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h" diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index ad009a02a2aa..eabff86a5428 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -22,12 +22,12 @@ #include "lldb/Core/Section.h" #include "lldb/Host/FileSystem.h" #include "lldb/Utility/RegularExpression.h" +#include "lldb/Utility/Timer.h" //#define DEBUG_OSO_DMAP // DO NOT CHECKIN WITH THIS NOT COMMENTED OUT #if defined(DEBUG_OSO_DMAP) #include "lldb/Core/StreamFile.h" #endif -#include "lldb/Core/Timer.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/LineTable.h" diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp index 094e48cf00e1..dbc1b9ee5470 100644 --- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp +++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp @@ -10,7 +10,6 @@ #include "SymbolFileSymtab.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Timer.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/ObjectFile.h" @@ -19,6 +18,7 @@ #include "lldb/Symbol/Symtab.h" #include "lldb/Symbol/TypeList.h" #include "lldb/Utility/RegularExpression.h" +#include "lldb/Utility/Timer.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp b/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp index 5a377d7b04f7..f952696ab21d 100644 --- a/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp +++ b/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp @@ -15,11 +15,11 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Host/Symbols.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp b/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp index 5a79cb30eb81..6d6abd62dad2 100644 --- a/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp +++ b/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp @@ -15,12 +15,12 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Host/Symbols.h" #include "lldb/Host/XML.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h b/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h index 56212b94521a..2dc5740da9b6 100644 --- a/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h +++ b/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h @@ -19,12 +19,12 @@ // Other libraries and framework include // Project includes #include "lldb/Core/ModuleList.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Target/Process.h" #include "lldb/Target/QueueItem.h" #include "lldb/Target/SystemRuntime.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/Utility/UUID.h" #include "AppleGetItemInfoHandler.h" diff --git a/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp b/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp index 9aad2e1e70e2..9d79a411faad 100644 --- a/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp +++ b/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp @@ -452,6 +452,33 @@ bool x86AssemblyInspectionEngine::lea_rsp_pattern_p(int &amount) { return false; } +// lea -0x28(%ebp), %esp +// (32-bit and 64-bit variants, 8-bit and 32-bit displacement) +bool x86AssemblyInspectionEngine::lea_rbp_rsp_pattern_p(int &amount) { + uint8_t *p = m_cur_insn; + if (m_wordsize == 8 && *p == 0x48) + p++; + + // Check opcode + if (*p != 0x8d) + return false; + ++p; + + // 8 bit displacement + if (*p == 0x65) { + amount = (int8_t)p[1]; + return true; + } + + // 32 bit displacement + if (*p == 0xa5) { + amount = (int32_t)extract_4(p + 1); + return true; + } + + return false; +} + // popq %rbx // popl %ebx bool x86AssemblyInspectionEngine::pop_reg_p(int ®no) { @@ -843,6 +870,12 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly( in_epilogue = true; } + else if (lea_rbp_rsp_pattern_p(stack_offset) && + row->GetCFAValue().GetRegisterNumber() == m_lldb_fp_regnum) { + current_sp_bytes_offset_from_cfa = + row->GetCFAValue().GetOffset() - stack_offset; + } + else if (ret_pattern_p() && prologue_completed_row.get()) { // Reinstate the saved prologue setup for any instructions // that come after the ret instruction diff --git a/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h b/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h index 1c84c89aee83..2e7875966cb6 100644 --- a/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h +++ b/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h @@ -102,6 +102,7 @@ private: bool sub_rsp_pattern_p(int &amount); bool add_rsp_pattern_p(int &amount); bool lea_rsp_pattern_p(int &amount); + bool lea_rbp_rsp_pattern_p(int &amount); bool push_reg_p(int ®no); bool pop_reg_p(int ®no); bool pop_rbp_pattern_p(); diff --git a/source/Symbol/DWARFCallFrameInfo.cpp b/source/Symbol/DWARFCallFrameInfo.cpp index 015ecd856aa8..9b1f8c694ccf 100644 --- a/source/Symbol/DWARFCallFrameInfo.cpp +++ b/source/Symbol/DWARFCallFrameInfo.cpp @@ -14,7 +14,6 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" -#include "lldb/Core/Timer.h" #include "lldb/Core/dwarf.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/DWARFCallFrameInfo.h" @@ -23,6 +22,7 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Timer.h" using namespace lldb; using namespace lldb_private; @@ -151,17 +151,8 @@ GetGNUEHPointer(const DataExtractor &DE, offset_t *offset_ptr, } DWARFCallFrameInfo::DWARFCallFrameInfo(ObjectFile &objfile, - SectionSP §ion_sp, - lldb::RegisterKind reg_kind, - bool is_eh_frame) - : m_objfile(objfile), m_section_sp(section_sp), - m_reg_kind(reg_kind), // The flavor of registers that the CFI data uses - // (enum RegisterKind) - m_flags(), m_cie_map(), m_cfi_data(), m_cfi_data_initialized(false), - m_fde_index(), m_fde_index_initialized(false), - m_is_eh_frame(is_eh_frame) {} - -DWARFCallFrameInfo::~DWARFCallFrameInfo() {} + SectionSP §ion_sp, Type type) + : m_objfile(objfile), m_section_sp(section_sp), m_type(type) {} bool DWARFCallFrameInfo::GetUnwindPlan(Address addr, UnwindPlan &unwind_plan) { FDEEntryMap::Entry fde_entry; @@ -268,14 +259,20 @@ DWARFCallFrameInfo::ParseCIE(const dw_offset_t cie_offset) { cie_id = m_cfi_data.GetU32(&offset); end_offset = cie_offset + length + 4; } - if (length > 0 && ((!m_is_eh_frame && cie_id == UINT32_MAX) || - (m_is_eh_frame && cie_id == 0ul))) { + if (length > 0 && ((m_type == DWARF && cie_id == UINT32_MAX) || + (m_type == EH && cie_id == 0ul))) { size_t i; // cie.offset = cie_offset; // cie.length = length; // cie.cieID = cieID; cie_sp->ptr_encoding = DW_EH_PE_absptr; // default cie_sp->version = m_cfi_data.GetU8(&offset); + if (cie_sp->version > CFI_VERSION4) { + Host::SystemLog(Host::eSystemLogError, + "CIE parse error: CFI version %d is not supported\n", + cie_sp->version); + return nullptr; + } for (i = 0; i < CFI_AUG_MAX_SIZE; ++i) { cie_sp->augmentation[i] = m_cfi_data.GetU8(&offset); @@ -294,11 +291,23 @@ DWARFCallFrameInfo::ParseCIE(const dw_offset_t cie_offset) { "CIE parse error: CIE augmentation string was too large " "for the fixed sized buffer of %d bytes.\n", CFI_AUG_MAX_SIZE); - return cie_sp; + return nullptr; } + + // m_cfi_data uses address size from target architecture of the process + // may ignore these fields? + if (m_type == DWARF && cie_sp->version >= CFI_VERSION4) { + cie_sp->address_size = m_cfi_data.GetU8(&offset); + cie_sp->segment_size = m_cfi_data.GetU8(&offset); + } + cie_sp->code_align = (uint32_t)m_cfi_data.GetULEB128(&offset); cie_sp->data_align = (int32_t)m_cfi_data.GetSLEB128(&offset); - cie_sp->return_addr_reg_num = m_cfi_data.GetU8(&offset); + + cie_sp->return_addr_reg_num = + m_type == DWARF && cie_sp->version >= CFI_VERSION3 + ? static_cast<uint32_t>(m_cfi_data.GetULEB128(&offset)) + : m_cfi_data.GetU8(&offset); if (cie_sp->augmentation[0]) { // Get the length of the eh_frame augmentation data @@ -461,11 +470,33 @@ void DWARFCallFrameInfo::GetFDEIndex() { m_fde_index_initialized = true; return; } + + // An FDE entry contains CIE_pointer in debug_frame in same place as cie_id + // in eh_frame. CIE_pointer is an offset into the .debug_frame section. + // So, variable cie_offset should be equal to cie_id for debug_frame. + // FDE entries with cie_id == 0 shouldn't be ignored for it. + if ((cie_id == 0 && m_type == EH) || cie_id == UINT32_MAX || len == 0) { + auto cie_sp = ParseCIE(current_entry); + if (!cie_sp) { + // Cannot parse, the reason is already logged + m_fde_index.Clear(); + m_fde_index_initialized = true; + return; + } + + m_cie_map[current_entry] = std::move(cie_sp); + offset = next_entry; + continue; + } + + if (m_type == DWARF) + cie_offset = cie_id; + if (cie_offset > m_cfi_data.GetByteSize()) { - Host::SystemLog( - Host::eSystemLogError, - "error: Invalid cie offset of 0x%x found in cie/fde at 0x%x\n", - cie_offset, current_entry); + Host::SystemLog(Host::eSystemLogError, + "error: Invalid cie offset of 0x%x " + "found in cie/fde at 0x%x\n", + cie_offset, current_entry); // Don't trust anything in this eh_frame section if we find blatantly // invalid data. m_fde_index.Clear(); @@ -473,12 +504,6 @@ void DWARFCallFrameInfo::GetFDEIndex() { return; } - if (cie_id == 0 || cie_id == UINT32_MAX || len == 0) { - m_cie_map[current_entry] = ParseCIE(current_entry); - offset = next_entry; - continue; - } - const CIE *cie = GetCIE(cie_offset); if (cie) { const lldb::addr_t pc_rel_addr = m_section_sp->GetFileAddress(); @@ -531,12 +556,13 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan(dw_offset_t dwarf_offset, cie_offset = m_cfi_data.GetU32(&offset); } - assert(cie_offset != 0 && cie_offset != UINT32_MAX); + // FDE entries with zeroth cie_offset may occur for debug_frame. + assert(!(m_type == EH && 0 == cie_offset) && cie_offset != UINT32_MAX); // Translate the CIE_id from the eh_frame format, which // is relative to the FDE offset, into a __eh_frame section // offset - if (m_is_eh_frame) { + if (m_type == EH) { unwind_plan.SetSourceName("eh_frame CFI"); cie_offset = current_entry + (is_64bit ? 12 : 4) - cie_offset; unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo); @@ -611,7 +637,7 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan(dw_offset_t dwarf_offset, *cie_initial_row = cie->initial_row; UnwindPlan::RowSP row(cie_initial_row); - unwind_plan.SetRegisterKind(m_reg_kind); + unwind_plan.SetRegisterKind(GetRegisterKind()); unwind_plan.SetReturnAddressRegister(cie->return_addr_reg_num); std::vector<UnwindPlan::RowSP> stack; diff --git a/source/Symbol/FuncUnwinders.cpp b/source/Symbol/FuncUnwinders.cpp index 3b94e250dac7..b9f50cd1b12f 100644 --- a/source/Symbol/FuncUnwinders.cpp +++ b/source/Symbol/FuncUnwinders.cpp @@ -39,7 +39,9 @@ FuncUnwinders::FuncUnwinders(UnwindTable &unwind_table, AddressRange range) m_unwind_plan_arch_default_sp(), m_unwind_plan_arch_default_at_func_entry_sp(), m_tried_unwind_plan_assembly(false), m_tried_unwind_plan_eh_frame(false), + m_tried_unwind_plan_debug_frame(false), m_tried_unwind_plan_eh_frame_augmented(false), + m_tried_unwind_plan_debug_frame_augmented(false), m_tried_unwind_plan_compact_unwind(false), m_tried_unwind_plan_arm_unwind(false), m_tried_unwind_fast(false), m_tried_unwind_arch_default(false), @@ -56,17 +58,14 @@ UnwindPlanSP FuncUnwinders::GetUnwindPlanAtCallSite(Target &target, int current_offset) { std::lock_guard<std::recursive_mutex> guard(m_mutex); - UnwindPlanSP unwind_plan_sp = GetEHFrameUnwindPlan(target, current_offset); - if (unwind_plan_sp) - return unwind_plan_sp; - - unwind_plan_sp = GetCompactUnwindUnwindPlan(target, current_offset); - if (unwind_plan_sp) - return unwind_plan_sp; - - unwind_plan_sp = GetArmUnwindUnwindPlan(target, current_offset); - if (unwind_plan_sp) - return unwind_plan_sp; + if (UnwindPlanSP plan_sp = GetEHFrameUnwindPlan(target, current_offset)) + return plan_sp; + if (UnwindPlanSP plan_sp = GetDebugFrameUnwindPlan(target, current_offset)) + return plan_sp; + if (UnwindPlanSP plan_sp = GetCompactUnwindUnwindPlan(target, current_offset)) + return plan_sp; + if (UnwindPlanSP plan_sp = GetArmUnwindUnwindPlan(target, current_offset)) + return plan_sp; return nullptr; } @@ -121,6 +120,29 @@ UnwindPlanSP FuncUnwinders::GetEHFrameUnwindPlan(Target &target, return m_unwind_plan_eh_frame_sp; } +UnwindPlanSP FuncUnwinders::GetDebugFrameUnwindPlan(Target &target, + int current_offset) { + std::lock_guard<std::recursive_mutex> guard(m_mutex); + if (m_unwind_plan_debug_frame_sp || m_tried_unwind_plan_debug_frame) + return m_unwind_plan_debug_frame_sp; + + m_tried_unwind_plan_debug_frame = true; + if (m_range.GetBaseAddress().IsValid()) { + Address current_pc(m_range.GetBaseAddress()); + if (current_offset != -1) + current_pc.SetOffset(current_pc.GetOffset() + current_offset); + DWARFCallFrameInfo *debug_frame = m_unwind_table.GetDebugFrameInfo(); + if (debug_frame) { + m_unwind_plan_debug_frame_sp.reset( + new UnwindPlan(lldb::eRegisterKindGeneric)); + if (!debug_frame->GetUnwindPlan(current_pc, + *m_unwind_plan_debug_frame_sp)) + m_unwind_plan_debug_frame_sp.reset(); + } + } + return m_unwind_plan_debug_frame_sp; +} + UnwindPlanSP FuncUnwinders::GetArmUnwindUnwindPlan(Target &target, int current_offset) { std::lock_guard<std::recursive_mutex> guard(m_mutex); @@ -187,6 +209,48 @@ UnwindPlanSP FuncUnwinders::GetEHFrameAugmentedUnwindPlan(Target &target, return m_unwind_plan_eh_frame_augmented_sp; } +UnwindPlanSP +FuncUnwinders::GetDebugFrameAugmentedUnwindPlan(Target &target, Thread &thread, + int current_offset) { + std::lock_guard<std::recursive_mutex> guard(m_mutex); + if (m_unwind_plan_debug_frame_augmented_sp.get() || + m_tried_unwind_plan_debug_frame_augmented) + return m_unwind_plan_debug_frame_augmented_sp; + + // Only supported on x86 architectures where we get debug_frame from the + // compiler that describes the prologue instructions perfectly, and sometimes + // the epilogue instructions too. + if (target.GetArchitecture().GetCore() != ArchSpec::eCore_x86_32_i386 && + target.GetArchitecture().GetCore() != ArchSpec::eCore_x86_64_x86_64 && + target.GetArchitecture().GetCore() != ArchSpec::eCore_x86_64_x86_64h) { + m_tried_unwind_plan_debug_frame_augmented = true; + return m_unwind_plan_debug_frame_augmented_sp; + } + + m_tried_unwind_plan_debug_frame_augmented = true; + + UnwindPlanSP debug_frame_plan = + GetDebugFrameUnwindPlan(target, current_offset); + if (!debug_frame_plan) + return m_unwind_plan_debug_frame_augmented_sp; + + m_unwind_plan_debug_frame_augmented_sp.reset( + new UnwindPlan(*debug_frame_plan)); + + // Augment the debug_frame instructions with epilogue descriptions if + // necessary so the UnwindPlan can be used at any instruction in the function. + + UnwindAssemblySP assembly_profiler_sp(GetUnwindAssemblyProfiler(target)); + if (assembly_profiler_sp) { + if (!assembly_profiler_sp->AugmentUnwindPlanFromCallSite( + m_range, thread, *m_unwind_plan_debug_frame_augmented_sp)) { + m_unwind_plan_debug_frame_augmented_sp.reset(); + } + } else + m_unwind_plan_debug_frame_augmented_sp.reset(); + return m_unwind_plan_debug_frame_augmented_sp; +} + UnwindPlanSP FuncUnwinders::GetAssemblyUnwindPlan(Target &target, Thread &thread, int current_offset) { @@ -248,6 +312,8 @@ UnwindPlanSP FuncUnwinders::GetUnwindPlanAtNonCallSite(Target &target, Thread &thread, int current_offset) { UnwindPlanSP eh_frame_sp = GetEHFrameUnwindPlan(target, current_offset); + if (!eh_frame_sp) + eh_frame_sp = GetDebugFrameUnwindPlan(target, current_offset); UnwindPlanSP arch_default_at_entry_sp = GetUnwindPlanArchitectureDefaultAtFunctionEntry(thread); UnwindPlanSP arch_default_sp = GetUnwindPlanArchitectureDefault(thread); @@ -255,28 +321,22 @@ UnwindPlanSP FuncUnwinders::GetUnwindPlanAtNonCallSite(Target &target, GetAssemblyUnwindPlan(target, thread, current_offset); // This point of this code is to detect when a function is using a - // non-standard ABI, and the eh_frame - // correctly describes that alternate ABI. This is addressing a specific - // situation on x86_64 linux - // systems where one function in a library pushes a value on the stack and - // jumps to another function. - // So using an assembly instruction based unwind will not work when you're in - // the second function - - // the stack has been modified in a non-ABI way. But we have eh_frame that - // correctly describes how to - // unwind from this location. So we're looking to see if the initial pc - // register save location from - // the eh_frame is different from the assembly unwind, the arch default - // unwind, and the arch default at - // initial function entry. + // non-standard ABI, and the eh_frame correctly describes that alternate ABI. + // This is addressing a specific situation on x86_64 linux systems where one + // function in a library pushes a value on the stack and jumps to another + // function. So using an assembly instruction based unwind will not work when + // you're in the second function - the stack has been modified in a non-ABI + // way. But we have eh_frame that correctly describes how to unwind from this + // location. So we're looking to see if the initial pc register save location + // from the eh_frame is different from the assembly unwind, the arch default + // unwind, and the arch default at initial function entry. // // We may have eh_frame that describes the entire function -- or we may have - // eh_frame that only describes - // the unwind after the prologue has executed -- so we need to check both the - // arch default (once the prologue - // has executed) and the arch default at initial function entry. And we may - // be running on a target where - // we have only some of the assembly/arch default unwind plans available. + // eh_frame that only describes the unwind after the prologue has executed -- + // so we need to check both the arch default (once the prologue has executed) + // and the arch default at initial function entry. And we may be running on a + // target where we have only some of the assembly/arch default unwind plans + // available. if (CompareUnwindPlansForIdenticalInitialPCLocation( thread, eh_frame_sp, arch_default_at_entry_sp) == eLazyBoolNo && @@ -287,11 +347,12 @@ UnwindPlanSP FuncUnwinders::GetUnwindPlanAtNonCallSite(Target &target, return eh_frame_sp; } - UnwindPlanSP eh_frame_augmented_sp = - GetEHFrameAugmentedUnwindPlan(target, thread, current_offset); - if (eh_frame_augmented_sp) { - return eh_frame_augmented_sp; - } + if (UnwindPlanSP plan_sp = + GetEHFrameAugmentedUnwindPlan(target, thread, current_offset)) + return plan_sp; + if (UnwindPlanSP plan_sp = + GetDebugFrameAugmentedUnwindPlan(target, thread, current_offset)) + return plan_sp; return assembly_sp; } diff --git a/source/Symbol/ObjectFile.cpp b/source/Symbol/ObjectFile.cpp index c970de6fef06..fd4180862c15 100644 --- a/source/Symbol/ObjectFile.cpp +++ b/source/Symbol/ObjectFile.cpp @@ -13,7 +13,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/Timer.h" #include "lldb/Symbol/ObjectContainer.h" #include "lldb/Symbol/SymbolFile.h" #include "lldb/Target/Process.h" @@ -25,6 +24,7 @@ #include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegularExpression.h" +#include "lldb/Utility/Timer.h" #include "lldb/lldb-private.h" using namespace lldb; diff --git a/source/Symbol/Symtab.cpp b/source/Symbol/Symtab.cpp index 3eec3e706185..3e2c965509d3 100644 --- a/source/Symbol/Symtab.cpp +++ b/source/Symbol/Symtab.cpp @@ -13,15 +13,15 @@ #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h" #include "Plugins/Language/ObjC/ObjCLanguage.h" #include "lldb/Core/Module.h" -#include "lldb/Core/Section.h" #include "lldb/Core/STLUtils.h" -#include "lldb/Core/Timer.h" +#include "lldb/Core/Section.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/Symtab.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Stream.h" +#include "lldb/Utility/Timer.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Symbol/UnwindTable.cpp b/source/Symbol/UnwindTable.cpp index 336f0c3e04a7..405d57754ea5 100644 --- a/source/Symbol/UnwindTable.cpp +++ b/source/Symbol/UnwindTable.cpp @@ -44,38 +44,64 @@ void UnwindTable::Initialize() { if (m_initialized) // check again once we've acquired the lock return; + m_initialized = true; SectionList *sl = m_object_file.GetSectionList(); - if (sl) { - SectionSP sect = sl->FindSectionByType(eSectionTypeEHFrame, true); - if (sect.get()) { - m_eh_frame_up.reset(new DWARFCallFrameInfo(m_object_file, sect, - eRegisterKindEHFrame, true)); - } - sect = sl->FindSectionByType(eSectionTypeCompactUnwind, true); - if (sect.get()) { - m_compact_unwind_up.reset(new CompactUnwindInfo(m_object_file, sect)); - } - sect = sl->FindSectionByType(eSectionTypeARMexidx, true); - if (sect.get()) { - SectionSP sect_extab = sl->FindSectionByType(eSectionTypeARMextab, true); - if (sect_extab.get()) { - m_arm_unwind_up.reset( - new ArmUnwindInfo(m_object_file, sect, sect_extab)); - } - } + if (!sl) + return; + + SectionSP sect = sl->FindSectionByType(eSectionTypeEHFrame, true); + if (sect.get()) { + m_eh_frame_up.reset( + new DWARFCallFrameInfo(m_object_file, sect, DWARFCallFrameInfo::EH)); } - m_initialized = true; + sect = sl->FindSectionByType(eSectionTypeDWARFDebugFrame, true); + if (sect) { + m_debug_frame_up.reset( + new DWARFCallFrameInfo(m_object_file, sect, DWARFCallFrameInfo::DWARF)); + } + + sect = sl->FindSectionByType(eSectionTypeCompactUnwind, true); + if (sect) { + m_compact_unwind_up.reset(new CompactUnwindInfo(m_object_file, sect)); + } + + sect = sl->FindSectionByType(eSectionTypeARMexidx, true); + if (sect) { + SectionSP sect_extab = sl->FindSectionByType(eSectionTypeARMextab, true); + if (sect_extab.get()) { + m_arm_unwind_up.reset(new ArmUnwindInfo(m_object_file, sect, sect_extab)); + } + } } UnwindTable::~UnwindTable() {} +llvm::Optional<AddressRange> UnwindTable::GetAddressRange(const Address &addr, + SymbolContext &sc) { + AddressRange range; + + // First check the symbol context + if (sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0, + false, range) && + range.GetBaseAddress().IsValid()) + return range; + + // Does the eh_frame unwind info has a function bounds for this addr? + if (m_eh_frame_up && m_eh_frame_up->GetAddressRange(addr, range)) + return range; + + // Try debug_frame as well + if (m_debug_frame_up && m_debug_frame_up->GetAddressRange(addr, range)) + return range; + + return llvm::None; +} + FuncUnwindersSP UnwindTable::GetFuncUnwindersContainingAddress(const Address &addr, SymbolContext &sc) { - FuncUnwindersSP no_unwind_found; - Initialize(); std::lock_guard<std::mutex> guard(m_mutex); @@ -96,23 +122,14 @@ UnwindTable::GetFuncUnwindersContainingAddress(const Address &addr, return pos->second; } - AddressRange range; - if (!sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0, - false, range) || - !range.GetBaseAddress().IsValid()) { - // Does the eh_frame unwind info has a function bounds for this addr? - if (m_eh_frame_up == nullptr || - !m_eh_frame_up->GetAddressRange(addr, range)) { - return no_unwind_found; - } - } + auto range_or = GetAddressRange(addr, sc); + if (!range_or) + return nullptr; - FuncUnwindersSP func_unwinder_sp(new FuncUnwinders(*this, range)); + FuncUnwindersSP func_unwinder_sp(new FuncUnwinders(*this, *range_or)); m_unwinds.insert(insert_pos, - std::make_pair(range.GetBaseAddress().GetFileAddress(), + std::make_pair(range_or->GetBaseAddress().GetFileAddress(), func_unwinder_sp)); - // StreamFile s(stdout, false); - // Dump (s); return func_unwinder_sp; } @@ -121,26 +138,16 @@ UnwindTable::GetFuncUnwindersContainingAddress(const Address &addr, // UnwindTable. This is intended for use by target modules show-unwind where we // want to create // new UnwindPlans, not re-use existing ones. - FuncUnwindersSP UnwindTable::GetUncachedFuncUnwindersContainingAddress(const Address &addr, SymbolContext &sc) { - FuncUnwindersSP no_unwind_found; Initialize(); - AddressRange range; - if (!sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0, - false, range) || - !range.GetBaseAddress().IsValid()) { - // Does the eh_frame unwind info has a function bounds for this addr? - if (m_eh_frame_up == nullptr || - !m_eh_frame_up->GetAddressRange(addr, range)) { - return no_unwind_found; - } - } + auto range_or = GetAddressRange(addr, sc); + if (!range_or) + return nullptr; - FuncUnwindersSP func_unwinder_sp(new FuncUnwinders(*this, range)); - return func_unwinder_sp; + return std::make_shared<FuncUnwinders>(*this, *range_or); } void UnwindTable::Dump(Stream &s) { @@ -161,6 +168,11 @@ DWARFCallFrameInfo *UnwindTable::GetEHFrameInfo() { return m_eh_frame_up.get(); } +DWARFCallFrameInfo *UnwindTable::GetDebugFrameInfo() { + Initialize(); + return m_debug_frame_up.get(); +} + CompactUnwindInfo *UnwindTable::GetCompactUnwindInfo() { Initialize(); return m_compact_unwind_up.get(); diff --git a/source/Symbol/Variable.cpp b/source/Symbol/Variable.cpp index fd19a0994966..ff32aa731465 100644 --- a/source/Symbol/Variable.cpp +++ b/source/Symbol/Variable.cpp @@ -160,7 +160,7 @@ void Variable::Dump(Stream *s, bool show_context) const { if (m_owner_scope) { ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule()); if (module_sp) - abi = ABI::FindPlugin(module_sp->GetArchitecture()).get(); + abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture()).get(); } m_location.GetDescription(s, lldb::eDescriptionLevelBrief, loclist_base_addr, abi); @@ -471,7 +471,7 @@ bool Variable::DumpLocationForAddress(Stream *s, const Address &address) { if (m_owner_scope) { ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule()); if (module_sp) - abi = ABI::FindPlugin(module_sp->GetArchitecture()).get(); + abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture()).get(); } const addr_t file_addr = address.GetFileAddress(); diff --git a/source/Target/ABI.cpp b/source/Target/ABI.cpp index 87363a3b8aeb..72f58be5a3d4 100644 --- a/source/Target/ABI.cpp +++ b/source/Target/ABI.cpp @@ -25,7 +25,7 @@ using namespace lldb; using namespace lldb_private; ABISP -ABI::FindPlugin(const ArchSpec &arch) { +ABI::FindPlugin(lldb::ProcessSP process_sp, const ArchSpec &arch) { ABISP abi_sp; ABICreateInstance create_callback; @@ -33,7 +33,7 @@ ABI::FindPlugin(const ArchSpec &arch) { (create_callback = PluginManager::GetABICreateCallbackAtIndex(idx)) != nullptr; ++idx) { - abi_sp = create_callback(arch); + abi_sp = create_callback(process_sp, arch); if (abi_sp) return abi_sp; @@ -42,8 +42,6 @@ ABI::FindPlugin(const ArchSpec &arch) { return abi_sp; } -ABI::ABI() = default; - ABI::~ABI() = default; bool ABI::GetRegisterInfoByName(const ConstString &name, RegisterInfo &info) { diff --git a/source/Target/ObjCLanguageRuntime.cpp b/source/Target/ObjCLanguageRuntime.cpp index 165c75a0952b..d3cc7c019dce 100644 --- a/source/Target/ObjCLanguageRuntime.cpp +++ b/source/Target/ObjCLanguageRuntime.cpp @@ -11,7 +11,6 @@ #include "lldb/Core/MappedHash.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Timer.h" #include "lldb/Core/ValueObject.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/SymbolContext.h" @@ -21,6 +20,7 @@ #include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/Target.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Timer.h" #include "llvm/ADT/StringRef.h" diff --git a/source/Target/Platform.cpp b/source/Target/Platform.cpp index cfd971e9de62..498facf8e0d0 100644 --- a/source/Target/Platform.cpp +++ b/source/Target/Platform.cpp @@ -25,7 +25,6 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" @@ -42,6 +41,7 @@ #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" +#include "lldb/Utility/StructuredData.h" #include "llvm/Support/FileSystem.h" diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp index c6ad536cee10..6cbe289ef26b 100644 --- a/source/Target/Process.cpp +++ b/source/Target/Process.cpp @@ -1735,7 +1735,7 @@ addr_t Process::GetImageInfoAddress() { return LLDB_INVALID_ADDRESS; } const lldb::ABISP &Process::GetABI() { if (!m_abi_sp) - m_abi_sp = ABI::FindPlugin(GetTarget().GetArchitecture()); + m_abi_sp = ABI::FindPlugin(shared_from_this(), GetTarget().GetArchitecture()); return m_abi_sp; } diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp index 5c46a024be60..4632ada26ed3 100644 --- a/source/Target/Target.cpp +++ b/source/Target/Target.cpp @@ -30,7 +30,6 @@ #include "lldb/Core/SourceManager.h" #include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" -#include "lldb/Core/Timer.h" #include "lldb/Core/ValueObject.h" #include "lldb/Expression/REPL.h" #include "lldb/Expression/UserExpression.h" @@ -58,6 +57,7 @@ #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Target/TargetList.cpp b/source/Target/TargetList.cpp index 43e1227ba205..5c652aced39f 100644 --- a/source/Target/TargetList.cpp +++ b/source/Target/TargetList.cpp @@ -15,7 +15,6 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/State.h" -#include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -24,6 +23,7 @@ #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" #include "lldb/Utility/TildeExpressionResolver.h" +#include "lldb/Utility/Timer.h" // Other libraries and framework includes #include "llvm/ADT/SmallString.h" diff --git a/source/Target/ThreadSpec.cpp b/source/Target/ThreadSpec.cpp index f769d1a775af..444a5a5b262a 100644 --- a/source/Target/ThreadSpec.cpp +++ b/source/Target/ThreadSpec.cpp @@ -11,9 +11,9 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Target/Thread.h" -#include "lldb/Core/StructuredData.h" #include "lldb/Target/ThreadSpec.h" +#include "lldb/Target/Thread.h" +#include "lldb/Utility/StructuredData.h" using namespace lldb; using namespace lldb_private; diff --git a/source/Utility/CMakeLists.txt b/source/Utility/CMakeLists.txt index 31b14acda962..78598562692b 100644 --- a/source/Utility/CMakeLists.txt +++ b/source/Utility/CMakeLists.txt @@ -1,5 +1,6 @@ add_lldb_library(lldbUtility Baton.cpp + Connection.cpp ConstString.cpp DataBufferHeap.cpp DataBufferLLVM.cpp @@ -8,6 +9,7 @@ add_lldb_library(lldbUtility FastDemangle.cpp FileSpec.cpp History.cpp + IOObject.cpp JSON.cpp LLDBAssert.cpp Log.cpp @@ -26,8 +28,10 @@ add_lldb_library(lldbUtility StringExtractorGDBRemote.cpp StringLexer.cpp StringList.cpp + StructuredData.cpp TaskPool.cpp TildeExpressionResolver.cpp + Timer.cpp UserID.cpp UriParser.cpp UUID.cpp diff --git a/source/Utility/Connection.cpp b/source/Utility/Connection.cpp new file mode 100644 index 000000000000..9f6114f6ed5d --- /dev/null +++ b/source/Utility/Connection.cpp @@ -0,0 +1,14 @@ +//===-- Connection.cpp ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Utility/Connection.h" + +using namespace lldb_private; + +Connection::~Connection() = default; diff --git a/source/Host/common/IOObject.cpp b/source/Utility/IOObject.cpp index 6f7de442be1d..df7929c4f911 100644 --- a/source/Host/common/IOObject.cpp +++ b/source/Utility/IOObject.cpp @@ -7,8 +7,9 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Host/IOObject.h" +#include "lldb/Utility/IOObject.h" using namespace lldb_private; const IOObject::WaitableHandle IOObject::kInvalidHandleValue = -1; +IOObject::~IOObject() = default; diff --git a/source/Utility/JSON.cpp b/source/Utility/JSON.cpp index cb23f140cbfe..1520bc7c47ec 100644 --- a/source/Utility/JSON.cpp +++ b/source/Utility/JSON.cpp @@ -191,7 +191,7 @@ JSONValue::SP JSONArray::GetObject(Index i) { JSONArray::Size JSONArray::GetNumElements() { return m_elements.size(); } -JSONParser::JSONParser(const char *cstr) : StringExtractor(cstr) {} +JSONParser::JSONParser(llvm::StringRef data) : StringExtractor(data) {} JSONParser::Token JSONParser::GetToken(std::string &value) { StreamString error; diff --git a/source/Core/StructuredData.cpp b/source/Utility/StructuredData.cpp index b03665ed3485..9fc05354cfd3 100644 --- a/source/Core/StructuredData.cpp +++ b/source/Utility/StructuredData.cpp @@ -7,28 +7,18 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Core/StructuredData.h" - -#include "lldb/Host/File.h" -#include "lldb/Host/StringConvert.h" +#include "lldb/Utility/StructuredData.h" #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/JSON.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" // for Stream #include "lldb/Utility/StreamString.h" -#include "lldb/lldb-enumerations.h" // for FilePermissions::eFilePermiss... -#include "lldb/lldb-forward.h" // for DataBufferSP - #include "llvm/ADT/STLExtras.h" // for make_unique - -#include <limits> // for numeric_limits - -#include <errno.h> +#include <cerrno> +#include <cstdlib> #include <inttypes.h> -#include <stdio.h> // for printf -#include <stdlib.h> -#include <sys/types.h> // for off_t +#include <limits> // for numeric_limits using namespace lldb_private; @@ -43,36 +33,20 @@ StructuredData::ObjectSP StructuredData::ParseJSONFromFile(const FileSpec &input_spec, Status &error) { StructuredData::ObjectSP return_sp; if (!input_spec.Exists()) { - error.SetErrorStringWithFormat("input file %s does not exist.", - input_spec.GetPath().c_str()); + error.SetErrorStringWithFormatv("input file {0} does not exist.", + input_spec); return return_sp; } - File input_file(nullptr, File::OpenOptions::eOpenOptionRead, - lldb::eFilePermissionsUserRead); - std::string input_path = input_spec.GetPath(); - error = - input_file.Open(input_path.c_str(), File::OpenOptions::eOpenOptionRead, - lldb::eFilePermissionsUserRead); - - if (!error.Success()) { - error.SetErrorStringWithFormat("could not open input file: %s - %s.", - input_spec.GetPath().c_str(), - error.AsCString()); + auto buffer_or_error = llvm::MemoryBuffer::getFile(input_spec.GetPath()); + if (!buffer_or_error) { + error.SetErrorStringWithFormatv("could not open input file: {0} - {1}.", + input_spec.GetPath(), + buffer_or_error.getError().message()); return return_sp; } - lldb::DataBufferSP input_data; - size_t num_bytes = std::numeric_limits<size_t>::max(); - off_t offset = 0; - error = input_file.Read(num_bytes, offset, true, input_data); - if (!error.Success()) { - error.SetErrorStringWithFormat("could not read input file: %s - %s.", - input_spec.GetPath().c_str(), - error.AsCString()); - return return_sp; - } - JSONParser json_parser((char *)input_data->GetBytes()); + JSONParser json_parser(buffer_or_error.get()->getBuffer()); return_sp = ParseJSONValue(json_parser); return return_sp; } @@ -146,16 +120,14 @@ static StructuredData::ObjectSP ParseJSONValue(JSONParser &json_parser) { return ParseJSONArray(json_parser); case JSONParser::Token::Integer: { - bool success = false; - uint64_t uval = StringConvert::ToUInt64(value.c_str(), 0, 0, &success); - if (success) + uint64_t uval; + if (llvm::to_integer(value, uval, 0)) return std::make_shared<StructuredData::Integer>(uval); } break; case JSONParser::Token::Float: { - bool success = false; - double val = StringConvert::ToDouble(value.c_str(), 0.0, &success); - if (success) + double val; + if (llvm::to_float(value, val)) return std::make_shared<StructuredData::Float>(val); } break; @@ -219,7 +191,7 @@ StructuredData::Object::GetObjectForDotSeparatedPath(llvm::StringRef path) { void StructuredData::Object::DumpToStdout(bool pretty_print) const { StreamString stream; Dump(stream, pretty_print); - printf("%s\n", stream.GetData()); + llvm::outs() << stream.GetString(); } void StructuredData::Array::Dump(Stream &s, bool pretty_print) const { diff --git a/source/Core/Timer.cpp b/source/Utility/Timer.cpp index 59c3e13a717e..fe7787458fa6 100644 --- a/source/Core/Timer.cpp +++ b/source/Utility/Timer.cpp @@ -6,11 +6,8 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -#include "lldb/Core/Timer.h" - -#include "lldb/Host/Host.h" +#include "lldb/Utility/Timer.h" #include "lldb/Utility/Stream.h" -#include "lldb/lldb-types.h" // for thread_key_t #include <algorithm> #include <map> diff --git a/tools/debugserver/source/RNBRemote.cpp b/tools/debugserver/source/RNBRemote.cpp index 038142a0351e..cf6b4b626914 100644 --- a/tools/debugserver/source/RNBRemote.cpp +++ b/tools/debugserver/source/RNBRemote.cpp @@ -6058,7 +6058,7 @@ rnb_err_t RNBRemote::HandlePacket_qProcessInfo(const char *p) { // need to override the host cpusubtype (which is in the // CPU_SUBTYPE_ARM64 subtype namespace) // with a reasonable CPU_SUBTYPE_ARMV7 subtype. - cpusubtype = 11; // CPU_SUBTYPE_ARM_V7S + cpusubtype = 12; // CPU_SUBTYPE_ARM_V7K } } rep << "cpusubtype:" << std::hex << cpusubtype << ';'; diff --git a/tools/debugserver/source/debugserver.cpp b/tools/debugserver/source/debugserver.cpp index bc1954de334a..318e72e971a5 100644 --- a/tools/debugserver/source/debugserver.cpp +++ b/tools/debugserver/source/debugserver.cpp @@ -876,8 +876,8 @@ static struct option g_long_options[] = { 'u'}, // If we need to handshake with our parent process, an option will be // passed down that specifies a unix socket name to use {"fd", required_argument, NULL, - 'FDSC'}, // A file descriptor was passed to this process when spawned that - // is already open and ready for communication + '2'}, // A file descriptor was passed to this process when spawned that + // is already open and ready for communication {"named-pipe", required_argument, NULL, 'P'}, {"reverse-connect", no_argument, NULL, 'R'}, {"env", required_argument, NULL, @@ -1261,7 +1261,7 @@ int main(int argc, char *argv[]) { } break; - case 'FDSC': + case '2': // File descriptor passed to this process during fork/exec and is already // open and ready for communication. communication_fd = atoi(optarg); diff --git a/tools/lldb-server/Acceptor.h b/tools/lldb-server/Acceptor.h index 207bb4d973a5..7d1a5695a364 100644 --- a/tools/lldb-server/Acceptor.h +++ b/tools/lldb-server/Acceptor.h @@ -9,8 +9,8 @@ #ifndef lldb_server_Acceptor_h_ #define lldb_server_Acceptor_h_ -#include "lldb/Core/Connection.h" #include "lldb/Host/Socket.h" +#include "lldb/Utility/Connection.h" #include "lldb/Utility/Status.h" #include <functional> diff --git a/unittests/Core/CMakeLists.txt b/unittests/Core/CMakeLists.txt index 73dd0d83fee3..426009661b12 100644 --- a/unittests/Core/CMakeLists.txt +++ b/unittests/Core/CMakeLists.txt @@ -6,8 +6,6 @@ add_lldb_unittest(LLDBCoreTests ScalarTest.cpp StateTest.cpp StreamCallbackTest.cpp - StructuredDataTest.cpp - TimerTest.cpp LINK_LIBS lldbCore diff --git a/unittests/Core/StructuredDataTest.cpp b/unittests/Core/StructuredDataTest.cpp deleted file mode 100644 index cdcf3236cd77..000000000000 --- a/unittests/Core/StructuredDataTest.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===-- StructuredDataTest.cpp ----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "gtest/gtest.h" - -#include "lldb/Core/StructuredData.h" -#include "lldb/Utility/StreamString.h" - -#include "llvm/BinaryFormat/MachO.h" - -using namespace lldb; -using namespace lldb_private; - -TEST(StructuredDataTest, StringDump) { - std::pair<llvm::StringRef, llvm::StringRef> TestCases[] = { - { R"(asdfg)", R"("asdfg")" }, - { R"(as"df)", R"("as\"df")" }, - { R"(as\df)", R"("as\\df")" }, - }; - for(auto P : TestCases) { - StreamString S; - const bool pretty_print = false; - StructuredData::String(P.first).Dump(S, pretty_print); - EXPECT_EQ(P.second, S.GetString()); - } -} diff --git a/unittests/Interpreter/CMakeLists.txt b/unittests/Interpreter/CMakeLists.txt index d884dee62ec5..7be092b24b5e 100644 --- a/unittests/Interpreter/CMakeLists.txt +++ b/unittests/Interpreter/CMakeLists.txt @@ -4,7 +4,7 @@ add_lldb_unittest(InterpreterTests LINK_LIBS lldbInterpreter - lldbUtilityMocks + lldbUtilityHelpers ) target_link_libraries(InterpreterTests diff --git a/unittests/Interpreter/TestCompletion.cpp b/unittests/Interpreter/TestCompletion.cpp index 0548b93d6f72..0baf61fdaf34 100644 --- a/unittests/Interpreter/TestCompletion.cpp +++ b/unittests/Interpreter/TestCompletion.cpp @@ -12,13 +12,12 @@ #include "lldb/Utility/StringList.h" #include "lldb/Utility/TildeExpressionResolver.h" +#include "unittests/Utility/Helpers/MockTildeExpressionResolver.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" -#include "unittests/Utility/Mocks/MockTildeExpressionResolver.h" - namespace fs = llvm::sys::fs; namespace path = llvm::sys::path; using namespace llvm; diff --git a/unittests/ObjectFile/ELF/CMakeLists.txt b/unittests/ObjectFile/ELF/CMakeLists.txt index a182f4a4244e..652c221a6d84 100644 --- a/unittests/ObjectFile/ELF/CMakeLists.txt +++ b/unittests/ObjectFile/ELF/CMakeLists.txt @@ -6,6 +6,7 @@ add_lldb_unittest(ObjectFileELFTests lldbPluginObjectFileELF lldbPluginSymbolVendorELF lldbCore + lldbUtilityHelpers ) add_dependencies(ObjectFileELFTests yaml2obj) diff --git a/unittests/ObjectFile/ELF/TestObjectFileELF.cpp b/unittests/ObjectFile/ELF/TestObjectFileELF.cpp index 6ed9b2357bb1..e9b3e9fcf237 100644 --- a/unittests/ObjectFile/ELF/TestObjectFileELF.cpp +++ b/unittests/ObjectFile/ELF/TestObjectFileELF.cpp @@ -9,20 +9,18 @@ //===----------------------------------------------------------------------===// #include "Plugins/ObjectFile/ELF/ObjectFileELF.h" +#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/Section.h" #include "lldb/Host/HostInfo.h" +#include "unittests/Utility/Helpers/TestUtilities.h" #include "llvm/Support/FileUtilities.h" #include "llvm/Support/Path.h" #include "llvm/Support/Program.h" #include "llvm/Support/raw_ostream.h" #include "gtest/gtest.h" -#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h" - -extern const char *TestMainArgv0; - using namespace lldb_private; using namespace lldb; @@ -32,10 +30,6 @@ public: HostInfo::Initialize(); ObjectFileELF::Initialize(); SymbolVendorELF::Initialize(); - - m_inputs_folder = llvm::sys::path::parent_path(TestMainArgv0); - llvm::sys::path::append(m_inputs_folder, "Inputs"); - llvm::sys::fs::make_absolute(m_inputs_folder); } void TearDown() override { @@ -45,7 +39,6 @@ public: } protected: - llvm::SmallString<128> m_inputs_folder; }; #define ASSERT_NO_ERROR(x) \ @@ -60,9 +53,8 @@ protected: } TEST_F(ObjectFileELFTest, SectionsResolveConsistently) { - llvm::SmallString<128> yaml = m_inputs_folder; - llvm::sys::path::append(yaml, "sections-resolve-consistently.yaml"); - llvm::SmallString<128> obj = m_inputs_folder; + std::string yaml = GetInputFilePath("sections-resolve-consistently.yaml"); + llvm::SmallString<128> obj; ASSERT_NO_ERROR(llvm::sys::fs::createTemporaryFile( "sections-resolve-consistently-%%%%%%", "obj", obj)); diff --git a/unittests/Process/CMakeLists.txt b/unittests/Process/CMakeLists.txt index 70f59382afa1..75db3bec625a 100644 --- a/unittests/Process/CMakeLists.txt +++ b/unittests/Process/CMakeLists.txt @@ -1,2 +1,5 @@ add_subdirectory(gdb-remote) +if (CMAKE_SYSTEM_NAME MATCHES "Linux|Android") + add_subdirectory(Linux) +endif() add_subdirectory(minidump) diff --git a/unittests/Process/Linux/CMakeLists.txt b/unittests/Process/Linux/CMakeLists.txt new file mode 100644 index 000000000000..3b55b5c84305 --- /dev/null +++ b/unittests/Process/Linux/CMakeLists.txt @@ -0,0 +1,8 @@ +include_directories(${LLDB_SOURCE_DIR}/source/Plugins/Process/Linux) + +add_lldb_unittest(ProcessorTraceTest + ProcessorTraceTest.cpp + + LINK_LIBS + lldbPluginProcessLinux + )
\ No newline at end of file diff --git a/unittests/Process/Linux/ProcessorTraceTest.cpp b/unittests/Process/Linux/ProcessorTraceTest.cpp new file mode 100644 index 000000000000..b732934d014d --- /dev/null +++ b/unittests/Process/Linux/ProcessorTraceTest.cpp @@ -0,0 +1,152 @@ +//===-- ProcessorTraceMonitorTest.cpp ------------------------- -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "gtest/gtest.h" + +#include "ProcessorTrace.h" +#include "llvm/ADT/ArrayRef.h" +// C Includes + +// C++ Includes + +using namespace lldb_private; +using namespace process_linux; + +size_t ReadCylicBufferWrapper(void *buf, size_t buf_size, void *cyc_buf, + size_t cyc_buf_size, size_t cyc_start, + size_t offset) { + llvm::MutableArrayRef<uint8_t> dst(reinterpret_cast<uint8_t *>(buf), + buf_size); + llvm::MutableArrayRef<uint8_t> src(reinterpret_cast<uint8_t *>(cyc_buf), + cyc_buf_size); + ProcessorTraceMonitor::ReadCyclicBuffer(dst, src, cyc_start, offset); + return dst.size(); +} + +TEST(CyclicBuffer, EdgeCases) { + size_t bytes_read = 0; + uint8_t cyclic_buffer[6] = {'l', 'i', 'c', 'c', 'y', 'c'}; + + // We will always leave the last bytes untouched + // so that string comparisions work. + char bigger_buffer[10] = {}; + char equal_size_buffer[7] = {}; + char smaller_buffer[4] = {}; + + // empty buffer to read into + bytes_read = ReadCylicBufferWrapper(smaller_buffer, 0, cyclic_buffer, + sizeof(cyclic_buffer), 3, 0); + ASSERT_EQ(0, bytes_read); + + // empty cyclic buffer + bytes_read = ReadCylicBufferWrapper(smaller_buffer, sizeof(smaller_buffer), + cyclic_buffer, 0, 3, 0); + ASSERT_EQ(0, bytes_read); + + // bigger offset + bytes_read = + ReadCylicBufferWrapper(smaller_buffer, sizeof(smaller_buffer), + cyclic_buffer, sizeof(cyclic_buffer), 3, 6); + ASSERT_EQ(0, bytes_read); + + // wrong offset + bytes_read = + ReadCylicBufferWrapper(smaller_buffer, sizeof(smaller_buffer), + cyclic_buffer, sizeof(cyclic_buffer), 3, 7); + ASSERT_EQ(0, bytes_read); + + // wrong start + bytes_read = + ReadCylicBufferWrapper(smaller_buffer, sizeof(smaller_buffer), + cyclic_buffer, sizeof(cyclic_buffer), 3, 7); + ASSERT_EQ(0, bytes_read); +} + +TEST(CyclicBuffer, EqualSizeBuffer) { + size_t bytes_read = 0; + uint8_t cyclic_buffer[6] = {'l', 'i', 'c', 'c', 'y', 'c'}; + + char cyclic[] = "cyclic"; + for (int i = 0; i < sizeof(cyclic); i++) { + // We will always leave the last bytes untouched + // so that string comparisions work. + char equal_size_buffer[7] = {}; + bytes_read = + ReadCylicBufferWrapper(equal_size_buffer, sizeof(cyclic_buffer), + cyclic_buffer, sizeof(cyclic_buffer), 3, i); + ASSERT_EQ((sizeof(cyclic) - i - 1), bytes_read); + ASSERT_STREQ(equal_size_buffer, (cyclic + i)); + } +} + +TEST(CyclicBuffer, SmallerSizeBuffer) { + size_t bytes_read = 0; + uint8_t cyclic_buffer[6] = {'l', 'i', 'c', 'c', 'y', 'c'}; + + // We will always leave the last bytes untouched + // so that string comparisions work. + char smaller_buffer[4] = {}; + bytes_read = + ReadCylicBufferWrapper(smaller_buffer, (sizeof(smaller_buffer) - 1), + cyclic_buffer, sizeof(cyclic_buffer), 3, 0); + ASSERT_EQ(3, bytes_read); + ASSERT_STREQ(smaller_buffer, "cyc"); + + bytes_read = + ReadCylicBufferWrapper(smaller_buffer, (sizeof(smaller_buffer) - 1), + cyclic_buffer, sizeof(cyclic_buffer), 3, 1); + ASSERT_EQ(3, bytes_read); + ASSERT_STREQ(smaller_buffer, "ycl"); + + bytes_read = + ReadCylicBufferWrapper(smaller_buffer, (sizeof(smaller_buffer) - 1), + cyclic_buffer, sizeof(cyclic_buffer), 3, 2); + ASSERT_EQ(3, bytes_read); + ASSERT_STREQ(smaller_buffer, "cli"); + + bytes_read = + ReadCylicBufferWrapper(smaller_buffer, (sizeof(smaller_buffer) - 1), + cyclic_buffer, sizeof(cyclic_buffer), 3, 3); + ASSERT_EQ(3, bytes_read); + ASSERT_STREQ(smaller_buffer, "lic"); + + { + char smaller_buffer[4] = {}; + bytes_read = + ReadCylicBufferWrapper(smaller_buffer, (sizeof(smaller_buffer) - 1), + cyclic_buffer, sizeof(cyclic_buffer), 3, 4); + ASSERT_EQ(2, bytes_read); + ASSERT_STREQ(smaller_buffer, "ic"); + } + { + char smaller_buffer[4] = {}; + bytes_read = + ReadCylicBufferWrapper(smaller_buffer, (sizeof(smaller_buffer) - 1), + cyclic_buffer, sizeof(cyclic_buffer), 3, 5); + ASSERT_EQ(1, bytes_read); + ASSERT_STREQ(smaller_buffer, "c"); + } +} + +TEST(CyclicBuffer, BiggerSizeBuffer) { + size_t bytes_read = 0; + uint8_t cyclic_buffer[6] = {'l', 'i', 'c', 'c', 'y', 'c'}; + + char cyclic[] = "cyclic"; + for (int i = 0; i < sizeof(cyclic); i++) { + // We will always leave the last bytes untouched + // so that string comparisions work. + char bigger_buffer[10] = {}; + bytes_read = + ReadCylicBufferWrapper(bigger_buffer, (sizeof(bigger_buffer) - 1), + cyclic_buffer, sizeof(cyclic_buffer), 3, i); + ASSERT_EQ((sizeof(cyclic) - i - 1), bytes_read); + ASSERT_STREQ(bigger_buffer, (cyclic + i)); + } +} diff --git a/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp index cd2583bb8f54..90a9c7ea7a0f 100644 --- a/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp +++ b/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp @@ -12,10 +12,10 @@ #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h" #include "lldb/Core/ModuleSpec.h" -#include "lldb/Core/StructuredData.h" -#include "lldb/Core/TraceOptions.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Utility/DataBuffer.h" +#include "lldb/Utility/StructuredData.h" +#include "lldb/Utility/TraceOptions.h" #include "lldb/lldb-enumerations.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/Testing/Support/Error.h" diff --git a/unittests/Process/minidump/CMakeLists.txt b/unittests/Process/minidump/CMakeLists.txt index 2b2df6327e9a..e1b8154e1c31 100644 --- a/unittests/Process/minidump/CMakeLists.txt +++ b/unittests/Process/minidump/CMakeLists.txt @@ -7,6 +7,7 @@ add_lldb_unittest(LLDBMinidumpTests lldbTarget lldbPluginProcessUtility lldbPluginProcessMinidump + lldbUtilityHelpers LINK_COMPONENTS Support ) diff --git a/unittests/Process/minidump/MinidumpParserTest.cpp b/unittests/Process/minidump/MinidumpParserTest.cpp index 755095f75918..a029466fc59e 100644 --- a/unittests/Process/minidump/MinidumpParserTest.cpp +++ b/unittests/Process/minidump/MinidumpParserTest.cpp @@ -23,7 +23,7 @@ #include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/FileSpec.h" - +#include "unittests/Utility/Helpers/TestUtilities.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/Support/FileSystem.h" @@ -35,24 +35,14 @@ // C++ includes #include <memory> -extern const char *TestMainArgv0; - using namespace lldb_private; using namespace minidump; class MinidumpParserTest : public testing::Test { public: - void SetUp() override { - llvm::StringRef dmp_folder = llvm::sys::path::parent_path(TestMainArgv0); - inputs_folder = dmp_folder; - llvm::sys::path::append(inputs_folder, "Inputs"); - } - void SetUpData(const char *minidump_filename, uint64_t load_size = UINT64_MAX) { - llvm::SmallString<128> filename = inputs_folder; - llvm::sys::path::append(filename, minidump_filename); - + std::string filename = GetInputFilePath(minidump_filename); auto BufferPtr = DataBufferLLVM::CreateSliceFromPath(filename, load_size, 0); llvm::Optional<MinidumpParser> optional_parser = @@ -62,7 +52,6 @@ public: ASSERT_GT(parser->GetData().size(), 0UL); } - llvm::SmallString<128> inputs_folder; std::unique_ptr<MinidumpParser> parser; }; diff --git a/unittests/Symbol/CMakeLists.txt b/unittests/Symbol/CMakeLists.txt index dca5f17b15de..2d042648c4b3 100644 --- a/unittests/Symbol/CMakeLists.txt +++ b/unittests/Symbol/CMakeLists.txt @@ -1,8 +1,17 @@ add_lldb_unittest(SymbolTests TestClangASTContext.cpp + TestDWARFCallFrameInfo.cpp TestType.cpp LINK_LIBS lldbHost lldbSymbol + lldbUtilityHelpers ) + +add_dependencies(SymbolTests yaml2obj) +add_definitions(-DYAML2OBJ="$<TARGET_FILE:yaml2obj>") +set(test_inputs + basic-call-frame-info.yaml + ) +add_unittest_inputs(SymbolTests "${test_inputs}") diff --git a/unittests/Symbol/Inputs/basic-call-frame-info.yaml b/unittests/Symbol/Inputs/basic-call-frame-info.yaml new file mode 100644 index 000000000000..7bd8a48b87db --- /dev/null +++ b/unittests/Symbol/Inputs/basic-call-frame-info.yaml @@ -0,0 +1,138 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 + Entry: 0x0000000000000260 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000000260 + AddressAlign: 0x0000000000000010 + Content: 554889E5897DFC8B45FC5DC30F1F4000554889E5897DFC8B45FC5DC30F1F4000554889E5897DFC8B45FC5DC3 +#0000000000000260 <eh_frame>: +# 260: 55 push %rbp +# 261: 48 89 e5 mov %rsp,%rbp +# 264: 89 7d fc mov %edi,-0x4(%rbp) +# 267: 8b 45 fc mov -0x4(%rbp),%eax +# 26a: 5d pop %rbp +# 26b: c3 retq +# 26c: 0f 1f 40 00 nopl 0x0(%rax) +# +#0000000000000270 <debug_frame3>: +# 270: 55 push %rbp +# 271: 48 89 e5 mov %rsp,%rbp +# 274: 89 7d fc mov %edi,-0x4(%rbp) +# 277: 8b 45 fc mov -0x4(%rbp),%eax +# 27a: 5d pop %rbp +# 27b: c3 retq +# 27c: 0f 1f 40 00 nopl 0x0(%rax) +# +#0000000000000280 <debug_frame4>: +# 280: 55 push %rbp +# 281: 48 89 e5 mov %rsp,%rbp +# 284: 89 7d fc mov %edi,-0x4(%rbp) +# 287: 8b 45 fc mov -0x4(%rbp),%eax +# 28a: 5d pop %rbp +# 28b: c3 retq + - Name: .eh_frame + Type: SHT_X86_64_UNWIND + Flags: [ SHF_ALLOC ] + Address: 0x0000000000000290 + AddressAlign: 0x0000000000000008 + Content: 1400000000000000017A5200017810011B0C0708900100001C0000001C000000B0FFFFFF0C00000000410E108602430D0600000000000000 +#00000000 0000000000000014 00000000 CIE +# Version: 1 +# Augmentation: "zR" +# Code alignment factor: 1 +# Data alignment factor: -8 +# Return address column: 16 +# Augmentation data: 1b +# +# DW_CFA_def_cfa: r7 (rsp) ofs 8 +# DW_CFA_offset: r16 (rip) at cfa-8 +# DW_CFA_nop +# DW_CFA_nop +# +#00000018 000000000000001c 0000001c FDE cie=00000000 pc=ffffffffffffffd0..ffffffffffffffdc +# DW_CFA_advance_loc: 1 to ffffffffffffffd1 +# DW_CFA_def_cfa_offset: 16 +# DW_CFA_offset: r6 (rbp) at cfa-16 +# DW_CFA_advance_loc: 3 to ffffffffffffffd4 +# DW_CFA_def_cfa_register: r6 (rbp) +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop + - Name: .debug_frame + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000008 + Content: 14000000FFFFFFFF03000178100C070890010000000000001C0000000000000070020000000000000C00000000000000410E108602430D0614000000FFFFFFFF040008000178100C07089001000000001C0000003800000080020000000000000C00000000000000410E108602430D06 +#00000000 0000000000000014 ffffffff CIE +# Version: 3 +# Augmentation: "" +# Code alignment factor: 1 +# Data alignment factor: -8 +# Return address column: 16 +# +# DW_CFA_def_cfa: r7 (rsp) ofs 8 +# DW_CFA_offset: r16 (rip) at cfa-8 +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# +#00000018 000000000000001c 00000000 FDE cie=00000000 pc=0000000000000270..000000000000027c +# DW_CFA_advance_loc: 1 to 0000000000000271 +# DW_CFA_def_cfa_offset: 16 +# DW_CFA_offset: r6 (rbp) at cfa-16 +# DW_CFA_advance_loc: 3 to 0000000000000274 +# DW_CFA_def_cfa_register: r6 (rbp) +# +#00000038 0000000000000014 ffffffff CIE +# Version: 4 +# Augmentation: "" +# Pointer Size: 8 +# Segment Size: 0 +# Code alignment factor: 1 +# Data alignment factor: -8 +# Return address column: 16 +# +# DW_CFA_def_cfa: r7 (rsp) ofs 8 +# DW_CFA_offset: r16 (rip) at cfa-8 +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# +#00000050 000000000000001c 00000038 FDE cie=00000038 pc=0000000000000280..000000000000028c +# DW_CFA_advance_loc: 1 to 0000000000000281 +# DW_CFA_def_cfa_offset: 16 +# DW_CFA_offset: r6 (rbp) at cfa-16 +# DW_CFA_advance_loc: 3 to 0000000000000284 +# DW_CFA_def_cfa_register: r6 (rbp) +Symbols: + Global: + - Name: eh_frame + Type: STT_FUNC + Section: .text + Value: 0x0000000000000260 + Size: 0x000000000000000C + - Name: debug_frame3 + Type: STT_FUNC + Section: .text + Value: 0x0000000000000270 + Size: 0x000000000000000C + - Name: debug_frame4 + Type: STT_FUNC + Section: .text + Value: 0x0000000000000280 + Size: 0x000000000000000C +... diff --git a/unittests/Symbol/TestDWARFCallFrameInfo.cpp b/unittests/Symbol/TestDWARFCallFrameInfo.cpp new file mode 100644 index 000000000000..40e3aac5fb37 --- /dev/null +++ b/unittests/Symbol/TestDWARFCallFrameInfo.cpp @@ -0,0 +1,142 @@ +//===-- TestDWARFCallFrameInfo.cpp ------------------------------*- C++ -*-===// +// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "Plugins/ObjectFile/ELF/ObjectFileELF.h" +#include "Plugins/Process/Utility/RegisterContext_x86.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/ModuleSpec.h" +#include "lldb/Core/Section.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/DWARFCallFrameInfo.h" +#include "lldb/Utility/StreamString.h" +#include "unittests/Utility/Helpers/TestUtilities.h" +#include "llvm/Support/FileUtilities.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/Program.h" +#include "llvm/Support/raw_ostream.h" +#include "gtest/gtest.h" + +using namespace lldb_private; +using namespace lldb; + +class DWARFCallFrameInfoTest : public testing::Test { +public: + void SetUp() override { + HostInfo::Initialize(); + ObjectFileELF::Initialize(); + } + + void TearDown() override { + ObjectFileELF::Terminate(); + HostInfo::Terminate(); + } + +protected: + void TestBasic(DWARFCallFrameInfo::Type type, llvm::StringRef symbol); +}; + +#define ASSERT_NO_ERROR(x) \ + if (std::error_code ASSERT_NO_ERROR_ec = x) { \ + llvm::SmallString<128> MessageStorage; \ + llvm::raw_svector_ostream Message(MessageStorage); \ + Message << #x ": did not return errc::success.\n" \ + << "error number: " << ASSERT_NO_ERROR_ec.value() << "\n" \ + << "error message: " << ASSERT_NO_ERROR_ec.message() << "\n"; \ + GTEST_FATAL_FAILURE_(MessageStorage.c_str()); \ + } else { \ + } + +namespace lldb_private { +static std::ostream &operator<<(std::ostream &OS, const UnwindPlan::Row &row) { + StreamString SS; + row.Dump(SS, nullptr, nullptr, 0); + return OS << SS.GetData(); +} +} // namespace lldb_private + +static UnwindPlan::Row GetExpectedRow0() { + UnwindPlan::Row row; + row.SetOffset(0); + row.GetCFAValue().SetIsRegisterPlusOffset(dwarf_rsp_x86_64, 8); + row.SetRegisterLocationToAtCFAPlusOffset(dwarf_rip_x86_64, -8, false); + return row; +} + +static UnwindPlan::Row GetExpectedRow1() { + UnwindPlan::Row row; + row.SetOffset(1); + row.GetCFAValue().SetIsRegisterPlusOffset(dwarf_rsp_x86_64, 16); + row.SetRegisterLocationToAtCFAPlusOffset(dwarf_rip_x86_64, -8, false); + row.SetRegisterLocationToAtCFAPlusOffset(dwarf_rbp_x86_64, -16, false); + return row; +} + +static UnwindPlan::Row GetExpectedRow2() { + UnwindPlan::Row row; + row.SetOffset(4); + row.GetCFAValue().SetIsRegisterPlusOffset(dwarf_rbp_x86_64, 16); + row.SetRegisterLocationToAtCFAPlusOffset(dwarf_rip_x86_64, -8, false); + row.SetRegisterLocationToAtCFAPlusOffset(dwarf_rbp_x86_64, -16, false); + return row; +} + +void DWARFCallFrameInfoTest::TestBasic(DWARFCallFrameInfo::Type type, + llvm::StringRef symbol) { + std::string yaml = GetInputFilePath("basic-call-frame-info.yaml"); + llvm::SmallString<128> obj; + + ASSERT_NO_ERROR(llvm::sys::fs::createTemporaryFile( + "basic-call-frame-info-%%%%%%", "obj", obj)); + llvm::FileRemover obj_remover(obj); + + const char *args[] = {YAML2OBJ, yaml.c_str(), nullptr}; + llvm::StringRef obj_ref = obj; + const llvm::StringRef *redirects[] = {nullptr, &obj_ref, nullptr}; + ASSERT_EQ(0, llvm::sys::ExecuteAndWait(YAML2OBJ, args, nullptr, redirects)); + + uint64_t size; + ASSERT_NO_ERROR(llvm::sys::fs::file_size(obj, size)); + ASSERT_GT(size, 0u); + + auto module_sp = std::make_shared<Module>(ModuleSpec(FileSpec(obj, false))); + SectionList *list = module_sp->GetSectionList(); + ASSERT_NE(nullptr, list); + + auto section_sp = list->FindSectionByType(type == DWARFCallFrameInfo::EH + ? eSectionTypeEHFrame + : eSectionTypeDWARFDebugFrame, + false); + ASSERT_NE(nullptr, section_sp); + + DWARFCallFrameInfo cfi(*module_sp->GetObjectFile(), section_sp, type); + + const Symbol *sym = module_sp->FindFirstSymbolWithNameAndType( + ConstString(symbol), eSymbolTypeAny); + ASSERT_NE(nullptr, sym); + + UnwindPlan plan(eRegisterKindGeneric); + ASSERT_TRUE(cfi.GetUnwindPlan(sym->GetAddress(), plan)); + ASSERT_EQ(3, plan.GetRowCount()); + EXPECT_EQ(GetExpectedRow0(), *plan.GetRowAtIndex(0)); + EXPECT_EQ(GetExpectedRow1(), *plan.GetRowAtIndex(1)); + EXPECT_EQ(GetExpectedRow2(), *plan.GetRowAtIndex(2)); +} + +TEST_F(DWARFCallFrameInfoTest, Basic_dwarf3) { + TestBasic(DWARFCallFrameInfo::DWARF, "debug_frame3"); +} + +TEST_F(DWARFCallFrameInfoTest, Basic_dwarf4) { + TestBasic(DWARFCallFrameInfo::DWARF, "debug_frame4"); +} + +TEST_F(DWARFCallFrameInfoTest, Basic_eh) { + TestBasic(DWARFCallFrameInfo::EH, "eh_frame"); +} diff --git a/unittests/SymbolFile/DWARF/CMakeLists.txt b/unittests/SymbolFile/DWARF/CMakeLists.txt index c764bd477fab..b2ece4eeaed7 100644 --- a/unittests/SymbolFile/DWARF/CMakeLists.txt +++ b/unittests/SymbolFile/DWARF/CMakeLists.txt @@ -8,6 +8,7 @@ add_lldb_unittest(SymbolFileDWARFTests lldbPluginObjectFilePECOFF lldbPluginSymbolFileDWARF lldbPluginSymbolFilePDB + lldbUtilityHelpers LINK_COMPONENTS Support DebugInfoPDB diff --git a/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp b/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp index 8ef6ad05bd54..298bed10f3f8 100644 --- a/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp +++ b/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp @@ -15,6 +15,9 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" +#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h" +#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" +#include "Plugins/SymbolFile/PDB/SymbolFilePDB.h" #include "lldb/Core/Address.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Module.h" @@ -25,12 +28,7 @@ #include "lldb/Symbol/LineTable.h" #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Utility/FileSpec.h" - -#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h" -#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" -#include "Plugins/SymbolFile/PDB/SymbolFilePDB.h" - -extern const char *TestMainArgv0; +#include "unittests/Utility/Helpers/TestUtilities.h" using namespace lldb_private; @@ -46,12 +44,7 @@ public: ClangASTContext::Initialize(); SymbolFilePDB::Initialize(); - llvm::StringRef exe_folder = llvm::sys::path::parent_path(TestMainArgv0); - llvm::SmallString<128> inputs_folder = exe_folder; - llvm::sys::path::append(inputs_folder, "Inputs"); - - m_dwarf_test_exe = inputs_folder; - llvm::sys::path::append(m_dwarf_test_exe, "test-dwarf.exe"); + m_dwarf_test_exe = GetInputFilePath("test-dwarf.exe"); } void TearDown() override { @@ -63,12 +56,12 @@ public: } protected: - llvm::SmallString<128> m_dwarf_test_exe; + std::string m_dwarf_test_exe; }; TEST_F(SymbolFileDWARFTests, TestAbilitiesForDWARF) { // Test that when we have Dwarf debug info, SymbolFileDWARF is used. - FileSpec fspec(m_dwarf_test_exe.c_str(), false); + FileSpec fspec(m_dwarf_test_exe, false); ArchSpec aspec("i686-pc-windows"); lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec); diff --git a/unittests/SymbolFile/PDB/CMakeLists.txt b/unittests/SymbolFile/PDB/CMakeLists.txt index d9aff4e2eaca..dd7e2248aed4 100644 --- a/unittests/SymbolFile/PDB/CMakeLists.txt +++ b/unittests/SymbolFile/PDB/CMakeLists.txt @@ -8,6 +8,7 @@ add_lldb_unittest(SymbolFilePDBTests lldbPluginObjectFilePECOFF lldbPluginSymbolFileDWARF lldbPluginSymbolFilePDB + lldbUtilityHelpers LINK_COMPONENTS Support DebugInfoPDB diff --git a/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp b/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp index 226057f89369..0e63a4104234 100644 --- a/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp +++ b/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp @@ -15,6 +15,9 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" +#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h" +#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" +#include "Plugins/SymbolFile/PDB/SymbolFilePDB.h" #include "lldb/Core/Address.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Module.h" @@ -25,10 +28,7 @@ #include "lldb/Symbol/LineTable.h" #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Utility/FileSpec.h" - -#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h" -#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" -#include "Plugins/SymbolFile/PDB/SymbolFilePDB.h" +#include "unittests/Utility/Helpers/TestUtilities.h" #if defined(_MSC_VER) #include "lldb/Host/windows/windows.h" @@ -37,8 +37,6 @@ #include <algorithm> -extern const char *TestMainArgv0; - using namespace lldb_private; class SymbolFilePDBTests : public testing::Test { @@ -57,14 +55,8 @@ public: ClangASTContext::Initialize(); SymbolFilePDB::Initialize(); - llvm::StringRef exe_folder = llvm::sys::path::parent_path(TestMainArgv0); - llvm::SmallString<128> inputs_folder = exe_folder; - llvm::sys::path::append(inputs_folder, "Inputs"); - - m_pdb_test_exe = inputs_folder; - m_types_test_exe = inputs_folder; - llvm::sys::path::append(m_pdb_test_exe, "test-pdb.exe"); - llvm::sys::path::append(m_types_test_exe, "test-pdb-types.exe"); + m_pdb_test_exe = GetInputFilePath("test-pdb.exe"); + m_types_test_exe = GetInputFilePath("test-pdb-types.exe"); } void TearDown() override { @@ -80,8 +72,8 @@ public: } protected: - llvm::SmallString<128> m_pdb_test_exe; - llvm::SmallString<128> m_types_test_exe; + std::string m_pdb_test_exe; + std::string m_types_test_exe; bool FileSpecMatchesAsBaseOrFull(const FileSpec &left, const FileSpec &right) const { diff --git a/unittests/Target/CMakeLists.txt b/unittests/Target/CMakeLists.txt index e4f6e52b0634..ec8f2db2c39f 100644 --- a/unittests/Target/CMakeLists.txt +++ b/unittests/Target/CMakeLists.txt @@ -8,6 +8,7 @@ add_lldb_unittest(TargetTests lldbSymbol lldbUtility lldbPluginObjectFileELF + lldbUtilityHelpers LINK_COMPONENTS Support ) diff --git a/unittests/Target/ModuleCacheTest.cpp b/unittests/Target/ModuleCacheTest.cpp index 8914f8b5eac4..122d789daf57 100644 --- a/unittests/Target/ModuleCacheTest.cpp +++ b/unittests/Target/ModuleCacheTest.cpp @@ -10,8 +10,7 @@ #include "lldb/Host/HostInfo.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/ModuleCache.h" - -extern const char *TestMainArgv0; +#include "unittests/Utility/Helpers/TestUtilities.h" using namespace lldb_private; using namespace lldb; @@ -26,7 +25,7 @@ public: protected: static FileSpec s_cache_dir; - static llvm::SmallString<128> s_test_executable; + static std::string s_test_executable; void TryGetAndPut(const FileSpec &cache_dir, const char *hostname, bool expect_download); @@ -34,7 +33,7 @@ protected: } FileSpec ModuleCacheTest::s_cache_dir; -llvm::SmallString<128> ModuleCacheTest::s_test_executable; +std::string ModuleCacheTest::s_test_executable; static const char dummy_hostname[] = "dummy_hostname"; static const char dummy_remote_dir[] = "bin"; @@ -71,10 +70,7 @@ void ModuleCacheTest::SetUpTestCase() { FileSpec tmpdir_spec; HostInfo::GetLLDBPath(lldb::ePathTypeLLDBTempSystemDir, s_cache_dir); - - llvm::StringRef exe_folder = llvm::sys::path::parent_path(TestMainArgv0); - s_test_executable = exe_folder; - llvm::sys::path::append(s_test_executable, "Inputs", module_name); + s_test_executable = GetInputFilePath(module_name); } void ModuleCacheTest::TearDownTestCase() { diff --git a/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp b/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp index e216d4be16fd..e97760967197 100644 --- a/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp +++ b/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp @@ -18,6 +18,7 @@ #include "lldb/Core/AddressRange.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Utility/StreamString.h" #include "llvm/Support/TargetSelect.h" @@ -130,6 +131,15 @@ std::unique_ptr<x86AssemblyInspectionEngine> Geti386Inspector() { return engine; } +namespace lldb_private { +static std::ostream &operator<<(std::ostream &OS, + const UnwindPlan::Row::CFAValue &CFA) { + StreamString S; + CFA.Dump(S, nullptr, nullptr); + return OS << S.GetData(); +} +} // namespace lldb_private + TEST_F(Testx86AssemblyInspectionEngine, TestSimple64bitFrameFunction) { std::unique_ptr<x86AssemblyInspectionEngine> engine = Getx86_64Inspector(); @@ -2337,3 +2347,71 @@ TEST_F(Testx86AssemblyInspectionEngine, Test32BitOnlyInstruction) { EXPECT_FALSE(row_sp->GetRegisterInfo(k_rbp, regloc)); } + +TEST_F(Testx86AssemblyInspectionEngine, TestStackRealign8BitDisp_i386) { + std::unique_ptr<x86AssemblyInspectionEngine> engine = Geti386Inspector(); + + uint8_t data[] = { + 0x55, // pushl %ebp + 0x89, 0xe5, // movl %esp, %ebp + 0x53, // pushl %ebx + 0x83, 0xe4, 0xf0, // andl $-16, %esp + 0x83, 0xec, 0x10, // subl $16, %esp + 0x8d, 0x65, 0xfc, // leal -4(%ebp), %esp + 0x5b, // popl %ebx + 0x5d, // popl %ebp + 0xc3, // retl + }; + + AddressRange sample_range(0x1000, sizeof(data)); + UnwindPlan plan(eRegisterKindLLDB); + ASSERT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(data, sizeof(data), + sample_range, plan)); + + UnwindPlan::Row::CFAValue esp_plus_4, esp_plus_8, ebp_plus_8; + esp_plus_4.SetIsRegisterPlusOffset(k_esp, 4); + esp_plus_8.SetIsRegisterPlusOffset(k_esp, 8); + ebp_plus_8.SetIsRegisterPlusOffset(k_ebp, 8); + + EXPECT_EQ(esp_plus_4, plan.GetRowForFunctionOffset(0)->GetCFAValue()); + EXPECT_EQ(esp_plus_8, plan.GetRowForFunctionOffset(1)->GetCFAValue()); + for (size_t i = 3; i < sizeof(data) - 2; ++i) + EXPECT_EQ(ebp_plus_8, plan.GetRowForFunctionOffset(i)->GetCFAValue()) + << "i: " << i; + EXPECT_EQ(esp_plus_4, + plan.GetRowForFunctionOffset(sizeof(data) - 1)->GetCFAValue()); +} + +TEST_F(Testx86AssemblyInspectionEngine, TestStackRealign32BitDisp_x86_64) { + std::unique_ptr<x86AssemblyInspectionEngine> engine = Getx86_64Inspector(); + + uint8_t data[] = { + 0x55, // pushq %rbp + 0x48, 0x89, 0xe5, // movq %rsp, %rbp + 0x53, // pushl %rbx + 0x48, 0x83, 0xe4, 0xf0, // andq $-16, %rsp + 0x48, 0x81, 0xec, 0x00, 0x01, 0x00, 0x00, // subq $256, %rsp + 0x48, 0x8d, 0x65, 0xf8, // leaq -8(%rbp), %rsp + 0x5b, // popq %rbx + 0x5d, // popq %rbp + 0xc3, // retq + }; + + AddressRange sample_range(0x1000, sizeof(data)); + UnwindPlan plan(eRegisterKindLLDB); + ASSERT_TRUE(engine->GetNonCallSiteUnwindPlanFromAssembly(data, sizeof(data), + sample_range, plan)); + + UnwindPlan::Row::CFAValue rsp_plus_8, rsp_plus_16, rbp_plus_16; + rsp_plus_8.SetIsRegisterPlusOffset(k_rsp, 8); + rsp_plus_16.SetIsRegisterPlusOffset(k_rsp, 16); + rbp_plus_16.SetIsRegisterPlusOffset(k_rbp, 16); + + EXPECT_EQ(rsp_plus_8, plan.GetRowForFunctionOffset(0)->GetCFAValue()); + EXPECT_EQ(rsp_plus_16, plan.GetRowForFunctionOffset(1)->GetCFAValue()); + for (size_t i = 4; i < sizeof(data) - 2; ++i) + EXPECT_EQ(rbp_plus_16, plan.GetRowForFunctionOffset(i)->GetCFAValue()) + << "i: " << i; + EXPECT_EQ(rsp_plus_8, + plan.GetRowForFunctionOffset(sizeof(data) - 1)->GetCFAValue()); +} diff --git a/unittests/Utility/CMakeLists.txt b/unittests/Utility/CMakeLists.txt index 86ac3c46d774..91cdbbda3ec3 100644 --- a/unittests/Utility/CMakeLists.txt +++ b/unittests/Utility/CMakeLists.txt @@ -1,4 +1,4 @@ -add_subdirectory(Mocks) +add_subdirectory(Helpers) add_lldb_unittest(UtilityTests ConstStringTest.cpp @@ -6,15 +6,21 @@ add_lldb_unittest(UtilityTests NameMatchesTest.cpp StatusTest.cpp StringExtractorTest.cpp + StructuredDataTest.cpp TaskPoolTest.cpp TildeExpressionResolverTest.cpp TimeoutTest.cpp + TimerTest.cpp UriParserTest.cpp VASprintfTest.cpp LINK_LIBS lldbUtility - lldbUtilityMocks + lldbUtilityHelpers LINK_COMPONENTS Support ) + +add_unittest_inputs(UtilityTests + StructuredData-basic.json + ) diff --git a/unittests/Utility/Mocks/CMakeLists.txt b/unittests/Utility/Helpers/CMakeLists.txt index 57db5bf3b628..36c774cb6826 100644 --- a/unittests/Utility/Mocks/CMakeLists.txt +++ b/unittests/Utility/Helpers/CMakeLists.txt @@ -1,5 +1,7 @@ -add_lldb_library(lldbUtilityMocks +set(EXCLUDE_FROM_ALL ON) +add_lldb_library(lldbUtilityHelpers MockTildeExpressionResolver.cpp + TestUtilities.cpp LINK_LIBS lldbUtility diff --git a/unittests/Utility/Mocks/MockTildeExpressionResolver.cpp b/unittests/Utility/Helpers/MockTildeExpressionResolver.cpp index 832836682b50..832836682b50 100644 --- a/unittests/Utility/Mocks/MockTildeExpressionResolver.cpp +++ b/unittests/Utility/Helpers/MockTildeExpressionResolver.cpp diff --git a/unittests/Utility/Mocks/MockTildeExpressionResolver.h b/unittests/Utility/Helpers/MockTildeExpressionResolver.h index 7ae5623f839a..18be1102e1fd 100644 --- a/unittests/Utility/Mocks/MockTildeExpressionResolver.h +++ b/unittests/Utility/Helpers/MockTildeExpressionResolver.h @@ -32,6 +32,6 @@ public: llvm::SmallVectorImpl<char> &Output) override; bool ResolvePartial(llvm::StringRef Expr, llvm::StringSet<> &Output) override; }; -} +} // namespace lldb_private #endif diff --git a/unittests/Utility/Helpers/TestUtilities.cpp b/unittests/Utility/Helpers/TestUtilities.cpp new file mode 100644 index 000000000000..eacf87661420 --- /dev/null +++ b/unittests/Utility/Helpers/TestUtilities.cpp @@ -0,0 +1,22 @@ +//===- TestUtilities.cpp ----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "TestUtilities.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" + +extern const char *TestMainArgv0; + +std::string lldb_private::GetInputFilePath(const llvm::Twine &name) { + llvm::SmallString<128> result = llvm::sys::path::parent_path(TestMainArgv0); + llvm::sys::fs::make_absolute(result); + llvm::sys::path::append(result, "Inputs", name); + return result.str(); +} diff --git a/unittests/Utility/Helpers/TestUtilities.h b/unittests/Utility/Helpers/TestUtilities.h new file mode 100644 index 000000000000..8d848797b7b2 --- /dev/null +++ b/unittests/Utility/Helpers/TestUtilities.h @@ -0,0 +1,20 @@ +//===- TestUtilities.h ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_UNITTESTS_UTILITY_HELPERS_TESTUTILITIES_H +#define LLDB_UNITTESTS_UTILITY_HELPERS_TESTUTILITIES_H + +#include "llvm/ADT/Twine.h" +#include <string> + +namespace lldb_private { +std::string GetInputFilePath(const llvm::Twine &name); +} + +#endif diff --git a/unittests/Utility/Inputs/StructuredData-basic.json b/unittests/Utility/Inputs/StructuredData-basic.json new file mode 100644 index 000000000000..b5d8bb58d9bc --- /dev/null +++ b/unittests/Utility/Inputs/StructuredData-basic.json @@ -0,0 +1 @@ +[1, 2, 3] diff --git a/unittests/Utility/StructuredDataTest.cpp b/unittests/Utility/StructuredDataTest.cpp new file mode 100644 index 000000000000..f346dd9e8322 --- /dev/null +++ b/unittests/Utility/StructuredDataTest.cpp @@ -0,0 +1,48 @@ +//===-- StructuredDataTest.cpp ----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "gtest/gtest.h" + +#include "Helpers/TestUtilities.h" +#include "lldb/Utility/Status.h" +#include "lldb/Utility/StreamString.h" +#include "lldb/Utility/StructuredData.h" +#include "llvm/Support/Path.h" + +using namespace lldb; +using namespace lldb_private; + +TEST(StructuredDataTest, StringDump) { + std::pair<llvm::StringRef, llvm::StringRef> TestCases[] = { + {R"(asdfg)", R"("asdfg")"}, + {R"(as"df)", R"("as\"df")"}, + {R"(as\df)", R"("as\\df")"}, + }; + for (auto P : TestCases) { + StreamString S; + const bool pretty_print = false; + StructuredData::String(P.first).Dump(S, pretty_print); + EXPECT_EQ(P.second, S.GetString()); + } +} + +TEST(StructuredDataTest, ParseJSONFromFile) { + Status status; + auto object_sp = StructuredData::ParseJSONFromFile( + FileSpec("non-existing-file.json", false), status); + EXPECT_EQ(nullptr, object_sp); + + std::string input = GetInputFilePath("StructuredData-basic.json"); + object_sp = StructuredData::ParseJSONFromFile(FileSpec(input, false), status); + ASSERT_NE(nullptr, object_sp); + + StreamString S; + object_sp->Dump(S, false); + EXPECT_EQ("[1,2,3]", S.GetString()); +} diff --git a/unittests/Utility/TildeExpressionResolverTest.cpp b/unittests/Utility/TildeExpressionResolverTest.cpp index fd953390ed5d..a24e998cb81d 100644 --- a/unittests/Utility/TildeExpressionResolverTest.cpp +++ b/unittests/Utility/TildeExpressionResolverTest.cpp @@ -1,6 +1,6 @@ #include "gtest/gtest.h" -#include "Mocks/MockTildeExpressionResolver.h" +#include "Helpers/MockTildeExpressionResolver.h" #include "lldb/Utility/TildeExpressionResolver.h" #include "llvm/ADT/SmallString.h" diff --git a/unittests/Core/TimerTest.cpp b/unittests/Utility/TimerTest.cpp index a35df0d49c8e..04b715915bff 100644 --- a/unittests/Core/TimerTest.cpp +++ b/unittests/Utility/TimerTest.cpp @@ -7,10 +7,9 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Core/Timer.h" -#include "gtest/gtest.h" - #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" +#include "gtest/gtest.h" #include <thread> using namespace lldb_private; diff --git a/unittests/tools/lldb-server/tests/MessageObjects.cpp b/unittests/tools/lldb-server/tests/MessageObjects.cpp index fd44bf6b23a9..9fcb4207675a 100644 --- a/unittests/tools/lldb-server/tests/MessageObjects.cpp +++ b/unittests/tools/lldb-server/tests/MessageObjects.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// #include "MessageObjects.h" -#include "lldb/Core/StructuredData.h" +#include "lldb/Utility/StructuredData.h" #include "llvm/ADT/StringExtras.h" #include "gtest/gtest.h" diff --git a/www/projects.html b/www/projects.html index e375eb9cc3d2..ff571998add5 100755 --- a/www/projects.html +++ b/www/projects.html @@ -441,6 +441,18 @@ And then you have to explain these conditions the user in some helpful way. </p> </li> + <li> + Unified IR interpreter. + <p> + Currently IRInterpreter implements a portion of the LLVM IR, but it doesn't handle + vector data types and there are plenty of instructions it also doesn't support. + Conversely, lli supports most of LLVM's IR but it doesn't handle remote memory and + its function calling support is very rudimentary. It would be useful to unify these + and make the IR interpreter -- both for LLVM and LLDB -- better. An alternate strategy + would be simply to JIT into the current process but have callbacks for non-stack memory + access. + </p> + </li> </ol> </div> <div class="postfooter"></div> |