1import lldb 2from intelpt_testcase import * 3from lldbsuite.test.lldbtest import * 4from lldbsuite.test import lldbutil 5from lldbsuite.test.decorators import * 6 7class TestTraceEvents(TraceIntelPTTestCaseBase): 8 9 @testSBAPIAndCommands 10 def testPauseEvents(self): 11 ''' 12 Everytime the target stops running on the CPU, a 'disabled' event will 13 be emitted, which is represented by the TraceCursor API as a 'paused' 14 event. 15 ''' 16 self.expect("target create " + 17 os.path.join(self.getSourceDir(), "intelpt-trace-multi-file", "a.out")) 18 self.expect("b 12") 19 self.expect("r") 20 self.traceStartThread() 21 self.expect("n") 22 self.expect("n") 23 self.expect("si") 24 self.expect("si") 25 self.expect("si") 26 # We ensure that the paused events are printed correctly forward 27 self.expect("thread trace dump instructions -e -f", 28 patterns=[f'''thread #1: tid = .* 29 a.out`main \+ 23 at main.cpp:12 30 0: {ADDRESS_REGEX} movl .* 31 1: \(event\) software disabled tracing 32 2: {ADDRESS_REGEX} addl .* 33 3: {ADDRESS_REGEX} movl .* 34 4: \(event\) software disabled tracing 35 a.out`main \+ 34 \[inlined\] inline_function\(\) at main.cpp:4 36 5: {ADDRESS_REGEX} movl .* 37 a.out`main \+ 41 \[inlined\] inline_function\(\) \+ 7 at main.cpp:5 38 6: {ADDRESS_REGEX} movl .* 39 7: {ADDRESS_REGEX} addl .* 40 8: {ADDRESS_REGEX} movl .* 41 a.out`main \+ 52 \[inlined\] inline_function\(\) \+ 18 at main.cpp:6 42 9: {ADDRESS_REGEX} movl .* 43 a.out`main \+ 55 at main.cpp:14 44 10: {ADDRESS_REGEX} movl .* 45 11: {ADDRESS_REGEX} addl .* 46 12: {ADDRESS_REGEX} movl .* 47 13: \(event\) software disabled tracing 48 a.out`main \+ 63 at main.cpp:16 49 14: {ADDRESS_REGEX} callq .* ; symbol stub for: foo\(\) 50 15: \(event\) software disabled tracing 51 a.out`symbol stub for: foo\(\) 52 16: {ADDRESS_REGEX} jmpq''']) 53 54 # We ensure that the paused events are printed correctly backward 55 self.expect("thread trace dump instructions -e --id 16", 56 patterns=[f'''thread #1: tid = .* 57 a.out`symbol stub for: foo\(\) 58 16: {ADDRESS_REGEX} jmpq .* 59 15: \(event\) software disabled tracing 60 a.out`main \+ 63 at main.cpp:16 61 14: {ADDRESS_REGEX} callq .* ; symbol stub for: foo\(\) 62 13: \(event\) software disabled tracing 63 a.out`main \+ 60 at main.cpp:14 64 12: {ADDRESS_REGEX} movl .* 65 11: {ADDRESS_REGEX} addl .* 66 10: {ADDRESS_REGEX} movl .* 67 a.out`main \+ 52 \[inlined\] inline_function\(\) \+ 18 at main.cpp:6 68 9: {ADDRESS_REGEX} movl .* 69 a.out`main \+ 49 \[inlined\] inline_function\(\) \+ 15 at main.cpp:5 70 8: {ADDRESS_REGEX} movl .* 71 7: {ADDRESS_REGEX} addl .* 72 6: {ADDRESS_REGEX} movl .* 73 a.out`main \+ 34 \[inlined\] inline_function\(\) at main.cpp:4 74 5: {ADDRESS_REGEX} movl .* 75 4: \(event\) software disabled tracing 76 a.out`main \+ 31 at main.cpp:12 77 3: {ADDRESS_REGEX} movl .* 78 2: {ADDRESS_REGEX} addl .* 79 1: \(event\) software disabled tracing 80 0: {ADDRESS_REGEX} movl .*''']) 81