Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
|
#include "config.h"
#include "common.h"
#include "glib_wrapper.h"
#include "arch.h"
#include "target_api.h"
#include "target.h"
#include "target_os.h"
#include "target_process.h"
#include "probe_api.h"
#include "probe.h"
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <signal.h>
#include <glib.h>
#include "target_linux_userproc.h"
#include "target_os_process.h"
#include "target_php.h"
#include "target_gdb.h"
Go to the source code of this file.
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 1729 of file target_api.c.
int _target_disable_sw_breakpoint | ( | struct target * | target, |
tid_t | tid, | ||
struct target_memmod * | mmod | ||
) |
Definition at line 1716 of file target_api.c.
int _target_enable_sw_breakpoint | ( | struct target * | target, |
tid_t | tid, | ||
struct target_memmod * | mmod | ||
) |
Definition at line 1703 of file target_api.c.
struct target_memmod* _target_insert_sw_breakpoint | ( | struct target * | target, |
tid_t | tid, | ||
ADDR | addr, | ||
int | is_phys, | ||
int | nowrite | ||
) |
Definition at line 1611 of file target_api.c.
int _target_remove_sw_breakpoint | ( | struct target * | target, |
tid_t | tid, | ||
struct target_memmod * | mmod | ||
) |
Definition at line 1673 of file target_api.c.
int _target_unchange_sw_breakpoint | ( | struct target * | target, |
tid_t | tid, | ||
struct target_memmod * | mmod | ||
) |
Definition at line 1744 of file target_api.c.
Definition at line 1028 of file target_api.c.
Definition at line 795 of file target_api.c.
struct target_spec* target_build_default_overlay_spec | ( | struct target * | target, |
tid_t | tid | ||
) |
Definition at line 711 of file target_api.c.
struct target_spec* target_build_spec | ( | target_type_t | type, |
target_mode_t | mode | ||
) |
Definition at line 394 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 1735 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 1446 of file target_api.c.
Definition at line 1138 of file target_api.c.
int target_cregno | ( | struct target * | target, |
common_reg_t | creg, | ||
REG * | reg | ||
) |
Definition at line 1077 of file target_api.c.
int target_detach_evloop | ( | struct target * | target | ) |
Definition at line 807 of file target_api.c.
int target_disable_feature | ( | struct target * | target, |
int | feature | ||
) |
Definition at line 1892 of file target_api.c.
Definition at line 1812 of file target_api.c.
Definition at line 1800 of file target_api.c.
int target_disable_sw_breakpoint | ( | struct target * | target, |
tid_t | tid, | ||
struct target_memmod * | mmod | ||
) |
Definition at line 1721 of file target_api.c.
void target_dump_all_threads | ( | struct target * | target, |
FILE * | stream, | ||
int | detail | ||
) |
Definition at line 1435 of file target_api.c.
Definition at line 1419 of file target_api.c.
int target_enable_feature | ( | struct target * | target, |
int | feature, | ||
void * | arg | ||
) |
Definition at line 1885 of file target_api.c.
Definition at line 1819 of file target_api.c.
Definition at line 1806 of file target_api.c.
int target_enable_sw_breakpoint | ( | struct target * | target, |
tid_t | tid, | ||
struct target_memmod * | mmod | ||
) |
Definition at line 1708 of file target_api.c.
int target_flush_all_threads | ( | struct target * | target | ) |
Definition at line 1275 of file target_api.c.
int target_flush_current_thread | ( | struct target * | target | ) |
Definition at line 1264 of file target_api.c.
Definition at line 1269 of file target_api.c.
void target_free_spec | ( | struct target_spec * | spec | ) |
Definition at line 436 of file target_api.c.
int target_gc_threads | ( | struct target * | target | ) |
Definition at line 1303 of file target_api.c.
uint64_t target_get_counter | ( | struct target * | target | ) |
Definition at line 1878 of file target_api.c.
uint64_t target_get_time | ( | struct target * | target | ) |
Definition at line 1871 of file target_api.c.
uint64_t target_get_tsc | ( | struct target * | target | ) |
Definition at line 1864 of file target_api.c.
Definition at line 1757 of file target_api.c.
Definition at line 1853 of file target_api.c.
GHashTable* target_hash_available_tids | ( | struct target * | target | ) |
Definition at line 1212 of file target_api.c.
GHashTable* target_hash_threads | ( | struct target * | target | ) |
Definition at line 1188 of file target_api.c.
void target_hold | ( | struct target * | target | ) |
Definition at line 1592 of file target_api.c.
int target_id | ( | struct target * | target | ) |
Definition at line 492 of file target_api.c.
struct target_memmod* target_insert_sw_breakpoint | ( | struct target * | target, |
tid_t | tid, | ||
ADDR | addr | ||
) |
Definition at line 1664 of file target_api.c.
struct target* target_instantiate | ( | struct target_spec * | spec, |
struct evloop * | evloop | ||
) |
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.
primary_target_specs | A struct target_spec, describing the "primary" target object to instantiate. |
base_target_specs | A GList of struct target_spec, describing the base target objects to instantiate. |
overlay_target_specs | A GList of struct target_spec, describing the overlay target objects to instantiate. |
evloop | An evloop that will "run" these target objects via evloop_run() or evloop_handleone(); see evloop_create() and target_monitor_evloop(). |
error_specs | A pointer to a GList that, if set, will be filled with target_spec objects that were not successfully instantiated and opened. |
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.
target_specs | A GList of struct target_spec, describing the kind of target objects to instantiate. |
evloop | An evloop that will "run" these target objects via evloop_run() or evloop_handleone(); see evloop_create() and target_monitor_evloop(). |
error_specs | A pointer to a GList that, if set, will be filled with target_spec objects that were not successfully instantiated and opened. |
Definition at line 271 of file target_api.c.
struct target* target_instantiate_overlay | ( | struct target * | target, |
tid_t | tid, | ||
struct target_spec * | spec | ||
) |
Definition at line 724 of file target_api.c.
Definition at line 824 of file target_api.c.
int target_is_open | ( | struct target * | target | ) |
Definition at line 1003 of file target_api.c.
int target_kill | ( | struct target * | target, |
int | sig | ||
) |
Definition at line 1587 of file target_api.c.
struct array_list* target_list_available_overlay_tids | ( | struct target * | target, |
target_type_t | type | ||
) |
Definition at line 633 of file target_api.c.
struct array_list* target_list_available_tids | ( | struct target * | target | ) |
Definition at line 1207 of file target_api.c.
struct array_list* target_list_overlays | ( | struct target * | target | ) |
Definition at line 663 of file target_api.c.
struct array_list* target_list_threads | ( | struct target * | target | ) |
Definition at line 1168 of file target_api.c.
struct array_list* target_list_tids | ( | struct target * | target | ) |
Definition at line 1145 of file target_api.c.
int target_load_all_threads | ( | struct target * | target, |
int | force | ||
) |
Definition at line 1253 of file target_api.c.
int target_load_available_threads | ( | struct target * | target, |
int | force | ||
) |
Definition at line 1235 of file target_api.c.
struct target_thread* target_load_current_thread | ( | struct target * | target, |
int | force | ||
) |
Definition at line 1240 of file target_api.c.
struct target_thread* target_load_thread | ( | struct target * | target, |
tid_t | tid, | ||
int | force | ||
) |
Definition at line 1246 of file target_api.c.
Definition at line 1606 of file target_api.c.
Definition at line 670 of file target_api.c.
Definition at line 690 of file target_api.c.
Definition at line 1601 of file target_api.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!).
target | The target object to monitor. |
Definition at line 830 of file target_api.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!).
evloop | The evloop object to monitor (via evloop_handleone()). | |
timeout | A timeout object that will be passed to select(). | |
[out] | target | A pointer to a target object that will be filled in with the target just handled. |
[out] | status | A pointer to a target_status_t that will be filled in with the status of the target just handled. |
Definition at line 841 of file target_api.c.
char* target_name | ( | struct target * | target | ) |
Definition at line 488 of file target_api.c.
Definition at line 1826 of file target_api.c.
int target_obj_flags_propagate | ( | struct target * | target, |
obj_flags_t | orf, | ||
obj_flags_t | nandf | ||
) |
Propagates object tracking flags to a target. Nobody should call this directly; the OBJ*() macros in object.h call it.
Definition at line 1555 of file target_api.c.
int target_open | ( | struct target * | target | ) |
Definition at line 496 of file target_api.c.
int target_pause | ( | struct target * | target | ) |
Definition at line 988 of file target_api.c.
Definition at line 1258 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 962 of file target_api.c.
unsigned char* target_read_addr | ( | struct target * | target, |
ADDR | addr, | ||
unsigned long | length, | ||
unsigned char * | buf | ||
) |
Definition at line 1014 of file target_api.c.
REGVAL target_read_creg | ( | struct target * | target, |
tid_t | tid, | ||
common_reg_t | reg | ||
) |
Definition at line 1119 of file target_api.c.
unsigned char* target_read_physaddr | ( | struct target * | target, |
ADDR | paddr, | ||
unsigned long | length, | ||
unsigned char * | buf | ||
) |
Definition at line 1039 of file target_api.c.
Definition at line 1083 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 1103 of file target_api.c.
Definition at line 1065 of file target_api.c.
Definition at line 1071 of file target_api.c.
void target_release | ( | struct target * | target | ) |
Definition at line 1596 of file target_api.c.
int target_remove_sw_breakpoint | ( | struct target * | target, |
tid_t | tid, | ||
struct target_memmod * | mmod | ||
) |
Definition at line 1695 of file target_api.c.
int target_resume | ( | struct target * | target | ) |
Definition at line 973 of file target_api.c.
int target_set_active_probing | ( | struct target * | target, |
active_probe_flags_t | flags | ||
) |
Definition at line 616 of file target_api.c.
Definition at line 1771 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 1778 of file target_api.c.
Definition at line 1838 of file target_api.c.
Definition at line 1844 of file target_api.c.
int target_snprintf | ( | struct target * | target, |
char * | buf, | ||
int | bufsiz | ||
) |
Definition at line 790 of file target_api.c.
target_status_t target_status | ( | struct target * | target | ) |
Definition at line 1007 of file target_api.c.
int target_thread_snprintf | ( | struct target * | target, |
tid_t | tid, | ||
char * | buf, | ||
int | bufsiz, | ||
int | detail, | ||
char * | sep, | ||
char * | kvsep | ||
) |
Definition at line 1360 of file target_api.c.
thread_status_t target_thread_status | ( | struct target * | target, |
tid_t | tid | ||
) |
Definition at line 1899 of file target_api.c.
target_type_t target_type | ( | struct target * | target | ) |
Definition at line 484 of file target_api.c.
int target_unchange_sw_breakpoint | ( | struct target * | target, |
tid_t | tid, | ||
struct target_memmod * | mmod | ||
) |
Definition at line 1749 of file target_api.c.
Definition at line 1786 of file target_api.c.
Definition at line 1793 of file target_api.c.
unsigned long target_write_addr | ( | struct target * | target, |
ADDR | addr, | ||
unsigned long | length, | ||
unsigned char * | buf | ||
) |
Definition at line 1021 of file target_api.c.
int target_write_creg | ( | struct target * | target, |
tid_t | tid, | ||
common_reg_t | reg, | ||
REGVAL | value | ||
) |
Definition at line 1128 of file target_api.c.
unsigned long target_write_physaddr | ( | struct target * | target, |
ADDR | paddr, | ||
unsigned long | length, | ||
unsigned char * | buf | ||
) |
Definition at line 1052 of file target_api.c.
Definition at line 1092 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 1111 of file target_api.c.