def _read_real_inferior_pid(n_gdb_pid): """Given the pid of gdb, return the pid of the inferior or -1 on error. This is inefficiently implemented by scanning entries in /proc.""" l_pid_dirs = glob.glob("/proc/[0-9]*") for pid_dir in l_pid_dirs: n_pid = fredutil.to_int(re.search("/proc/([0-9]+).*", pid_dir).group(1)) try: f = open(pid_dir + "/stat") except IOError: continue n_ppid = fredutil.to_int(f.read().split()[3]) f.close() if n_ppid == n_gdb_pid: return n_pid return -1
def _read_real_inferior_pid(n_gdb_pid): """Given the pid of gdb, return the pid of the inferior or -1 on error. This is inefficiently implemented by scanning entries in /proc.""" l_pid_dirs = glob.glob("/proc/[0-9]*") for pid_dir in l_pid_dirs: n_pid = fredutil.to_int( re.search("/proc/([0-9]+).*", pid_dir).group(1)) try: f = open(pid_dir + "/stat") except IOError: continue n_ppid = fredutil.to_int(f.read().split()[3]) f.close() if n_ppid == n_gdb_pid: return n_pid return -1
def count(self): """Return integer representation of 'count' argument.""" fredutil.fred_assert(self.b_count_cmd, "Tried to get count of non-count cmd.") return fredutil.to_int(self.s_args, 1)