PukABI

Documentation

« back to PM2 home.

Public API header for Puk-ABI. More...

#include "Puk-ABI-internals.h"
#include <sys/types.h>
#include <errno.h>
#include "Puk-ABI-symbols.h"
Include dependency graph for Puk-ABI.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  puk_mem_reg_s
 a registered memory entry More...
 
struct  puk_mem_invalidate_hook_s
 

Macros

#define PUK_ABI
 
#define MKSYMFX(SYM, RETTYPE, ARGSDECL, ARGSUSE, PRE, POST, ISREAL)   PUK_ABI_MKTYPE(SYM, RETTYPE, ARGSDECL)
 Generates symbol types, structures, stubs, and wrappers.
 
#define MKSYMVX1(SYM, RETTYPE, ARGSDECL, ARG1, PROCESSING, ISREAL)   PUK_ABI_MKTYPE(SYM, RETTYPE, ARGSDECL)
 
#define MKSYMVX2(SYM, RETTYPE, ARGSDECL, ARG1, ARG2, PROCESSING, ISREAL)   PUK_ABI_MKTYPE(SYM, RETTYPE, ARGSDECL)
 
#define MKSYMVX3(SYM, RETTYPE, ARGSDECL, ARG1, ARG2, ARG3, PROCESSING, ISREAL)   PUK_ABI_MKTYPE(SYM, RETTYPE, ARGSDECL)
 
#define MKSYMPX(SYM, RETTYPE, ARGSDECL, ARGSUSE, PRE, POST, ISREAL)   PUK_ABI_MKTYPE(SYM, RETTYPE, ARGSDECL)
 
#define MKSYMNOSUPPORT(SYM)   PUK_ABI_MKTYPE(SYM, void, (void))
 
#define PUK_ABI_REAL(SYM)   (*((_PASTE(SYM, _func_t))(PUK_ABI_SYM_REAL(SYM))))
 Call the real libc symbol (always REAL, no locking)- it is up to the user to appropriately puk_spinlock_{acquire|release}().
 
#define PUK_ABI_VIRTUAL(SYM)   (*((_PASTE(SYM, _func_t))(PUK_ABI_SYM_VIRTUAL(SYM))))
 Call the virtual symbol (always virtual).
 
#define PUK_ABI_STUB(SYM)   (SYM) /* PUK_ABI_SYM_STUB(SYM) */
 Call the stub symbol (auto choice)
 
#define PUK_ABI_WRAP(SYM)   PUK_ABI_SYM_WRAP(SYM)
 Call the wrap symbol (real + puk_spinlock_{acquire|release}() )
 
#define PUK_ABI_FSYS_REAL(SYM)   SYM
 
#define PUK_ABI_FSYS_WRAP(SYM)   SYM
 
#define PUK_ABI_PROC_REAL(SYM)   SYM
 
#define PUK_ABI_PROC_WRAP(SYM)   SYM
 
#define PUK_ABI_MEM_REAL(SYM)   SYM
 
#define PUK_ABI_MEM_WRAP(SYM)   SYM
 
#define PUK_ABI_RESOLV_REAL(SYM)   SYM
 
#define PUK_ABI_RESOLV_WRAP(SYM)   SYM
 
#define __puk_abi_wrap__errno   errno
 
#define puk_abi_seterrno(VAL)   ( errno = (VAL) )
 
#define puk_abi_geterrno()   (errno)
 
#define puk_abi_real_errno()   (errno)
 
#define puk_abi_set_virtual(SYM, FUNC)    { PUK_ABI_SYM_GETDESC(SYM)()->ptr_virtual = (FUNC); }
 sets the handler for a virtual symbol
 

Typedefs

typedef void *(* puk_mem_register_t) (void *context, const void *ptr, size_t len)
 hook to register memory- returned value is used as key
 
typedef void(* puk_mem_unregister_t) (void *context, const void *ptr, void *key)
 hook to unregister memory
 
typedef struct puk_mem_invalidate_hook_spuk_mem_invalidate_hook_t
 
typedef void(* puk_mem_pre_hook_t) (void)
 
typedef void(* puk_mem_post_hook_t) (void)
 

Functions

void puk_mem_set_handlers (puk_mem_register_t reg, puk_mem_unregister_t unreg)
 sets handlers to register memory
 
const struct puk_mem_reg_spuk_mem_reg (void *context, const void *ptr, size_t len)
 asks for memory registration- does nothing if registration has been cached
 
void puk_mem_unreg (const struct puk_mem_reg_s *reg)
 marks registration entry as 'unused'
 
void puk_abi_mem_set_invalidate_hook (puk_mem_invalidate_hook_t hook)
 set a hook called to invalidate memory
 
void puk_abi_mem_unset_invalidate_hook (puk_mem_invalidate_hook_t hook)
 unset a hook called to invalidate memory
 
void puk_abi_mem_set_hooks (puk_mem_pre_hook_t pre_hook, puk_mem_post_hook_t post_hook)
 set hooks called before & after memory operations
 
int puk_abi_vfd_alloc (void)
 
void puk_abi_vfd_free (int abi_fd)
 
void puk_abi_disable_preload (void)
 disable LD_PRELOAD to prevent forked processes (xterm, gdb) from runnig with PukABI
 
void puk_abi_set_spinlock_handlers (void(*acquire)(void), void(*release)(void), int(*trylock)(void))
 sets the main spinlock handlers.
 
void puk_abi_set_errno_handler (int *(*errno_handler)(void))
 sets the errno location function
 
void puk_abi_unset_errno_handler (void)
 remove the errno location function handler
 

Detailed Description

Public API header for Puk-ABI.

Author
Alexandre Denis
Note
Only stuff defined in this file is part of the API, even if internals are #include'd for inlined functions.
Warning
Do not include this file in PukABI itself! MKSYMxX macros have different declarations.

Definition in file Puk-ABI.h.

Macro Definition Documentation

◆ __puk_abi_wrap__errno

#define __puk_abi_wrap__errno   errno

Definition at line 128 of file Puk-ABI.h.

◆ MKSYMFX

#define MKSYMFX (   SYM,
  RETTYPE,
  ARGSDECL,
  ARGSUSE,
  PRE,
  POST,
  ISREAL 
)    PUK_ABI_MKTYPE(SYM, RETTYPE, ARGSDECL)

Generates symbol types, structures, stubs, and wrappers.

Definition at line 55 of file Puk-ABI.h.

◆ MKSYMNOSUPPORT

#define MKSYMNOSUPPORT (   SYM)    PUK_ABI_MKTYPE(SYM, void, (void))

Definition at line 61 of file Puk-ABI.h.

◆ MKSYMPX

#define MKSYMPX (   SYM,
  RETTYPE,
  ARGSDECL,
  ARGSUSE,
  PRE,
  POST,
  ISREAL 
)    PUK_ABI_MKTYPE(SYM, RETTYPE, ARGSDECL)

Definition at line 59 of file Puk-ABI.h.

◆ MKSYMVX1

#define MKSYMVX1 (   SYM,
  RETTYPE,
  ARGSDECL,
  ARG1,
  PROCESSING,
  ISREAL 
)    PUK_ABI_MKTYPE(SYM, RETTYPE, ARGSDECL)

Definition at line 56 of file Puk-ABI.h.

◆ MKSYMVX2

#define MKSYMVX2 (   SYM,
  RETTYPE,
  ARGSDECL,
  ARG1,
  ARG2,
  PROCESSING,
  ISREAL 
)    PUK_ABI_MKTYPE(SYM, RETTYPE, ARGSDECL)

Definition at line 57 of file Puk-ABI.h.

◆ MKSYMVX3

#define MKSYMVX3 (   SYM,
  RETTYPE,
  ARGSDECL,
  ARG1,
  ARG2,
  ARG3,
  PROCESSING,
  ISREAL 
)    PUK_ABI_MKTYPE(SYM, RETTYPE, ARGSDECL)

Definition at line 58 of file Puk-ABI.h.

◆ PUK_ABI

#define PUK_ABI

Definition at line 41 of file Puk-ABI.h.

◆ PUK_ABI_FSYS_REAL

#define PUK_ABI_FSYS_REAL (   SYM)    SYM

Definition at line 92 of file Puk-ABI.h.

◆ PUK_ABI_FSYS_WRAP

#define PUK_ABI_FSYS_WRAP (   SYM)    SYM

Definition at line 93 of file Puk-ABI.h.

◆ puk_abi_geterrno

#define puk_abi_geterrno ( )    (errno)

Definition at line 130 of file Puk-ABI.h.

◆ PUK_ABI_MEM_REAL

#define PUK_ABI_MEM_REAL (   SYM)    SYM

Definition at line 108 of file Puk-ABI.h.

◆ PUK_ABI_MEM_WRAP

#define PUK_ABI_MEM_WRAP (   SYM)    SYM

Definition at line 109 of file Puk-ABI.h.

◆ PUK_ABI_PROC_REAL

#define PUK_ABI_PROC_REAL (   SYM)    SYM

Definition at line 100 of file Puk-ABI.h.

◆ PUK_ABI_PROC_WRAP

#define PUK_ABI_PROC_WRAP (   SYM)    SYM

Definition at line 101 of file Puk-ABI.h.

◆ PUK_ABI_REAL

#define PUK_ABI_REAL (   SYM)    (*((_PASTE(SYM, _func_t))(PUK_ABI_SYM_REAL(SYM))))

Call the real libc symbol (always REAL, no locking)- it is up to the user to appropriately puk_spinlock_{acquire|release}().

Definition at line 73 of file Puk-ABI.h.

◆ puk_abi_real_errno

#define puk_abi_real_errno ( )    (errno)

Definition at line 131 of file Puk-ABI.h.

◆ PUK_ABI_RESOLV_REAL

#define PUK_ABI_RESOLV_REAL (   SYM)    SYM

Definition at line 116 of file Puk-ABI.h.

◆ PUK_ABI_RESOLV_WRAP

#define PUK_ABI_RESOLV_WRAP (   SYM)    SYM

Definition at line 117 of file Puk-ABI.h.

◆ puk_abi_set_virtual

#define puk_abi_set_virtual (   SYM,
  FUNC 
)     { PUK_ABI_SYM_GETDESC(SYM)()->ptr_virtual = (FUNC); }

sets the handler for a virtual symbol

Definition at line 187 of file Puk-ABI.h.

◆ puk_abi_seterrno

#define puk_abi_seterrno (   VAL)    ( errno = (VAL) )

Definition at line 129 of file Puk-ABI.h.

◆ PUK_ABI_STUB

#define PUK_ABI_STUB (   SYM)    (SYM) /* PUK_ABI_SYM_STUB(SYM) */

Call the stub symbol (auto choice)

Definition at line 82 of file Puk-ABI.h.

◆ PUK_ABI_VIRTUAL

#define PUK_ABI_VIRTUAL (   SYM)    (*((_PASTE(SYM, _func_t))(PUK_ABI_SYM_VIRTUAL(SYM))))

Call the virtual symbol (always virtual).

Note
not really usefull, except for completeness of PukABI API.

Definition at line 78 of file Puk-ABI.h.

◆ PUK_ABI_WRAP

#define PUK_ABI_WRAP (   SYM)    PUK_ABI_SYM_WRAP(SYM)

Call the wrap symbol (real + puk_spinlock_{acquire|release}() )

Definition at line 86 of file Puk-ABI.h.

Typedef Documentation

◆ puk_mem_invalidate_hook_t

Definition at line 162 of file Puk-ABI.h.

◆ puk_mem_post_hook_t

typedef void(* puk_mem_post_hook_t) (void)

Definition at line 169 of file Puk-ABI.h.

◆ puk_mem_pre_hook_t

typedef void(* puk_mem_pre_hook_t) (void)

Definition at line 168 of file Puk-ABI.h.

◆ puk_mem_register_t

typedef void *(* puk_mem_register_t) (void *context, const void *ptr, size_t len)

hook to register memory- returned value is used as key

Definition at line 147 of file Puk-ABI.h.

◆ puk_mem_unregister_t

typedef void(* puk_mem_unregister_t) (void *context, const void *ptr, void *key)

hook to unregister memory

Definition at line 149 of file Puk-ABI.h.

Function Documentation

◆ puk_abi_disable_preload()

void puk_abi_disable_preload ( void  )
extern

disable LD_PRELOAD to prevent forked processes (xterm, gdb) from runnig with PukABI

Definition at line 240 of file puk-abi-tools.c.

◆ puk_abi_mem_set_hooks()

void puk_abi_mem_set_hooks ( puk_mem_pre_hook_t  pre_hook,
puk_mem_post_hook_t  post_hook 
)

set hooks called before & after memory operations

◆ puk_abi_mem_set_invalidate_hook()

void puk_abi_mem_set_invalidate_hook ( puk_mem_invalidate_hook_t  hook)

set a hook called to invalidate memory

◆ puk_abi_mem_unset_invalidate_hook()

void puk_abi_mem_unset_invalidate_hook ( puk_mem_invalidate_hook_t  hook)

unset a hook called to invalidate memory

◆ puk_abi_set_errno_handler()

void puk_abi_set_errno_handler ( int *(*)(void)  errno_handler)
extern

sets the errno location function

◆ puk_abi_set_spinlock_handlers()

void puk_abi_set_spinlock_handlers ( void(*)(void)  acquire,
void(*)(void)  release,
int(*)(void)  trylock 
)
extern

sets the main spinlock handlers.

Set to NULL to cancel locks handlers.

Definition at line 231 of file puk-abi-tools.c.

References puk_spinlock_s::acquire, puk_spinlock, puk_spinlock_s::release, and puk_spinlock_s::trylock.

◆ puk_abi_unset_errno_handler()

void puk_abi_unset_errno_handler ( void  )
extern

remove the errno location function handler

◆ puk_abi_vfd_alloc()

int puk_abi_vfd_alloc ( void  )
extern

◆ puk_abi_vfd_free()

void puk_abi_vfd_free ( int  abi_fd)
extern

◆ puk_mem_reg()

const struct puk_mem_reg_s * puk_mem_reg ( void *  context,
const void *  ptr,
size_t  len 
)

asks for memory registration- does nothing if registration has been cached

◆ puk_mem_set_handlers()

void puk_mem_set_handlers ( puk_mem_register_t  reg,
puk_mem_unregister_t  unreg 
)

sets handlers to register memory

◆ puk_mem_unreg()

void puk_mem_unreg ( const struct puk_mem_reg_s reg)

marks registration entry as 'unused'