GDBserver

Macros | Enumerations | Functions
linux-procfs.c File Reference
`#include "common-defs.h"`
`#include "linux-procfs.h"`
`#include "filestuff.h"`
`#include <dirent.h>`
`#include <sys/stat.h>`

Go to the source code of this file.

## Macros
#define | TASK_COMM_LEN 16 /* As defined in the kernel's sched.h. */

## Enumerations
enum | proc_state { PROC_STATE_UNKNOWN, PROC_STATE_STOPPED, PROC_STATE_TRACING_STOP, PROC_STATE_DEAD, PROC_STATE_ZOMBIE }

## Functions
static int | linux_proc_get_int (pid_t lwpid, const char *field, int warn)
int | linux_proc_get_tgid (pid_t lwpid)
pid_t | linux_proc_get_tracerpid_nowarn (pid_t lwpid)
static enum proc_state | parse_proc_status_state (const char *state)
static int | linux_proc_pid_get_state (pid_t pid, int warn, enum proc_state *state)
int | linux_proc_pid_is_gone (pid_t pid)
static int | linux_proc_pid_has_state (pid_t pid, enum proc_state state, int warn)
int | linux_proc_pid_is_stopped (pid_t pid)
int | linux_proc_pid_is_trace_stopped_nowarn (pid_t pid)
static int | linux_proc_pid_is_zombie_maybe_warn (pid_t pid, int warn)
int | linux_proc_pid_is_zombie_nowarn (pid_t pid)
int | linux_proc_pid_is_zombie (pid_t pid)
const char * | linux_proc_tid_get_name (ptid_t ptid)
void | linux_proc_attach_tgid_threads (pid_t pid, linux_proc_attach_lwp_func attach_lwp)
int | linux_proc_task_list_dir_exists (pid_t pid)
char * | linux_proc_pid_to_exec_file (int pid)

## Macro Definition Documentation

## ◆ TASK_COMM_LEN

#define TASK_COMM_LEN 16 /* As defined in the kernel's sched.h. */

Referenced by linux_proc_tid_get_name().

## Enumeration Type Documentation

## ◆ proc_state

enum proc_state

Enumerator
PROC_STATE_UNKNOWN |
PROC_STATE_STOPPED |
PROC_STATE_TRACING_STOP |
PROC_STATE_DEAD |
PROC_STATE_ZOMBIE |

Definition at line 75 of file linux-procfs.c.

## Function Documentation

## ◆ linux_proc_attach_tgid_threads()

void linux_proc_attach_tgid_threads | ( | pid_t | pid,
|  | linux_proc_attach_lwp_func | attach_lwp
| ) |  |

Definition at line 275 of file linux-procfs.c.

References _, linux_proc_get_tgid(), ptid_build(), warning(), and xsnprintf().

Referenced by linux_attach().

## ◆ linux_proc_get_int()

static int linux_proc_get_int | ( | pid_t | lwpid,
|  | const char * | field,
|  | int | warn
| ) |  |
| static

Definition at line 29 of file linux-procfs.c.

References _, gdb_fopen_cloexec(), and warning().

Referenced by linux_proc_get_tgid(), and linux_proc_get_tracerpid_nowarn().

## ◆ linux_proc_get_tgid()

int linux_proc_get_tgid | ( | pid_t | lwpid | ) |

Definition at line 58 of file linux-procfs.c.

References linux_proc_get_int().

Referenced by linux_proc_attach_tgid_threads().

## ◆ linux_proc_get_tracerpid_nowarn()

pid_t linux_proc_get_tracerpid_nowarn | ( | pid_t | lwpid | ) |

Definition at line 66 of file linux-procfs.c.

References linux_proc_get_int().

Referenced by linux_ptrace_attach_fail_reason().

## ◆ linux_proc_pid_get_state()

static int linux_proc_pid_get_state | ( | pid_t | pid,
|  | int | warn,
|  | enum proc_state * | state
| ) |  |
| static

Definition at line 127 of file linux-procfs.c.

References _, gdb_fopen_cloexec(), parse_proc_status_state(), startswith(), warning(), and xsnprintf().

Referenced by linux_proc_pid_has_state(), and linux_proc_pid_is_gone().

## ◆ linux_proc_pid_has_state()

static int linux_proc_pid_has_state | ( | pid_t | pid,
|  | enum proc_state | state,
|  | int | warn
| ) |  |
| static

Definition at line 180 of file linux-procfs.c.

References linux_proc_pid_get_state().

Referenced by linux_proc_pid_is_stopped(), linux_proc_pid_is_trace_stopped_nowarn(), and linux_proc_pid_is_zombie_maybe_warn().

## ◆ linux_proc_pid_is_gone()

int linux_proc_pid_is_gone | ( | pid_t | pid | ) |

Definition at line 155 of file linux-procfs.c.

References linux_proc_pid_get_state(), PROC_STATE_DEAD, and PROC_STATE_ZOMBIE.

Referenced by attach_proc_task_lwp_callback().

## ◆ linux_proc_pid_is_stopped()

int linux_proc_pid_is_stopped | ( | pid_t | pid | ) |

Definition at line 193 of file linux-procfs.c.

References linux_proc_pid_has_state(), and PROC_STATE_STOPPED.

Referenced by linux_attach_lwp().

## ◆ linux_proc_pid_is_trace_stopped_nowarn()

int linux_proc_pid_is_trace_stopped_nowarn | ( | pid_t | pid | ) |

Definition at line 202 of file linux-procfs.c.

References linux_proc_pid_has_state(), and PROC_STATE_TRACING_STOP.

Referenced by check_ptrace_stopped_lwp_gone().

## ◆ linux_proc_pid_is_zombie()

int linux_proc_pid_is_zombie | ( | pid_t | pid | ) |

Definition at line 227 of file linux-procfs.c.

References linux_proc_pid_is_zombie_maybe_warn().

Referenced by check_zombie_leaders().

## ◆ linux_proc_pid_is_zombie_maybe_warn()

static int linux_proc_pid_is_zombie_maybe_warn | ( | pid_t | pid,
|  | int | warn
| ) |  |
| static

Definition at line 211 of file linux-procfs.c.

References linux_proc_pid_has_state(), and PROC_STATE_ZOMBIE.

Referenced by linux_proc_pid_is_zombie(), and linux_proc_pid_is_zombie_nowarn().

## ◆ linux_proc_pid_is_zombie_nowarn()

int linux_proc_pid_is_zombie_nowarn | ( | pid_t | pid | ) |

Definition at line 219 of file linux-procfs.c.

References linux_proc_pid_is_zombie_maybe_warn().

Referenced by linux_ptrace_attach_fail_reason().

## ◆ linux_proc_pid_to_exec_file()

char* linux_proc_pid_to_exec_file | ( | int | pid | ) |

Definition at line 345 of file linux-procfs.c.

References name, and xsnprintf().

Referenced by handle_extended_wait().

## ◆ linux_proc_task_list_dir_exists()

int linux_proc_task_list_dir_exists | ( | pid_t | pid | ) |

Definition at line 333 of file linux-procfs.c.

References xsnprintf().

Referenced by thread_db_init().

## ◆ linux_proc_tid_get_name()

const char* linux_proc_tid_get_name | ( | ptid_t | ptid | ) |

Definition at line 235 of file linux-procfs.c.

References gdb_fopen_cloexec(), ptid_get_lwp(), ptid_get_pid(), ptid_lwp_p(), TASK_COMM_LEN, and xsnprintf().

## ◆ parse_proc_status_state()

static enum proc_state parse_proc_status_state | ( | const char * | state | ) |
| static

Definition at line 97 of file linux-procfs.c.

References PROC_STATE_DEAD, PROC_STATE_STOPPED, PROC_STATE_TRACING_STOP, PROC_STATE_UNKNOWN, PROC_STATE_ZOMBIE, and skip_spaces().

Referenced by linux_proc_pid_get_state().