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