[Lldb-commits] [lldb] 810c3cf - ThreadPlanTracer::TracingStarted can't call virtual methods on Thread.

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 20 10:56:55 PST 2019


Author: Jim Ingham
Date: 2019-12-20T10:56:39-08:00
New Revision: 810c3cfa664b38b27bc30afaadab3d775cb17922

URL: https://github.com/llvm/llvm-project/commit/810c3cfa664b38b27bc30afaadab3d775cb17922
DIFF: https://github.com/llvm/llvm-project/commit/810c3cfa664b38b27bc30afaadab3d775cb17922.diff

LOG:     ThreadPlanTracer::TracingStarted can't call virtual methods on Thread.

    TracingStarted gets called in the Thread constructor, which means you can't
    call a virtual method of the class.  So delay setting up the m_register_values
    till you need them.  NFC as lldb just crashes if you don't do this.

    The thread tracing is an only occasionally useful feature, and it only sort
    of works.  I'm not adding tests etc. at this point, I'm just poking at it a
    bit.  If I get it working better I'll write tests and so forth.

Added: 
    

Modified: 
    lldb/source/Target/ThreadPlanTracer.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Target/ThreadPlanTracer.cpp b/lldb/source/Target/ThreadPlanTracer.cpp
index 5782fe8e6443..b50c1636b7ff 100644
--- a/lldb/source/Target/ThreadPlanTracer.cpp
+++ b/lldb/source/Target/ThreadPlanTracer.cpp
@@ -115,10 +115,6 @@ TypeFromUser ThreadPlanAssemblyTracer::GetIntPointerType() {
 ThreadPlanAssemblyTracer::~ThreadPlanAssemblyTracer() = default;
 
 void ThreadPlanAssemblyTracer::TracingStarted() {
-  RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
-
-  if (m_register_values.empty())
-    m_register_values.resize(reg_ctx->GetRegisterCount());
 }
 
 void ThreadPlanAssemblyTracer::TracingEnded() { m_register_values.clear(); }
@@ -208,6 +204,11 @@ void ThreadPlanAssemblyTracer::Log() {
     }
   }
 
+  if (m_register_values.empty()) {
+    RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
+    m_register_values.resize(reg_ctx->GetRegisterCount());
+  }
+
   RegisterValue reg_value;
   for (uint32_t reg_num = 0, num_registers = reg_ctx->GetRegisterCount();
        reg_num < num_registers; ++reg_num) {


        


More information about the lldb-commits mailing list