[Lldb-commits] [lldb] 3bea730 - [lldb] Fix compilation with gcc-6.5
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 31 23:45:07 PDT 2021
Author: Pavel Labath
Date: 2021-04-01T08:44:50+02:00
New Revision: 3bea7306e8669f94bacafae68748a9139cfc0b98
URL: https://github.com/llvm/llvm-project/commit/3bea7306e8669f94bacafae68748a9139cfc0b98
DIFF: https://github.com/llvm/llvm-project/commit/3bea7306e8669f94bacafae68748a9139cfc0b98.diff
LOG: [lldb] Fix compilation with gcc-6.5
This fixes (works around) two errors with gcc-6.5.
- in the RegisterContext_x86 files, gcc is unable to synthesize a
default constructor -- it thinks it needs to initialize the virtual
base class, even though said classes are abstract. I fix that by
providing a dummy constructor.
- In ReproducerInstrumentationTest, it is not able to deduce that the
TestingRegistry class is movable (it contains a map of unique
pointers). I change the type from Optional<TestingRegistry> to
unique_ptr<TestingRegistry), so that moving is not required
(copying/moving a polymorphic type is not a very good idea in any
case).
Added:
Modified:
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h
lldb/unittests/Utility/ReproducerInstrumentationTest.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
index dfd0106837853..7d5ea575269dc 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
@@ -58,6 +58,12 @@ class NativeRegisterContextLinux
virtual llvm::Optional<MmapData> GetMmapData() { return llvm::None; }
protected:
+ // NB: This constructor is here only because gcc<=6.5 requires a virtual base
+ // class initializer on abstract class (even though it is never used). It can
+ // be deleted once we move to gcc>=7.0.
+ NativeRegisterContextLinux(NativeThreadProtocol &thread)
+ : NativeRegisterContextRegisterInfo(thread, nullptr) {}
+
lldb::ByteOrder GetByteOrder() const;
virtual Status ReadRegisterRaw(uint32_t reg_index, RegisterValue ®_value);
diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
index c197d70825b4b..bd4b168f4964e 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
@@ -292,6 +292,8 @@ NativeRegisterContextLinux_x86_64::NativeRegisterContextLinux_x86_64(
const ArchSpec &target_arch, NativeThreadProtocol &native_thread)
: NativeRegisterContextRegisterInfo(
native_thread, CreateRegisterInfoInterface(target_arch)),
+ NativeRegisterContextLinux(native_thread),
+ NativeRegisterContextDBReg_x86(native_thread),
m_xstate_type(XStateType::Invalid), m_ymm_set(), m_mpx_set(),
m_reg_info(), m_gpr_x86_64() {
// Set up data about ranges of valid registers.
diff --git a/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h b/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h
index c0c6ce29eab53..a4ed8bfb97eaf 100644
--- a/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h
+++ b/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h
@@ -16,6 +16,12 @@ namespace lldb_private {
class NativeRegisterContextDBReg_x86
: public virtual NativeRegisterContextRegisterInfo {
public:
+ // NB: This constructor is here only because gcc<=6.5 requires a virtual base
+ // class initializer on abstract class (even though it is never used). It can
+ // be deleted once we move to gcc>=7.0.
+ NativeRegisterContextDBReg_x86(NativeThreadProtocol &thread)
+ : NativeRegisterContextRegisterInfo(thread, nullptr) {}
+
Status IsWatchpointHit(uint32_t wp_index, bool &is_hit) override;
Status GetWatchpointHitIndex(uint32_t &wp_index,
diff --git a/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp b/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp
index e9f6fcf34e17f..ce259c5969e09 100644
--- a/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp
+++ b/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp
@@ -50,7 +50,7 @@ class TestingRegistry : public Registry {
TestingRegistry();
};
-static llvm::Optional<TestingRegistry> g_registry;
+static std::unique_ptr<TestingRegistry> g_registry;
static llvm::Optional<Serializer> g_serializer;
static llvm::Optional<Deserializer> g_deserializer;
@@ -75,13 +75,13 @@ inline TestInstrumentationData GetTestInstrumentationData() {
class TestInstrumentationDataRAII {
public:
TestInstrumentationDataRAII(llvm::raw_string_ostream &os) {
- g_registry.emplace();
+ g_registry = std::make_unique<TestingRegistry>();
g_serializer.emplace(os);
g_deserializer.reset();
}
TestInstrumentationDataRAII(llvm::StringRef buffer) {
- g_registry.emplace();
+ g_registry = std::make_unique<TestingRegistry>();
g_serializer.reset();
g_deserializer.emplace(buffer);
}
More information about the lldb-commits
mailing list