GDB (xrefs)
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions | Variables
linux-osdata.c File Reference
#include "gdbsupport/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 "gdbsupport/xml-utils.h"
#include "gdbsupport/buffer.h"
#include <dirent.h>
#include <sys/stat.h>
#include "gdbsupport/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 gdb::optional< size_t > get_core_array_size_using_sys_possible ()
 
static size_t get_core_array_size ()
 
static std::string linux_xfer_osdata_processes ()
 
static std::string linux_xfer_osdata_processgroups ()
 
static std::string linux_xfer_osdata_threads ()
 
static std::string linux_xfer_osdata_cpus ()
 
static std::string linux_xfer_osdata_fds ()
 
static const char * format_socket_state (unsigned char state)
 
static void print_sockets (unsigned short family, int tcp, std::string &buffer)
 
static std::string linux_xfer_osdata_isockets ()
 
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 std::string linux_xfer_osdata_shm ()
 
static std::string linux_xfer_osdata_sem ()
 
static std::string linux_xfer_osdata_msg ()
 
static std::string linux_xfer_osdata_modules ()
 
static std::string linux_xfer_osdata_info_os_types ()
 
static LONGEST common_getter (struct osdata_type *osd, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
 
LONGEST linux_common_xfer_osdata (const char *annex, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
 

Variables

static 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.

◆ NAMELEN

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

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

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

◆ commandline_from_pid()

static char * commandline_from_pid ( PID_T  pid)
static

◆ common_getter()

static LONGEST common_getter ( struct osdata_type osd,
gdb_byte *  readbuf,
ULONGEST  offset,
ULONGEST  len 
)
static

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

References osdata_type::buffer, and osdata_type::take_snapshot.

Referenced by linux_common_xfer_osdata().

◆ format_socket_state()

static const char * format_socket_state ( unsigned char  state)
static

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

Referenced by print_sockets().

◆ get_core_array_size()

static size_t get_core_array_size ( )
static

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

References get_core_array_size_using_sys_possible().

Referenced by linux_xfer_osdata_processes().

◆ get_core_array_size_using_sys_possible()

static gdb::optional< size_t > get_core_array_size_using_sys_possible ( )
static

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

References size.

Referenced by get_core_array_size().

◆ 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 237 of file linux-osdata.c.

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

Referenced by linux_xfer_osdata_processes().

◆ get_process_owner()

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

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

References MAX_PID_T_STRLEN, and pid.

Referenced by linux_xfer_osdata_processes().

◆ group_from_gid()

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

◆ linux_common_core_of_thread()

int linux_common_core_of_thread ( ptid_t  ptid)

◆ linux_common_xfer_osdata()

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

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

References common_getter(), osdata_table, and osdata_type::type.

Referenced by linux_nat_xfer_osdata().

◆ linux_xfer_osdata_cpus()

static std::string linux_xfer_osdata_cpus ( )
static

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

◆ linux_xfer_osdata_fds()

static std::string linux_xfer_osdata_fds ( )
static

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

References command_from_pid(), NAMELEN, and pid.

◆ linux_xfer_osdata_info_os_types()

static std::string linux_xfer_osdata_info_os_types ( )
static

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

References osdata_table, and osdata_type::type.

◆ linux_xfer_osdata_isockets()

static std::string linux_xfer_osdata_isockets ( )
static

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

References print_sockets().

◆ linux_xfer_osdata_modules()

static std::string linux_xfer_osdata_modules ( )
static

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

References name, size, and status.

◆ linux_xfer_osdata_msg()

static std::string linux_xfer_osdata_msg ( )
static

◆ linux_xfer_osdata_processes()

static std::string linux_xfer_osdata_processes ( )
static

◆ linux_xfer_osdata_processgroups()

static std::string linux_xfer_osdata_processgroups ( )
static

◆ linux_xfer_osdata_sem()

static std::string linux_xfer_osdata_sem ( )
static

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

References group_from_gid(), time_from_time_t(), and user_from_uid().

◆ linux_xfer_osdata_shm()

static std::string linux_xfer_osdata_shm ( )
static

◆ linux_xfer_osdata_threads()

static std::string linux_xfer_osdata_threads ( )
static

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

References command_from_pid(), linux_common_core_of_thread(), NAMELEN, and pid.

◆ print_sockets()

static void print_sockets ( unsigned short  family,
int  tcp,
std::string &  buffer 
)
static

◆ time_from_time_t()

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

◆ user_from_uid()

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

Variable Documentation

◆ osdata_table

struct osdata_type osdata_table[]
static
Initial value:
= {
{ "types", "Types", "Listing of info os types you can list",
{ "cpus", "CPUs", "Listing of all cpus/cores on the system",
{ "files", "File descriptors", "Listing of all file descriptors",
{ "modules", "Kernel modules", "Listing of all loaded kernel modules",
{ "msg", "Message queues", "Listing of all message queues",
{ "processes", "Processes", "Listing of all processes",
{ "procgroups", "Process groups", "Listing of all process groups",
{ "semaphores", "Semaphores", "Listing of all semaphores",
{ "shm", "Shared-memory regions", "Listing of all shared-memory regions",
{ "sockets", "Sockets", "Listing of all internet-domain sockets",
{ "threads", "Threads", "Listing of all threads",
{ NULL, NULL, NULL }
}
static std::string linux_xfer_osdata_cpus()
static std::string linux_xfer_osdata_modules()
static std::string linux_xfer_osdata_processgroups()
static std::string linux_xfer_osdata_sem()
static std::string linux_xfer_osdata_processes()
static std::string linux_xfer_osdata_threads()
static std::string linux_xfer_osdata_msg()
static std::string linux_xfer_osdata_isockets()
static std::string linux_xfer_osdata_shm()
static std::string linux_xfer_osdata_fds()
static std::string linux_xfer_osdata_info_os_types()

Referenced by linux_common_xfer_osdata(), and linux_xfer_osdata_info_os_types().