def test_process_launch_for_universal(self): """Test process launch of a universal binary.""" from lldbsuite.test.lldbutil import print_registers # Invoke the default build rule. self.build() # Note that "testit" is a universal binary. exe = os.path.join(os.getcwd(), "testit") # By default, x86_64 is assumed if no architecture is specified. self.expect("file " + exe, CURRENT_EXECUTABLE_SET, startstr="Current executable set to ", substrs=["testit' (x86_64)."]) # Break inside the main. lldbutil.run_break_set_by_file_and_line(self, "main.c", self.line, num_expected_locations=1, loc_exact=True) # We should be able to launch the x86_64 executable. self.runCmd("run", RUN_SUCCEEDED) # Check whether we have a 64-bit process launched. target = self.dbg.GetSelectedTarget() process = target.GetProcess() self.assertTrue( target and process and self.invoke(process, 'GetAddressByteSize') == 8, "64-bit process launched") frame = process.GetThreadAtIndex(0).GetFrameAtIndex(0) registers = print_registers(frame, string_buffer=True) self.expect(registers, exe=False, substrs=['Name: rax']) self.runCmd("continue") # Now specify i386 as the architecture for "testit". self.expect("file -a i386 " + exe, CURRENT_EXECUTABLE_SET, startstr="Current executable set to ", substrs=["testit' (i386)."]) # Break inside the main. lldbutil.run_break_set_by_file_and_line(self, "main.c", self.line, num_expected_locations=1, loc_exact=True) # We should be able to launch the i386 executable as well. self.runCmd("run", RUN_SUCCEEDED) # Check whether we have a 32-bit process launched. target = self.dbg.GetSelectedTarget() process = target.GetProcess() self.assertTrue(target and process, "32-bit process launched") pointerSize = self.invoke(process, 'GetAddressByteSize') self.assertTrue( pointerSize == 4, "AddressByteSize of 32-bit process should be 4, got %d instead." % pointerSize) frame = process.GetThreadAtIndex(0).GetFrameAtIndex(0) registers = print_registers(frame, string_buffer=True) self.expect(registers, exe=False, substrs=['Name: eax']) self.runCmd("continue")
def test_process_launch_for_universal(self): """Test process launch of a universal binary.""" from lldbsuite.test.lldbutil import print_registers # Invoke the default build rule. self.build() # Note that "testit" is a universal binary. exe = os.path.join(os.getcwd(), "testit") # By default, x86_64 is assumed if no architecture is specified. self.expect("file " + exe, CURRENT_EXECUTABLE_SET, startstr = "Current executable set to ", substrs = ["testit' (x86_64)."]) # Break inside the main. lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True) # We should be able to launch the x86_64 executable. self.runCmd("run", RUN_SUCCEEDED) # Check whether we have a 64-bit process launched. target = self.dbg.GetSelectedTarget() process = target.GetProcess() self.assertTrue(target and process and self.invoke(process, 'GetAddressByteSize') == 8, "64-bit process launched") frame = process.GetThreadAtIndex(0).GetFrameAtIndex(0) registers = print_registers(frame, string_buffer=True) self.expect(registers, exe=False, substrs = ['Name: rax']) self.runCmd("continue") # Now specify i386 as the architecture for "testit". self.expect("file -a i386 " + exe, CURRENT_EXECUTABLE_SET, startstr = "Current executable set to ", substrs = ["testit' (i386)."]) # Break inside the main. lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True) # We should be able to launch the i386 executable as well. self.runCmd("run", RUN_SUCCEEDED) # Check whether we have a 32-bit process launched. target = self.dbg.GetSelectedTarget() process = target.GetProcess() self.assertTrue(target and process, "32-bit process launched") pointerSize = self.invoke(process, 'GetAddressByteSize') self.assertTrue(pointerSize == 4, "AddressByteSize of 32-bit process should be 4, got %d instead." % pointerSize) frame = process.GetThreadAtIndex(0).GetFrameAtIndex(0) registers = print_registers(frame, string_buffer=True) self.expect(registers, exe=False, substrs = ['Name: eax']) self.runCmd("continue")