[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

via lldb-commits lldb-commits at lists.llvm.org
Sun Jan 7 12:30:57 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Nicholas Mosier (nmosier)

<details>
<summary>Changes</summary>

Fix #<!-- -->77251.

---
Full diff: https://github.com/llvm/llvm-project/pull/77252.diff


6 Files Affected:

- (modified) lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp (+1-3) 
- (modified) lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp (+5) 
- (modified) lldb/source/Plugins/Trace/intel-pt/DecodedThread.h (+4) 
- (modified) lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp (+2-2) 
- (modified) lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp (+2-2) 
- (modified) lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp (+5-7) 


``````````diff
diff --git a/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp b/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
index d4f7dc354e9fed..44224229e625bf 100644
--- a/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
@@ -158,7 +158,7 @@ CommandObjectProcessTraceStartIntelPT::CommandOptions::GetDefinitions() {
   return llvm::ArrayRef(g_process_trace_start_intel_pt_options);
 }
 
-bool CommandObjectProcessTraceStartIntelPT::DoExecute(
+void CommandObjectProcessTraceStartIntelPT::DoExecute(
     Args &command, CommandReturnObject &result) {
   if (Error err = m_trace.Start(
           m_options.m_ipt_trace_size, m_options.m_process_buffer_size_limit,
@@ -167,8 +167,6 @@ bool CommandObjectProcessTraceStartIntelPT::DoExecute(
     result.SetError(Status(std::move(err)));
   else
     result.SetStatus(eReturnStatusSuccessFinishResult);
-
-  return result.Succeeded();
 }
 
 std::optional<uint64_t>
diff --git a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
index 17f8f51bdf0e0d..145e0386f6a023 100644
--- a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
@@ -85,6 +85,11 @@ double DecodedThread::NanosecondsRange::GetInterpolatedTime(
   return interpolate(next_range->nanos);
 }
 
+DecodedThread::TraceItemStorage::TraceItemStorage(
+    const TraceItemStorage &other) {
+  std::memcpy(this, &other, sizeof *this);
+}
+
 uint64_t DecodedThread::GetItemsCount() const { return m_item_kinds.size(); }
 
 lldb::addr_t
diff --git a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
index 5745cdb67ab68f..88bf748d186a36 100644
--- a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
+++ b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
@@ -276,6 +276,10 @@ class DecodedThread : public std::enable_shared_from_this<DecodedThread> {
 
     /// The string message of this item if it's an error
     std::string error;
+
+    TraceItemStorage() {}
+    ~TraceItemStorage() {}
+    TraceItemStorage(const TraceItemStorage &other);
   };
 
   /// Create a new trace item.
diff --git a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
index cdf81954eee902..f8241ef6a79329 100644
--- a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
@@ -572,7 +572,7 @@ Error lldb_private::trace_intel_pt::DecodeSingleTraceForThread(
     Expected<PSBBlockDecoder> decoder = PSBBlockDecoder::Create(
         trace_intel_pt, block, buffer.slice(block.psb_offset, block.size),
         *decoded_thread.GetThread()->GetProcess(),
-        i + 1 < blocks->size() ? blocks->at(i + 1).starting_ip : None,
+        i + 1 < blocks->size() ? blocks->at(i + 1).starting_ip : std::nullopt,
         decoded_thread, std::nullopt);
     if (!decoder)
       return decoder.takeError();
@@ -640,7 +640,7 @@ Error lldb_private::trace_intel_pt::DecodeSystemWideTraceForThread(
           *decoded_thread.GetThread()->GetProcess(),
           j + 1 < execution.psb_blocks.size()
               ? execution.psb_blocks[j + 1].starting_ip
-              : None,
+              : std::nullopt,
           decoded_thread, execution.thread_execution.GetEndTSC());
       if (!decoder)
         return decoder.takeError();
diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
index 66d342196cf10d..dda6cd74343f0f 100644
--- a/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
@@ -35,7 +35,7 @@ void TraceCursorIntelPT::Next() {
 void TraceCursorIntelPT::ClearTimingRangesIfInvalid() {
   if (m_tsc_range_calculated) {
     if (!m_tsc_range || m_pos < 0 || !m_tsc_range->InRange(m_pos)) {
-      m_tsc_range = None;
+      m_tsc_range = std::nullopt;
       m_tsc_range_calculated = false;
     }
   }
@@ -43,7 +43,7 @@ void TraceCursorIntelPT::ClearTimingRangesIfInvalid() {
   if (m_nanoseconds_range_calculated) {
     if (!m_nanoseconds_range || m_pos < 0 ||
         !m_nanoseconds_range->InRange(m_pos)) {
-      m_nanoseconds_range = None;
+      m_nanoseconds_range = std::nullopt;
       m_nanoseconds_range_calculated = false;
     }
   }
diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp
index bd9cca675f2d74..654a8686841762 100644
--- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp
@@ -103,12 +103,10 @@ TraceIntelPTBundleLoader::CreateEmptyProcess(lldb::pid_t pid,
   ParsedProcess parsed_process;
   parsed_process.target_sp = target_sp;
 
-  // This should instead try to directly create an instance of ProcessTrace.
-  // ProcessSP process_sp = target_sp->CreateProcess(
-  //    /*listener*/ nullptr, "trace",
-  //    /*crash_file*/ nullptr,
-  //    /*can_connect*/ false);
-
+  ProcessSP process_sp = target_sp->CreateProcess(
+      /*listener*/ nullptr, "trace",
+      /*crash_file*/ nullptr,
+      /*can_connect*/ false);
   process_sp->SetID(static_cast<lldb::pid_t>(pid));
 
   return parsed_process;
@@ -344,7 +342,7 @@ Error TraceIntelPTBundleLoader::AugmentThreadsFromContextSwitches(
     if (indexed_threads[proc->second].count(tid))
       return;
     indexed_threads[proc->second].insert(tid);
-    proc->second->threads.push_back({tid, /*ipt_trace=*/None});
+    proc->second->threads.push_back({tid, /*ipt_trace=*/std::nullopt});
   };
 
   for (const JSONCpu &cpu : *bundle_description.cpus) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/77252


More information about the lldb-commits mailing list