DMTCP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Typedefs | Functions
pid_syscallsreal.c File Reference
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/syscall.h>
#include <unistd.h>
#include "pidwrappers.h"

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 
#define _XOPEN_SOURCE   500
 
#define GET_FUNC_ADDR(name)   pid_real_func_addr[PIDVIRT_ENUM(name)] = _real_dlsym(RTLD_NEXT, #name);
 
#define GET_FUNC_ADDR_V(name, v)
 
#define GET_SYSVIPC_CTL_FUNC_ADDR(name)   GET_FUNC_ADDR(name)
 
#define GET_FOPEN_FUNC_ADDR(name)   GET_FUNC_ADDR(name)
 
#define REAL_FUNC_PASSTHROUGH_WORK(name)
 
#define REAL_FUNC_PASSTHROUGH(name)   REAL_FUNC_PASSTHROUGH_TYPED(int, name)
 
#define REAL_FUNC_PASSTHROUGH_TYPED(type, name)
 
#define REAL_FUNC_PASSTHROUGH_VOID(name)
 
#define REAL_FUNC_PASSTHROUGH_NORETURN(name)
 

Typedefs

typedef int(* funcptr_t )()
 
typedef pid_t(* funcptr_pid_t )()
 
typedef funcptr_t(* signal_funcptr_t )()
 
typedef void *(* dlsym_fnptr_t )(void *handle, const char *symbol)
 

Functions

LIB_PRIVATE void pid_initialize_wrappers ()
 
void * dmtcp_get_libc_dlsym_addr ()
 
LIB_PRIVATE void * _real_dlsym (void *handle, const char *symbol)
 
LIB_PRIVATE pid_t _real_getpid (void)
 
LIB_PRIVATE pid_t _real_getppid (void)
 
LIB_PRIVATE pid_t _real_tcgetsid (int fd)
 
LIB_PRIVATE int _real_tcsetpgrp (int fd, pid_t pgrp)
 
LIB_PRIVATE pid_t _real_tcgetpgrp (int fd)
 
LIB_PRIVATE pid_t _real_getpgrp (void)
 
LIB_PRIVATE pid_t _real_setpgrp (void)
 
LIB_PRIVATE pid_t _real_getpgid (pid_t pid)
 
LIB_PRIVATE int _real_setpgid (pid_t pid, pid_t pgid)
 
LIB_PRIVATE pid_t _real_getsid (pid_t pid)
 
LIB_PRIVATE pid_t _real_setsid (void)
 
LIB_PRIVATE int _real_kill (pid_t pid, int sig)
 
LIB_PRIVATE pid_t _real_wait (__WAIT_STATUS stat_loc)
 
LIB_PRIVATE pid_t _real_waitpid (pid_t pid, int *stat_loc, int options)
 
LIB_PRIVATE int _real_waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options)
 
LIB_PRIVATE pid_t _real_wait3 (__WAIT_STATUS status, int options, struct rusage *rusage)
 
LIB_PRIVATE pid_t _real_wait4 (pid_t pid, __WAIT_STATUS status, int options, struct rusage *rusage)
 
LIB_PRIVATE int _real_ioctl (int d, unsigned long int request,...)
 
LIB_PRIVATE int _real_setgid (gid_t gid)
 
LIB_PRIVATE int _real_setuid (uid_t uid)
 
LIB_PRIVATE long _real_ptrace (enum __ptrace_request request, pid_t pid, void *addr, void *data)
 
LIB_PRIVATE pid_t _real_gettid (void)
 
LIB_PRIVATE int _real_tkill (int tid, int sig)
 
LIB_PRIVATE int _real_tgkill (int tgid, int tid, int sig)
 
LIB_PRIVATE long _real_syscall (long sys_num,...)
 
LIB_PRIVATE pid_t _real_fork ()
 
LIB_PRIVATE int _real_clone (int(*function)(void *), void *child_stack, int flags, void *arg, int *parent_tidptr, struct user_desc *newtls, int *child_tidptr)
 
LIB_PRIVATE int _real_shmget (key_t key, size_t size, int shmflg)
 
LIB_PRIVATE void * _real_shmat (int shmid, const void *shmaddr, int shmflg)
 
LIB_PRIVATE int _real_shmdt (const void *shmaddr)
 
LIB_PRIVATE int _real_shmctl (int shmid, int cmd, struct shmid_ds *buf)
 
LIB_PRIVATE int _real_semctl (int semid, int semnum, int cmd,...)
 
LIB_PRIVATE int _real_msgctl (int msqid, int cmd, struct msqid_ds *buf)
 
LIB_PRIVATE int _real_mq_notify (mqd_t mqdes, const struct sigevent *sevp)
 
LIB_PRIVATE int _real_clock_getcpuclockid (pid_t pid, clockid_t *clock_id)
 
LIB_PRIVATE int _real_timer_create (clockid_t clockid, struct sigevent *sevp, timer_t *timerid)
 
LIB_PRIVATE void _real_pthread_exit (void *retval)
 
LIB_PRIVATE int _real_fcntl (int fd, int cmd, void *arg)
 
int _real_open (const char *path, int flags,...)
 
int _real_open64 (const char *path, int flags,...)
 
FILE * _real_fopen (const char *path, const char *mode)
 
FILE * _real_fopen64 (const char *path, const char *mode)
 
int _real_fclose (FILE *fp)
 
int _real_xstat (int vers, const char *path, struct stat *buf)
 
int _real_xstat64 (int vers, const char *path, struct stat64 *buf)
 
int _real_lxstat (int vers, const char *path, struct stat *buf)
 
int _real_lxstat64 (int vers, const char *path, struct stat64 *buf)
 
ssize_t _real_readlink (const char *path, char *buf, size_t bufsiz)
 

Macro Definition Documentation

#define _GNU_SOURCE

Definition at line 23 of file pid_syscallsreal.c.

#define _XOPEN_SOURCE   500

Definition at line 24 of file pid_syscallsreal.c.

#define GET_FOPEN_FUNC_ADDR (   name)    GET_FUNC_ADDR(name)

Definition at line 64 of file pid_syscallsreal.c.

#define GET_FUNC_ADDR (   name)    pid_real_func_addr[PIDVIRT_ENUM(name)] = _real_dlsym(RTLD_NEXT, #name);

Definition at line 43 of file pid_syscallsreal.c.

#define GET_FUNC_ADDR_V (   name,
 
)
Value:
pid_real_func_addr[PIDVIRT_ENUM(name)] = dlvsym(RTLD_NEXT, #name, v); \
if (pid_real_func_addr[PIDVIRT_ENUM(name)] == NULL) { \
/* Symbol version not found, try the default and hope for the best */ \
GET_FUNC_ADDR(name); \
}

Definition at line 46 of file pid_syscallsreal.c.

#define GET_SYSVIPC_CTL_FUNC_ADDR (   name)    GET_FUNC_ADDR(name)

Definition at line 63 of file pid_syscallsreal.c.

#define REAL_FUNC_PASSTHROUGH (   name)    REAL_FUNC_PASSTHROUGH_TYPED(int, name)

Definition at line 93 of file pid_syscallsreal.c.

#define REAL_FUNC_PASSTHROUGH_NORETURN (   name)
Value:
static void (*fn)() __attribute__ ((__noreturn__)) = NULL; \
REAL_FUNC_PASSTHROUGH_WORK(name) \
(*fn)

Definition at line 105 of file pid_syscallsreal.c.

#define REAL_FUNC_PASSTHROUGH_TYPED (   type,
  name 
)
Value:
static type (*fn)() = NULL; \
REAL_FUNC_PASSTHROUGH_WORK(name) \
return (*fn)

Definition at line 95 of file pid_syscallsreal.c.

#define REAL_FUNC_PASSTHROUGH_VOID (   name)
Value:
static void (*fn)() = NULL; \
REAL_FUNC_PASSTHROUGH_WORK(name) \
(*fn)

Definition at line 100 of file pid_syscallsreal.c.

#define REAL_FUNC_PASSTHROUGH_WORK (   name)
Value:
if (fn == NULL) { \
if (pid_real_func_addr[PIDVIRT_ENUM(name)] == NULL) \
pid_initialize_wrappers(); \
fn = pid_real_func_addr[PIDVIRT_ENUM(name)]; \
if (fn == NULL) { \
fprintf(stderr, "%s:%d: *** DMTCP: Error: lookup failed for %s.\n" \
" The symbol wasn't found in current library" \
" loading sequence.\n" \
" Aborting.\n", __FILE__, __LINE__, #name); \
abort(); \
} \
}

Definition at line 79 of file pid_syscallsreal.c.

Typedef Documentation

typedef void*(* dlsym_fnptr_t)(void *handle, const char *symbol)

Definition at line 38 of file pid_syscallsreal.c.

typedef pid_t( * funcptr_pid_t)()

Definition at line 36 of file pid_syscallsreal.c.

typedef int( * funcptr_t)()

Definition at line 35 of file pid_syscallsreal.c.

typedef funcptr_t( * signal_funcptr_t)()

Definition at line 37 of file pid_syscallsreal.c.

Function Documentation

LIB_PRIVATE int _real_clock_getcpuclockid ( pid_t  pid,
clockid_t *  clock_id 
)

Definition at line 336 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_clone ( int(*)(void *)  function,
void *  child_stack,
int  flags,
void *  arg,
int *  parent_tidptr,
struct user_desc newtls,
int *  child_tidptr 
)

Definition at line 288 of file pid_syscallsreal.c.

LIB_PRIVATE void* _real_dlsym ( void *  handle,
const char *  symbol 
)

Definition at line 113 of file pid_syscallsreal.c.

int _real_fclose ( FILE *  fp)

Definition at line 390 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_fcntl ( int  fd,
int  cmd,
void *  arg 
)

Definition at line 353 of file pid_syscallsreal.c.

FILE* _real_fopen ( const char *  path,
const char *  mode 
)

Definition at line 382 of file pid_syscallsreal.c.

FILE* _real_fopen64 ( const char *  path,
const char *  mode 
)

Definition at line 386 of file pid_syscallsreal.c.

LIB_PRIVATE pid_t _real_fork ( void  )

Definition at line 283 of file pid_syscallsreal.c.

LIB_PRIVATE pid_t _real_getpgid ( pid_t  pid)

Definition at line 163 of file pid_syscallsreal.c.

LIB_PRIVATE pid_t _real_getpgrp ( void  )

Definition at line 153 of file pid_syscallsreal.c.

LIB_PRIVATE pid_t _real_getpid ( void  )

Definition at line 124 of file pid_syscallsreal.c.

LIB_PRIVATE pid_t _real_getppid ( void  )

Definition at line 131 of file pid_syscallsreal.c.

LIB_PRIVATE pid_t _real_getsid ( pid_t  pid)

Definition at line 173 of file pid_syscallsreal.c.

LIB_PRIVATE pid_t _real_gettid ( void  )

Definition at line 245 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_ioctl ( int  d,
unsigned long int  request,
  ... 
)

Definition at line 213 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_kill ( pid_t  pid,
int  sig 
)

Definition at line 183 of file pid_syscallsreal.c.

int _real_lxstat ( int  vers,
const char *  path,
struct stat *  buf 
)

Definition at line 402 of file pid_syscallsreal.c.

int _real_lxstat64 ( int  vers,
const char *  path,
struct stat64 *  buf 
)

Definition at line 406 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_mq_notify ( mqd_t  mqdes,
const struct sigevent *  sevp 
)

Definition at line 331 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_msgctl ( int  msqid,
int  cmd,
struct msqid_ds *  buf 
)

Definition at line 325 of file pid_syscallsreal.c.

int _real_open ( const char *  path,
int  flags,
  ... 
)

Definition at line 358 of file pid_syscallsreal.c.

int _real_open64 ( const char *  path,
int  flags,
  ... 
)

Definition at line 370 of file pid_syscallsreal.c.

LIB_PRIVATE void _real_pthread_exit ( void *  retval)

Definition at line 348 of file pid_syscallsreal.c.

LIB_PRIVATE long _real_ptrace ( enum __ptrace_request  request,
pid_t  pid,
void *  addr,
void *  data 
)

Definition at line 238 of file pid_syscallsreal.c.

ssize_t _real_readlink ( const char *  path,
char *  buf,
size_t  bufsiz 
)

Definition at line 410 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_semctl ( int  semid,
int  semnum,
int  cmd,
  ... 
)

Definition at line 315 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_setgid ( gid_t  gid)

Definition at line 228 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_setpgid ( pid_t  pid,
pid_t  pgid 
)

Definition at line 168 of file pid_syscallsreal.c.

LIB_PRIVATE pid_t _real_setpgrp ( void  )

Definition at line 158 of file pid_syscallsreal.c.

LIB_PRIVATE pid_t _real_setsid ( void  )

Definition at line 178 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_setuid ( uid_t  uid)

Definition at line 233 of file pid_syscallsreal.c.

LIB_PRIVATE void* _real_shmat ( int  shmid,
const void *  shmaddr,
int  shmflg 
)

Definition at line 300 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_shmctl ( int  shmid,
int  cmd,
struct shmid_ds *  buf 
)

Definition at line 310 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_shmdt ( const void *  shmaddr)

Definition at line 305 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_shmget ( key_t  key,
size_t  size,
int  shmflg 
)

Definition at line 295 of file pid_syscallsreal.c.

LIB_PRIVATE long _real_syscall ( long  sys_num,
  ... 
)

Definition at line 266 of file pid_syscallsreal.c.

LIB_PRIVATE pid_t _real_tcgetpgrp ( int  fd)

Definition at line 148 of file pid_syscallsreal.c.

LIB_PRIVATE pid_t _real_tcgetsid ( int  fd)

Definition at line 138 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_tcsetpgrp ( int  fd,
pid_t  pgrp 
)

Definition at line 143 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_tgkill ( int  tgid,
int  tid,
int  sig 
)

Definition at line 259 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_timer_create ( clockid_t  clockid,
struct sigevent *  sevp,
timer_t *  timerid 
)

Definition at line 341 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_tkill ( int  tid,
int  sig 
)

Definition at line 252 of file pid_syscallsreal.c.

LIB_PRIVATE pid_t _real_wait ( __WAIT_STATUS  stat_loc)

Definition at line 188 of file pid_syscallsreal.c.

LIB_PRIVATE pid_t _real_wait3 ( __WAIT_STATUS  status,
int  options,
struct rusage *  rusage 
)

Definition at line 203 of file pid_syscallsreal.c.

LIB_PRIVATE pid_t _real_wait4 ( pid_t  pid,
__WAIT_STATUS  status,
int  options,
struct rusage *  rusage 
)

Definition at line 208 of file pid_syscallsreal.c.

LIB_PRIVATE int _real_waitid ( idtype_t  idtype,
id_t  id,
siginfo_t *  infop,
int  options 
)

Definition at line 198 of file pid_syscallsreal.c.

LIB_PRIVATE pid_t _real_waitpid ( pid_t  pid,
int *  stat_loc,
int  options 
)

Definition at line 193 of file pid_syscallsreal.c.

int _real_xstat ( int  vers,
const char *  path,
struct stat *  buf 
)

Definition at line 394 of file pid_syscallsreal.c.

int _real_xstat64 ( int  vers,
const char *  path,
struct stat64 *  buf 
)

Definition at line 398 of file pid_syscallsreal.c.

void* dmtcp_get_libc_dlsym_addr ( )

Definition at line 408 of file dmtcpplugin.cpp.

LIB_PRIVATE void pid_initialize_wrappers ( )

Definition at line 68 of file pid_syscallsreal.c.