[Lldb-commits] [lldb] f0d0612 - [NFC][trace] remove dead function

Walter Erquinigo via lldb-commits lldb-commits at lists.llvm.org
Wed Jun 23 23:19:07 PDT 2021


Author: Walter Erquinigo
Date: 2021-06-23T23:18:53-07:00
New Revision: f0d06124769f477a26f8fa2589f0ace85419c120

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

LOG: [NFC][trace] remove dead function

The Trace::GetCursorPosition function was never really implemented well and it's being replaced by a more correct TraceCursor object.

Added: 
    

Modified: 
    lldb/include/lldb/Target/Trace.h
    lldb/source/Commands/CommandObjectThread.cpp
    lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
    lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
    lldb/test/API/commands/trace/TestTraceStartStop.py
    lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Target/Trace.h b/lldb/include/lldb/Target/Trace.h
index bb2b93514994c..cc84270b80081 100644
--- a/lldb/include/lldb/Target/Trace.h
+++ b/lldb/include/lldb/Target/Trace.h
@@ -137,18 +137,6 @@ class Trace : public PluginInterface,
   ///     The JSON schema of this Trace plug-in.
   virtual llvm::StringRef GetSchema() = 0;
 
-  /// Each decoded thread contains a cursor to the current position the user is
-  /// stopped at. When reverse debugging, each operation like reverse-next or
-  /// reverse-continue will move this cursor, which is then picked by any
-  /// subsequent dump or reverse operation.
-  ///
-  /// The initial position for this cursor is the last element of the thread,
-  /// which is the most recent chronologically.
-  ///
-  /// \return
-  ///     The current position of the thread's trace or \b 0 if empty.
-  virtual size_t GetCursorPosition(Thread &thread) = 0;
-
   /// Dump \a count instructions of the given thread's trace ending at the
   /// given \a end_position position.
   ///

diff  --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index 1d31f112ae63f..292f9c6a0a74e 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -2086,15 +2086,20 @@ class CommandObjectTraceDumpInstructions
     ThreadSP thread_sp =
         m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid);
 
-    size_t count = m_options.m_count;
-    ssize_t position = m_options.m_position.getValueOr(
-                           trace_sp->GetCursorPosition(*thread_sp)) -
-                       m_consecutive_repetitions * count;
-    if (position < 0)
-      result.AppendError("error: no more data");
-    else
-      trace_sp->DumpTraceInstructions(*thread_sp, result.GetOutputStream(),
-                                      count, position, m_options.m_raw);
+    if (llvm::Optional<size_t> insn_count =
+            trace_sp->GetInstructionCount(*thread_sp)) {
+      size_t count = m_options.m_count;
+      ssize_t position =
+          m_options.m_position.getValueOr((ssize_t)*insn_count - 1) -
+          m_consecutive_repetitions * count;
+      if (position < 0)
+        result.AppendError("error: no more data");
+      else
+        trace_sp->DumpTraceInstructions(*thread_sp, result.GetOutputStream(),
+                                        count, position, m_options.m_raw);
+    } else {
+      result.AppendError("error: not traced");
+    }
     return true;
   }
 

diff  --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
index 5546e2e96788a..df4e1e11b99a2 100644
--- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
@@ -99,13 +99,6 @@ const DecodedThread *TraceIntelPT::Decode(Thread &thread) {
   return &it->second->Decode();
 }
 
-size_t TraceIntelPT::GetCursorPosition(Thread &thread) {
-  const DecodedThread *decoded_thread = Decode(thread);
-  if (!decoded_thread)
-    return 0;
-  return decoded_thread->GetCursorPosition();
-}
-
 lldb::TraceCursorUP TraceIntelPT::GetCursor(Thread &thread) {
   // TODO: to implement
   return nullptr;

diff  --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
index d25316e0c658d..2e414abca4ea6 100644
--- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
+++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
@@ -72,8 +72,6 @@ class TraceIntelPT : public Trace {
 
   llvm::Optional<size_t> GetInstructionCount(Thread &thread) override;
 
-  size_t GetCursorPosition(Thread &thread) override;
-
   lldb::TraceCursorUP GetCursor(Thread &thread) override;
 
   void DoRefreshLiveProcessState(

diff  --git a/lldb/test/API/commands/trace/TestTraceStartStop.py b/lldb/test/API/commands/trace/TestTraceStartStop.py
index 22aff10359820..91cf5afa26002 100644
--- a/lldb/test/API/commands/trace/TestTraceStartStop.py
+++ b/lldb/test/API/commands/trace/TestTraceStartStop.py
@@ -69,7 +69,7 @@ def testStoppingAThread(self):
         # process stopping should stop the thread
         self.expect("process trace stop")
         self.expect("n")
-        self.expect("thread trace dump instructions", substrs=["not traced"])
+        self.expect("thread trace dump instructions", error=True, substrs=["not traced"])
 
 
     @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64']))

diff  --git a/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py b/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py
index 4b7fbc9f388de..e58234ff18b88 100644
--- a/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py
+++ b/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py
@@ -97,8 +97,8 @@ def testStartMultipleLiveThreadsWithStops(self):
         self.expect("continue")
         self.expect("thread trace dump instructions", substrs=['main.cpp:4'])
         self.expect("thread trace dump instructions 3", substrs=['main.cpp:4'])
-        self.expect("thread trace dump instructions 1", substrs=['not traced'])
-        self.expect("thread trace dump instructions 2", substrs=['not traced'])
+        self.expect("thread trace dump instructions 1", error=True, substrs=['not traced'])
+        self.expect("thread trace dump instructions 2", error=True, substrs=['not traced'])
 
     @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64']))
     def testStartMultipleLiveThreadsWithThreadStartAll(self):
@@ -128,9 +128,9 @@ def testStartMultipleLiveThreadsWithThreadStartAll(self):
 
         # We'll stop at the next breakpoint in thread 3, and nothing should be traced
         self.expect("continue")
-        self.expect("thread trace dump instructions 3", substrs=['not traced'])
-        self.expect("thread trace dump instructions 1", substrs=['not traced'])
-        self.expect("thread trace dump instructions 2", substrs=['not traced'])
+        self.expect("thread trace dump instructions 3", error=True, substrs=['not traced'])
+        self.expect("thread trace dump instructions 1", error=True, substrs=['not traced'])
+        self.expect("thread trace dump instructions 2", error=True, substrs=['not traced'])
 
     @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64']))
     @testSBAPIAndCommands


        


More information about the lldb-commits mailing list