def __init__(self, test_bin, board, host, framework, run_as_root, gtest_filter, user_gtest_filter, sysroot, test_bin_args): if not test_bin_args: test_bin_args = [test_bin] if not test_bin: test_bin = test_bin_args[0] self.bin = test_bin self.args = test_bin_args self.board = board self.host = host self.run_as_root = run_as_root (self.gtest_filter, self.user_gtest_filter) = \ self.generateGtestFilter(gtest_filter, user_gtest_filter) if sysroot: self.sysroot = sysroot else: self.sysroot = cros_build_lib.GetSysroot(self.board) self.framework = framework if self.framework == 'auto': qemu_arch = qemu.Qemu.DetectArch(self.bin, self.sysroot) if qemu_arch is None: self.framework = 'ldso' else: self.framework = 'qemu' if self.framework == 'qemu': self.qemu = qemu.Qemu(self.sysroot, arch=qemu_arch)
def VerifyAndFinishInitialization(self, device): """Verify files/processes exist and flags are correct.""" if not self.board: if self.remote: self.board = cros_build_lib.GetBoard(device_board=device.board, override_board=self.board) else: raise GdbCannotDetectBoardError( 'Cannot determine which board to use. ' 'Please specify the with --board flag.') self.sysroot = cros_build_lib.GetSysroot(board=self.board) self.prompt = '(%s-gdb) ' % self.board self.inf_cmd = self.RemoveSysrootPrefix(self.inf_cmd) self.cross_gdb = self.GetCrossGdb() if self.remote: # If given remote process name, find pid & inf_cmd on remote device. if self.remote_process_name or self.pid: self._FindRemoteProcess(device) # Verify that sysroot is valid (exists). if not os.path.isdir(self.sysroot): raise GdbMissingSysrootError('Sysroot does not exist: %s' % self.sysroot) self.device = device sysroot_inf_cmd = '' if self.inf_cmd: sysroot_inf_cmd = os.path.join(self.sysroot, self.inf_cmd.lstrip('/')) # Verify that inf_cmd, if given, exists. if sysroot_inf_cmd and not os.path.exists(sysroot_inf_cmd): raise GdbMissingInferiorError('Cannot find file %s (in sysroot).' % sysroot_inf_cmd) # Check to see if inf_cmd is stripped, and if so, check to see if debug file # exists. If not, tell user and give them the option of quitting & getting # the debug info. if sysroot_inf_cmd: stripped_info = cros_build_lib.RunCommand( ['file', sysroot_inf_cmd], capture_output=True).output if not ' not stripped' in stripped_info: debug_file = os.path.join(self.sysroot, 'usr/lib/debug', self.inf_cmd.lstrip('/')) debug_file += '.debug' if not os.path.exists(debug_file): equery = 'equery-%s' % self.board package = cros_build_lib.RunCommand( [equery, '-q', 'b', self.inf_cmd], capture_output=True).output logging.info( self._MISSING_DEBUG_INFO_MSG % { 'board': self.board, 'inf_cmd': self.inf_cmd, 'package': package, 'debug_file': debug_file }) answer = cros_build_lib.BooleanPrompt() if not answer: raise GdbEarlyExitError( 'Exiting early, at user request.') # Set up qemu, if appropriate. qemu_arch = qemu.Qemu.DetectArch(self._GDB, self.sysroot) if qemu_arch is None: self.framework = 'ldso' else: self.framework = 'qemu' self.qemu = qemu.Qemu(self.sysroot, arch=qemu_arch) if self.remote: # Verify cgdb flag info. if self.cgdb: if osutils.Which('cgdb') is None: raise GdbMissingDebuggerError( 'Cannot find cgdb. Please install ' 'cgdb first.')