Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions | Variables
target_linux_userproc.c File Reference
#include "config.h"
#include "glib_wrapper.h"
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include <sys/ptrace.h>
#include <sys/user.h>
#include <sys/reg.h>
#include <bits/wordsize.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
#include <dirent.h>
#include <sys/time.h>
#include <argp.h>
#include <gelf.h>
#include <elf.h>
#include <libelf.h>
#include "common.h"
#include "object.h"
#include "arch.h"
#include "arch_x86.h"
#include "arch_x86_64.h"
#include "waitpipe.h"
#include "evloop.h"
#include "binfile.h"
#include "dwdebug.h"
#include "dwdebug_priv.h"
#include "target_api.h"
#include "target.h"
#include "target_linux_userproc.h"
Include dependency graph for target_linux_userproc.c:

Go to the source code of this file.

Macros

#define EF_RF   (0x00010000)
 
#define INITIAL_PTRACE_OPTS   PTRACE_O_TRACECLONE | PTRACE_O_TRACEEXIT
 
#define LUP_SC_EXEC   11
 
#define LUP_SC_MPROTECT   125
 
#define LUP_SC_MMAP   90
 
#define LUP_SC_MUNMAP   91
 
#define LUP_SC_MMAP2   192
 
#define LUP_SC_PRCTL   172
 
#define LUP_SC_ARCH_PRCTL   172 /* no arch_prctl */
 
#define LUP_SC_SET_THREAD_AREA   243
 
#define RF   "llx"
 
#define DRF   "x"
 
#define VWORDBYTESIZE   __WORDSIZE / 8
 

Functions

struct targetlinux_userproc_instantiate (struct target_spec *spec, struct evloop *evloop)
 
int linux_userproc_attach_evloop (struct target *target, struct evloop *evloop)
 
int linux_userproc_detach_evloop (struct target *target)
 
int linux_userproc_disable_hw_breakpoints (struct target *target, tid_t tid)
 
int linux_userproc_enable_hw_breakpoints (struct target *target, tid_t tid)
 
int linux_userproc_disable_hw_breakpoint (struct target *target, tid_t tid, REG dreg)
 
int linux_userproc_enable_hw_breakpoint (struct target *target, tid_t tid, REG dreg)
 
int linux_userproc_notify_sw_breakpoint (struct target *target, ADDR addr, int notification)
 
int linux_userproc_singlestep (struct target *target, tid_t tid, int isbp, struct target *overlay)
 
int linux_userproc_singlestep_end (struct target *target, tid_t tid, struct target *overlay)
 
int linux_userproc_spec_to_argv (struct target_spec *spec, int *argc, char ***argv)
 
error_t linux_userproc_argp_parse_opt (int key, char *arg, struct argp_state *state)
 
int linux_userproc_last_signo (struct target *target, tid_t tid)
 
int linux_userproc_last_status (struct target *target, tid_t tid)
 
int linux_userproc_at_syscall (struct target *target, tid_t tid)
 
int linux_userproc_at_exec (struct target *target, tid_t tid)
 
int linux_userproc_at_exit (struct target *target, tid_t tid)
 
int linux_userproc_pid (struct target *target)
 
struct linux_userproc_speclinux_userproc_build_spec (void)
 
void linux_userproc_free_spec (struct linux_userproc_spec *lspec)
 
int linux_userproc_attach_thread (struct target *target, tid_t parent, tid_t child)
 
int __poll_and_handle_detaching (struct target *target, struct target_thread *tthread)
 
int linux_userproc_detach_thread (struct target *target, tid_t tid, int detaching_all, int stay_paused)
 
int linux_userproc_evloop_handler (int readfd, int fdtype, void *state)
 

Variables

struct target_ops linux_userspace_process_ops
 
struct argp_option linux_userproc_argp_opts []
 
struct argp linux_userproc_argp
 
char * linux_userproc_argp_header = "Ptrace Backend Options"
 

Macro Definition Documentation

#define DRF   "x"
#define EF_RF   (0x00010000)

Definition at line 58 of file target_linux_userproc.c.

#define INITIAL_PTRACE_OPTS   PTRACE_O_TRACECLONE | PTRACE_O_TRACEEXIT

Definition at line 495 of file target_linux_userproc.c.

#define LUP_SC_ARCH_PRCTL   172 /* no arch_prctl */
#define LUP_SC_EXEC   11
#define LUP_SC_MMAP   90
#define LUP_SC_MMAP2   192
#define LUP_SC_MPROTECT   125
#define LUP_SC_MUNMAP   91
#define LUP_SC_PRCTL   172
#define LUP_SC_SET_THREAD_AREA   243
#define RF   "llx"
#define VWORDBYTESIZE   __WORDSIZE / 8

Definition at line 4347 of file target_linux_userproc.c.

Function Documentation

int __poll_and_handle_detaching ( struct target target,
struct target_thread tthread 
)

Definition at line 1657 of file target_linux_userproc.c.

error_t linux_userproc_argp_parse_opt ( int  key,
char *  arg,
struct argp_state *  state 
)

Definition at line 328 of file target_linux_userproc.c.

int linux_userproc_at_exec ( struct target target,
tid_t  tid 
)

Definition at line 551 of file target_linux_userproc.c.

int linux_userproc_at_exit ( struct target target,
tid_t  tid 
)

Definition at line 568 of file target_linux_userproc.c.

int linux_userproc_at_syscall ( struct target target,
tid_t  tid 
)

Definition at line 534 of file target_linux_userproc.c.

int linux_userproc_attach_evloop ( struct target target,
struct evloop evloop 
)

Definition at line 3842 of file target_linux_userproc.c.

int linux_userproc_attach_thread ( struct target target,
tid_t  parent,
tid_t  child 
)

Definition at line 1300 of file target_linux_userproc.c.

struct linux_userproc_spec* linux_userproc_build_spec ( void  )

Definition at line 608 of file target_linux_userproc.c.

int linux_userproc_detach_evloop ( struct target target)

Definition at line 3873 of file target_linux_userproc.c.

int linux_userproc_detach_thread ( struct target target,
tid_t  tid,
int  detaching_all,
int  stay_paused 
)

Definition at line 1693 of file target_linux_userproc.c.

int linux_userproc_disable_hw_breakpoint ( struct target target,
tid_t  tid,
REG  dreg 
)

Definition at line 4683 of file target_linux_userproc.c.

int linux_userproc_disable_hw_breakpoints ( struct target target,
tid_t  tid 
)

Definition at line 4650 of file target_linux_userproc.c.

int linux_userproc_enable_hw_breakpoint ( struct target target,
tid_t  tid,
REG  dreg 
)

Definition at line 4730 of file target_linux_userproc.c.

int linux_userproc_enable_hw_breakpoints ( struct target target,
tid_t  tid 
)

Definition at line 4661 of file target_linux_userproc.c.

int linux_userproc_evloop_handler ( int  readfd,
int  fdtype,
void *  state 
)

Definition at line 3633 of file target_linux_userproc.c.

void linux_userproc_free_spec ( struct linux_userproc_spec lspec)

Definition at line 617 of file target_linux_userproc.c.

struct target * linux_userproc_instantiate ( struct target_spec spec,
struct evloop evloop 
)

Definition at line 595 of file target_linux_userproc.c.

int linux_userproc_last_signo ( struct target target,
tid_t  tid 
)

These are the only user-visible functions.

Definition at line 502 of file target_linux_userproc.c.

int linux_userproc_last_status ( struct target target,
tid_t  tid 
)

Definition at line 518 of file target_linux_userproc.c.

int linux_userproc_notify_sw_breakpoint ( struct target target,
ADDR  addr,
int  notification 
)

Definition at line 4778 of file target_linux_userproc.c.

int linux_userproc_pid ( struct target target)

Definition at line 585 of file target_linux_userproc.c.

int linux_userproc_singlestep ( struct target target,
tid_t  tid,
int  isbp,
struct target overlay 
)

Definition at line 4783 of file target_linux_userproc.c.

int linux_userproc_singlestep_end ( struct target target,
tid_t  tid,
struct target overlay 
)

Definition at line 4850 of file target_linux_userproc.c.

int linux_userproc_spec_to_argv ( struct target_spec spec,
int *  argc,
char ***  argv 
)

Definition at line 245 of file target_linux_userproc.c.

Variable Documentation

struct argp linux_userproc_argp
Initial value:
= {
}
error_t linux_userproc_argp_parse_opt(int key, char *arg, struct argp_state *state)
struct argp_option linux_userproc_argp_opts[]

Definition at line 485 of file target_linux_userproc.c.

char* linux_userproc_argp_header = "Ptrace Backend Options"

Definition at line 488 of file target_linux_userproc.c.

struct argp_option linux_userproc_argp_opts[]
Initial value:
= {
{ "pid",'p',"PID",0,"A target process to attach to.",-4 },
{ "program",'b',"FILE",0,"A program to launch as the target.",-4 },
{ "args",'a',"LIST",0,"A comma-separated argument list.",-4 },
{ "envvars",'e',"LIST",0,"A comma-separated envvar list.",-4 },
{ 0,0,0,0,0,0 },
}

Definition at line 236 of file target_linux_userproc.c.

struct target_ops linux_userspace_process_ops

Definition at line 172 of file target_linux_userproc.c.