1import lldb 2from lldbsuite.test.lldbtest import * 3from lldbsuite.test import lldbutil 4from lldbsuite.test.decorators import * 5 6class TestTraceLoad(TestBase): 7 8 mydir = TestBase.compute_mydir(__file__) 9 NO_DEBUG_INFO_TESTCASE = True 10 11 def setUp(self): 12 TestBase.setUp(self) 13 if 'intel-pt' not in configuration.enabled_plugins: 14 self.skipTest("The intel-pt test plugin is not enabled") 15 16 def expectGenericHelpMessageForStartCommand(self): 17 self.expect("help thread trace start", 18 substrs=["Syntax: thread trace start [<trace-options>]"]) 19 20 def testStartStopSessionFileThreads(self): 21 # it should fail for processes from json session files 22 self.expect("trace load -v " + os.path.join(self.getSourceDir(), "intelpt-trace", "trace.json")) 23 self.expect("thread trace start", error=True, 24 substrs=["error: Tracing is not supported. Can't trace a non-live process"]) 25 26 # the help command should be the generic one, as it's not a live process 27 self.expectGenericHelpMessageForStartCommand() 28 29 # this should fail because 'trace stop' is not yet implemented 30 self.expect("thread trace stop", error=True, 31 substrs=["error: Failed stopping thread 3842849"]) 32 33 @skipIf(oslist=no_match(['linux']), archs=no_match(['i386', 'x86_64'])) 34 def testStartStopLiveThreads(self): 35 # The help command should be the generic one if there's no process running 36 self.expectGenericHelpMessageForStartCommand() 37 38 self.expect("thread trace start", error=True, 39 substrs=["error: Process not available"]) 40 41 self.expect("file " + os.path.join(self.getSourceDir(), "intelpt-trace", "a.out")) 42 self.expect("b main") 43 44 self.expect("thread trace start", error=True, 45 substrs=["error: Process not available"]) 46 47 # The help command should be the generic one if there's still no process running 48 self.expectGenericHelpMessageForStartCommand() 49 50 self.expect("r") 51 52 # the help command should be the intel-pt one now 53 self.expect("help thread trace start", 54 substrs=["Start tracing one or more threads with intel-pt.", 55 "Syntax: thread trace start [<thread-index> <thread-index> ...] [<intel-pt-options>]"]) 56 57 self.expect("thread trace start", 58 patterns=["would trace tid .* with size_in_kb 4 and custom_config 0"]) 59 60 self.expect("thread trace start --size 20 --custom-config 1", 61 patterns=["would trace tid .* with size_in_kb 20 and custom_config 1"]) 62 63 # This fails because "trace stop" is not yet implemented. 64 self.expect("thread trace stop", error=True, 65 substrs=["error: Process is not being traced"]) 66 67 self.expect("c") 68 # Now the process has finished, so the commands should fail 69 self.expect("thread trace start", error=True, 70 substrs=["error: Process must be launched"]) 71 72 self.expect("thread trace stop", error=True, 73 substrs=["error: Process must be launched"]) 74