GDBserver

Classes | Macros | Typedefs | Functions | Variables
linux-osdata.c File Reference
`#include "common-defs.h"`
`#include "linux-osdata.h"`
`#include <sys/types.h>`
`#include <sys/sysinfo.h>`
`#include <ctype.h>`
`#include <utmp.h>`
`#include <time.h>`
`#include <unistd.h>`
`#include <pwd.h>`
`#include <grp.h>`
`#include <netdb.h>`
`#include <netinet/in.h>`
`#include <arpa/inet.h>`
`#include "xml-utils.h"`
`#include "buffer.h"`
`#include <dirent.h>`
`#include <sys/stat.h>`
`#include "filestuff.h"`
`#include <algorithm>`

Go to the source code of this file.

## Classes
struct | pid_pgid_entry
union | socket_addr
struct | osdata_type

## Macros
#define | NAMELEN(dirent) strlen ((dirent)->d_name)
#define | MAX_PID_T_STRLEN (sizeof ("-9223372036854775808") - 1)

## Typedefs
typedef long long | PID_T
typedef long long | TIME_T

## Functions
int | linux_common_core_of_thread (ptid_t ptid)
static void | command_from_pid (char *command, int maxlen, PID_T pid)
static char * | commandline_from_pid (PID_T pid)
static void | user_from_uid (char *user, int maxlen, uid_t uid)
static int | get_process_owner (uid_t *owner, PID_T pid)
static int | get_cores_used_by_process (PID_T pid, int *cores, const int num_cores)
static LONGEST | linux_xfer_osdata_processes (gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
static LONGEST | linux_xfer_osdata_processgroups (gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
static LONGEST | linux_xfer_osdata_threads (gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
static LONGEST | linux_xfer_osdata_cpus (gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
static LONGEST | linux_xfer_osdata_fds (gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
static const char * | format_socket_state (unsigned char state)
static void | print_sockets (unsigned short family, int tcp, struct buffer *buffer)
static LONGEST | linux_xfer_osdata_isockets (gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
static void | time_from_time_t (char *time, int maxlen, TIME_T seconds)
static void | group_from_gid (char *group, int maxlen, gid_t gid)
static LONGEST | linux_xfer_osdata_shm (gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
static LONGEST | linux_xfer_osdata_sem (gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
static LONGEST | linux_xfer_osdata_msg (gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
static LONGEST | linux_xfer_osdata_modules (gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
LONGEST | linux_common_xfer_osdata (const char *annex, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)

## Variables
struct osdata_type | osdata_table []

## Macro Definition Documentation

## ◆ MAX_PID_T_STRLEN

#define MAX_PID_T_STRLEN (sizeof ("-9223372036854775808") - 1)

Definition at line 55 of file linux-osdata.c.

Referenced by get_cores_used_by_process(), get_process_owner(), linux_common_core_of_thread(), linux_xfer_osdata_processes(), and linux_xfer_osdata_processgroups().

## ◆ NAMELEN

#define NAMELEN | ( |  | dirent | ) | strlen ((dirent)->d_name)

Definition at line 42 of file linux-osdata.c.

Referenced by get_cores_used_by_process(), linux_xfer_osdata_fds(), linux_xfer_osdata_processes(), linux_xfer_osdata_processgroups(), and linux_xfer_osdata_threads().

## Typedef Documentation

## ◆ PID_T

typedef long long PID_T

Definition at line 48 of file linux-osdata.c.

## ◆ TIME_T

typedef long long TIME_T

Definition at line 53 of file linux-osdata.c.

## Function Documentation

## ◆ command_from_pid()

static void command_from_pid | ( | char * | command,
|  | int | maxlen,
|  | PID_T | pid
| ) |  |
| static

Definition at line 116 of file linux-osdata.c.

References fp, gdb_fopen_cloexec(), xfree(), and xstrprintf().

Referenced by commandline_from_pid(), linux_xfer_osdata_fds(), linux_xfer_osdata_msg(), linux_xfer_osdata_processgroups(), linux_xfer_osdata_shm(), and linux_xfer_osdata_threads().

## ◆ commandline_from_pid()

static char* commandline_from_pid | ( | PID_T | pid | ) |
| static

Definition at line 153 of file linux-osdata.c.

References command_from_pid(), gdb_fopen_cloexec(), xfree(), xmalloc(), xrealloc(), and xstrprintf().

Referenced by linux_xfer_osdata_processes(), and linux_xfer_osdata_processgroups().

## ◆ format_socket_state()

static const char* format_socket_state | ( | unsigned char | state | ) |
| static

Definition at line 859 of file linux-osdata.c.

Referenced by print_sockets().

## ◆ get_cores_used_by_process()

static int get_cores_used_by_process | ( | PID_T | pid,
|  | int * | cores,
|  | const int | num_cores
| ) |  |
| static

Definition at line 248 of file linux-osdata.c.

References linux_common_core_of_thread(), MAX_PID_T_STRLEN, NAMELEN, and ptid_build().

Referenced by linux_xfer_osdata_processes().

## ◆ get_process_owner()

static int get_process_owner | ( | uid_t * | owner,
|  | PID_T | pid
| ) |  |
| static

Definition at line 228 of file linux-osdata.c.

References MAX_PID_T_STRLEN, and S_ISDIR.

Referenced by linux_xfer_osdata_processes().

## ◆ group_from_gid()

static void group_from_gid | ( | char * | group,
|  | int | maxlen,
|  | gid_t | gid
| ) |  |
| static

Definition at line 1112 of file linux-osdata.c.

Referenced by linux_xfer_osdata_msg(), linux_xfer_osdata_sem(), and linux_xfer_osdata_shm().

## ◆ linux_common_core_of_thread()

int linux_common_core_of_thread | ( | ptid_t | ptid | ) |

Definition at line 62 of file linux-osdata.c.

References gdb_fopen_cloexec(), MAX_PID_T_STRLEN, ptid_get_lwp(), ptid_get_pid(), xfree(), and xrealloc().

Referenced by get_cores_used_by_process(), and linux_xfer_osdata_threads().

## ◆ linux_common_xfer_osdata()

LONGEST linux_common_xfer_osdata | ( | const char * | annex,
|  | gdb_byte * | readbuf,
|  | ULONGEST | offset,
|  | ULONGEST | len
| ) |  |

Definition at line 1616 of file linux-osdata.c.

References buffer_finish(), buffer_free(), buffer_grow_str, buffer_grow_str0, buffer_init(), buffer_xml_printf(), gdb_assert, offset, osdata_table, and osdata_type::type.

Referenced by linux_qxfer_osdata().

## ◆ linux_xfer_osdata_cpus()

static LONGEST linux_xfer_osdata_cpus | ( | gdb_byte * | readbuf,
|  | ULONGEST | offset,
|  | ULONGEST | len
| ) |  |
| static

Definition at line 648 of file linux-osdata.c.

References buffer_finish(), buffer_free(), buffer_grow_str, buffer_grow_str0, buffer_init(), buffer_xml_printf(), fp, gdb_fopen_cloexec(), and offset.

## ◆ linux_xfer_osdata_fds()

static LONGEST linux_xfer_osdata_fds | ( | gdb_byte * | readbuf,
|  | ULONGEST | offset,
|  | ULONGEST | len
| ) |  |
| static

Definition at line 744 of file linux-osdata.c.

References buffer_finish(), buffer_free(), buffer_grow_str, buffer_grow_str0, buffer_init(), buffer_xml_printf(), command_from_pid(), NAMELEN, offset, S_ISDIR, xfree(), xsnprintf(), and xstrprintf().

## ◆ linux_xfer_osdata_isockets()

static LONGEST linux_xfer_osdata_isockets | ( | gdb_byte * | readbuf,
|  | ULONGEST | offset,
|  | ULONGEST | len
| ) |  |
| static

Definition at line 1049 of file linux-osdata.c.

References buffer_finish(), buffer_free(), buffer_grow_str, buffer_grow_str0, buffer_init(), offset, and print_sockets().

## ◆ linux_xfer_osdata_modules()

static LONGEST linux_xfer_osdata_modules | ( | gdb_byte * | readbuf,
|  | ULONGEST | offset,
|  | ULONGEST | len
| ) |  |
| static

Definition at line 1484 of file linux-osdata.c.

References buffer_finish(), buffer_free(), buffer_grow_str, buffer_grow_str0, buffer_init(), buffer_xml_printf(), fp, gdb_fopen_cloexec(), name, and offset.

## ◆ linux_xfer_osdata_msg()

static LONGEST linux_xfer_osdata_msg | ( | gdb_byte * | readbuf,
|  | ULONGEST | offset,
|  | ULONGEST | len
| ) |  |
| static

Definition at line 1362 of file linux-osdata.c.

References buffer_finish(), buffer_free(), buffer_grow_str, buffer_grow_str0, buffer_init(), buffer_xml_printf(), command_from_pid(), fp, gdb_fopen_cloexec(), group_from_gid(), offset, time_from_time_t(), and user_from_uid().

## ◆ linux_xfer_osdata_processes()

static LONGEST linux_xfer_osdata_processes | ( | gdb_byte * | readbuf,
|  | ULONGEST | offset,
|  | ULONGEST | len
| ) |  |
| static

Definition at line 286 of file linux-osdata.c.

References buffer_finish(), buffer_free(), buffer_grow_str, buffer_grow_str0, buffer_init(), buffer_xml_printf(), commandline_from_pid(), get_cores_used_by_process(), get_process_owner(), MAX_PID_T_STRLEN, NAMELEN, offset, user_from_uid(), xcalloc(), XCNEWVEC, and xfree().

## ◆ linux_xfer_osdata_processgroups()

static LONGEST linux_xfer_osdata_processgroups | ( | gdb_byte * | readbuf,
|  | ULONGEST | offset,
|  | ULONGEST | len
| ) |  |
| static

Definition at line 433 of file linux-osdata.c.

References buffer_finish(), buffer_free(), buffer_grow_str, buffer_grow_str0, buffer_init(), buffer_xml_printf(), command_from_pid(), commandline_from_pid(), MAX_PID_T_STRLEN, NAMELEN, offset, and xfree().

## ◆ linux_xfer_osdata_sem()

static LONGEST linux_xfer_osdata_sem | ( | gdb_byte * | readbuf,
|  | ULONGEST | offset,
|  | ULONGEST | len
| ) |  |
| static

Definition at line 1254 of file linux-osdata.c.

References buffer_finish(), buffer_free(), buffer_grow_str, buffer_grow_str0, buffer_init(), buffer_xml_printf(), fp, gdb_fopen_cloexec(), group_from_gid(), offset, time_from_time_t(), and user_from_uid().

## ◆ linux_xfer_osdata_shm()

static LONGEST linux_xfer_osdata_shm | ( | gdb_byte * | readbuf,
|  | ULONGEST | offset,
|  | ULONGEST | len
| ) |  |
| static

Definition at line 1130 of file linux-osdata.c.

References buffer_finish(), buffer_free(), buffer_grow_str, buffer_grow_str0, buffer_init(), buffer_xml_printf(), command_from_pid(), fp, gdb_fopen_cloexec(), group_from_gid(), offset, time_from_time_t(), and user_from_uid().

## ◆ linux_xfer_osdata_threads()

static LONGEST linux_xfer_osdata_threads | ( | gdb_byte * | readbuf,
|  | ULONGEST | offset,
|  | ULONGEST | len
| ) |  |
| static

Definition at line 534 of file linux-osdata.c.

References buffer_finish(), buffer_free(), buffer_grow_str, buffer_grow_str0, buffer_init(), buffer_xml_printf(), command_from_pid(), linux_common_core_of_thread(), NAMELEN, offset, ptid_build(), S_ISDIR, xfree(), xsnprintf(), and xstrprintf().

## ◆ print_sockets()

static void print_sockets | ( | unsigned short | family,
|  | int | tcp,
|  | struct buffer * | buffer
| ) |  |
| static

Definition at line 918 of file linux-osdata.c.

References buffer_xml_printf(), format_socket_state(), fp, gdb_fopen_cloexec(), socket_addr::sa, socket_addr::sin, socket_addr::sin6, and user_from_uid().

Referenced by linux_xfer_osdata_isockets().

## ◆ time_from_time_t()

static void time_from_time_t | ( | char * | time,
|  | int | maxlen,
|  | TIME_T | seconds
| ) |  |
| static

Definition at line 1095 of file linux-osdata.c.

Referenced by linux_xfer_osdata_msg(), linux_xfer_osdata_sem(), and linux_xfer_osdata_shm().

## ◆ user_from_uid()

static void user_from_uid | ( | char * | user,
|  | int | maxlen,
|  | uid_t | uid
| ) |  |
| static

Definition at line 210 of file linux-osdata.c.

Referenced by linux_xfer_osdata_msg(), linux_xfer_osdata_processes(), linux_xfer_osdata_sem(), linux_xfer_osdata_shm(), and print_sockets().

## Variable Documentation

## ◆ osdata_table

struct osdata_type osdata_table[]

Initial value:
= {
{ "cpus", "CPUs", "Listing of all cpus/cores on the system",
linux_xfer_osdata_cpus },
{ "files", "File descriptors", "Listing of all file descriptors",
linux_xfer_osdata_fds },
{ "modules", "Kernel modules", "Listing of all loaded kernel modules",
linux_xfer_osdata_modules },
{ "msg", "Message queues", "Listing of all message queues",
linux_xfer_osdata_msg },
{ "processes", "Processes", "Listing of all processes",
linux_xfer_osdata_processes },
{ "procgroups", "Process groups", "Listing of all process groups",
linux_xfer_osdata_processgroups },
{ "semaphores", "Semaphores", "Listing of all semaphores",
linux_xfer_osdata_sem },
{ "shm", "Shared-memory regions", "Listing of all shared-memory regions",
linux_xfer_osdata_shm },
{ "sockets", "Sockets", "Listing of all internet-domain sockets",
linux_xfer_osdata_isockets },
{ "threads", "Threads", "Listing of all threads",
linux_xfer_osdata_threads },
{ NULL, NULL, NULL }
}
linux_xfer_osdata_modules
static LONGEST linux_xfer_osdata_modules(gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
Definition: linux-osdata.c:1484
linux_xfer_osdata_isockets
static LONGEST linux_xfer_osdata_isockets(gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
Definition: linux-osdata.c:1049
linux_xfer_osdata_shm
static LONGEST linux_xfer_osdata_shm(gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
Definition: linux-osdata.c:1130
linux_xfer_osdata_fds
static LONGEST linux_xfer_osdata_fds(gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
Definition: linux-osdata.c:744
linux_xfer_osdata_cpus
static LONGEST linux_xfer_osdata_cpus(gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
Definition: linux-osdata.c:648
linux_xfer_osdata_msg
static LONGEST linux_xfer_osdata_msg(gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
Definition: linux-osdata.c:1362
linux_xfer_osdata_processgroups
static LONGEST linux_xfer_osdata_processgroups(gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
Definition: linux-osdata.c:433
linux_xfer_osdata_processes
static LONGEST linux_xfer_osdata_processes(gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
Definition: linux-osdata.c:286
linux_xfer_osdata_threads
static LONGEST linux_xfer_osdata_threads(gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
Definition: linux-osdata.c:534
linux_xfer_osdata_sem
static LONGEST linux_xfer_osdata_sem(gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
Definition: linux-osdata.c:1254

Referenced by linux_common_xfer_osdata().