hanbingwang updated this revision to Diff 359671.
hanbingwang marked an inline comment as done.
hanbingwang added a comment.

F18016096: Screen Shot 2021-07-18 at 11.07.29 PM.png 
<https://reviews.llvm.org/F18016096>

print out the tracing plugin name exactly once when there are one or more than 
one threads.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105717/new/

https://reviews.llvm.org/D105717

Files:
  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/TestTraceDumpInfo.py
  lldb/test/API/commands/trace/TestTraceLoad.py

Index: lldb/test/API/commands/trace/TestTraceLoad.py
===================================================================
--- lldb/test/API/commands/trace/TestTraceLoad.py
+++ lldb/test/API/commands/trace/TestTraceLoad.py
@@ -33,7 +33,7 @@
         # check that the Process and Thread objects were created correctly
         self.expect("thread info", substrs=["tid = 3842849"])
         self.expect("thread list", substrs=["Process 1234 stopped", "tid = 3842849"])
-        self.expect("thread trace dump info", substrs=['''Tracing technology: intel-pt
+        self.expect("thread trace dump info", substrs=['''Trace technology: intel-pt
 thread #1: tid = 3842849
 Raw trace size: 4096 bytes'''])
 
Index: lldb/test/API/commands/trace/TestTraceDumpInfo.py
===================================================================
--- lldb/test/API/commands/trace/TestTraceDumpInfo.py
+++ lldb/test/API/commands/trace/TestTraceDumpInfo.py
@@ -35,6 +35,6 @@
         substrs=["intel-pt"])
 
         self.expect("thread trace dump info",
-            substrs=['''Tracing technology: intel-pt
+            substrs=['''Trace technology: intel-pt
 thread #1: tid = 3842849
 Raw trace size: 4096 bytes'''])
Index: lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
===================================================================
--- lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
+++ lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
@@ -67,7 +67,7 @@
 
   lldb::TraceCursorUP GetCursor(Thread &thread) override;
 
-  void DumpTraceInfo(Thread &thread, Stream &s, bool verbose, lldb_private::ConstString plugin_name) override;
+  void DumpTraceInfo(Thread &thread, Stream &s, bool verbose) override;
 
   llvm::Optional<size_t> GetRawTraceSize(Thread &thread);
 
Index: lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
===================================================================
--- lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
+++ lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
@@ -108,9 +108,9 @@
   return Decode(thread)->GetCursor();
 }
 
-void TraceIntelPT::DumpTraceInfo(Thread &thread, Stream &s, bool verbose, lldb_private::ConstString plugin_name) {
+void TraceIntelPT::DumpTraceInfo(Thread &thread, Stream &s, bool verbose) {
   Optional<size_t> raw_size = GetRawTraceSize(thread);
-  s.Printf("Tracing technology: %s\nthread #%u: tid = %" PRIu64, plugin_name.AsCString(), thread.GetIndexID(), thread.GetID());
+  s.Printf("thread #%u: tid = %" PRIu64, thread.GetIndexID(), thread.GetID());
   if (!raw_size) {
     s.Printf(", not traced\n");
     return;
Index: lldb/source/Commands/CommandObjectThread.cpp
===================================================================
--- lldb/source/Commands/CommandObjectThread.cpp
+++ lldb/source/Commands/CommandObjectThread.cpp
@@ -32,7 +32,6 @@
 #include "lldb/Target/ThreadPlan.h"
 #include "lldb/Target/ThreadPlanStepInRange.h"
 #include "lldb/Target/Trace.h"
-#include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/State.h"
 
 using namespace lldb;
@@ -2155,10 +2154,21 @@
     bool m_verbose;
   };
 
+  bool DoExecute(Args &command, CommandReturnObject &result) override {
+    Target &target = m_exe_ctx.GetTargetRef();
+    result.GetOutputStream().Printf(
+        "Trace technology: %s\n",
+        target.GetTrace()->GetPluginName().AsCString());
+    return CommandObjectIterateOverThreads::DoExecute(command, result);
+  }
+
   CommandObjectTraceDumpInfo(CommandInterpreter &interpreter)
       : CommandObjectIterateOverThreads(
             interpreter, "thread trace dump info",
-            "Dump the traced info for one thread.", nullptr,
+            "Dump the traced information for one or more threads.  If no "
+            "threads are specified, show the current thread.  Use the "
+            "thread-index \"all\" to see all threads.",
+            nullptr,
             eCommandRequiresProcess | eCommandTryTargetAPILock |
                 eCommandProcessMustBeLaunched | eCommandProcessMustBePaused |
                 eCommandProcessMustBeTraced),
@@ -2174,7 +2184,7 @@
     ThreadSP thread_sp =
         m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid);
     trace_sp->DumpTraceInfo(*thread_sp, result.GetOutputStream(),
-                             m_options.m_verbose,  trace_sp->GetPluginName());
+                            m_options.m_verbose);
     return true;
   }
 
Index: lldb/include/lldb/Target/Trace.h
===================================================================
--- lldb/include/lldb/Target/Trace.h
+++ lldb/include/lldb/Target/Trace.h
@@ -152,10 +152,7 @@
   /// \param[in] verbose
   ///     If \b true, print detailed info
   ///     If \b false, print compact info
-  ///
-  /// \param[in] plugin_name
-  ///     The name of the tracing technology being used being used
-  virtual void DumpTraceInfo(Thread &thread, Stream &s, bool verbose, lldb_private::ConstString plugin_name) = 0;
+  virtual void DumpTraceInfo(Thread &thread, Stream &s, bool verbose) = 0;
 
   /// Check if a thread is currently traced by this object.
   ///
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to