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 | Functions | Variables
target_os_linux_generic.c File Reference
#include "config.h"
#include <assert.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <glib.h>
#include "common.h"
#include "glib_wrapper.h"
#include "arch.h"
#include "arch_x86.h"
#include "arch_x86_64.h"
#include "binfile.h"
#include "target.h"
#include "target_event.h"
#include "target_os.h"
#include "target_os_linux_generic.h"
Include dependency graph for target_os_linux_generic.c:

Go to the source code of this file.

Data Structures

struct  os_linux_signame
 
struct  old_linux_syscall_probe_state
 
struct  match_pid_data
 
struct  __update_module_data
 

Macros

#define LOCAL_TIF_SIGPENDING   (1UL << 2)
 
#define SYSCALL_GLOBAL_ENTRY_PROBE   "os_linux_syscall_entry_probe"
 
#define SYSCALL_GLOBAL_RET_PROBE   "os_linux_syscall_ret_probe"
 
#define DCACHE_AUTOFS_PENDING   0x0001
 
#define DCACHE_NFSFS_RENAMED   0x0002
 
#define DCACHE_DISCONNECTED   0x0004
 
#define DCACHE_REFERENCED   0x0008
 
#define DCACHE_UNHASHED   0x0010
 
#define DCACHE_INOTIFY_PARENT_WATCHED   0x0020
 
#define _LINUX_MAX_ERRNO   4095
 
#define _LINUX_IS_ERR(x)   unlikely((x) >= (REGVAL)-_LINUX_MAX_ERRNO)
 

Functions

struct target_threados_linux_load_thread_from_value (struct target *target, struct value *taskv)
 
struct target_threados_linux_load_current_thread (struct target *target, int force)
 
result_t os_linux_int3_handler (struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
 
result_t os_linux_debug_handler (struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
 
int os_linux_attach (struct target *target)
 
int os_linux_fini (struct target *target)
 
int os_linux_postloadinit (struct target *target)
 
int os_linux_postopened (struct target *target)
 
int os_linux_handle_exception (struct target *target)
 
target_os_type_t os_linux_type (struct target *target)
 
uint64_t os_linux_version (struct target *target)
 
int os_linux_version_cmp (struct target *target, uint64_t vers)
 
char * os_linux_version_string (struct target *target)
 
int os_linux_thread_get_pgd_phys (struct target *target, struct target_thread *tthread, ADDR *pgdp)
 
int os_linux_thread_is_user (struct target *target, struct target_thread *tthread)
 
struct target_threados_linux_thread_get_leader (struct target *target, struct target_thread *tthread)
 
int os_linux_signal_enqueue (struct target *target, struct target_thread *tthread, int signo, void *data)
 
const char * os_linux_signal_to_name (struct target *target, int signo)
 
int os_linux_signal_from_name (struct target *target, const char *name)
 
int os_linux_syscall_table_load (struct target *target)
 
int os_linux_syscall_table_unload (struct target *target)
 
GHashTable * os_linux_syscall_table_get (struct target *target)
 
struct target_os_syscallos_linux_syscall_lookup_name (struct target *target, char *name)
 
struct target_os_syscallos_linux_syscall_lookup_num (struct target *target, int num)
 
struct target_os_syscallos_linux_syscall_lookup_addr (struct target *target, ADDR addr)
 
struct probeos_linux_syscall_probe (struct target *target, tid_t tid, struct target_os_syscall *syscall, probe_handler_t pre_handler, probe_handler_t post_handler, void *handler_data)
 
struct probeos_linux_syscall_probe_all (struct target *target, tid_t tid, probe_handler_t pre_handler, probe_handler_t post_handler, void *handler_data)
 
num_t os_linux_get_preempt_count (struct target *target)
 
ADDR os_linux_current_thread_ptr (struct target *target, REGVAL kernel_esp)
 
struct symbolos_linux_get_task_struct_type (struct target *target)
 
struct symbolos_linux_get_task_struct_type_ptr (struct target *target)
 
struct valueos_linux_load_current_thread_as_type (struct target *target, struct symbol *datatype, REGVAL kernel_esp)
 
int os_linux_get_task_pid (struct target *target, struct value *task)
 
struct valueos_linux_get_task (struct target *target, tid_t tid)
 
char * os_linux_d_path (struct target *target, struct value *dentry, struct value *vfsmnt, struct value *root_dentry, struct value *root_vfsmnt, char *buf, int buflen)
 
char * os_linux_file_get_path (struct target *target, struct value *task, struct value *file, char *ibuf, int buflen)
 
int os_linux_list_for_each_struct (struct target *t, struct bsymbol *bsymbol, char *list_head_member_name, int nofree, os_linux_list_iterator_t iterator, void *data)
 
int os_linux_list_for_each_entry (struct target *t, struct bsymbol *btype, struct bsymbol *list_head, char *list_head_member_name, int nofree, os_linux_list_iterator_t iterator, void *data)
 
struct array_listos_linux_list_available_tids (struct target *target)
 
int os_linux_load_available_threads (struct target *target, int force)
 
struct target_threados_linux_load_thread (struct target *target, tid_t tid, int force)
 
void os_linux_free_thread_state (struct target *target, void *state)
 
int os_linux_flush_current_thread (struct target *target)
 
int os_linux_flush_thread (struct target *target, tid_t tid)
 
int os_linux_invalidate_thread (struct target *target, struct target_thread *tthread)
 
int os_linux_thread_snprintf (struct target *target, struct target_thread *tthread, char *buf, int bufsiz, int detail, char *sep, char *kvsep)
 
result_t os_linux_active_memory_handler (struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
 
result_t os_linux_active_thread_entry_handler (struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
 
result_t os_linux_active_thread_exit_handler (struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
 
GHashTable * os_linux_processes_load (struct target *target)
 
struct target_processos_linux_process_load (struct target *target, struct target_thread *tthread)
 
int os_linux_set_active_probing (struct target *target, active_probe_flags_t flags)
 
int os_linux_thread_singlestep (struct target *target, tid_t tid, int isbp, struct target *overlay, int force_emulate)
 
int os_linux_thread_singlestep_end (struct target *target, tid_t tid, struct target *overlay, int force_emulate)
 
void os_linux_generic_register (void)
 

Variables

struct probe_ops os_linux_syscall_ret_probe_ops
 
struct probe_ops os_linux_global_syscall_ret_probe_ops
 
struct target_personality_ops os_linux_generic_personality_ops
 
struct target_os_ops os_linux_generic_os_ops
 

Macro Definition Documentation

#define _LINUX_IS_ERR (   x)    unlikely((x) >= (REGVAL)-_LINUX_MAX_ERRNO)

Definition at line 7991 of file target_os_linux_generic.c.

#define _LINUX_MAX_ERRNO   4095

Definition at line 7990 of file target_os_linux_generic.c.

#define DCACHE_AUTOFS_PENDING   0x0001

Definition at line 3460 of file target_os_linux_generic.c.

#define DCACHE_DISCONNECTED   0x0004

Definition at line 3462 of file target_os_linux_generic.c.

#define DCACHE_INOTIFY_PARENT_WATCHED   0x0020

Definition at line 3465 of file target_os_linux_generic.c.

#define DCACHE_NFSFS_RENAMED   0x0002

Definition at line 3461 of file target_os_linux_generic.c.

#define DCACHE_REFERENCED   0x0008

Definition at line 3463 of file target_os_linux_generic.c.

#define DCACHE_UNHASHED   0x0010

Definition at line 3464 of file target_os_linux_generic.c.

#define LOCAL_TIF_SIGPENDING   (1UL << 2)
#define SYSCALL_GLOBAL_ENTRY_PROBE   "os_linux_syscall_entry_probe"

Definition at line 2619 of file target_os_linux_generic.c.

#define SYSCALL_GLOBAL_RET_PROBE   "os_linux_syscall_ret_probe"

Definition at line 2620 of file target_os_linux_generic.c.

Function Documentation

result_t os_linux_active_memory_handler ( struct probe probe,
tid_t  tid,
void *  handler_data,
struct probe trigger,
struct probe base 
)

Definition at line 7749 of file target_os_linux_generic.c.

result_t os_linux_active_thread_entry_handler ( struct probe probe,
tid_t  tid,
void *  handler_data,
struct probe trigger,
struct probe base 
)

Definition at line 7993 of file target_os_linux_generic.c.

result_t os_linux_active_thread_exit_handler ( struct probe probe,
tid_t  tid,
void *  handler_data,
struct probe trigger,
struct probe base 
)

Definition at line 8103 of file target_os_linux_generic.c.

int os_linux_attach ( struct target target)

Definition at line 58 of file target_os_linux_generic.c.

ADDR os_linux_current_thread_ptr ( struct target target,
REGVAL  kernel_esp 
)

Definition at line 3204 of file target_os_linux_generic.c.

char* os_linux_d_path ( struct target target,
struct value dentry,
struct value vfsmnt,
struct value root_dentry,
struct value root_vfsmnt,
char *  buf,
int  buflen 
)

Definition at line 3471 of file target_os_linux_generic.c.

result_t os_linux_debug_handler ( struct probe probe,
tid_t  tid,
void *  handler_data,
struct probe trigger,
struct probe base 
)

Definition at line 1634 of file target_os_linux_generic.c.

char* os_linux_file_get_path ( struct target target,
struct value task,
struct value file,
char *  ibuf,
int  buflen 
)

Definition at line 3687 of file target_os_linux_generic.c.

int os_linux_fini ( struct target target)

Definition at line 431 of file target_os_linux_generic.c.

int os_linux_flush_current_thread ( struct target target)

WARNING: esp and ss may not be valid if the sleeping thread was interrupted while it was in the kernel, because the interrupt gate does not push ss and esp; see include/asm-i386/processor.h .

Definition at line 6224 of file target_os_linux_generic.c.

int os_linux_flush_thread ( struct target target,
tid_t  tid 
)

WARNING: esp and ss may not be valid if the sleeping thread was interrupted while it was in the kernel, because the interrupt gate does not push ss and esp; see include/asm-i386/processor.h .

XXX: what the heck?? memset(&ltstate->context,0,sizeof(vcpu_guest_context_t)); ltstate->context.user_regs.eip = ltstate->eip; ltstate->context.user_regs.esp = ltstate->esp; ltstate->context.user_regs.fs = ltstate->fs; ltstate->context.user_regs.gs = ltstate->gs;

Definition at line 6503 of file target_os_linux_generic.c.

void os_linux_free_thread_state ( struct target target,
void *  state 
)

Definition at line 5136 of file target_os_linux_generic.c.

void os_linux_generic_register ( void  )

Globals.

Definition at line 9476 of file target_os_linux_generic.c.

num_t os_linux_get_preempt_count ( struct target target)

Definition at line 3101 of file target_os_linux_generic.c.

struct value* os_linux_get_task ( struct target target,
tid_t  tid 
)

Definition at line 3438 of file target_os_linux_generic.c.

int os_linux_get_task_pid ( struct target target,
struct value task 
)

Definition at line 3390 of file target_os_linux_generic.c.

struct symbol* os_linux_get_task_struct_type ( struct target target)

Definition at line 3285 of file target_os_linux_generic.c.

struct symbol* os_linux_get_task_struct_type_ptr ( struct target target)

Definition at line 3299 of file target_os_linux_generic.c.

int os_linux_handle_exception ( struct target target)

Definition at line 1755 of file target_os_linux_generic.c.

result_t os_linux_int3_handler ( struct probe probe,
tid_t  tid,
void *  handler_data,
struct probe trigger,
struct probe base 
)

Definition at line 1495 of file target_os_linux_generic.c.

int os_linux_invalidate_thread ( struct target target,
struct target_thread tthread 
)

Definition at line 7086 of file target_os_linux_generic.c.

struct array_list* os_linux_list_available_tids ( struct target target)

Definition at line 3988 of file target_os_linux_generic.c.

int os_linux_list_for_each_entry ( struct target t,
struct bsymbol btype,
struct bsymbol list_head,
char *  list_head_member_name,
int  nofree,
os_linux_list_iterator_t  iterator,
void *  data 
)

Definition at line 3877 of file target_os_linux_generic.c.

int os_linux_list_for_each_struct ( struct target t,
struct bsymbol bsymbol,
char *  list_head_member_name,
int  nofree,
os_linux_list_iterator_t  iterator,
void *  data 
)

Definition at line 3770 of file target_os_linux_generic.c.

int os_linux_load_available_threads ( struct target target,
int  force 
)

Definition at line 4050 of file target_os_linux_generic.c.

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

WARNING: esp and ss may not be valid if the sleeping thread was interrupted while it was in the kernel, because the interrupt gate does not push ss and esp; see include/asm-i386/processor.h .

(SOFTIRQ_COUNT(preempt_count) || HARDIRQ_COUNT(preempt_count))) {

Definition at line 4291 of file target_os_linux_generic.c.

struct value* os_linux_load_current_thread_as_type ( struct target target,
struct symbol datatype,
REGVAL  kernel_esp 
)

Definition at line 3372 of file target_os_linux_generic.c.

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

Definition at line 4099 of file target_os_linux_generic.c.

struct target_thread * os_linux_load_thread_from_value ( struct target target,
struct value taskv 
)

Prototypes.

WARNING: esp and ss may not be valid if the sleeping thread was interrupted while it was in the kernel, because the interrupt gate does not push ss and esp; see include/asm-i386/processor.h .

Definition at line 5166 of file target_os_linux_generic.c.

int os_linux_postloadinit ( struct target target)

Definition at line 500 of file target_os_linux_generic.c.

int os_linux_postopened ( struct target target)

Definition at line 1208 of file target_os_linux_generic.c.

struct target_process* os_linux_process_load ( struct target target,
struct target_thread tthread 
)

Definition at line 8821 of file target_os_linux_generic.c.

GHashTable* os_linux_processes_load ( struct target target)

Definition at line 8817 of file target_os_linux_generic.c.

int os_linux_set_active_probing ( struct target target,
active_probe_flags_t  flags 
)

Definition at line 8960 of file target_os_linux_generic.c.

int os_linux_signal_enqueue ( struct target target,
struct target_thread tthread,
int  signo,
void *  data 
)

Definition at line 2038 of file target_os_linux_generic.c.

int os_linux_signal_from_name ( struct target target,
const char *  name 
)

Definition at line 2221 of file target_os_linux_generic.c.

const char* os_linux_signal_to_name ( struct target target,
int  signo 
)

Definition at line 2209 of file target_os_linux_generic.c.

struct target_os_syscall* os_linux_syscall_lookup_addr ( struct target target,
ADDR  addr 
)

Definition at line 2479 of file target_os_linux_generic.c.

struct target_os_syscall* os_linux_syscall_lookup_name ( struct target target,
char *  name 
)

Definition at line 2446 of file target_os_linux_generic.c.

struct target_os_syscall* os_linux_syscall_lookup_num ( struct target target,
int  num 
)

Definition at line 2462 of file target_os_linux_generic.c.

struct probe* os_linux_syscall_probe ( struct target target,
tid_t  tid,
struct target_os_syscall syscall,
probe_handler_t  pre_handler,
probe_handler_t  post_handler,
void *  handler_data 
)

Definition at line 3027 of file target_os_linux_generic.c.

struct probe* os_linux_syscall_probe_all ( struct target target,
tid_t  tid,
probe_handler_t  pre_handler,
probe_handler_t  post_handler,
void *  handler_data 
)

Definition at line 3073 of file target_os_linux_generic.c.

GHashTable* os_linux_syscall_table_get ( struct target target)

Definition at line 2442 of file target_os_linux_generic.c.

int os_linux_syscall_table_load ( struct target target)

Definition at line 2297 of file target_os_linux_generic.c.

int os_linux_syscall_table_unload ( struct target target)

Definition at line 2400 of file target_os_linux_generic.c.

struct target_thread* os_linux_thread_get_leader ( struct target target,
struct target_thread tthread 
)

Definition at line 1972 of file target_os_linux_generic.c.

int os_linux_thread_get_pgd_phys ( struct target target,
struct target_thread tthread,
ADDR pgdp 
)

Definition at line 1953 of file target_os_linux_generic.c.

int os_linux_thread_is_user ( struct target target,
struct target_thread tthread 
)

Definition at line 1961 of file target_os_linux_generic.c.

int os_linux_thread_singlestep ( struct target target,
tid_t  tid,
int  isbp,
struct target overlay,
int  force_emulate 
)

Definition at line 9327 of file target_os_linux_generic.c.

int os_linux_thread_singlestep_end ( struct target target,
tid_t  tid,
struct target overlay,
int  force_emulate 
)

Definition at line 9371 of file target_os_linux_generic.c.

int os_linux_thread_snprintf ( struct target target,
struct target_thread tthread,
char *  buf,
int  bufsiz,
int  detail,
char *  sep,
char *  kvsep 
)

Definition at line 7114 of file target_os_linux_generic.c.

target_os_type_t os_linux_type ( struct target target)

Definition at line 1831 of file target_os_linux_generic.c.

uint64_t os_linux_version ( struct target target)

Definition at line 1842 of file target_os_linux_generic.c.

int os_linux_version_cmp ( struct target target,
uint64_t  vers 
)

Definition at line 1935 of file target_os_linux_generic.c.

char* os_linux_version_string ( struct target target)

Definition at line 1948 of file target_os_linux_generic.c.

Variable Documentation

struct target_os_ops os_linux_generic_os_ops

Definition at line 9442 of file target_os_linux_generic.c.

struct target_personality_ops os_linux_generic_personality_ops
Initial value:
= {
.attach = os_linux_attach,
.init = NULL,
.fini = os_linux_fini,
.postloadinit = os_linux_postloadinit,
.postopened = os_linux_postopened,
.set_active_probing = os_linux_set_active_probing,
.free_thread_state = os_linux_free_thread_state,
.list_available_tids = os_linux_list_available_tids,
.load_thread = os_linux_load_thread,
.load_current_thread = os_linux_load_current_thread,
.load_available_threads = os_linux_load_available_threads,
.flush_thread = os_linux_flush_thread,
.flush_current_thread = os_linux_flush_current_thread,
.invalidate_thread = os_linux_invalidate_thread,
.thread_snprintf = os_linux_thread_snprintf,
.copy_registers = target_regcache_copy_registers,
.readreg_tidctxt = target_regcache_readreg_tidctxt,
.writereg_tidctxt = target_regcache_writereg_tidctxt,
}
REGVAL target_regcache_readreg_tidctxt(struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg)
Definition: target.c:6885
int os_linux_set_active_probing(struct target *target, active_probe_flags_t flags)
GHashTable * target_regcache_copy_registers(struct target *target, tid_t tid)
Definition: target.c:6862
struct target_thread * os_linux_load_thread(struct target *target, tid_t tid, int force)
struct array_list * os_linux_list_available_tids(struct target *target)
int os_linux_load_available_threads(struct target *target, int force)
int target_regcache_writereg_tidctxt(struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg, REGVAL value)
Definition: target.c:6907
struct target_thread * os_linux_load_current_thread(struct target *target, int force)
int os_linux_postopened(struct target *target)
int os_linux_invalidate_thread(struct target *target, struct target_thread *tthread)
int os_linux_thread_snprintf(struct target *target, struct target_thread *tthread, char *buf, int bufsiz, int detail, char *sep, char *kvsep)
int os_linux_postloadinit(struct target *target)
REGVAL target_regcache_readreg(struct target *target, tid_t tid, REG reg)
Definition: target.c:6528
int os_linux_flush_current_thread(struct target *target)
int os_linux_fini(struct target *target)
void os_linux_free_thread_state(struct target *target, void *state)
int os_linux_flush_thread(struct target *target, tid_t tid)
int os_linux_attach(struct target *target)
int target_regcache_writereg(struct target *target, tid_t tid, REG reg, REGVAL value)
Definition: target.c:6569

Definition at line 9414 of file target_os_linux_generic.c.

struct probe_ops os_linux_global_syscall_ret_probe_ops
Initial value:
= {
.gettype = _os_linux_global_syscall_probe_gettype,
}
void * target_os_syscall_probe_summarize_tid(struct probe *probe, tid_t tid)
Definition: target_os.c:495
void * target_os_syscall_probe_summarize(struct probe *probe)
Definition: target_os.c:491

Definition at line 3066 of file target_os_linux_generic.c.

struct probe_ops os_linux_syscall_ret_probe_ops
Initial value:
= {
.gettype = _os_linux_syscall_probe_gettype,
.get_raw_value_table = probe_value_get_raw_table_function_ee,
.get_last_value_table = probe_value_get_last_table_function_ee,
.get_last_raw_value_table = probe_value_get_last_raw_table_function_ee,
.get_last_raw_value = probe_value_get_last_raw_function_ee,
.values_notify_phase = probe_value_notify_phase_function_ee,
.values_free = probe_values_free_stacked,
}
void * target_os_syscall_probe_summarize_tid(struct probe *probe, tid_t tid)
Definition: target_os.c:495
void * target_os_syscall_probe_summarize(struct probe *probe)
Definition: target_os.c:491
struct value * probe_value_get_function_ee(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:467
void probe_values_free_stacked(struct probe *probe)
Definition: probe_value.c:149
struct value * probe_value_get_last_function_ee(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:477
GHashTable * probe_value_get_raw_table_function_ee(struct probe *probe, tid_t tid)
Definition: probe_value.c:376
GHashTable * probe_value_get_table_function_ee(struct probe *probe, tid_t tid)
Definition: probe_value.c:372
void probe_value_notify_phase_function_ee(struct probe *probe, tid_t tid, probe_handler_phase_t phase)
Definition: probe_value.c:96
struct value * probe_value_get_last_raw_function_ee(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:482
struct value * probe_value_get_raw_function_ee(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:472
GHashTable * probe_value_get_last_raw_table_function_ee(struct probe *probe, tid_t tid)
Definition: probe_value.c:384
GHashTable * probe_value_get_last_table_function_ee(struct probe *probe, tid_t tid)
Definition: probe_value.c:380

Definition at line 3009 of file target_os_linux_generic.c.