1 """ 2 Test some lldb command abbreviations. 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 def execute_command (command): 13 # print '%% %s' % (command) 14 (exit_status, output) = commands.getstatusoutput (command) 15 # if output: 16 # print output 17 # print 'status = %u' % (exit_status) 18 return exit_status 19 20 class FatArchiveTestCase(TestBase): 21 22 mydir = os.path.join("functionalities", "fat_archives") 23 24 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 25 @dwarf_test 26 def test_with_dwarf (self): 27 if self.getArchitecture() == 'x86_64': 28 execute_command ("make CC='%s'" % (os.environ["CC"])) 29 self.main () 30 else: 31 self.skipTest("This test requires x86_64 as the architecture for the inferior") 32 33 def main (self): 34 '''This test compiles a quick example by making a fat file (universal) full of 35 skinny .o files and makes sure we can use them to resolve breakpoints when doing 36 DWARF in .o file debugging. The only thing this test needs to do is to compile and 37 set a breakpoint in the target and verify any breakpoint locations have valid debug 38 info for the function, and source file and line.''' 39 exe = os.path.join (os.getcwd(), "a.out") 40 41 # Create the target 42 target = self.dbg.CreateTarget(exe) 43 44 # Create a breakpoint by name 45 breakpoint = target.BreakpointCreateByName ('foo', exe) 46 self.assertTrue(breakpoint, VALID_BREAKPOINT) 47 48 # Make sure the breakpoint resolves to a function, file and line 49 for bp_loc in breakpoint: 50 # Get a section offset address (lldb.SBAddress) from the breakpoint location 51 bp_loc_addr = bp_loc.GetAddress() 52 line_entry = bp_loc_addr.GetLineEntry() 53 function = bp_loc_addr.GetFunction() 54 self.assertTrue(function.IsValid(), "Verify breakpoint in fat BSD archive has valid function debug info") 55 self.assertTrue(line_entry.GetFileSpec(), "Verify breakpoint in fat BSD archive has source file information") 56 self.assertTrue(line_entry.GetLine() != 0, "Verify breakpoint in fat BSD archive has source line information") 57 58 if __name__ == '__main__': 59 import atexit 60 lldb.SBDebugger.Initialize() 61 atexit.register(lambda: lldb.SBDebugger.Terminate()) 62 unittest2.main() 63 64