31 size_t field_len = strlen (field);
36 snprintf (buf,
sizeof (buf),
"/proc/%d/status", (
int) lwpid);
38 if (status_file == NULL)
41 warning (
_(
"unable to open /proc file '%s'"), buf);
45 while (fgets (buf,
sizeof (buf), status_file))
46 if (strncmp (buf, field, field_len) == 0 && buf[field_len] ==
':')
48 retval = strtol (&buf[field_len + 1], NULL, 10);
85 xsnprintf (buffer, buffer_size,
"/proc/%d/status", (
int) pid);
90 warning (
_(
"unable to open /proc file '%s'"), buffer);
95 while (fgets (buffer, buffer_size, procfile) != NULL)
120 else if (have_state == 0)
127 return (strstr (buffer,
"Z (") != NULL
128 || strstr (buffer,
"X (") != NULL);
142 return (have_state > 0 && strstr (buffer, state) != NULL);
196 int new_threads_found;
202 xsnprintf (pathname,
sizeof (pathname),
"/proc/%ld/task", (
long) pid);
203 dir = opendir (pathname);
206 warning (
_(
"Could not open /proc/%ld/task."), (
long) pid);
214 for (iterations = 0; iterations < 2; iterations++)
218 new_threads_found = 0;
219 while ((dp = readdir (dir)) != NULL)
224 lwp = strtoul (dp->d_name, NULL, 10);
229 if (attach_lwp (ptid))
230 new_threads_found = 1;
234 if (new_threads_found)
254 xsnprintf (pathname,
sizeof (pathname),
"/proc/%ld/task", (
long) pid);
255 return (stat (pathname, &buf) == 0);
263 static char buf[PATH_MAX];
267 xsnprintf (name, PATH_MAX,
"/proc/%d/exe", pid);
268 len = readlink (name, buf, PATH_MAX - 1);
int(* linux_proc_attach_lwp_func)(ptid_t ptid)
int linux_proc_task_list_dir_exists(pid_t pid)
static int linux_proc_pid_has_state(pid_t pid, const char *state, int warn)
void warning(const char *fmt,...)
static int linux_proc_pid_get_state(pid_t pid, char *buffer, size_t buffer_size, int warn)
FILE * gdb_fopen_cloexec(const char *filename, const char *opentype)
static int linux_proc_get_int(pid_t lwpid, const char *field, int warn)
int linux_proc_pid_is_zombie_nowarn(pid_t pid)
ptid_t ptid_build(int pid, long lwp, long tid)
int linux_proc_get_tgid(pid_t lwpid)
int linux_proc_pid_is_stopped(pid_t pid)
char * linux_proc_pid_to_exec_file(int pid)
static int startswith(const char *string, const char *pattern)
int linux_proc_pid_is_gone(pid_t pid)
int xsnprintf(char *str, size_t size, const char *format,...)
pid_t linux_proc_get_tracerpid_nowarn(pid_t lwpid)
int linux_proc_pid_is_zombie(pid_t pid)
void linux_proc_attach_tgid_threads(pid_t pid, linux_proc_attach_lwp_func attach_lwp)
static int linux_proc_pid_is_zombie_maybe_warn(pid_t pid, int warn)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int int rusage_t pid_t pid
const ULONGEST const LONGEST len
int linux_proc_pid_is_trace_stopped_nowarn(pid_t pid)