1import lldb
2from intelpt_testcase import *
3from lldbsuite.test.lldbtest import *
4from lldbsuite.test import lldbutil
5from lldbsuite.test.decorators import *
6
7class TestTraceDumpInfo(TraceIntelPTTestCaseBase):
8    mydir = TestBase.compute_mydir(__file__)
9
10    def testErrorMessages(self):
11        # We first check the output when there are no targets
12        self.expect("thread trace dump info",
13            substrs=["error: invalid target, create a target using the 'target create' command"],
14            error=True)
15
16        # We now check the output when there's a non-running target
17        self.expect("target create " +
18            os.path.join(self.getSourceDir(), "intelpt-trace", "a.out"))
19
20        self.expect("thread trace dump info",
21            substrs=["error: Command requires a current process."],
22            error=True)
23
24        # Now we check the output when there's a running target without a trace
25        self.expect("b main")
26        self.expect("run")
27
28        self.expect("thread trace dump info",
29            substrs=["error: Process is not being traced"],
30            error=True)
31
32    def testDumpRawTraceSize(self):
33        self.expect("trace load -v " +
34        os.path.join(self.getSourceDir(), "intelpt-trace", "trace.json"),
35        substrs=["intel-pt"])
36
37        self.expect("thread trace dump info",
38            substrs=['''Trace technology: intel-pt
39
40thread #1: tid = 3842849
41  Total number of instructions: 21
42
43  Memory usage:
44    Raw trace size: 4 KiB
45    Total approximate memory usage (excluding raw trace): 1.27 KiB
46    Average memory usage per instruction (excluding raw trace): 61.76 bytes
47
48  Timing:
49    Decoding instructions: ''', '''s
50
51  Events:
52    Number of instructions with events: 1
53    Number of individual events: 1
54      paused: 1
55
56  Errors:
57    Number of TSC decoding errors: 0'''],
58            patterns=["Decoding instructions: \d.\d\ds"])
59