|
| 1 | +""" |
| 2 | +Test that argdumper is a viable launching strategy. |
| 3 | +""" |
| 4 | +import commands |
| 5 | +import lldb |
| 6 | +import os |
| 7 | +import time |
| 8 | +import unittest2 |
| 9 | +from lldbtest import * |
| 10 | +import lldbutil |
| 11 | + |
| 12 | +class LaunchWithGlobTestCase(TestBase): |
| 13 | + |
| 14 | + mydir = TestBase.compute_mydir(__file__) |
| 15 | + |
| 16 | + |
| 17 | + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") |
| 18 | + @dsym_test |
| 19 | + def test_with_dsym (self): |
| 20 | + self.buildDsym() |
| 21 | + self.do_test () |
| 22 | + |
| 23 | + |
| 24 | + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") |
| 25 | + @dwarf_test |
| 26 | + def test_with_dwarf (self): |
| 27 | + self.buildDwarf() |
| 28 | + self.do_test () |
| 29 | + |
| 30 | + def do_test (self): |
| 31 | + exe = os.path.join (os.getcwd(), "a.out") |
| 32 | + |
| 33 | + self.runCmd("target create %s" % exe) |
| 34 | + |
| 35 | + # Create the target |
| 36 | + target = self.dbg.CreateTarget(exe) |
| 37 | + |
| 38 | + # Create any breakpoints we need |
| 39 | + breakpoint = target.BreakpointCreateBySourceRegex ('break here', lldb.SBFileSpec ("main.cpp", False)) |
| 40 | + self.assertTrue(breakpoint, VALID_BREAKPOINT) |
| 41 | + |
| 42 | + self.runCmd("process launch -G true -w %s -- fi*.tx?" % (os.getcwd())) |
| 43 | + |
| 44 | + process = self.process() |
| 45 | + |
| 46 | + self.assertTrue(process.GetState() == lldb.eStateStopped, |
| 47 | + STOPPED_DUE_TO_BREAKPOINT) |
| 48 | + |
| 49 | + thread = process.GetThreadAtIndex (0) |
| 50 | + |
| 51 | + self.assertTrue (thread.IsValid(), |
| 52 | + "Process stopped at 'main' should have a valid thread"); |
| 53 | + |
| 54 | + stop_reason = thread.GetStopReason() |
| 55 | + |
| 56 | + self.assertTrue (stop_reason == lldb.eStopReasonBreakpoint, |
| 57 | + "Thread in process stopped in 'main' should have a stop reason of eStopReasonBreakpoint"); |
| 58 | + |
| 59 | + self.expect("frame variable argv[1]", substrs=['file1.txt']) |
| 60 | + self.expect("frame variable argv[2]", substrs=['file2.txt']) |
| 61 | + self.expect("frame variable argv[3]", substrs=['file3.txt']) |
| 62 | + self.expect("frame variable argv[4]", substrs=['file4.txy']) |
| 63 | + self.expect("frame variable argv[5]", substrs=['file5.tyx'], matching=False) |
| 64 | + |
| 65 | +if __name__ == '__main__': |
| 66 | + import atexit |
| 67 | + lldb.SBDebugger.Initialize() |
| 68 | + atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 69 | + unittest2.main() |
| 70 | + |
0 commit comments