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
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
target_api.h File Reference
#include "config.h"
#include "common.h"
#include "object.h"
#include "arch.h"
#include "list.h"
#include "evloop.h"
#include "dwdebug.h"
#include "target_event.h"
#include "probe_api.h"
#include <glib.h>
Include dependency graph for target_api.h:

Go to the source code of this file.

Data Structures

struct  target_decoder_lib
 
struct  target_decoder_binding
 
struct  target_thread
 
struct  target_spec
 
struct  target_argp_parser_state
 
struct  target_location_ctxt
 
struct  target_location_ctxt_frame
 
struct  target
 
struct  target_ops
 
struct  target_personality_ops
 
struct  value
 

Macros

#define TID_GLOBAL   INT32_MAX
 
#define TARGET_TYPE_BITS   5
 
#define TARGET_TYPE_MASK_BASE   (TARGET_TYPE_PTRACE | TARGET_TYPE_XEN | TARGET_TYPE_GDB)
 
#define TARGET_TYPE_MASK_OVERLAY   (TARGET_TYPE_PHP | TARGET_TYPE_OS_PROCESS)
 
#define TSTATUS_MAX   TSTATUS_STOPPED
 
#define TSTATUS(n)   (((n) <= TSTATUS_MAX) ? TSTATUS_STRINGS[(n)] : NULL)
 
#define THREAD_STATUS_MAX   THREAD_STATUS_RETURNING_KERNEL
 
#define THREAD_STATUS_BITS   5
 
#define THREAD_SPECIFIC_STATUS(status)   ((thread_status_t)(status) >= THREAD_STATUS_SLEEPING)
 
#define THREAD_STATUS(n)
 
#define THREAD_CTXT_DEFAULT   0
 
#define REGION_TYPE(n)   (((n) < __REGION_TYPE_MAX) ? REGION_TYPE_STRINGS[(n)] : NULL)
 
#define POLL(n)
 
#define APF_WILD   (APF_THREAD_ENTRY | APF_THREAD_EXIT | APF_MEMORY | APF_OTHER)
 
#define APF_OS
 
#define APF_PROCESS
 
#define APF_APP
 
#define APF_ALL   (APF_WILD | APF_OS | APF_PROCESS | APF_APP)
 
#define VLS(target, tlctxt, varstr, loadflags, outvarptr, outvalueptr, errlabel)
 
#define VL(target, tlctxt, invalue, varstr, loadflags, outvalueptr, errlabel)
 
#define VLV(target, tlctxt, invalue, varstr, loadflags, outvarptr, outvalueptr, errlabel)
 
#define VLVAR(target, tlctxt, invalue, varstr, loadflags, outvarptr, errlabel)
 
#define VLVAL(target, tlctxt, invalue, varstr, loadflags, outvalueptr, errlabel)
 
#define VLA(target, addr, loadflags, outbufptr, outbuflen, outvalueptr, errlabel)
 
#define value_to_u64(v)   (*((uint64_t *)(v)->buf))
 
#define value_to_u32(v)   (*((uint32_t *)(v)->buf))
 
#define value_to_u16(v)   (*((uint16_t *)(v)->buf))
 
#define value_to_u8(v)   (*((uint8_t *)(v)->buf))
 
#define value_to_i64(v)   (*((int64_t *)(v)->buf))
 
#define value_to_i32(v)   (*((int32_t *)(v)->buf))
 
#define value_to_i16(v)   (*((int16_t *)(v)->buf))
 
#define value_to_i8(v)   (*((int8_t *)(v)->buf))
 
#define value_to_unsigned_long   value_to_u32
 
#define value_to_long   value_to_i32
 
#define value_to_int   value_to_i32
 
#define value_to_unsigned_int   value_to_u32
 
#define value_to_char(v)   ((char)value_to_i8((v)))
 
#define value_to_unsigned_char(v)   ((unsigned char)value_to_i8((v)))
 
#define value_to_string(v)   ((v)->buf)
 
#define value_to_num(v)   value_to_i32((v))
 

Typedefs

typedef unsigned int thread_ctxt_t
 
typedef uintptr_t value_hash_t
 
typedef int(* target_decoder_t )(struct target *target, void *data, struct value *value, char *buf, int buflen)
 
typedef target_status_t(* target_exception_handler_t )(struct target *target, target_exception_flags_t flags, int *again, void *priv)
 
typedef result_t(* target_debug_bp_handler_t )(struct target *target, struct target_thread *tthread, struct probepoint *probepoint, int was_stepping)
 
typedef result_t(* target_debug_handler_t )(struct target *target, struct target_thread *tthread, struct probepoint *probepoint)
 

Enumerations

enum  target_type_t {
  TARGET_TYPE_NONE = 0, TARGET_TYPE_PTRACE = 1 << 0, TARGET_TYPE_XEN = 1 << 1, TARGET_TYPE_OS_PROCESS = 1 << 2,
  TARGET_TYPE_PHP = 1 << 3, TARGET_TYPE_GDB = 1 << 4
}
 
enum  target_personality_t { TARGET_PERSONALITY_NONE = 0, TARGET_PERSONALITY_OS = 1, TARGET_PERSONALITY_PROCESS = 2, TARGET_PERSONALITY_APPLICATION = 3 }
 
enum  target_mode_t { TARGET_MODE_NONE = 0, TARGET_MODE_LIVE = 1, TARGET_MODE_RECORD = 2, TARGET_MODE_REPLAY = 3 }
 
enum  target_status_t {
  TSTATUS_UNKNOWN = 0, TSTATUS_RUNNING = 1, TSTATUS_PAUSED = 2, TSTATUS_ERROR = 3,
  TSTATUS_DONE = 4, TSTATUS_EXITING = 5, TSTATUS_DEAD = 16, TSTATUS_STOPPED,
  TSTATUS_INTERRUPTED = 255
}
 
enum  thread_status_t {
  THREAD_STATUS_UNKNOWN = 0, THREAD_STATUS_RUNNING = 1, THREAD_STATUS_PAUSED = 2, THREAD_STATUS_ERROR = 3,
  THREAD_STATUS_DONE = 4, THREAD_STATUS_EXITING = 5, THREAD_STATUS_DEAD = 16, THREAD_STATUS_STOPPED,
  THREAD_STATUS_SLEEPING, THREAD_STATUS_ZOMBIE, THREAD_STATUS_BLOCKEDIO, THREAD_STATUS_PAGING,
  THREAD_STATUS_RETURNING_USER, THREAD_STATUS_RETURNING_KERNEL
}
 
enum  thread_bpmode_t { THREAD_BPMODE_STRICT = 0, THREAD_BPMODE_SEMI_STRICT = 1, THREAD_BPMODE_LOOSE = 2 }
 
enum  region_type_t {
  REGION_TYPE_FILE = 1, REGION_TYPE_HEAP, REGION_TYPE_STACK, REGION_TYPE_VDSO,
  REGION_TYPE_VSYSCALL, REGION_TYPE_ANON, REGION_TYPE_UNKNOWN = 0, REGION_TYPE_HEAP = 1,
  REGION_TYPE_STACK = 2, REGION_TYPE_VDSO = 3, REGION_TYPE_VSYSCALL = 4, REGION_TYPE_ANON = 5,
  REGION_TYPE_MAIN = 6, REGION_TYPE_LIB = 7, __REGION_TYPE_MAX
}
 
enum  target_exception_flags_t {
  EXCEPTION_NONE = 1 << 0, EXCEPTION_SINGLESTEP = 1 << 1, EXCEPTION_SINGLESTEP_BOGUS = 1 << 2, EXCEPTION_SINGLESTEP_CMD = 1 << 3,
  EXCEPTION_BREAKPOINT = 1 << 4
}
 
enum  target_poll_outcome_t {
  POLL_NOTHING = 0, POLL_ERROR = 1, POLL_SUCCESS = 2, POLL_UNKNOWN = 3,
  __POLL_MAX
}
 
enum  load_flags_t {
  LOAD_FLAG_NONE = 0, LOAD_FLAG_NO_CHECK_BOUNDS = 1, LOAD_FLAG_NO_CHECK_VISIBILITY = 2, LOAD_FLAG_AUTO_DEREF = 4,
  LOAD_FLAG_AUTO_DEREF_RECURSE = 8, LOAD_FLAG_AUTO_STRING = 16, LOAD_FLAG_NO_AUTO_RESOLVE = 32, LOAD_FLAG_VALUE_FORCE_COPY = 64
}
 
enum  active_probe_flags_t {
  AFP_NONE = 0, APF_THREAD_ENTRY = 1 << 0, APF_THREAD_EXIT = 1 << 1, APF_MEMORY = 1 << 2,
  APF_OTHER = 1 << 3, APF_OS_THREAD_ENTRY = 1 << 8, APF_OS_THREAD_EXIT = 1 << 9, APF_OS_MEMORY = 1 << 10,
  APF_OS_OTHER = 1 << 11, APF_PROCESS_THREAD_ENTRY = 1 << 16, APF_PROCESS_THREAD_EXIT = 1 << 17, APF_PROCESS_MEMORY = 1 << 18,
  APF_PROCESS_OTHER = 1 << 19, APF_APP_THREAD_ENTRY = 1 << 24, APF_APP_THREAD_EXIT = 1 << 25, APF_APP_MEMORY = 1 << 26,
  APF_APP_OTHER = 1 << 27
}
 
enum  value_diff_t { VALUE_DIFF_SAME = 0, VALUE_DIFF_DIFF = 1, VALUE_DIFF_MAYBE = 2, VALUE_DIFF_UNKNOWN = 3 }
 
enum  thread_resumeat_t {
  THREAD_RESUMEAT_NONE = 0, THREAD_RESUMEAT_BPH = 1, THREAD_RESUMEAT_SSR, THREAD_RESUMEAT_NA,
  THREAD_RESUMEAT_PH
}
 
enum  target_location_ctxt_flag_t {
  TLCTXT_NONE = 0, TLCTXT_AUTOLOAD_ARGS = 1 << 0, TLCTXT_AUTOLOAD_LOCALS = 1 << 1, TLCTXT_AUTOLOAD_INSCOPE = 1 << 2,
  TLCTXT_FOLLOW_OVERLAYS = 1 << 3
}
 
enum  target_unwind_style_t { TARGET_UNWIND_STYLE_GDB = 1, TARGET_UNWIND_STYLE_PROG = 2, TARGET_UNWIND_STYLE_PROG_KEYS = 3 }
 

Functions

void target_init (void)
 
void target_fini (void)
 
struct target_spectarget_argp_driver_parse_one (struct argp *driver_parser, void *driver_state, int argc, char **argv, target_type_t target_types, int filter_quoted)
 
int target_argp_driver_parse (struct argp *driver_parser, void *driver_state, int argc, char **argv, target_type_t target_types, int filter_quoted, struct target_spec **primary_target_spec, GList **base_target_specs, GList **overlay_target_specs)
 
struct target_spectarget_argp_target_spec (struct argp_state *state)
 
void * target_argp_driver_state (struct argp_state *state)
 
void target_driver_argp_init_children (struct argp_state *state)
 
int target_spec_to_argv (struct target_spec *spec, char *arg0, int *argc, char ***argv)
 
struct target_spectarget_build_spec (target_type_t type, target_mode_t mode)
 
void target_free_spec (struct target_spec *spec)
 
struct targettarget_instantiate (struct target_spec *spec, struct evloop *evloop)
 
GList * target_instantiate_and_open (struct target_spec *primary_target_spec, GList *base_target_specs, GList *overlay_target_specs, struct evloop *evloop, GList **error_specs)
 
GList * target_instantiate_and_open_list (GList *target_specs, struct evloop *evloop, GList **error_specs)
 
struct targettarget_lookup_target_id (int id)
 
target_type_t target_type (struct target *target)
 
char * target_name (struct target *target)
 
int target_id (struct target *target)
 
int target_open (struct target *target)
 
int target_open_all (struct target *target)
 
int target_snprintf (struct target *target, char *buf, int bufsiz)
 
int target_attach_evloop (struct target *target, struct evloop *evloop)
 
int target_detach_evloop (struct target *target)
 
int target_is_evloop_attached (struct target *target, struct evloop *evloop)
 
int target_has_base (struct target *overlay, struct target *base)
 
int target_set_active_probing (struct target *target, active_probe_flags_t flags)
 
target_status_t target_monitor (struct target *target)
 
int target_monitor_evloop (struct evloop *evloop, struct timeval *timeout, struct target **target, target_status_t *status)
 
int target_monitor_handling_exception (struct target *target)
 
int target_monitor_schedule_interrupt (struct target *target)
 
void target_monitor_schedule_global_interrupt (void)
 
void target_monitor_clear_global_interrupt (void)
 
int target_monitor_was_interrupted (siginfo_t *last_siginfo)
 
int target_install_default_sighandlers (void(*sighandler)(int signo, siginfo_t *siginfo, void *x))
 
int target_install_custom_sighandlers (sigset_t *ignored, sigset_t *interrupt, sigset_t *exit, void(*sighandler)(int signo, siginfo_t *siginfo, void *x))
 
void target_default_cleanup (void)
 
void target_default_sighandler (int signo, siginfo_t *siginfo, void *x)
 
target_status_t target_poll (struct target *target, struct timeval *tv, target_poll_outcome_t *outcome, int *pstatus)
 
int target_resume (struct target *target)
 
int target_pause (struct target *target)
 
int target_is_open (struct target *target)
 
target_status_t target_status (struct target *target)
 
int target_close (struct target *target)
 
int target_finalize (struct target *target)
 
int target_kill (struct target *target, int sig)
 
void target_hold (struct target *target)
 
void target_release (struct target *target)
 
struct array_listtarget_list_available_overlay_tids (struct target *target, target_type_t type)
 
struct array_listtarget_list_overlays (struct target *target)
 
tid_t target_lookup_overlay_thread_by_id (struct target *target, int id)
 
tid_t target_lookup_overlay_thread_by_name (struct target *target, char *name)
 
struct target_spectarget_build_default_overlay_spec (struct target *target, tid_t tid)
 
struct targettarget_instantiate_overlay (struct target *target, tid_t tid, struct target_spec *spec)
 
target_status_t target_notify_overlay (struct target *overlay, target_exception_flags_t flags, tid_t tid, ADDR ipval, int *again)
 
struct probetarget_lookup_probe (struct target *target, int probe_id)
 
struct actiontarget_lookup_action (struct target *target, int action_id)
 
unsigned char * target_read_addr (struct target *target, ADDR addr, unsigned long length, unsigned char *buf)
 
unsigned long target_write_addr (struct target *target, ADDR addr, unsigned long length, unsigned char *buf)
 
int target_addr_v2p (struct target *target, tid_t tid, ADDR vaddr, ADDR *paddr)
 
unsigned char * target_read_physaddr (struct target *target, ADDR paddr, unsigned long length, unsigned char *buf)
 
unsigned long target_write_physaddr (struct target *target, ADDR paddr, unsigned long length, unsigned char *buf)
 
const char * target_regname (struct target *target, REG reg)
 
int target_regno (struct target *target, char *name, REG *reg)
 
int target_cregno (struct target *target, common_reg_t creg, REG *reg)
 
REGVAL target_read_reg (struct target *target, tid_t tid, REG reg)
 
int target_write_reg (struct target *target, tid_t tid, REG reg, REGVAL value)
 
REGVAL target_read_reg_ctxt (struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg)
 
int target_write_reg_ctxt (struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg, REGVAL value)
 
REGVAL target_read_creg (struct target *target, tid_t tid, common_reg_t reg)
 
int target_write_creg (struct target *target, tid_t tid, common_reg_t reg, REGVAL value)
 
GHashTable * target_copy_registers (struct target *target, tid_t tid)
 
tid_t target_gettid (struct target *target)
 
struct array_listtarget_list_tids (struct target *target)
 
struct array_listtarget_list_threads (struct target *target)
 
GHashTable * target_hash_threads (struct target *target)
 
struct array_listtarget_list_available_tids (struct target *target)
 
GHashTable * target_hash_available_tids (struct target *target)
 
struct target_threadtarget_load_current_thread (struct target *target, int force)
 
struct target_threadtarget_load_thread (struct target *target, tid_t tid, int force)
 
int target_load_all_threads (struct target *target, int force)
 
int target_load_available_threads (struct target *target, int force)
 
int target_pause_thread (struct target *target, tid_t tid, int nowait)
 
int target_flush_current_thread (struct target *target)
 
int target_flush_thread (struct target *target, tid_t tid)
 
int target_flush_all_threads (struct target *target)
 
int target_gc_threads (struct target *target)
 
int target_thread_snprintf (struct target *target, tid_t tid, char *buf, int bufsiz, int detail, char *sep, char *key_val_sep)
 
void target_dump_thread (struct target *target, tid_t tid, FILE *stream, int detail)
 
void target_dump_all_threads (struct target *target, FILE *stream, int detail)
 
struct target_memmodtarget_insert_sw_breakpoint (struct target *target, tid_t tid, ADDR addr)
 
int target_remove_sw_breakpoint (struct target *target, tid_t tid, struct target_memmod *mmod)
 
int target_enable_sw_breakpoint (struct target *target, tid_t tid, struct target_memmod *mmod)
 
int target_disable_sw_breakpoint (struct target *target, tid_t tid, struct target_memmod *mmod)
 
int target_change_sw_breakpoint (struct target *target, tid_t tid, struct target_memmod *mmod, unsigned char *code, unsigned long code_len)
 
int target_unchange_sw_breakpoint (struct target *target, tid_t tid, struct target_memmod *mmod)
 
REG target_get_unused_debug_reg (struct target *target, tid_t tid)
 
int target_set_hw_breakpoint (struct target *target, tid_t tid, REG reg, ADDR addr)
 
int target_set_hw_watchpoint (struct target *target, tid_t tid, REG reg, ADDR addr, probepoint_whence_t whence, int watchsize)
 
int target_unset_hw_breakpoint (struct target *target, tid_t tid, REG reg)
 
int target_unset_hw_watchpoint (struct target *target, tid_t tid, REG reg)
 
int target_disable_hw_breakpoints (struct target *target, tid_t tid)
 
int target_enable_hw_breakpoints (struct target *target, tid_t tid)
 
int target_disable_hw_breakpoint (struct target *target, tid_t tid, REG dreg)
 
int target_enable_hw_breakpoint (struct target *target, tid_t tid, REG dreg)
 
int target_notify_sw_breakpoint (struct target *target, ADDR addr, int notification)
 
int target_singlestep (struct target *target, tid_t tid, int isbp)
 
int target_singlestep_end (struct target *target, tid_t tid)
 
uint64_t target_get_tsc (struct target *target)
 
uint64_t target_get_time (struct target *target)
 
uint64_t target_get_counter (struct target *target)
 
int target_enable_feature (struct target *target, int feature, void *arg)
 
int target_disable_feature (struct target *target, int feature)
 
thread_status_t target_thread_status (struct target *target, tid_t tid)
 
int target_lookup_safe_disasm_range (struct target *target, ADDR addr, ADDR *start, ADDR *end, void **data)
 
int target_lookup_next_safe_disasm_range (struct target *target, ADDR addr, ADDR *start, ADDR *end, void **data)
 
unsigned char * target_load_code (struct target *target, ADDR start, unsigned int len, int nocache, int force_copy, int *caller_free)
 
struct scopetarget_lookup_addr (struct target *target, uint64_t addr)
 
struct bsymboltarget_lookup_sym (struct target *target, const char *name, const char *delim, char *srcfile, symbol_type_flag_t ftype)
 
struct bsymboltarget_lookup_sym_member (struct target *target, struct bsymbol *bsymbol, const char *name, const char *delim)
 
struct bsymboltarget_lookup_sym_addr (struct target *target, ADDR addr)
 
struct bsymboltarget_lookup_sym_line (struct target *target, char *filename, int line, SMOFFSET *offset, ADDR *addr)
 
int target_lookup_line_addr (struct target *target, char *filename, ADDR addr)
 
int target_contains_real (struct target *target, ADDR addr)
 
int target_find_memory_real (struct target *target, ADDR addr, struct addrspace **space_saveptr, struct memregion **region_saveptr, struct memrange **range_saveptr)
 
int target_bsymbol_resolve_base (struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, ADDR *o_addr, struct memrange **o_range)
 
ADDR target_addressof_symbol (struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, load_flags_t flags, struct memrange **range_saveptr)
 
OFFSET target_offsetof_symbol (struct target *target, struct bsymbol *bsymbol, char *member, const char *delim)
 
struct valuetarget_load_symbol (struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, load_flags_t flags)
 
struct valuetarget_load_symbol_member (struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, const char *member, const char *delim, load_flags_t flags)
 
struct valuetarget_load_value_member (struct target *target, struct target_location_ctxt *tlctxt, struct value *old_value, const char *member, const char *delim, load_flags_t flags)
 
struct valuetarget_load_type (struct target *target, struct symbol *type, ADDR addr, load_flags_t flags)
 
struct valuetarget_load_type_reg (struct target *target, struct symbol *type, tid_t tid, REG reg, load_flags_t flags)
 
struct valuetarget_load_type_regval (struct target *target, struct symbol *type, tid_t tid, REG reg, REGVAL regval, load_flags_t flags)
 
struct valuetarget_load_addr_obj (struct target *target, struct memregion *region, ADDR obj_addr, load_flags_t flags, int len)
 
struct valuetarget_load_addr_real (struct target *target, ADDR addr, load_flags_t flags, int len)
 
ADDR target_autoload_pointers (struct target *target, struct symbol *datatype, ADDR addr, load_flags_t flags, struct symbol **datatype_saveptr, struct memrange **range_saveptr)
 
ADDR target_load_pointers (struct target *target, ADDR addr, int count, struct memrange **range_saveptr)
 
struct symboltarget_create_synthetic_type_pointer (struct target *target, struct symbol *type)
 
char * bsymbol_get_name (struct bsymbol *bsymbol)
 
struct symbolbsymbol_get_symbol (struct bsymbol *bsymbol)
 
struct lsymbolbsymbol_get_lsymbol (struct bsymbol *bsymbol)
 
int bsymbol_is_inline (struct bsymbol *bsymbol)
 
struct bsymbolbsymbol_create_noninline (struct bsymbol *bsymbol)
 
void bsymbol_dump (struct bsymbol *bsymbol, struct dump_info *ud)
 
void bsymbol_hold (struct bsymbol *bsymbol)
 
REFCNT bsymbol_release (struct bsymbol *bsymbol)
 
struct valuevalue_clone (struct value *in)
 
ADDR value_addr (struct value *value)
 
void value_free (struct value *value)
 
int value_snprintf (struct value *value, char *buf, int buflen)
 
void value_dump (struct value *value, struct dump_info *ud)
 
void value_dump_simple (struct value *value, struct dump_info *ud)
 
struct valuevalue_reload_as_type (struct value *value, struct symbol *type, int force)
 
int value_refresh (struct value *value, int recursive)
 
int value_refresh_diff (struct value *value, int recurse, value_diff_t *vdiff, char **old_buf, int *old_bufsiz, value_hash_t *old_vhash)
 
signed char v_c (struct value *v)
 
unsigned char v_uc (struct value *v)
 
wchar_t v_wc (struct value *v)
 
uint8_t v_u8 (struct value *v)
 
uint16_t v_u16 (struct value *v)
 
uint32_t v_u32 (struct value *v)
 
uint64_t v_u64 (struct value *v)
 
int8_t v_i8 (struct value *v)
 
int16_t v_i16 (struct value *v)
 
int32_t v_i32 (struct value *v)
 
int64_t v_i64 (struct value *v)
 
num_t v_num (struct value *v)
 
unum_t v_unum (struct value *v)
 
float v_f (struct value *v)
 
double v_d (struct value *v)
 
long double v_dd (struct value *v)
 
ADDR v_addr (struct value *v)
 
char * v_string (struct value *v)
 
int value_update (struct value *value, const char *buf, int bufsiz)
 
int value_update_zero (struct value *value, const char *buf, int bufsiz)
 
int value_update_c (struct value *value, signed char v)
 
int value_update_uc (struct value *value, unsigned char v)
 
int value_update_wc (struct value *value, wchar_t v)
 
int value_update_u8 (struct value *value, uint8_t v)
 
int value_update_u16 (struct value *value, uint16_t v)
 
int value_update_u32 (struct value *value, uint32_t v)
 
int value_update_u64 (struct value *value, uint64_t v)
 
int value_update_i8 (struct value *value, int8_t v)
 
int value_update_i16 (struct value *value, int16_t v)
 
int value_update_i32 (struct value *value, int32_t v)
 
int value_update_i64 (struct value *value, int64_t v)
 
int value_update_f (struct value *value, float v)
 
int value_update_d (struct value *value, double v)
 
int value_update_dd (struct value *value, long double v)
 
int value_update_addr (struct value *value, ADDR v)
 
int value_update_num (struct value *value, num_t v)
 
int value_update_unum (struct value *value, unum_t v)
 
int target_store_value (struct target *target, struct value *value)
 
signed char rv_c (void *buf)
 
unsigned char rv_uc (void *buf)
 
wchar_t rv_wc (void *buf)
 
uint8_t rv_u8 (void *buf)
 
uint16_t rv_u16 (void *buf)
 
uint32_t rv_u32 (void *buf)
 
uint64_t rv_u64 (void *buf)
 
int8_t rv_i8 (void *buf)
 
int16_t rv_i16 (void *buf)
 
int32_t rv_i32 (void *buf)
 
int64_t rv_i64 (void *buf)
 
float rv_f (void *buf)
 
double rv_d (void *buf)
 
long double rv_dd (void *buf)
 
ADDR rv_addr (void *buf)
 
int target_decoder_lib_register (struct target_decoder_lib *lib)
 
int target_decoder_lib_bind (struct target *target, char *decoder_lib, char *decoder_lib_lib)
 
int target_decoder_binding_add (struct target_decoder_binding *tdb, struct bsymbol *bsymbol, target_decoder_t dfn)
 
int target_decoder_lookup (struct target *target, struct value *value, target_decoder_t *decoder, void **decoder_data)
 
struct target_location_ctxttarget_global_tlctxt (struct target *target)
 
struct target_location_ctxttarget_location_ctxt_create (struct target *target, tid_t tid, struct memregion *region)
 
struct target_location_ctxttarget_location_ctxt_create_from_bsymbol (struct target *target, tid_t tid, struct bsymbol *bsymbol)
 
void target_location_ctxt_retarget_bsymbol (struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol)
 
void target_location_ctxt_free (struct target_location_ctxt *tlctxt)
 
struct target_location_ctxttarget_unwind (struct target *target, tid_t tid)
 
int target_unwind_snprintf (char *buf, int buflen, struct target *target, tid_t tid, target_unwind_style_t fstyle, char *frame_sep, char *ksep)
 
int target_location_ctxt_unwind (struct target_location_ctxt *tlctxt)
 
struct target_location_ctxt_frametarget_location_ctxt_current_frame (struct target_location_ctxt *tlctxt)
 
int target_location_ctxt_read_reg (struct target_location_ctxt *tlctxt, REG reg, REGVAL *o_regval)
 
struct target_location_ctxt_frametarget_location_ctxt_get_frame (struct target_location_ctxt *tlctxt, int frame)
 
struct target_location_ctxt_frametarget_location_ctxt_prev (struct target_location_ctxt *tlctxt)
 

Variables

char * TSTATUS_STRINGS []
 
char * THREAD_STATUS_STRINGS []
 
char * REGION_TYPE_STRINGS []
 
char * POLL_STRINGS []
 

Macro Definition Documentation

#define APF_ALL   (APF_WILD | APF_OS | APF_PROCESS | APF_APP)

Definition at line 463 of file target_api.h.

#define APF_APP
#define APF_OS
#define APF_PROCESS
#define APF_WILD   (APF_THREAD_ENTRY | APF_THREAD_EXIT | APF_MEMORY | APF_OTHER)

Definition at line 456 of file target_api.h.

#define POLL (   n)
Value:
(((n) < sizeof(POLL_STRINGS)/sizeof(char *)) \
? POLL_STRINGS[(n)] : NULL)
char * POLL_STRINGS[]
Definition: target.c:6964

Definition at line 403 of file target_api.h.

#define REGION_TYPE (   n)    (((n) < __REGION_TYPE_MAX) ? REGION_TYPE_STRINGS[(n)] : NULL)

Definition at line 384 of file target_api.h.

#define TARGET_TYPE_BITS   5

Definition at line 171 of file target_api.h.

#define TARGET_TYPE_MASK_BASE   (TARGET_TYPE_PTRACE | TARGET_TYPE_XEN | TARGET_TYPE_GDB)

Definition at line 172 of file target_api.h.

#define TARGET_TYPE_MASK_OVERLAY   (TARGET_TYPE_PHP | TARGET_TYPE_OS_PROCESS)

Definition at line 174 of file target_api.h.

#define THREAD_CTXT_DEFAULT   0

Definition at line 301 of file target_api.h.

#define THREAD_SPECIFIC_STATUS (   status)    ((thread_status_t)(status) >= THREAD_STATUS_SLEEPING)

Definition at line 284 of file target_api.h.

#define THREAD_STATUS (   n)
Value:

Definition at line 288 of file target_api.h.

#define THREAD_STATUS_BITS   5

Definition at line 282 of file target_api.h.

#define THREAD_STATUS_MAX   THREAD_STATUS_RETURNING_KERNEL

Definition at line 280 of file target_api.h.

#define TID_GLOBAL   INT32_MAX

Definition at line 145 of file target_api.h.

#define TSTATUS (   n)    (((n) <= TSTATUS_MAX) ? TSTATUS_STRINGS[(n)] : NULL)

Definition at line 252 of file target_api.h.

#define TSTATUS_MAX   TSTATUS_STOPPED

Definition at line 249 of file target_api.h.

#define value_to_char (   v)    ((char)value_to_i8((v)))

Definition at line 1931 of file target_api.h.

#define value_to_i16 (   v)    (*((int16_t *)(v)->buf))

Definition at line 1917 of file target_api.h.

#define value_to_i32 (   v)    (*((int32_t *)(v)->buf))

Definition at line 1916 of file target_api.h.

#define value_to_i64 (   v)    (*((int64_t *)(v)->buf))

Definition at line 1915 of file target_api.h.

#define value_to_i8 (   v)    (*((int8_t *)(v)->buf))

Definition at line 1918 of file target_api.h.

#define value_to_int   value_to_i32

Definition at line 1928 of file target_api.h.

#define value_to_long   value_to_i32

Definition at line 1925 of file target_api.h.

#define value_to_num (   v)    value_to_i32((v))

Definition at line 1937 of file target_api.h.

#define value_to_string (   v)    ((v)->buf)

Definition at line 1933 of file target_api.h.

#define value_to_u16 (   v)    (*((uint16_t *)(v)->buf))

Definition at line 1912 of file target_api.h.

#define value_to_u32 (   v)    (*((uint32_t *)(v)->buf))

Definition at line 1911 of file target_api.h.

#define value_to_u64 (   v)    (*((uint64_t *)(v)->buf))

Definition at line 1910 of file target_api.h.

#define value_to_u8 (   v)    (*((uint8_t *)(v)->buf))

Definition at line 1913 of file target_api.h.

#define value_to_unsigned_char (   v)    ((unsigned char)value_to_i8((v)))

Definition at line 1932 of file target_api.h.

#define value_to_unsigned_int   value_to_u32

Definition at line 1929 of file target_api.h.

#define value_to_unsigned_long   value_to_u32

Definition at line 1924 of file target_api.h.

#define VL (   target,
  tlctxt,
  invalue,
  varstr,
  loadflags,
  outvalueptr,
  errlabel 
)
Value:
do { \
struct value *_outvalue; \
\
if ((invalue) != NULL) { \
_outvalue = target_load_value_member((target),(tlctxt),(invalue),(varstr), \
NULL,(loadflags)); \
} \
else { \
struct bsymbol *_varsym; \
_varsym = target_lookup_sym((target),(varstr),NULL,NULL, \
if (!_varsym) { \
goto errlabel; \
} \
_outvalue = target_load_symbol((target),(tlctxt),_varsym, \
(loadflags)); \
bsymbol_release(_varsym); \
} \
if (!_outvalue) \
goto errlabel; \
if (outvalueptr) { \
if (0 && *(struct value **)(outvalueptr) == invalue) { \
value_free(*(struct value **)(outvalueptr)); \
} \
*(struct value **)(outvalueptr) = _outvalue; \
} \
else { \
value_free(_outvalue); \
} \
} while (0);
struct bsymbol * target_lookup_sym(struct target *target, const char *name, const char *delim, char *srcfile, symbol_type_flag_t ftype)
Definition: target.c:2199
struct value * target_load_symbol(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, load_flags_t flags)
Definition: target.c:3270
void value_free(struct value *value)
Definition: value.c:282
REFCNT bsymbol_release(struct bsymbol *bsymbol)
Definition: symbol.c:90
struct value * target_load_value_member(struct target *target, struct target_location_ctxt *tlctxt, struct value *old_value, const char *member, const char *delim, load_flags_t flags)
Definition: target.c:2942

Definition at line 1708 of file target_api.h.

#define VLA (   target,
  addr,
  loadflags,
  outbufptr,
  outbuflen,
  outvalueptr,
  errlabel 
)
Value:
do { \
struct value *_outvalue; \
\
_outvalue = target_load_addr_real((target),(addr),(loadflags), \
outbuflen); \
if (!_outvalue) \
goto errlabel; \
if (!*outbufptr) { \
*outbufptr = malloc(outbuflen); \
} \
memcpy(*outbufptr,_outvalue->buf,outbuflen); \
if (outvalueptr) { \
*(struct value **)(outvalueptr) = _outvalue; \
} \
else { \
value_free(_outvalue); \
} \
} while (0);
ADDR addr
Definition: target_api.h:3309
void value_free(struct value *value)
Definition: value.c:282
struct value * target_load_addr_real(struct target *target, ADDR addr, load_flags_t flags, int len)
Definition: target.c:3758
void * malloc(size_t size)
Definition: debugserver.c:214

Definition at line 1840 of file target_api.h.

#define VLS (   target,
  tlctxt,
  varstr,
  loadflags,
  outvarptr,
  outvalueptr,
  errlabel 
)
Value:
do { \
struct value *_outvalue; \
void *__outvar = (outvarptr); \
struct bsymbol *_varsym; \
_varsym = target_lookup_sym((target),(varstr),NULL,NULL, \
if (!_varsym) { \
goto errlabel; \
} \
_outvalue = target_load_symbol((target),(tlctxt),_varsym, \
(loadflags)); \
bsymbol_release(_varsym); \
if (!_outvalue) \
goto errlabel; \
if (__outvar) { \
if ((int)sizeof(*(outvarptr)) < _outvalue->bufsiz) { \
verror("outvar size %u smaller than outvalue len %d\n", \
(unsigned)sizeof(*(outvarptr)),_outvalue->bufsiz); \
value_free(_outvalue); \
goto errlabel; \
} \
memcpy(outvarptr,_outvalue->buf, \
((int)sizeof(*(outvarptr))) > _outvalue->bufsiz \
? _outvalue->bufsiz : (int)sizeof(*(outvarptr)));\
} \
if (outvalueptr) \
*(struct value **)(outvalueptr) = _outvalue; \
value_free(_outvalue); \
} while (0);
struct bsymbol * target_lookup_sym(struct target *target, const char *name, const char *delim, char *srcfile, symbol_type_flag_t ftype)
Definition: target.c:2199
#define verror(format,...)
Definition: log.h:30
struct value * target_load_symbol(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, load_flags_t flags)
Definition: target.c:3270
void value_free(struct value *value)
Definition: value.c:282
REFCNT bsymbol_release(struct bsymbol *bsymbol)
Definition: symbol.c:90

Value macros.

Definition at line 1677 of file target_api.h.

#define VLV (   target,
  tlctxt,
  invalue,
  varstr,
  loadflags,
  outvarptr,
  outvalueptr,
  errlabel 
)

Definition at line 1739 of file target_api.h.

#define VLVAL (   target,
  tlctxt,
  invalue,
  varstr,
  loadflags,
  outvalueptr,
  errlabel 
)
Value:
do { \
struct value *_outvalue; \
\
if ((invalue) != NULL) { \
_outvalue = target_load_value_member((target),(tlctxt),(invalue),(varstr), \
NULL,(loadflags)); \
} \
else { \
struct bsymbol *_varsym; \
_varsym = target_lookup_sym((target),(varstr),NULL,NULL, \
if (!_varsym) { \
goto errlabel; \
} \
_outvalue = target_load_symbol((target),(tlctxt),_varsym, \
(loadflags)); \
bsymbol_release(_varsym); \
} \
if (!_outvalue) \
goto errlabel; \
if (0 && *(struct value **)(outvalueptr) == invalue) { \
value_free(*(struct value **)(outvalueptr)); \
} \
*(struct value **)(outvalueptr) = _outvalue; \
} while (0);
struct bsymbol * target_lookup_sym(struct target *target, const char *name, const char *delim, char *srcfile, symbol_type_flag_t ftype)
Definition: target.c:2199
struct value * target_load_symbol(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, load_flags_t flags)
Definition: target.c:3270
void value_free(struct value *value)
Definition: value.c:282
REFCNT bsymbol_release(struct bsymbol *bsymbol)
Definition: symbol.c:90
struct value * target_load_value_member(struct target *target, struct target_location_ctxt *tlctxt, struct value *old_value, const char *member, const char *delim, load_flags_t flags)
Definition: target.c:2942

Definition at line 1814 of file target_api.h.

#define VLVAR (   target,
  tlctxt,
  invalue,
  varstr,
  loadflags,
  outvarptr,
  errlabel 
)

Definition at line 1782 of file target_api.h.

Typedef Documentation

typedef result_t(* target_debug_bp_handler_t)(struct target *target, struct target_thread *tthread, struct probepoint *probepoint, int was_stepping)

Definition at line 2308 of file target_api.h.

typedef result_t(* target_debug_handler_t)(struct target *target, struct target_thread *tthread, struct probepoint *probepoint)

Definition at line 2312 of file target_api.h.

typedef int(* target_decoder_t)(struct target *target, void *data, struct value *value, char *buf, int buflen)

Definition at line 1977 of file target_api.h.

typedef target_status_t(* target_exception_handler_t)(struct target *target, target_exception_flags_t flags, int *again, void *priv)

Definition at line 2304 of file target_api.h.

typedef unsigned int thread_ctxt_t

Definition at line 300 of file target_api.h.

typedef uintptr_t value_hash_t

Definition at line 1641 of file target_api.h.

Enumeration Type Documentation

Enumerator
AFP_NONE 
APF_THREAD_ENTRY 
APF_THREAD_EXIT 
APF_MEMORY 
APF_OTHER 
APF_OS_THREAD_ENTRY 
APF_OS_THREAD_EXIT 
APF_OS_MEMORY 
APF_OS_OTHER 
APF_PROCESS_THREAD_ENTRY 
APF_PROCESS_THREAD_EXIT 
APF_PROCESS_MEMORY 
APF_PROCESS_OTHER 
APF_APP_THREAD_ENTRY 
APF_APP_THREAD_EXIT 
APF_APP_MEMORY 
APF_APP_OTHER 

Definition at line 432 of file target_api.h.

Enumerator
LOAD_FLAG_NONE 
LOAD_FLAG_NO_CHECK_BOUNDS 
LOAD_FLAG_NO_CHECK_VISIBILITY 
LOAD_FLAG_AUTO_DEREF 
LOAD_FLAG_AUTO_DEREF_RECURSE 
LOAD_FLAG_AUTO_STRING 
LOAD_FLAG_NO_AUTO_RESOLVE 
LOAD_FLAG_VALUE_FORCE_COPY 

Definition at line 406 of file target_api.h.

Enumerator
REGION_TYPE_FILE 
REGION_TYPE_HEAP 
REGION_TYPE_STACK 
REGION_TYPE_VDSO 
REGION_TYPE_VSYSCALL 
REGION_TYPE_ANON 
REGION_TYPE_UNKNOWN 
REGION_TYPE_HEAP 
REGION_TYPE_STACK 
REGION_TYPE_VDSO 
REGION_TYPE_VSYSCALL 
REGION_TYPE_ANON 
REGION_TYPE_MAIN 
REGION_TYPE_LIB 
__REGION_TYPE_MAX 

Definition at line 372 of file target_api.h.

Enumerator
EXCEPTION_NONE 
EXCEPTION_SINGLESTEP 
EXCEPTION_SINGLESTEP_BOGUS 
EXCEPTION_SINGLESTEP_CMD 
EXCEPTION_BREAKPOINT 

Definition at line 386 of file target_api.h.

Enumerator
TLCTXT_NONE 
TLCTXT_AUTOLOAD_ARGS 
TLCTXT_AUTOLOAD_LOCALS 
TLCTXT_AUTOLOAD_INSCOPE 
TLCTXT_FOLLOW_OVERLAYS 

Definition at line 2356 of file target_api.h.

Enumerator
TARGET_MODE_NONE 
TARGET_MODE_LIVE 
TARGET_MODE_RECORD 
TARGET_MODE_REPLAY 

Definition at line 187 of file target_api.h.

Enumerator
TARGET_PERSONALITY_NONE 
TARGET_PERSONALITY_OS 
TARGET_PERSONALITY_PROCESS 
TARGET_PERSONALITY_APPLICATION 

Definition at line 180 of file target_api.h.

Enumerator
POLL_NOTHING 
POLL_ERROR 
POLL_SUCCESS 
POLL_UNKNOWN 
__POLL_MAX 

Definition at line 394 of file target_api.h.

Enumerator
TSTATUS_UNKNOWN 
TSTATUS_RUNNING 
TSTATUS_PAUSED 
TSTATUS_ERROR 
TSTATUS_DONE 
TSTATUS_EXITING 
TSTATUS_DEAD 
TSTATUS_STOPPED 
TSTATUS_INTERRUPTED 

Definition at line 197 of file target_api.h.

Enumerator
TARGET_TYPE_NONE 
TARGET_TYPE_PTRACE 
TARGET_TYPE_XEN 
TARGET_TYPE_OS_PROCESS 
TARGET_TYPE_PHP 
TARGET_TYPE_GDB 

Definition at line 163 of file target_api.h.

Enumerator
TARGET_UNWIND_STYLE_GDB 
TARGET_UNWIND_STYLE_PROG 
TARGET_UNWIND_STYLE_PROG_KEYS 

Definition at line 2432 of file target_api.h.

Enumerator
THREAD_BPMODE_STRICT 
THREAD_BPMODE_SEMI_STRICT 
THREAD_BPMODE_LOOSE 

Definition at line 366 of file target_api.h.

The primary target data structures.

Enumerator
THREAD_RESUMEAT_NONE 
THREAD_RESUMEAT_BPH 
THREAD_RESUMEAT_SSR 
THREAD_RESUMEAT_NA 
THREAD_RESUMEAT_PH 

Definition at line 2069 of file target_api.h.

Enumerator
THREAD_STATUS_UNKNOWN 
THREAD_STATUS_RUNNING 
THREAD_STATUS_PAUSED 
THREAD_STATUS_ERROR 
THREAD_STATUS_DONE 
THREAD_STATUS_EXITING 
THREAD_STATUS_DEAD 
THREAD_STATUS_STOPPED 
THREAD_STATUS_SLEEPING 
THREAD_STATUS_ZOMBIE 
THREAD_STATUS_BLOCKEDIO 
THREAD_STATUS_PAGING 
THREAD_STATUS_RETURNING_USER 
THREAD_STATUS_RETURNING_KERNEL 

Definition at line 254 of file target_api.h.

Enumerator
VALUE_DIFF_SAME 
VALUE_DIFF_DIFF 
VALUE_DIFF_MAYBE 
VALUE_DIFF_UNKNOWN 

Definition at line 1634 of file target_api.h.

Function Documentation

struct bsymbol* bsymbol_create_noninline ( struct bsymbol bsymbol)

Definition at line 80 of file symbol.c.

void bsymbol_dump ( struct bsymbol bsymbol,
struct dump_info ud 
)

Definition at line 120 of file symbol.c.

struct lsymbol* bsymbol_get_lsymbol ( struct bsymbol bsymbol)

Definition at line 70 of file symbol.c.

char* bsymbol_get_name ( struct bsymbol bsymbol)

Bound symbol interface functions – user should not need any more knowledge of bsymbols other than these few functions.

Definition at line 62 of file symbol.c.

struct symbol* bsymbol_get_symbol ( struct bsymbol bsymbol)

Definition at line 66 of file symbol.c.

void bsymbol_hold ( struct bsymbol bsymbol)
int bsymbol_is_inline ( struct bsymbol bsymbol)

Definition at line 74 of file symbol.c.

REFCNT bsymbol_release ( struct bsymbol bsymbol)

Definition at line 90 of file symbol.c.

ADDR rv_addr ( void *  buf)

Definition at line 1350 of file value.c.

signed char rv_c ( void *  buf)

Quick raw value converters

Definition at line 1336 of file value.c.

double rv_d ( void *  buf)

Definition at line 1348 of file value.c.

long double rv_dd ( void *  buf)

Definition at line 1349 of file value.c.

float rv_f ( void *  buf)

Definition at line 1347 of file value.c.

int16_t rv_i16 ( void *  buf)

Definition at line 1344 of file value.c.

int32_t rv_i32 ( void *  buf)

Definition at line 1345 of file value.c.

int64_t rv_i64 ( void *  buf)

Definition at line 1346 of file value.c.

int8_t rv_i8 ( void *  buf)

Definition at line 1343 of file value.c.

uint16_t rv_u16 ( void *  buf)

Definition at line 1340 of file value.c.

uint32_t rv_u32 ( void *  buf)

Definition at line 1341 of file value.c.

uint64_t rv_u64 ( void *  buf)

Definition at line 1342 of file value.c.

uint8_t rv_u8 ( void *  buf)

Definition at line 1339 of file value.c.

unsigned char rv_uc ( void *  buf)

Definition at line 1337 of file value.c.

wchar_t rv_wc ( void *  buf)

Definition at line 1338 of file value.c.

int target_addr_v2p ( struct target target,
tid_t  tid,
ADDR  vaddr,
ADDR paddr 
)

Definition at line 1072 of file target_api.c.

ADDR target_addressof_symbol ( struct target target,
struct target_location_ctxt tlctxt,
struct bsymbol bsymbol,
load_flags_t  flags,
struct memrange **  range_saveptr 
)

Load functions. Everything that gets loaded is loaded as a value struct.

Each load function can handle a bsymbol that contains a nested symbol chain. Members may nest in either 1) functions, or 2) struct/unions. Obviously, once you are in a struct/union, the only members of those can be variables. Thus, all functions must come first in the chain. So, here are some examples of nested symbols that can be followed by these functions: function.subfunc.param1, function.local, function.localstructinst.x, structinst.x.y.z, structinst->x.y.z, structinst->x->y->z Now, since we support automatic pointer dereferencing, you don't have to worry about actually using -> or .; you just use . . If the final symbol is itself a pointer to something, if the AUTO_DEREF or AUTO_STRING load flags are set, the pointer will be dereferenced as much as possible before loading. Otherwise, it won't be. The AUTO_DEREF flags do not affect the behavior of intermediate pointer symbols in the chain; those are always autoloaded if possible. If you don't like this intermediate pointer autoloading behavior, don't use it!

Definition at line 3490 of file target.c.

int target_argp_driver_parse ( struct argp *  driver_parser,
void *  driver_state,
int  argc,
char **  argv,
target_type_t  target_types,
int  filter_quoted,
struct target_spec **  primary_target_spec,
GList **  base_target_specs,
GList **  overlay_target_specs 
)

Parses possibly multiple target specification objects by parsing command line arguments provided in the standard argc, argv pair. The caller should be a StackDB program who wants to build a target_spec object containing the details about one or more targets (and perhaps one or more stacks of overlay targets built atop them) to instantiate. This program may also require its own arguments, which it can retrieve and parse after any StackDB-relevant arguments have been extracted (see the User Guide section on standard StackDB arguments).

Parameters
driver_parserA fully-specified GNU argp parser struct (see http://www.gnu.org/software/libc/manual/html_node/Argp.html). May be NULL, if your program doesn't require any arguments.
driver_stateA pointer to an object that will be passed to your driver_parser when driver_parser->parser is invoked. May always be NULL; it's up to you.
argcA count of the arguments in argv; usually is main()'s first argument.
argvAn argument vector; usually is main()'s second argument.
target_typesA mask of allowed target types (drivers) that your program can be applied to.
filter_quotedIf set non-zero, the StackDB argp wrapper will catch any arguments after the "--" characters on the command line, and save them to be processed. The Ptrace driver will process any arguments after "--" and use them to launch a program that StackDB will attach to).
[out]primary_target_specThe primary target_spec. This should be a pointer to a target_spec * that is set to NULL; this function will allocate a target_spec * according to the argv parameter.
[out]base_target_specsA GList * of base target_specs. This should be a pointer to a GList * that is set to NULL. This function will allocate a GList * of target_spec * structs based on any –base '...' argv members. The primary target_spec object is not in this list!
[out]overlay_target_specsA GList * of overlay target_specs. This should be a pointer to a GList * that is set to NULL. This function will allocate a GList * of target_spec * structs based on any –overlay '...' argv members.
Returns
0 on success; non-zero on failure.

Definition at line 913 of file target.c.

struct target_spec* target_argp_driver_parse_one ( struct argp *  driver_parser,
void *  driver_state,
int  argc,
char **  argv,
target_type_t  target_types,
int  filter_quoted 
)

Returns a single target specification object by parsing command line arguments provided in the standard argc, argv pair. The caller should be a StackDB program who wants to build a target_spec object containing the details about a target (and perhaps its overlay targets) to instantiate. This program may also require its own arguments, which it can retrieve and parse after any StackDB-relevant arguments have been extracted (see the User Guide section on standard StackDB arguments).

Parameters
driver_parserA fully-specified GNU argp parser struct (see http://www.gnu.org/software/libc/manual/html_node/Argp.html). May be NULL, if your program doesn't require any arguments.
driver_stateA pointer to an object that will be passed to your driver_parser when driver_parser->parser is invoked. May always be NULL; it's up to you.
argcA count of the arguments in argv; usually is main()'s first argument.
argvAn argument vector; usually is main()'s second argument.
target_typesA mask of allowed target types (drivers) that your program can be applied to.
filter_quotedIf set non-zero, the StackDB argp wrapper will catch any arguments after the "--" characters on the command line, and save them to be processed. The Ptrace driver will process any arguments after "--" and use them to launch a program that StackDB will attach to).
Returns
A target_spec that can be passed to target_instantiate(). Do not free this struct; once passed to target_instantiate(), the returned target object owns it; and it cannot be passed to another call to target_instantiate().

Definition at line 802 of file target.c.

void* target_argp_driver_state ( struct argp_state *  state)

Definition at line 716 of file target.c.

struct target_spec* target_argp_target_spec ( struct argp_state *  state)

Definition at line 709 of file target.c.

int target_attach_evloop ( struct target target,
struct evloop evloop 
)

Definition at line 834 of file target_api.c.

ADDR target_autoload_pointers ( struct target target,
struct symbol datatype,
ADDR  addr,
load_flags_t  flags,
struct symbol **  datatype_saveptr,
struct memrange **  range_saveptr 
)

Definition at line 3668 of file target.c.

int target_bsymbol_resolve_base ( struct target target,
struct target_location_ctxt tlctxt,
struct bsymbol bsymbol,
ADDR o_addr,
struct memrange **  o_range 
)

Definition at line 2618 of file target.c.

struct target_spec* target_build_default_overlay_spec ( struct target target,
tid_t  tid 
)

Definition at line 734 of file target_api.c.

struct target_spec* target_build_spec ( target_type_t  type,
target_mode_t  mode 
)

Definition at line 410 of file target_api.c.

int target_change_sw_breakpoint ( struct target target,
tid_t  tid,
struct target_memmod mmod,
unsigned char *  code,
unsigned long  code_len 
)

Definition at line 1800 of file target_api.c.

int target_close ( struct target target)

Closes a target and releases all its live resources.

(Internally, this calls the following target_ops: detach(), kill() (if target->kill_on_close is set).)

Definition at line 1511 of file target_api.c.

int target_contains_real ( struct target target,
ADDR  addr 
)

Address/memory range functions.

Definition at line 3602 of file target.c.

GHashTable* target_copy_registers ( struct target target,
tid_t  tid 
)

Definition at line 1203 of file target_api.c.

struct symbol* target_create_synthetic_type_pointer ( struct target target,
struct symbol type 
)

Symbol functions.

Definition at line 27 of file symbol.c.

int target_cregno ( struct target target,
common_reg_t  creg,
REG reg 
)

Definition at line 1126 of file target_api.c.

int target_decoder_binding_add ( struct target_decoder_binding tdb,
struct bsymbol bsymbol,
target_decoder_t  dfn 
)

Definition at line 6338 of file target.c.

int target_decoder_lib_bind ( struct target target,
char *  decoder_lib,
char *  decoder_lib_lib 
)

Definition at line 6206 of file target.c.

int target_decoder_lib_register ( struct target_decoder_lib lib)

Definition at line 6195 of file target.c.

int target_decoder_lookup ( struct target target,
struct value value,
target_decoder_t decoder,
void **  decoder_data 
)

Definition at line 6350 of file target.c.

void target_default_cleanup ( void  )

A function that pauses, closes, and finalizes all targets the target library knows of. If any of the target objects was handling an exception, it schedules an interrupt for that target — and the user (the caller of target_monitor() or target_monitor_evloop() must call target_default_cleanup() if the returned target status is TSTATUS_INTERRUPTED. The user must also identify if the signal was a fatal signal, or a simple interruption; this is up to the user.

Definition at line 128 of file target.c.

void target_default_sighandler ( int  signo,
siginfo_t *  siginfo,
void *  x 
)

The default signal handler for the target library. Saves off the signal information into a global variable (accessible via target_monitor_was_interrupted()); calls the user sighandler if specified; pauses all target objects if the signal was supposed to result in an interrupt of the target_monitor_evloop() function (and pauses them safely by employing target_monitor_schedule_interrupt() on any target that is currently handling an exception); OR calls the target_default_cleanup() function if the signal is fatal.

Definition at line 174 of file target.c.

int target_detach_evloop ( struct target target)

Definition at line 846 of file target_api.c.

int target_disable_feature ( struct target target,
int  feature 
)

Definition at line 1957 of file target_api.c.

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

Definition at line 1877 of file target_api.c.

int target_disable_hw_breakpoints ( struct target target,
tid_t  tid 
)

Definition at line 1865 of file target_api.c.

int target_disable_sw_breakpoint ( struct target target,
tid_t  tid,
struct target_memmod mmod 
)

Definition at line 1786 of file target_api.c.

void target_driver_argp_init_children ( struct argp_state *  state)

Definition at line 1057 of file target.c.

void target_dump_all_threads ( struct target target,
FILE *  stream,
int  detail 
)

Definition at line 1500 of file target_api.c.

void target_dump_thread ( struct target target,
tid_t  tid,
FILE *  stream,
int  detail 
)

Definition at line 1484 of file target_api.c.

int target_enable_feature ( struct target target,
int  feature,
void *  arg 
)

Definition at line 1950 of file target_api.c.

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

Definition at line 1884 of file target_api.c.

int target_enable_hw_breakpoints ( struct target target,
tid_t  tid 
)

Definition at line 1871 of file target_api.c.

int target_enable_sw_breakpoint ( struct target target,
tid_t  tid,
struct target_memmod mmod 
)

Definition at line 1773 of file target_api.c.

int target_finalize ( struct target target)

Finalizes a target. This means the library drops its internal reference to the target — and thus, the user did not call target_hold() after target_open(), this will also have the effect of freeing the target struct – because the target library will remove the target struct from its internal structs, and drop a ref. Unless some other caller had held a ref to it for some other reason, this will deallocate it. Thus – if you want to hold onto the struct for subsequent calls, hold onto it first!

NB: the library will never drop its ref to the target struct object unless the user calls target_finalize() – or target_fini(). It may detach (on your behalf) from an exiting target, but that does not perform the work of target_finalize() by itself – you still get to do that so you can handle the exiting/exited target.

Definition at line 1955 of file target.c.

int target_find_memory_real ( struct target target,
ADDR  addr,
struct addrspace **  space_saveptr,
struct memregion **  region_saveptr,
struct memrange **  range_saveptr 
)

Definition at line 3578 of file target.c.

void target_fini ( void  )

This function should be called by the StackDB user when the user is done using StackDB, or when their program is about to exit. It cleans up global StackDB state. One way to do this is to to schedule it to be called via atexit(3) — although note that will not work in the case where the program is terminated by signal delivery.

target_fini() can safely be called at any point in your program, except from within a probe or action handler! It will result in any active, open target objects being closed and freed. After calling this function, you cannot use any other StackDB library target_* functions until you call target_init() again.

Definition at line 91 of file target.c.

int target_flush_all_threads ( struct target target)

Definition at line 1340 of file target_api.c.

int target_flush_current_thread ( struct target target)

Definition at line 1329 of file target_api.c.

int target_flush_thread ( struct target target,
tid_t  tid 
)

Definition at line 1334 of file target_api.c.

void target_free_spec ( struct target_spec spec)

Definition at line 453 of file target_api.c.

int target_gc_threads ( struct target target)

Definition at line 1368 of file target_api.c.

uint64_t target_get_counter ( struct target target)

Definition at line 1943 of file target_api.c.

uint64_t target_get_time ( struct target target)

Definition at line 1936 of file target_api.c.

uint64_t target_get_tsc ( struct target target)

Definition at line 1929 of file target_api.c.

REG target_get_unused_debug_reg ( struct target target,
tid_t  tid 
)

Definition at line 1822 of file target_api.c.

tid_t target_gettid ( struct target target)

Definition at line 1918 of file target_api.c.

struct target_location_ctxt* target_global_tlctxt ( struct target target)

Target location contexts (unwinding, symbol loading/address resolution).

We use a target_location_ctxt struct that wraps location_ctxt in dwdebug. Thus, you can lookup/load symbols in the current thread, or in an unwind context. You must supply a context, however – loading symbols is meaningless if you don't have a thread context and a memory context binding the symbol to an execution context.

A context keeps a notion of current frame, which it shares with its underlying location_ctxt (i.e., with the dwdebug library). This enables these two libraries to unwind cooperatively (dwdebug handles location resolution/computation and saved register resolution/computation; target caches restored registers and keeps a stack of frames and their metadata).

Definition at line 5299 of file target.c.

int target_has_base ( struct target overlay,
struct target base 
)
GHashTable* target_hash_available_tids ( struct target target)

Definition at line 1277 of file target_api.c.

GHashTable* target_hash_threads ( struct target target)

Definition at line 1253 of file target_api.c.

void target_hold ( struct target target)

Definition at line 1657 of file target_api.c.

int target_id ( struct target target)

Definition at line 509 of file target_api.c.

void target_init ( void  )

This file describes the publicly-accessible target API. The target library is really a library of debug routines that supports multiple backends. It is built atop the dwdebug library, which is a library for parsing DWARF debug information. It provides two backends: a Linux ptrace userspace backend, and a Xen virtual machine (assumes a Linux guest) backend. Both backends are x86-only at the moment. The linux ptrace backend supports 32/64-bit targets, but not 32-bit emulated atop 64-bit host. The Xen VM/Linux guest backend supports 32-bit Xen/guest; it has partial, nonfunctional support for 64-bit-ness. Right now, the backend code does not separate the logic for dealing with a target in an architecture-independent way – the arch stuff is jammed in with the target code. This should not be this way; eventually, hopefully, it will change into a target backend that supports different arch/machine ops. Also, there are probably some x86-isms that have leaked into the "generic" target and probe code :(.

The target library supports two modes of dealing with threads inside a target. Some targets provide control over executing threads (i.e., can the library pause random threads at will, or not); the Linux ptrace target of course supports this; the Xen VM target does not (it could mostly support "pausing" all non-current threads in a single CPU guest, BUT even this requires that the debug lib handle NMIs, asynch interrupts, and some synchronous exceptions – overloading the kernel's IDT – but right now we don't do this).

Targets that do not provide control over thread scheduling must still provide thread identification. This is important for shared (i.e., memory-based) breakpoints, which any thread could hit at any time – not just the thread the user is interested in. Our handling of such breakpoints must be context-aware, so that we maintain handling information on a per-thread basis.

So the library supports two kinds of targets: ones that provide thread control (ptrace), and ones that provide thread awareness (Xen).

The intent is that the target library provides a library above the dwdebug library, so you should never (or rarely) have to call into dwdebug to deal with symbol information. The reason for this attempted restriction is as follows. First, an in-memory representation of DWARF debug data that facilitates fast lookups is big. So, we want to share it between targets (or between all target library users) as much as possible (possible when targets use the same debuginfo, or a subset thereof). Second, memory locations are, naturally, virtual addresses in debuginfo. For the statically-linked core of an executable, there is no difference between virtual/physical; the core is mmap'd at the static addresses. But shared objects/libs may be mmap'd anywhere in the address space, so we have to translate. Rather than smacking the details of physical translation into the debuginfo data structures, for each target instance, we build this translation into the target library. This is perhaps annoying, but facilitates better sharing.

The target library is described via the API functions listed below. To build a new target backend, you must implement the target_ops operations; see the documentation for struct target_ops below.

For information on how to probe a target, see probe_api.h . This function must be called by StackDB user before using any library functions.

Definition at line 69 of file target.c.

struct target_memmod* target_insert_sw_breakpoint ( struct target target,
tid_t  tid,
ADDR  addr 
)

Definition at line 1729 of file target_api.c.

int target_install_custom_sighandlers ( sigset_t *  ignored,
sigset_t *  interrupt,
sigset_t *  exit,
void(*)(int signo, siginfo_t *siginfo, void *x)  sighandler 
)

Install the library's default signal handler, but customize which signals it is set for!

Parameters
ignoredA pointer to a sigset_t (see man 3 sigset) of signals to be ignored.
interruptA pointer to a sigset_t of signals to cause target_monitor or target_monitor_evloop to be interrupted so that you can handle a signal synchronously with respect to target exception handling (i.e., safely!).
exitA pointer to a sigset_t of signals that will cause your program to be exit. Remember, if one of your targets is being handled when the handler is invoked, the library cannot free that target — and you must call target_default_cleanup() again yourself to finish the cleanup!
sighandlerA signal handler function in your program (see man sigaction) that will be called by the target library's default signal handler. This function is called immediately after the handler saves off the siginfo into a global variable for later retrieval by your program, to give you notice that the target library is about to handle a signal for you. Usually, the only thing that your handler should do is clean up any state that the default handler is unaware of (i.e., remove any probes you placed on targets). Note that when your handler is called, the default handler has not yet paused all targets — so if you are going to modify any targets, you must pause them first.
Returns
Returns nonzero on failure; 0 on success.

Definition at line 270 of file target.c.

int target_install_default_sighandlers ( void(*)(int signo, siginfo_t *siginfo, void *x)  sighandler)

Install some default signal handlers for the target library. It is very important to handle signals that would be fatal, because you must remove any probes placed on any targets — otherwise those programs will very likely crash when they hit the probes — because nothing is attached to them any longer.

This function installs the target_default_sighandler() on the following signals: SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, SIGPIPE, SIGTERM, SIGBUS, SIGXCPU, and SIGXFSZ. It sets up SIGUSR1, SIGUSR2, and SIGALRM to be ignored. If you want to change those signal sets, see target_install_custom_sighandlers().

Parameters
sighandlerA signal handler function in your program (see man sigaction) that will be called by the target library's default signal handler. This function is called immediately after the handler saves off the siginfo into a global variable for later retrieval by your program, to give you notice that the target library is about to handle a signal for you. Usually, the only thing that your handler should do is clean up any state that the default handler is unaware of (i.e., remove any probes you placed on targets). Note that when your handler is called, the default handler has not yet paused all targets — so if you are going to modify any targets, you must pause them first.
Returns
Returns nonzero on failure; 0 on success.

Definition at line 240 of file target.c.

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

Instantiates a target object according to the configuration provided in spec. The returned target object is configured and prepared to be passed to target_open(), at which point it will be attached to the target program. Once instantiated, it is recorded in the library's global data structures, so calls like target_lookup_target_id() will succeed. It remains in the library's global structures until target_close() is called, at which point it is removed. If you pass an event loop evloop, the target object will be attached to the given evloop.

Event loops are our homegrown, powerful wrapper around select(). Most StackDB drivers are capable of turning debug exceptions into notifications on file descriptors, and those descriptors can be passed to the event loop. Moreover, event loops allow you to integrate your program's own event-driven main loop with StackDB's event-driven paradigm. You can pass your own FDs and handlers to StackDB's event loop, and evloop_run() or evloop_handleone() can be called to do the event loop work for you. However, many people won't need a separate event loop, and can simple use target_monitor() to control target execution — because all of their program's work is done in reacting to StackDB probes. Moreover, target_monitor() is interruptible, so you need not use a polling strategy — you can interrupt it from your own signal handlers.

Parameters
specA target_spec, describing the kind of target object to instantiate.
evloopAn evloop that will "run" this target object via evloop_run() or evloop_handleone(); see evloop_create().
Returns
A target object that is ready to be passed to target_open() when you want to attach to the target program; need not be immediate.

The generic target API!

Definition at line 55 of file target_api.c.

GList* target_instantiate_and_open ( struct target_spec primary_target_spec,
GList *  base_target_specs,
GList *  overlay_target_specs,
struct evloop evloop,
GList **  error_specs 
)

Instantiates and opens target objects according to the target_spec objects in the primary_target_spec, base_target_specs, and overlay_target_specs params. The returned target objects are already opened, since if there are overlay target specs, we would need to open the corresponding base target in order to instantiate the overlay — and to be consistent, we just open all the targets. Once instantiated, the targets are recorded in global data structures, so calls like target_lookup_target_id() will succeed. The targets remain in the library's global structures until target_finalize() is called, at which point it is removed. If you pass an event loop evloop, the target object will be attached to the given evloop. You'll almost certainly want to use an evloop with this function, and then invoke target_monitor_evloop() to monitor your targets.

This function will handle both base and overlay target specs, and does not require that the lists are ordered by dependency.

If you pass a valid error_specs pointer, if a target_spec in the list cannot be instantiated and opened, that target_spec will be appended to the error_specs list, but this function will still return a list of successfully opened target objects. If you don't pass a valid error_specs pointer, if any target_spec fails to be instantiated and opened, this function will abort, close and finalize any just-opened targets, and return NULL.

Parameters
primary_target_specsA struct target_spec, describing the "primary" target object to instantiate.
base_target_specsA GList of struct target_spec, describing the base target objects to instantiate.
overlay_target_specsA GList of struct target_spec, describing the overlay target objects to instantiate.
evloopAn evloop that will "run" these target objects via evloop_run() or evloop_handleone(); see evloop_create() and target_monitor_evloop().
error_specsA pointer to a GList that, if set, will be filled with target_spec objects that were not successfully instantiated and opened.
Returns
A GList of opened, paused target objects, or NULL on error or if all specs failed to result in an opened target (i.e., they were all placed in the error_specs list).

Definition at line 92 of file target_api.c.

GList* target_instantiate_and_open_list ( GList *  target_specs,
struct evloop evloop,
GList **  error_specs 
)

Instantiates and opens target objects according to the target_spec objects in the target_specs param. The returned target objects are already opened, since if there are overlay target specs, we would need to open the corresponding base target in order to instantiate the overlay — and to be consistent, we just open all the targets. Once instantiated, the targets are recorded in global data structures, so calls like target_lookup_target_id() will succeed. The targets remain in the library's global structures until target_finalize() is called, at which point it is removed. If you pass an event loop evloop, the target object will be attached to the given evloop. You'll almost certainly want to use an evloop with this function, and then invoke target_monitor_evloop() to monitor your targets.

This function will handle both base and overlay target specs, and does not require that the lists are ordered by dependency.

If you pass a valid error_specs pointer, if a target_spec in the list cannot be instantiated and opened, that target_spec will be appended to the error_specs list, but this function will still return a list of successfully opened target objects. If you don't pass a valid error_specs pointer, if any target_spec fails to be instantiated and opened, this function will abort, close and finalize any just-opened targets, and return NULL.

Parameters
target_specsA GList of struct target_spec, describing the kind of target objects to instantiate.
evloopAn evloop that will "run" these target objects via evloop_run() or evloop_handleone(); see evloop_create() and target_monitor_evloop().
error_specsA pointer to a GList that, if set, will be filled with target_spec objects that were not successfully instantiated and opened.
Returns
A GList of opened, paused target objects, or NULL on error or if all specs failed to result in an opened target (i.e., they were all placed in the error_specs list).

Definition at line 287 of file target_api.c.

struct target* target_instantiate_overlay ( struct target target,
tid_t  tid,
struct target_spec spec 
)

Definition at line 757 of file target_api.c.

int target_is_evloop_attached ( struct target target,
struct evloop evloop 
)

Definition at line 863 of file target_api.c.

int target_is_open ( struct target target)

Definition at line 1042 of file target_api.c.

int target_kill ( struct target target,
int  sig 
)

Definition at line 1652 of file target_api.c.

struct array_list* target_list_available_overlay_tids ( struct target target,
target_type_t  type 
)

Definition at line 656 of file target_api.c.

struct array_list* target_list_available_tids ( struct target target)

Definition at line 1272 of file target_api.c.

struct array_list* target_list_overlays ( struct target target)

Definition at line 686 of file target_api.c.

struct array_list* target_list_threads ( struct target target)

Definition at line 1233 of file target_api.c.

struct array_list* target_list_tids ( struct target target)

Definition at line 1210 of file target_api.c.

struct value* target_load_addr_obj ( struct target target,
struct memregion region,
ADDR  obj_addr,
load_flags_t  flags,
int  len 
)

Definition at line 3742 of file target.c.

struct value* target_load_addr_real ( struct target target,
ADDR  addr,
load_flags_t  flags,
int  len 
)

Definition at line 3758 of file target.c.

int target_load_all_threads ( struct target target,
int  force 
)

Definition at line 1318 of file target_api.c.

int target_load_available_threads ( struct target target,
int  force 
)

Definition at line 1300 of file target_api.c.

unsigned char* target_load_code ( struct target target,
ADDR  start,
unsigned int  len,
int  nocache,
int  force_copy,
int *  caller_free 
)

Definition at line 3909 of file target.c.

struct target_thread* target_load_current_thread ( struct target target,
int  force 
)

Definition at line 1305 of file target_api.c.

ADDR target_load_pointers ( struct target target,
ADDR  addr,
int  count,
struct memrange **  range_saveptr 
)

Definition at line 3617 of file target.c.

struct value* target_load_symbol ( struct target target,
struct target_location_ctxt tlctxt,
struct bsymbol bsymbol,
load_flags_t  flags 
)

Definition at line 3270 of file target.c.

struct value* target_load_symbol_member ( struct target target,
struct target_location_ctxt tlctxt,
struct bsymbol bsymbol,
const char *  member,
const char *  delim,
load_flags_t  flags 
)

Definition at line 2920 of file target.c.

struct target_thread* target_load_thread ( struct target target,
tid_t  tid,
int  force 
)

Definition at line 1311 of file target_api.c.

struct value* target_load_type ( struct target target,
struct symbol type,
ADDR  addr,
load_flags_t  flags 
)

Definition at line 2653 of file target.c.

struct value* target_load_type_reg ( struct target target,
struct symbol type,
tid_t  tid,
REG  reg,
load_flags_t  flags 
)

Definition at line 2910 of file target.c.

struct value* target_load_type_regval ( struct target target,
struct symbol type,
tid_t  tid,
REG  reg,
REGVAL  regval,
load_flags_t  flags 
)

Definition at line 2762 of file target.c.

struct value* target_load_value_member ( struct target target,
struct target_location_ctxt tlctxt,
struct value old_value,
const char *  member,
const char *  delim,
load_flags_t  flags 
)

Definition at line 2942 of file target.c.

struct target_location_ctxt* target_location_ctxt_create ( struct target target,
tid_t  tid,
struct memregion region 
)

Definition at line 5304 of file target.c.

struct target_location_ctxt* target_location_ctxt_create_from_bsymbol ( struct target target,
tid_t  tid,
struct bsymbol bsymbol 
)

Definition at line 5325 of file target.c.

struct target_location_ctxt_frame* target_location_ctxt_current_frame ( struct target_location_ctxt tlctxt)

Definition at line 5748 of file target.c.

void target_location_ctxt_free ( struct target_location_ctxt tlctxt)

Definition at line 5348 of file target.c.

struct target_location_ctxt_frame* target_location_ctxt_get_frame ( struct target_location_ctxt tlctxt,
int  frame 
)

Definition at line 5742 of file target.c.

struct target_location_ctxt_frame* target_location_ctxt_prev ( struct target_location_ctxt tlctxt)

Definition at line 5812 of file target.c.

int target_location_ctxt_read_reg ( struct target_location_ctxt tlctxt,
REG  reg,
REGVAL o_regval 
)

Definition at line 5756 of file target.c.

void target_location_ctxt_retarget_bsymbol ( struct target_location_ctxt tlctxt,
struct bsymbol bsymbol 
)

Definition at line 5343 of file target.c.

int target_location_ctxt_unwind ( struct target_location_ctxt tlctxt)

Definition at line 5417 of file target.c.

struct action* target_lookup_action ( struct target target,
int  action_id 
)

Definition at line 1671 of file target_api.c.

struct scope* target_lookup_addr ( struct target target,
uint64_t  addr 
)

Lookup functions.

Definition at line 2053 of file target.c.

int target_lookup_line_addr ( struct target target,
char *  filename,
ADDR  addr 
)

Definition at line 2320 of file target.c.

int target_lookup_next_safe_disasm_range ( struct target target,
ADDR  addr,
ADDR start,
ADDR end,
void **  data 
)

Definition at line 3860 of file target.c.

tid_t target_lookup_overlay_thread_by_id ( struct target target,
int  id 
)

Definition at line 693 of file target_api.c.

tid_t target_lookup_overlay_thread_by_name ( struct target target,
char *  name 
)

Definition at line 713 of file target_api.c.

struct probe* target_lookup_probe ( struct target target,
int  probe_id 
)

Definition at line 1666 of file target_api.c.

int target_lookup_safe_disasm_range ( struct target target,
ADDR  addr,
ADDR start,
ADDR end,
void **  data 
)

Functions to deal with "widest range" lookup, text code loading and caching, and safe disassembly. We want to be sure we always start disassembly at a safe place in the text bytes we load – not wherever the library use requests (which might be in some weird place). Plus, we want to cache well-defined chunks of code to avoid fragmentation in the cache.

Definition at line 3825 of file target.c.

struct bsymbol* target_lookup_sym ( struct target target,
const char *  name,
const char *  delim,
char *  srcfile,
symbol_type_flag_t  ftype 
)

Definition at line 2199 of file target.c.

struct bsymbol* target_lookup_sym_addr ( struct target target,
ADDR  addr 
)

Definition at line 2093 of file target.c.

struct bsymbol* target_lookup_sym_line ( struct target target,
char *  filename,
int  line,
SMOFFSET offset,
ADDR addr 
)

Definition at line 2267 of file target.c.

struct bsymbol* target_lookup_sym_member ( struct target target,
struct bsymbol bsymbol,
const char *  name,
const char *  delim 
)

Definition at line 2248 of file target.c.

struct target* target_lookup_target_id ( int  id)

Definition at line 332 of file target.c.

target_status_t target_monitor ( struct target target)

Monitors a target for debug/exception events and, when such events occur, handles any probes attached to the target. This is a synchronous, blocking monitor style: it only returns if it can't handle some condition that arises; if an error occurs while handling an expected debug exception; or if the user scheduled an interrupt via target_monitor_schedule_interrupt() (so to schedule an interrupt when using target_monitor(), call target_monitor_schedule_interrupt() followed by alarm(0) or kill(getpid(),SIGALRM), if you've ignored or setup a handler for SIGALRM!).

Parameters
targetThe target object to monitor.
Returns
The current status of the target.

Definition at line 869 of file target_api.c.

void target_monitor_clear_global_interrupt ( void  )

Clears the global target_monitor interrupt flag.

Definition at line 235 of file target.c.

int target_monitor_evloop ( struct evloop evloop,
struct timeval *  timeout,
struct target **  target,
target_status_t status 
)

Monitors an evloop (with target objects attached to it!) for debug/exception events and, when such events occur, handles any probes attached to the target. This is a synchronous, blocking monitor style: it only returns if it can't handle some condition that arises; if an error occurs while handling an expected debug exception; or if the user scheduled an interrupt via target_monitor_schedule_global_interrupt() or on a particular target via target_monitor_schedule_interrupt() (so to schedule an interrupt when using target_monitor_evloop(), call target_monitor_schedule_interrupt() followed by alarm(0) or kill(getpid(),SIGALRM), if you've ignored or setup a handler for SIGALRM!).

Parameters
evloopThe evloop object to monitor (via evloop_handleone()).
timeoutA timeout object that will be passed to select().
[out]targetA pointer to a target object that will be filled in with the target just handled.
[out]statusA pointer to a target_status_t that will be filled in with the status of the target just handled.
Returns
Returns < 0 if there was an error handling the evloop; 0 if evloop_handleone() successfully handled some interaction with one of the target objects, and the user is required to handle it (and in that case, the *target and *status out params are set to the target that was handled — this only happens if the target's status is not TSTATUS_RUNING nor TSTATUS_PAUSED — meaning it's an exceptional case the user must handle); 0 if there were no more targets attached to the evloop (so, differentiate that case via evloop_maxsize(evloop) < 0).

Definition at line 880 of file target_api.c.

int target_monitor_handling_exception ( struct target target)

This function is useful only when using target_monitor() and employing your own custom signal handling. It may be useful to call it from your signal handler to see if the target you are monitoring is handling an exception. If it is handling an exception, it is unsafe to call any target_*() operations on it — for instance, you cannot attempt to remove a probe. In this case, the best thing to do is call target_monitor_schedule_interrupt(target), and wait for target_monitor() to return with a status of TSTATUS_INTERRUPTED. So, part of your signal handler might look like this:

if (target_monitor_handling_exception(t)) { needtodosomething = 1; target_monitor_schedule_interrupt(t); } else { target_pause(t); cleanup(); }

Returns
Returns 1 if the target object specified is in the middle of handling an exception; 0 if not.

Definition at line 317 of file target.c.

void target_monitor_schedule_global_interrupt ( void  )

Sets the global target_monitor_interrupt flag.

Definition at line 321 of file target.c.

int target_monitor_schedule_interrupt ( struct target target)

Schedules an an interrupt to happen after target_monitor() finishes handling the current exception, if any. See target_monitor_handling_exception().

Definition at line 325 of file target.c.

int target_monitor_was_interrupted ( siginfo_t *  last_siginfo)
Returns
Returns 1 (and sets last_siginfo to the siginfo of the last signal) if the last iteration of the monitor was interrupted; 0 otherwise.

Definition at line 226 of file target.c.

char* target_name ( struct target target)

Definition at line 505 of file target_api.c.

target_status_t target_notify_overlay ( struct target overlay,
target_exception_flags_t  flags,
tid_t  tid,
ADDR  ipval,
int *  again 
)

Definition at line 4491 of file target.c.

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

Definition at line 1891 of file target_api.c.

OFFSET target_offsetof_symbol ( struct target target,
struct bsymbol bsymbol,
char *  member,
const char *  delim 
)

Definition at line 3485 of file target.c.

int target_open ( struct target target)

Definition at line 513 of file target_api.c.

int target_open_all ( struct target target)
int target_pause ( struct target target)

Definition at line 1027 of file target_api.c.

int target_pause_thread ( struct target target,
tid_t  tid,
int  nowait 
)

Definition at line 1323 of file target_api.c.

target_status_t target_poll ( struct target target,
struct timeval *  tv,
target_poll_outcome_t outcome,
int *  pstatus 
)

Definition at line 1001 of file target_api.c.

unsigned char* target_read_addr ( struct target target,
ADDR  addr,
unsigned long  length,
unsigned char *  buf 
)

Definition at line 1053 of file target_api.c.

REGVAL target_read_creg ( struct target target,
tid_t  tid,
common_reg_t  reg 
)

Definition at line 1178 of file target_api.c.

unsigned char* target_read_physaddr ( struct target target,
ADDR  paddr,
unsigned long  length,
unsigned char *  buf 
)

Definition at line 1083 of file target_api.c.

REGVAL target_read_reg ( struct target target,
tid_t  tid,
REG  reg 
)

Definition at line 1132 of file target_api.c.

REGVAL target_read_reg_ctxt ( struct target target,
tid_t  tid,
thread_ctxt_t  tidctxt,
REG  reg 
)

Definition at line 1157 of file target_api.c.

const char* target_regname ( struct target target,
REG  reg 
)

Definition at line 1114 of file target_api.c.

int target_regno ( struct target target,
char *  name,
REG reg 
)

Definition at line 1120 of file target_api.c.

void target_release ( struct target target)

Definition at line 1661 of file target_api.c.

int target_remove_sw_breakpoint ( struct target target,
tid_t  tid,
struct target_memmod mmod 
)

Definition at line 1760 of file target_api.c.

int target_resume ( struct target target)

Definition at line 1012 of file target_api.c.

int target_set_active_probing ( struct target target,
active_probe_flags_t  flags 
)

Definition at line 633 of file target_api.c.

int target_set_hw_breakpoint ( struct target target,
tid_t  tid,
REG  reg,
ADDR  addr 
)

Definition at line 1836 of file target_api.c.

int target_set_hw_watchpoint ( struct target target,
tid_t  tid,
REG  reg,
ADDR  addr,
probepoint_whence_t  whence,
int  watchsize 
)

Definition at line 1843 of file target_api.c.

int target_singlestep ( struct target target,
tid_t  tid,
int  isbp 
)

Definition at line 1903 of file target_api.c.

int target_singlestep_end ( struct target target,
tid_t  tid 
)

Definition at line 1909 of file target_api.c.

int target_snprintf ( struct target target,
char *  buf,
int  bufsiz 
)

Definition at line 829 of file target_api.c.

int target_spec_to_argv ( struct target_spec spec,
char *  arg0,
int *  argc,
char ***  argv 
)

Definition at line 416 of file target.c.

target_status_t target_status ( struct target target)

Definition at line 1046 of file target_api.c.

int target_store_value ( struct target target,
struct value value 
)

The single value store function.

Definition at line 3548 of file target.c.

int target_thread_snprintf ( struct target target,
tid_t  tid,
char *  buf,
int  bufsiz,
int  detail,
char *  sep,
char *  key_val_sep 
)

Definition at line 1425 of file target_api.c.

thread_status_t target_thread_status ( struct target target,
tid_t  tid 
)

Definition at line 1964 of file target_api.c.

target_type_t target_type ( struct target target)

Definition at line 501 of file target_api.c.

int target_unchange_sw_breakpoint ( struct target target,
tid_t  tid,
struct target_memmod mmod 
)

Definition at line 1814 of file target_api.c.

int target_unset_hw_breakpoint ( struct target target,
tid_t  tid,
REG  reg 
)

Definition at line 1851 of file target_api.c.

int target_unset_hw_watchpoint ( struct target target,
tid_t  tid,
REG  reg 
)

Definition at line 1858 of file target_api.c.

struct target_location_ctxt* target_unwind ( struct target target,
tid_t  tid 
)

Definition at line 5354 of file target.c.

int target_unwind_snprintf ( char *  buf,
int  buflen,
struct target target,
tid_t  tid,
target_unwind_style_t  fstyle,
char *  frame_sep,
char *  ksep 
)

Definition at line 5482 of file target.c.

unsigned long target_write_addr ( struct target target,
ADDR  addr,
unsigned long  length,
unsigned char *  buf 
)

Definition at line 1060 of file target_api.c.

int target_write_creg ( struct target target,
tid_t  tid,
common_reg_t  reg,
REGVAL  value 
)

Definition at line 1187 of file target_api.c.

unsigned long target_write_physaddr ( struct target target,
ADDR  paddr,
unsigned long  length,
unsigned char *  buf 
)

Definition at line 1096 of file target_api.c.

int target_write_reg ( struct target target,
tid_t  tid,
REG  reg,
REGVAL  value 
)

Definition at line 1141 of file target_api.c.

int target_write_reg_ctxt ( struct target target,
tid_t  tid,
thread_ctxt_t  tidctxt,
REG  reg,
REGVAL  value 
)

Definition at line 1165 of file target_api.c.

ADDR v_addr ( struct value v)

Definition at line 429 of file value.c.

signed char v_c ( struct value v)

Quick value converters

Definition at line 385 of file value.c.

double v_d ( struct value v)

Definition at line 427 of file value.c.

long double v_dd ( struct value v)

Definition at line 428 of file value.c.

float v_f ( struct value v)

Definition at line 426 of file value.c.

int16_t v_i16 ( struct value v)

Definition at line 393 of file value.c.

int32_t v_i32 ( struct value v)

Definition at line 394 of file value.c.

int64_t v_i64 ( struct value v)

Definition at line 395 of file value.c.

int8_t v_i8 ( struct value v)

Definition at line 392 of file value.c.

num_t v_num ( struct value v)

Definition at line 396 of file value.c.

char* v_string ( struct value v)

Definition at line 430 of file value.c.

uint16_t v_u16 ( struct value v)

Definition at line 389 of file value.c.

uint32_t v_u32 ( struct value v)

Definition at line 390 of file value.c.

uint64_t v_u64 ( struct value v)

Definition at line 391 of file value.c.

uint8_t v_u8 ( struct value v)

Definition at line 388 of file value.c.

unsigned char v_uc ( struct value v)

Definition at line 386 of file value.c.

unum_t v_unum ( struct value v)

Definition at line 411 of file value.c.

wchar_t v_wc ( struct value v)

Definition at line 387 of file value.c.

ADDR value_addr ( struct value value)

Definition at line 302 of file value.c.

struct value* value_clone ( struct value in)

Value functions.

Definition at line 195 of file value.c.

void value_dump ( struct value value,
struct dump_info ud 
)

Definition at line 1294 of file value.c.

void value_dump_simple ( struct value value,
struct dump_info ud 
)

Definition at line 1289 of file value.c.

void value_free ( struct value value)

Definition at line 282 of file value.c.

int value_refresh ( struct value value,
int  recursive 
)

Definition at line 329 of file value.c.

int value_refresh_diff ( struct value value,
int  recurse,
value_diff_t vdiff,
char **  old_buf,
int *  old_bufsiz,
value_hash_t old_vhash 
)

Definition at line 378 of file value.c.

struct value* value_reload_as_type ( struct value value,
struct symbol type,
int  force 
)

Definition at line 224 of file value.c.

int value_snprintf ( struct value value,
char *  buf,
int  buflen 
)

Definition at line 639 of file value.c.

int value_update ( struct value value,
const char *  buf,
int  bufsiz 
)

Value update functions.

Definition at line 432 of file value.c.

int value_update_addr ( struct value value,
ADDR  v 
)

Definition at line 577 of file value.c.

int value_update_c ( struct value value,
signed char  v 
)

Definition at line 465 of file value.c.

int value_update_d ( struct value value,
double  v 
)

Definition at line 561 of file value.c.

int value_update_dd ( struct value value,
long double  v 
)

Definition at line 569 of file value.c.

int value_update_f ( struct value value,
float  v 
)

Definition at line 553 of file value.c.

int value_update_i16 ( struct value value,
int16_t  v 
)

Definition at line 529 of file value.c.

int value_update_i32 ( struct value value,
int32_t  v 
)

Definition at line 537 of file value.c.

int value_update_i64 ( struct value value,
int64_t  v 
)

Definition at line 545 of file value.c.

int value_update_i8 ( struct value value,
int8_t  v 
)

Definition at line 521 of file value.c.

int value_update_num ( struct value value,
num_t  v 
)

Definition at line 586 of file value.c.

int value_update_u16 ( struct value value,
uint16_t  v 
)

Definition at line 497 of file value.c.

int value_update_u32 ( struct value value,
uint32_t  v 
)

Definition at line 505 of file value.c.

int value_update_u64 ( struct value value,
uint64_t  v 
)

Definition at line 513 of file value.c.

int value_update_u8 ( struct value value,
uint8_t  v 
)

Definition at line 489 of file value.c.

int value_update_uc ( struct value value,
unsigned char  v 
)

Definition at line 473 of file value.c.

int value_update_unum ( struct value value,
unum_t  v 
)

Definition at line 601 of file value.c.

int value_update_wc ( struct value value,
wchar_t  v 
)

Definition at line 481 of file value.c.

int value_update_zero ( struct value value,
const char *  buf,
int  bufsiz 
)

Definition at line 447 of file value.c.

Variable Documentation

char* POLL_STRINGS[]

Definition at line 6964 of file target.c.

char* REGION_TYPE_STRINGS[]

Definition at line 6971 of file target.c.

char* THREAD_STATUS_STRINGS[]

Definition at line 6945 of file target.c.

char* TSTATUS_STRINGS[]

Definition at line 6933 of file target.c.