<div dir="ltr"><a class="gmail_plusreply" id="plusReplyChip-0" href="mailto:tstellar@redhat.com" tabindex="-1">+Tom Stellard</a> - Could this get cherry-picked into 12.0.N for the next point release? Without it, LLDB in the 12 release doesn't build with GCC <= 6.5 which the docs indicate is supposed to work.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 31, 2021 at 11:45 PM Pavel Labath via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org">lldb-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Author: Pavel Labath<br>
Date: 2021-04-01T08:44:50+02:00<br>
New Revision: 3bea7306e8669f94bacafae68748a9139cfc0b98<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/3bea7306e8669f94bacafae68748a9139cfc0b98" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/3bea7306e8669f94bacafae68748a9139cfc0b98</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/3bea7306e8669f94bacafae68748a9139cfc0b98.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/3bea7306e8669f94bacafae68748a9139cfc0b98.diff</a><br>
<br>
LOG: [lldb] Fix compilation with gcc-6.5<br>
<br>
This fixes (works around) two errors with gcc-6.5.<br>
- in the RegisterContext_x86 files, gcc is unable to synthesize a<br>
  default constructor -- it thinks it needs to initialize the virtual<br>
  base class, even though said classes are abstract. I fix that by<br>
  providing a dummy constructor.<br>
- In ReproducerInstrumentationTest, it is not able to deduce that the<br>
  TestingRegistry class is movable (it contains a map of unique<br>
  pointers). I change the type from Optional<TestingRegistry> to<br>
  unique_ptr<TestingRegistry), so that moving is not required<br>
  (copying/moving a polymorphic type is not a very good idea in any<br>
  case).<br>
<br>
Added: <br>
<br>
<br>
Modified: <br>
    lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h<br>
    lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp<br>
    lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h<br>
    lldb/unittests/Utility/ReproducerInstrumentationTest.cpp<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff  --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h<br>
index dfd0106837853..7d5ea575269dc 100644<br>
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h<br>
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h<br>
@@ -58,6 +58,12 @@ class NativeRegisterContextLinux<br>
   virtual llvm::Optional<MmapData> GetMmapData() { return llvm::None; }<br>
<br>
 protected:<br>
+  // NB: This constructor is here only because gcc<=6.5 requires a virtual base<br>
+  // class initializer on abstract class (even though it is never used). It can<br>
+  // be deleted once we move to gcc>=7.0.<br>
+  NativeRegisterContextLinux(NativeThreadProtocol &thread)<br>
+      : NativeRegisterContextRegisterInfo(thread, nullptr) {}<br>
+<br>
   lldb::ByteOrder GetByteOrder() const;<br>
<br>
   virtual Status ReadRegisterRaw(uint32_t reg_index, RegisterValue &reg_value);<br>
<br>
diff  --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp<br>
index c197d70825b4b..bd4b168f4964e 100644<br>
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp<br>
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp<br>
@@ -292,6 +292,8 @@ NativeRegisterContextLinux_x86_64::NativeRegisterContextLinux_x86_64(<br>
     const ArchSpec &target_arch, NativeThreadProtocol &native_thread)<br>
     : NativeRegisterContextRegisterInfo(<br>
           native_thread, CreateRegisterInfoInterface(target_arch)),<br>
+      NativeRegisterContextLinux(native_thread),<br>
+      NativeRegisterContextDBReg_x86(native_thread),<br>
       m_xstate_type(XStateType::Invalid), m_ymm_set(), m_mpx_set(),<br>
       m_reg_info(), m_gpr_x86_64() {<br>
   // Set up data about ranges of valid registers.<br>
<br>
diff  --git a/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h b/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h<br>
index c0c6ce29eab53..a4ed8bfb97eaf 100644<br>
--- a/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h<br>
+++ b/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h<br>
@@ -16,6 +16,12 @@ namespace lldb_private {<br>
 class NativeRegisterContextDBReg_x86<br>
     : public virtual NativeRegisterContextRegisterInfo {<br>
 public:<br>
+  // NB: This constructor is here only because gcc<=6.5 requires a virtual base<br>
+  // class initializer on abstract class (even though it is never used). It can<br>
+  // be deleted once we move to gcc>=7.0.<br>
+  NativeRegisterContextDBReg_x86(NativeThreadProtocol &thread)<br>
+      : NativeRegisterContextRegisterInfo(thread, nullptr) {}<br>
+<br>
   Status IsWatchpointHit(uint32_t wp_index, bool &is_hit) override;<br>
<br>
   Status GetWatchpointHitIndex(uint32_t &wp_index,<br>
<br>
diff  --git a/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp b/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp<br>
index e9f6fcf34e17f..ce259c5969e09 100644<br>
--- a/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp<br>
+++ b/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp<br>
@@ -50,7 +50,7 @@ class TestingRegistry : public Registry {<br>
   TestingRegistry();<br>
 };<br>
<br>
-static llvm::Optional<TestingRegistry> g_registry;<br>
+static std::unique_ptr<TestingRegistry> g_registry;<br>
 static llvm::Optional<Serializer> g_serializer;<br>
 static llvm::Optional<Deserializer> g_deserializer;<br>
<br>
@@ -75,13 +75,13 @@ inline TestInstrumentationData GetTestInstrumentationData() {<br>
 class TestInstrumentationDataRAII {<br>
 public:<br>
   TestInstrumentationDataRAII(llvm::raw_string_ostream &os) {<br>
-    g_registry.emplace();<br>
+    g_registry = std::make_unique<TestingRegistry>();<br>
     g_serializer.emplace(os);<br>
     g_deserializer.reset();<br>
   }<br>
<br>
   TestInstrumentationDataRAII(llvm::StringRef buffer) {<br>
-    g_registry.emplace();<br>
+    g_registry = std::make_unique<TestingRegistry>();<br>
     g_serializer.reset();<br>
     g_deserializer.emplace(buffer);<br>
   }<br>
<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div>