diff options
Diffstat (limited to 'source/Plugins')
73 files changed, 1104 insertions, 152 deletions
diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp index 06b1c7054c1f0..fd5ee6ede4c37 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 5aa817c20ec2a..d3c20e1e618fa 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 a545dfc837da0..e301b21d542a9 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 589e2ea468efc..2dd7337542db2 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 c393ac9c916b8..716a73b854b39 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 88fb6ffd7a40a..e026e3248672a 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 614c6e8938065..882d5cd23e58d 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 81f1277419a64..f046968c213d2 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 ce8f8a65e3e34..f91ed851a3e54 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 c048e8634ae5e..8d23c2419bab8 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 425bf2ce0bf6d..74274f08b24f3 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 5f808291eac01..5a6809371d9fe 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 cb3644d46af47..63da5a77b48fb 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 038bf656b1f17..4dce54c4f073b 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 a77252a204999..95e2a7b0afeb0 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 980553c506bdb..0de8e7751fce4 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 baa478ea1106b..749e170fa17d1 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 ac7d9b8719460..6258c08e35f9d 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 00adfe1be82d8..06a8ce932fdae 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 8cb9bf24881f2..df3ebe83faf8d 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 449990d71304b..c090f01ccb1cd 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 29237a68fc9ec..21608a5c1cdd8 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 7f76d49bfb0fd..967e407188fac 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 e233a900e3954..5e3d20d7898b6 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 deccca8c29e93..10bbae5664918 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 8d420e88167c2..5b67e8656d365 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 fdfe45b663c17..a02d1ad9bee36 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 dd42686195b18..db90966e56157 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 81c2fcfb194fb..8b5052e4e2302 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 9fd21c06f30cb..e9af5a6cdc747 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 87440a2489e68..516d9fef5e8e2 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 2a10582b65d28..dc737d22a67a5 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 0c478bd57e827..8f138fc12073e 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 6aaf66cbb486f..2ba005e02ad42 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 b6f6ff7af19d4..2f33987751699 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 f15bcaa13844b..2a7735959a910 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 8a388a6673724..25bfce7a2b835 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 20e9a930b4861..3b33cf1601fb7 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 055a8219f1547..06406c6f16556 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 1a4ae1a21aecc..9bc171e454c98 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 4739a4934aa65..5607a71ad5aab 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 14bf0784dc2cc..588f3f7aec645 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 1eec30ef38c7c..2e16804109620 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 a29cc9e1ed868..f87852ed7f440 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 8a46d730caffa..8330cac160e6a 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 e39a1788fc000..8e378802de9c6 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 aa6fe44120680..6bf093f6a39a7 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 0000000000000..7043d50256e6c --- /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 0000000000000..ddcaf0f842b5b --- /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 66fb7aa155b42..d9a4508df0a34 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 0bd90dbf76202..1a4511a822309 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 a30bfa1e1f16c..228acfbed4eee 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 bce77d7e0a324..bd73a29e08713 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 6306651da7a15..a38110faaec62 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 d34a79453fed4..7523260c13e4a 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 73e3732df3efa..977c34c2a69b3 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 aeb7c742b4f44..042c96111bb3f 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 d7a4e961b5406..54a472d7332e0 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 27caf42fc4a5f..1a5b60aea2887 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 e613e3d6aa6c7..beeb647823676 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 d6d695fc2e746..b7fbd7347d086 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 fc97a76de59b5..79b2acc4b4f38 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 e923225f1d989..13c2d8726821d 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 67d8828c45167..694d34fc211cc 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 04bc2f4970757..766899c497b02 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 252a9807a3b5f..ef18c2b5d3bab 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 ad009a02a2aa2..eabff86a54287 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 094e48cf00e18..dbc1b9ee54705 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 5a377d7b04f7c..f952696ab21dd 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 5a79cb30eb813..6d6abd62dad2a 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 56212b94521a4..2dc5740da9b6b 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 9aad2e1e70e2a..9d79a411faad5 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 1c84c89aee833..2e7875966cb6c 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(); |