[Lldb-commits] [lldb] 752e9cd - [trace][intelpt][docs] Added intel-pt build instructions for lldb

2022-03-19 Thread Alisamar Husain via lldb-commits

Author: Alisamar Husain
Date: 2022-03-19T15:26:59+05:30
New Revision: 752e9cdbb06affae5c082c31c4f5ea53e46e92c6

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

LOG: [trace][intelpt][docs] Added intel-pt build instructions for lldb

Differential Revision: https://reviews.llvm.org/D121935

Added: 
lldb/docs/use/intel_pt.rst

Modified: 
lldb/docs/index.rst

Removed: 




diff  --git a/lldb/docs/index.rst b/lldb/docs/index.rst
index e189c432c4fef..3b47ee52eb394 100644
--- a/lldb/docs/index.rst
+++ b/lldb/docs/index.rst
@@ -139,6 +139,7 @@ interesting areas to contribute to lldb.
use/qemu-testing
use/troubleshooting
use/links
+   use/intel_pt
 
 .. toctree::
:hidden:

diff  --git a/lldb/docs/use/intel_pt.rst b/lldb/docs/use/intel_pt.rst
new file mode 100644
index 0..40f9043102f76
--- /dev/null
+++ b/lldb/docs/use/intel_pt.rst
@@ -0,0 +1,232 @@
+Tracing with Intel Processor Trace (Intel PT)
+=
+
+.. contents::
+  :local:
+
+Intel PT is a technology available in modern Intel CPUs that allows efficient 
+tracing of all the instructions executed by a process. 
+LLDB can collect traces and dump them using its symbolication stack. 
+You can read more here 
+https://easyperf.net/blog/2019/08/23/Intel-Processor-Trace.
+
+Prerequisites
+-
+
+Confirm that your CPU supports Intel PT 
+(see 
https://www.intel.com/content/www/us/en/support/articles/56730/processors.html)
 
+and that your operating system is Linux.
+
+Check for the existence of this particular file on your Linux system
+:: 
+
+  $ cat /sys/bus/event_source/devices/intel_pt/type
+
+The output should be a number. Otherwise, try upgrading your kernel.
+
+
+Build Instructions
+--
+
+Clone and build the low level Intel PT 
+decoder library [LibIPT library](https://github.com/intel/libipt).
+:: 
+
+  $ git clone g...@github.com:intel/libipt.git
+  $ mkdir libipt-build
+  $ cmake -S libipt -B libipt-build
+  $ cd libipt-build
+  $ make
+
+This will generate a few files in the `/lib` 
+and `/libipt/include` directories.
+
+Configure and build LLDB with Intel PT support
+:: 
+
+  $ cmake \
+  -DLLDB_BUILD_INTEL_PT=ON \
+  -DLIBIPT_INCLUDE_PATH="/libipt/include" \
+  -DLIBIPT_LIBRARY_PATH="/lib" \
+  ... other common configuration parameters 
+
+:: 
+
+  $ cd  && ninja lldb lldb-server # if using Ninja
+
+
+How to Use
+--
+
+When you are debugging a process, you can turn on intel-pt tracing, 
+which will “record” all the instructions that the process will execute. 
+After turning it on, you can continue debugging, and at any breakpoint, 
+you can inspect the instruction list.
+ 
+For example:
+::
+  lldb 
+  > b main
+  > run
+  > process trace start # start tracing on all threads, including future ones
+  # keep debugging until you hit a breakpoint
+  
+  > thread trace dump instructions
+  # this should output something like
+
+  thread #2: tid = 2861133, total instructions = 5305673
+libc.so.6`__GI___libc_read + 45 at read.c:25:1
+  [4962255] 0x7fffeb64c63dsubq   $0x10, %rsp
+  [4962256] 0x7fffeb64c641movq   %rdi, -0x18(%rbp)
+libc.so.6`__GI___libc_read + 53 [inlined] __libc_read at read.c:26:10
+  [4962257] 0x7fffeb64c645callq  0x7fffeb66b640; 
__libc_enable_asynccancel
+libc.so.6`__libc_enable_asynccancel
+  [4962258] 0x7fffeb66b640movl   %fs:0x308, %eax
+libc.so.6`__libc_enable_asynccancel + 8
+  [4962259] 0x7fffeb66b648movl   %eax, %r11d
+
+  # you can keep pressing ENTER to see more and more instructions
+ 
+The number between brackets is the instruction index, 
+and by default the current thread will be picked.
+ 
+Configuring the trace size
+--
+ 
+The CPU stores the instruction list in a compressed format in a ring buffer, 
+which keeps the latest information. 
+By default, LLDB uses a buffer of 4KB per thread, 
+but you can change it by running. 
+The size must be a power of 2 and at least 4KB.
+::
+  thread trace start all -s 
+ 
+For reference, a 1MB trace buffer can easily store around 5M instructions.
+ 
+Printing more instructions
+--
+ 
+If you want to dump more instructions at a time, you can run
+::
+  thread trace dump instructions -c 
+ 
+Printing the instructions of another thread
+---
+
+By default the current thread will be picked when dumping instructions, 
+but you can do
+:: 
+  thread trace dump instructions <#thread index>
+  #e.g.
+  thread trace dump instructions 8
+ 
+to select another thread.
+ 
+Crash Analysis
+--
+ 
+What if you are debugging + tracing a process that crashes? 

[Lldb-commits] [PATCH] D122073: [docs] Fixed minor ordering issue

2022-03-19 Thread Alisamar Husain via Phabricator via lldb-commits
zrthxn created this revision.
zrthxn added a reviewer: wallace.
Herald added a subscriber: arphaman.
Herald added a project: All.
zrthxn requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122073

Files:
  lldb/docs/index.rst
  lldb/docs/use/intel_pt.rst


Index: lldb/docs/use/intel_pt.rst
===
--- lldb/docs/use/intel_pt.rst
+++ lldb/docs/use/intel_pt.rst
@@ -1,5 +1,5 @@
-Tracing with Intel Processor Trace (Intel PT)
-=
+Tracing with Intel Processor Trace
+==
 
 .. contents::
   :local:
Index: lldb/docs/index.rst
===
--- lldb/docs/index.rst
+++ lldb/docs/index.rst
@@ -137,9 +137,9 @@
use/python-reference
use/remote
use/qemu-testing
+   use/intel_pt
use/troubleshooting
use/links
-   use/intel_pt
 
 .. toctree::
:hidden:


Index: lldb/docs/use/intel_pt.rst
===
--- lldb/docs/use/intel_pt.rst
+++ lldb/docs/use/intel_pt.rst
@@ -1,5 +1,5 @@
-Tracing with Intel Processor Trace (Intel PT)
-=
+Tracing with Intel Processor Trace
+==
 
 .. contents::
   :local:
Index: lldb/docs/index.rst
===
--- lldb/docs/index.rst
+++ lldb/docs/index.rst
@@ -137,9 +137,9 @@
use/python-reference
use/remote
use/qemu-testing
+   use/intel_pt
use/troubleshooting
use/links
-   use/intel_pt
 
 .. toctree::
:hidden:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D122073: [docs] Fixed minor ordering issue

2022-03-19 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: JDevlieghere.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122073

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 1bcc28b - [docs] Fixed minor ordering issue

2022-03-19 Thread Alisamar Husain via lldb-commits

Author: Alisamar Husain
Date: 2022-03-19T22:23:42+05:30
New Revision: 1bcc28b884ff4fbe2ecc011b8ea2b84e7987167b

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

LOG: [docs] Fixed minor ordering issue

Differential Revision: https://reviews.llvm.org/D122073

Added: 


Modified: 
lldb/docs/index.rst
lldb/docs/use/intel_pt.rst

Removed: 




diff  --git a/lldb/docs/index.rst b/lldb/docs/index.rst
index 3b47ee52eb394..4a595590529a4 100644
--- a/lldb/docs/index.rst
+++ b/lldb/docs/index.rst
@@ -137,9 +137,9 @@ interesting areas to contribute to lldb.
use/python-reference
use/remote
use/qemu-testing
+   use/intel_pt
use/troubleshooting
use/links
-   use/intel_pt
 
 .. toctree::
:hidden:

diff  --git a/lldb/docs/use/intel_pt.rst b/lldb/docs/use/intel_pt.rst
index 40f9043102f76..95a13618b213f 100644
--- a/lldb/docs/use/intel_pt.rst
+++ b/lldb/docs/use/intel_pt.rst
@@ -1,5 +1,5 @@
-Tracing with Intel Processor Trace (Intel PT)
-=
+Tracing with Intel Processor Trace
+==
 
 .. contents::
   :local:



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D122073: [docs] Fixed minor ordering issue

2022-03-19 Thread Alisamar Husain via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1bcc28b884ff: [docs] Fixed minor ordering issue (authored by 
zrthxn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122073

Files:
  lldb/docs/index.rst
  lldb/docs/use/intel_pt.rst


Index: lldb/docs/use/intel_pt.rst
===
--- lldb/docs/use/intel_pt.rst
+++ lldb/docs/use/intel_pt.rst
@@ -1,5 +1,5 @@
-Tracing with Intel Processor Trace (Intel PT)
-=
+Tracing with Intel Processor Trace
+==
 
 .. contents::
   :local:
Index: lldb/docs/index.rst
===
--- lldb/docs/index.rst
+++ lldb/docs/index.rst
@@ -137,9 +137,9 @@
use/python-reference
use/remote
use/qemu-testing
+   use/intel_pt
use/troubleshooting
use/links
-   use/intel_pt
 
 .. toctree::
:hidden:


Index: lldb/docs/use/intel_pt.rst
===
--- lldb/docs/use/intel_pt.rst
+++ lldb/docs/use/intel_pt.rst
@@ -1,5 +1,5 @@
-Tracing with Intel Processor Trace (Intel PT)
-=
+Tracing with Intel Processor Trace
+==
 
 .. contents::
   :local:
Index: lldb/docs/index.rst
===
--- lldb/docs/index.rst
+++ lldb/docs/index.rst
@@ -137,9 +137,9 @@
use/python-reference
use/remote
use/qemu-testing
+   use/intel_pt
use/troubleshooting
use/links
-   use/intel_pt
 
 .. toctree::
:hidden:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D122076: [trace][intelpt] Instruction count in trace info

2022-03-19 Thread Alisamar Husain via Phabricator via lldb-commits
zrthxn created this revision.
zrthxn added a reviewer: wallace.
Herald added a project: All.
zrthxn requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Added a line to `thread trace dump info` results which shows total number of 
instructions executed until now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122076

Files:
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/test/API/commands/trace/TestTraceDumpInfo.py


Index: lldb/test/API/commands/trace/TestTraceDumpInfo.py
===
--- lldb/test/API/commands/trace/TestTraceDumpInfo.py
+++ lldb/test/API/commands/trace/TestTraceDumpInfo.py
@@ -38,4 +38,5 @@
 substrs=['''Trace technology: intel-pt
 
 thread #1: tid = 3842849
-  Raw trace size: 4096 bytes'''])
+  Raw trace size: 4096 bytes
+  Total number of instructions: 25'''])
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
@@ -105,12 +105,15 @@
 
 void TraceIntelPT::DumpTraceInfo(Thread &thread, Stream &s, bool verbose) {
   Optional raw_size = GetRawTraceSize(thread);
+  size_t inst_size = (*Decode(thread)).GetInstructions().size();
   s.Printf("\nthread #%u: tid = %" PRIu64, thread.GetIndexID(), 
thread.GetID());
   if (!raw_size) {
 s.Printf(", not traced\n");
 return;
   }
-  s.Printf("\n  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("\n");
+  s.Printf("  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("  Total number of instructions: %zu\n", inst_size);
   return;
 }
 


Index: lldb/test/API/commands/trace/TestTraceDumpInfo.py
===
--- lldb/test/API/commands/trace/TestTraceDumpInfo.py
+++ lldb/test/API/commands/trace/TestTraceDumpInfo.py
@@ -38,4 +38,5 @@
 substrs=['''Trace technology: intel-pt
 
 thread #1: tid = 3842849
-  Raw trace size: 4096 bytes'''])
+  Raw trace size: 4096 bytes
+  Total number of instructions: 25'''])
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
@@ -105,12 +105,15 @@
 
 void TraceIntelPT::DumpTraceInfo(Thread &thread, Stream &s, bool verbose) {
   Optional raw_size = GetRawTraceSize(thread);
+  size_t inst_size = (*Decode(thread)).GetInstructions().size();
   s.Printf("\nthread #%u: tid = %" PRIu64, thread.GetIndexID(), thread.GetID());
   if (!raw_size) {
 s.Printf(", not traced\n");
 return;
   }
-  s.Printf("\n  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("\n");
+  s.Printf("  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("  Total number of instructions: %zu\n", inst_size);
   return;
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D122076: [trace][intelpt] Instruction count in trace info

2022-03-19 Thread Alisamar Husain via Phabricator via lldb-commits
zrthxn updated this revision to Diff 416736.
zrthxn added a comment.

Fix failing test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122076

Files:
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/test/API/commands/trace/TestTraceDumpInfo.py


Index: lldb/test/API/commands/trace/TestTraceDumpInfo.py
===
--- lldb/test/API/commands/trace/TestTraceDumpInfo.py
+++ lldb/test/API/commands/trace/TestTraceDumpInfo.py
@@ -38,4 +38,5 @@
 substrs=['''Trace technology: intel-pt
 
 thread #1: tid = 3842849
-  Raw trace size: 4096 bytes'''])
+  Raw trace size: 4096 bytes
+  Total number of instructions: 21'''])
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
@@ -105,12 +105,15 @@
 
 void TraceIntelPT::DumpTraceInfo(Thread &thread, Stream &s, bool verbose) {
   Optional raw_size = GetRawTraceSize(thread);
+  size_t inst_size = (*Decode(thread)).GetInstructions().size();
   s.Printf("\nthread #%u: tid = %" PRIu64, thread.GetIndexID(), 
thread.GetID());
   if (!raw_size) {
 s.Printf(", not traced\n");
 return;
   }
-  s.Printf("\n  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("\n");
+  s.Printf("  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("  Total number of instructions: %zu\n", inst_size);
   return;
 }
 


Index: lldb/test/API/commands/trace/TestTraceDumpInfo.py
===
--- lldb/test/API/commands/trace/TestTraceDumpInfo.py
+++ lldb/test/API/commands/trace/TestTraceDumpInfo.py
@@ -38,4 +38,5 @@
 substrs=['''Trace technology: intel-pt
 
 thread #1: tid = 3842849
-  Raw trace size: 4096 bytes'''])
+  Raw trace size: 4096 bytes
+  Total number of instructions: 21'''])
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
@@ -105,12 +105,15 @@
 
 void TraceIntelPT::DumpTraceInfo(Thread &thread, Stream &s, bool verbose) {
   Optional raw_size = GetRawTraceSize(thread);
+  size_t inst_size = (*Decode(thread)).GetInstructions().size();
   s.Printf("\nthread #%u: tid = %" PRIu64, thread.GetIndexID(), thread.GetID());
   if (!raw_size) {
 s.Printf(", not traced\n");
 return;
   }
-  s.Printf("\n  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("\n");
+  s.Printf("  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("  Total number of instructions: %zu\n", inst_size);
   return;
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D122076: [trace][intelpt] Instruction count in trace info

2022-03-19 Thread walter erquinigo via Phabricator via lldb-commits
wallace requested changes to this revision.
wallace added a comment.
This revision now requires changes to proceed.

just some minor details and good to go




Comment at: lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp:108
   Optional raw_size = GetRawTraceSize(thread);
+  size_t inst_size = (*Decode(thread)).GetInstructions().size();
   s.Printf("\nthread #%u: tid = %" PRIu64, thread.GetIndexID(), 
thread.GetID());

use -> instead of dereferencing. It's less characters and more readable



Comment at: lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp:116
+  s.Printf("  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("  Total number of instructions: %zu\n", inst_size);
   return;

no need to create a new variable. You can just inline everything here. It's not 
complex



Comment at: lldb/test/API/commands/trace/TestTraceDumpInfo.py:38-42
 substrs=['''Trace technology: intel-pt
 
 thread #1: tid = 3842849
-  Raw trace size: 4096 bytes'''])
+  Raw trace size: 4096 bytes
+  Total number of instructions: 21'''])

thanks for putting the entire output here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122076

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D122076: [trace][intelpt] Instruction count in trace info

2022-03-19 Thread Alisamar Husain via Phabricator via lldb-commits
zrthxn updated this revision to Diff 416756.
zrthxn added a comment.

Using arrow op and made it inline. I think creating a variable looks a bit 
better but this is fine too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122076

Files:
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/test/API/commands/trace/TestTraceDumpInfo.py


Index: lldb/test/API/commands/trace/TestTraceDumpInfo.py
===
--- lldb/test/API/commands/trace/TestTraceDumpInfo.py
+++ lldb/test/API/commands/trace/TestTraceDumpInfo.py
@@ -38,4 +38,5 @@
 substrs=['''Trace technology: intel-pt
 
 thread #1: tid = 3842849
-  Raw trace size: 4096 bytes'''])
+  Raw trace size: 4096 bytes
+  Total number of instructions: 21'''])
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
@@ -110,7 +110,10 @@
 s.Printf(", not traced\n");
 return;
   }
-  s.Printf("\n  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("\n");
+  s.Printf("  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("  Total number of instructions: %zu\n", 
+Decode(thread)->GetInstructions().size());
   return;
 }
 


Index: lldb/test/API/commands/trace/TestTraceDumpInfo.py
===
--- lldb/test/API/commands/trace/TestTraceDumpInfo.py
+++ lldb/test/API/commands/trace/TestTraceDumpInfo.py
@@ -38,4 +38,5 @@
 substrs=['''Trace technology: intel-pt
 
 thread #1: tid = 3842849
-  Raw trace size: 4096 bytes'''])
+  Raw trace size: 4096 bytes
+  Total number of instructions: 21'''])
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
@@ -110,7 +110,10 @@
 s.Printf(", not traced\n");
 return;
   }
-  s.Printf("\n  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("\n");
+  s.Printf("  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("  Total number of instructions: %zu\n", 
+Decode(thread)->GetInstructions().size());
   return;
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D122076: [trace][intelpt] Instruction count in trace info

2022-03-19 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

Lgtm!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122076

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 8271220 - [trace][intelpt] Instruction count in trace info

2022-03-19 Thread Alisamar Husain via lldb-commits

Author: Alisamar Husain
Date: 2022-03-20T11:28:16+05:30
New Revision: 8271220a9981d0cb3186e8fc25477f622ea5c2c9

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

LOG: [trace][intelpt] Instruction count in trace info

Added a line to `thread trace dump info` results which shows total number of 
instructions executed until now.

Differential Revision: https://reviews.llvm.org/D122076

Added: 


Modified: 
lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
lldb/test/API/commands/trace/TestTraceDumpInfo.py

Removed: 




diff  --git a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp 
b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
index 6ec957771e47d..831cd3764672c 100644
--- a/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
@@ -110,7 +110,10 @@ void TraceIntelPT::DumpTraceInfo(Thread &thread, Stream 
&s, bool verbose) {
 s.Printf(", not traced\n");
 return;
   }
-  s.Printf("\n  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("\n");
+  s.Printf("  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("  Total number of instructions: %zu\n", 
+Decode(thread)->GetInstructions().size());
   return;
 }
 

diff  --git a/lldb/test/API/commands/trace/TestTraceDumpInfo.py 
b/lldb/test/API/commands/trace/TestTraceDumpInfo.py
index 99877aaa27ae5..18088e07b8df3 100644
--- a/lldb/test/API/commands/trace/TestTraceDumpInfo.py
+++ b/lldb/test/API/commands/trace/TestTraceDumpInfo.py
@@ -38,4 +38,5 @@ def testDumpRawTraceSize(self):
 substrs=['''Trace technology: intel-pt
 
 thread #1: tid = 3842849
-  Raw trace size: 4096 bytes'''])
+  Raw trace size: 4096 bytes
+  Total number of instructions: 21'''])



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D122076: [trace][intelpt] Instruction count in trace info

2022-03-19 Thread Alisamar Husain via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8271220a9981: [trace][intelpt] Instruction count in trace 
info (authored by zrthxn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122076

Files:
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/test/API/commands/trace/TestTraceDumpInfo.py


Index: lldb/test/API/commands/trace/TestTraceDumpInfo.py
===
--- lldb/test/API/commands/trace/TestTraceDumpInfo.py
+++ lldb/test/API/commands/trace/TestTraceDumpInfo.py
@@ -38,4 +38,5 @@
 substrs=['''Trace technology: intel-pt
 
 thread #1: tid = 3842849
-  Raw trace size: 4096 bytes'''])
+  Raw trace size: 4096 bytes
+  Total number of instructions: 21'''])
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
@@ -110,7 +110,10 @@
 s.Printf(", not traced\n");
 return;
   }
-  s.Printf("\n  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("\n");
+  s.Printf("  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("  Total number of instructions: %zu\n", 
+Decode(thread)->GetInstructions().size());
   return;
 }
 


Index: lldb/test/API/commands/trace/TestTraceDumpInfo.py
===
--- lldb/test/API/commands/trace/TestTraceDumpInfo.py
+++ lldb/test/API/commands/trace/TestTraceDumpInfo.py
@@ -38,4 +38,5 @@
 substrs=['''Trace technology: intel-pt
 
 thread #1: tid = 3842849
-  Raw trace size: 4096 bytes'''])
+  Raw trace size: 4096 bytes
+  Total number of instructions: 21'''])
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
@@ -110,7 +110,10 @@
 s.Printf(", not traced\n");
 return;
   }
-  s.Printf("\n  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("\n");
+  s.Printf("  Raw trace size: %zu bytes\n", *raw_size);
+  s.Printf("  Total number of instructions: %zu\n", 
+Decode(thread)->GetInstructions().size());
   return;
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits