108 lines · python
1import lldb2from intelpt_testcase import *3from lldbsuite.test.lldbtest import *4from lldbsuite.test import lldbutil5from lldbsuite.test.decorators import *6 7 8class TestTraceDumpInfo(TraceIntelPTTestCaseBase):9 def testErrorMessages(self):10 # We first check the output when there are no targets11 self.expect(12 "thread trace dump info",13 substrs=[14 "error: invalid target, create a target using the 'target create' command"15 ],16 error=True,17 )18 19 # We now check the output when there's a non-running target20 self.expect(21 "target create "22 + os.path.join(self.getSourceDir(), "intelpt-trace", "a.out")23 )24 25 self.expect(26 "thread trace dump info",27 substrs=["error: Command requires a current process."],28 error=True,29 )30 31 # Now we check the output when there's a running target without a trace32 self.expect("b main")33 self.expect("run")34 35 self.expect(36 "thread trace dump info",37 substrs=["error: Process is not being traced"],38 error=True,39 )40 41 def testDumpRawTraceSize(self):42 self.expect(43 "trace load -v "44 + os.path.join(self.getSourceDir(), "intelpt-trace", "trace.json"),45 substrs=["intel-pt"],46 )47 48 self.expect(49 "thread trace dump info",50 substrs=[51 """thread #1: tid = 384284952 53 Trace technology: intel-pt54 55 Total number of trace items: 2856 57 Memory usage:58 Raw trace size: 4 KiB""",59 """60 61 Events:62 Number of individual events: 763 software disabled tracing: 264 hardware disabled tracing: 465 trace synchronization point: 1""",66 ],67 patterns=[r"Decoding instructions: \d.\d\ds"],68 )69 70 def testDumpRawTraceSizeJSON(self):71 self.expect(72 "trace load -v "73 + os.path.join(self.getSourceDir(), "intelpt-trace", "trace.json"),74 substrs=["intel-pt"],75 )76 77 self.expect(78 "thread trace dump info --json ",79 substrs=[80 """{81 "traceTechnology": "intel-pt",82 "threadStats": {83 "tid": 3842849,84 "traceItemsCount": 28,""",85 """86 },87 "events": {88 "totalCount": 7,89 "individualCounts": {90 "software disabled tracing": 2,91 "hardware disabled tracing": 4,92 "trace synchronization point": 193 }94 },95 "errors": {96 "totalCount": 0,97 "libiptErrors": {},98 "fatalErrors": 0,99 "otherErrors": 0100 }101 },102 "globalStats": {103 "timingInSeconds": {}104 }105}""",106 ],107 )108