31 size_t field_len = strlen (field);
35 snprintf (buf,
sizeof (buf),
"/proc/%d/status", (
int) lwpid);
37 if (status_file == NULL)
40 warning (
_(
"unable to open /proc file '%s'"), buf);
44 while (fgets (buf,
sizeof (buf), status_file.get ()))
45 if (strncmp (buf, field, field_len) == 0 && buf[field_len] ==
':')
47 retval = strtol (&buf[field_len + 1], NULL, 10);
107 if (strcmp (state,
"T (stopped)\n") == 0)
134 if (procfile == NULL)
142 while (fgets (
buffer,
sizeof (
buffer), procfile.get ()) != NULL)
167 else if (have_state == 0)
186 return (have_state > 0 && cur_state == state);
237 #define TASK_COMM_LEN 16 241 const char *comm_val;
245 xsnprintf (comm_path,
sizeof (comm_path),
246 "/proc/%ld/task/%ld/comm", (
long) pid, (
long) tid);
249 if (comm_file == NULL)
252 comm_val = fgets (comm_buf,
sizeof (comm_buf), comm_file.get ());
254 if (comm_val != NULL)
259 for (i = 0; i <
sizeof (comm_buf); i++)
261 if (comm_buf[i] ==
'\n')
280 int new_threads_found;
286 xsnprintf (pathname,
sizeof (pathname),
"/proc/%ld/task", (
long) pid);
287 dir = opendir (pathname);
290 warning (
_(
"Could not open /proc/%ld/task."), (
long) pid);
298 for (iterations = 0; iterations < 2; iterations++)
302 new_threads_found = 0;
303 while ((dp = readdir (dir)) != NULL)
308 lwp = strtoul (dp->d_name, NULL, 10);
313 if (attach_lwp (ptid))
314 new_threads_found = 1;
318 if (new_threads_found)
338 xsnprintf (pathname,
sizeof (pathname),
"/proc/%ld/task", (
long) pid);
339 return (stat (pathname, &buf) == 0);
347 static char buf[PATH_MAX];
352 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)
int ptid_get_pid(const ptid_t &ptid)
void warning(const char *fmt,...)
const char * linux_proc_tid_get_name(ptid_t ptid)
static int linux_proc_pid_get_state(pid_t pid, int warn, enum proc_state *state)
char * skip_spaces(char *chp)
static int linux_proc_pid_has_state(pid_t pid, enum proc_state state, int warn)
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)
static enum proc_state parse_proc_status_state(const char *state)
std::unique_ptr< FILE, gdb_file_deleter > gdb_file_up
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)
gdb_file_up gdb_fopen_cloexec(const char *filename, const char *opentype)
static int startswith(const char *string, const char *pattern)
long ptid_get_lwp(const ptid_t &ptid)
int ptid_lwp_p(const ptid_t &ptid)
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)
int linux_proc_pid_is_trace_stopped_nowarn(pid_t pid)