GDBserver
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 <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 std::string 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)

◆ NAMELEN

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

Typedef Documentation

◆ PID_T

typedef long long PID_T

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

◆ TIME_T

typedef long long TIME_T

Definition at line 52 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 std::string commandline_from_pid ( PID_T pid)
static

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

References command_from_pid().

Referenced by linux_xfer_osdata_processes(), and linux_xfer_osdata_processgroups().

◆ common_getter()

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

Definition at line 1388 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 735 of file linux-osdata.c.

Referenced by print_sockets().

◆ get_core_array_size()

static size_t get_core_array_size ( )
static

Definition at line 307 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 261 of file linux-osdata.c.

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

References linux_common_core_of_thread(), MAX_PID_T_STRLEN, and NAMELEN.

Referenced by linux_xfer_osdata_processes().

◆ get_process_owner()

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

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

References MAX_PID_T_STRLEN.

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)

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

References MAX_PID_T_STRLEN.

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

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

◆ linux_xfer_osdata_cpus()

static std::string linux_xfer_osdata_cpus ( )
static

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

◆ linux_xfer_osdata_fds()

static std::string linux_xfer_osdata_fds ( )
static

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

References command_from_pid(), and NAMELEN.

◆ linux_xfer_osdata_info_os_types()

static std::string linux_xfer_osdata_info_os_types ( )
static

Definition at line 1362 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 925 of file linux-osdata.c.

References print_sockets().

◆ linux_xfer_osdata_modules()

static std::string linux_xfer_osdata_modules ( )
static

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

◆ 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

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

References command_from_pid(), commandline_from_pid(), MAX_PID_T_STRLEN, and NAMELEN.

◆ linux_xfer_osdata_sem()

static std::string linux_xfer_osdata_sem ( )
static

Definition at line 1078 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 500 of file linux-osdata.c.

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

◆ 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().