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 1794 of file target_api.c.
int _target_disable_sw_breakpoint | ( | struct target * | target, |
tid_t | tid, | ||
struct target_memmod * | mmod | ||
) |
Definition at line 1781 of file target_api.c.
int _target_enable_sw_breakpoint | ( | struct target * | target, |
tid_t | tid, | ||
struct target_memmod * | mmod | ||
) |
Definition at line 1768 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 1676 of file target_api.c.
int _target_remove_sw_breakpoint | ( | struct target * | target, |
tid_t | tid, | ||
struct target_memmod * | mmod | ||
) |
Definition at line 1738 of file target_api.c.
int _target_unchange_sw_breakpoint | ( | struct target * | target, |
tid_t | tid, | ||
struct target_memmod * | mmod | ||
) |
Definition at line 1809 of file target_api.c.
Definition at line 1072 of file target_api.c.
Definition at line 834 of file target_api.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.
Definition at line 1203 of file target_api.c.
int target_cregno | ( | struct target * | target, |
common_reg_t | creg, | ||
REG * | reg | ||
) |
Definition at line 1126 of file target_api.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.
Definition at line 1877 of file target_api.c.
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_dump_all_threads | ( | struct target * | target, |
FILE * | stream, | ||
int | detail | ||
) |
Definition at line 1500 of file target_api.c.
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.
Definition at line 1884 of file target_api.c.
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_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.
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.
Definition at line 1822 of file target_api.c.
Definition at line 1918 of file target_api.c.
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.
struct target_memmod* target_insert_sw_breakpoint | ( | struct target * | target, |
tid_t | tid, | ||
ADDR | addr | ||
) |
Definition at line 1729 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 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.
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.
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.
struct target_thread* target_load_current_thread | ( | struct target * | target, |
int | force | ||
) |
Definition at line 1305 of file target_api.c.
struct target_thread* target_load_thread | ( | struct target * | target, |
tid_t | tid, | ||
int | force | ||
) |
Definition at line 1311 of file target_api.c.
Definition at line 1671 of file target_api.c.
Definition at line 693 of file target_api.c.
Definition at line 713 of file target_api.c.
Definition at line 1666 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 869 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 880 of file target_api.c.
char* target_name | ( | struct target * | target | ) |
Definition at line 505 of file target_api.c.
Definition at line 1891 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 1620 of file target_api.c.
int target_open | ( | struct target * | target | ) |
Definition at line 513 of file target_api.c.
int target_pause | ( | struct target * | target | ) |
Definition at line 1027 of file target_api.c.
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.
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.
Definition at line 1114 of file target_api.c.
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.
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.
Definition at line 1903 of file target_api.c.
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.
target_status_t target_status | ( | struct target * | target | ) |
Definition at line 1046 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 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.
Definition at line 1851 of file target_api.c.
Definition at line 1858 of file target_api.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.
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.