Rizin
unix-like reverse engineering framework and cli tools
|
#include <rz_util/rz_log.h>
#include <rz_debug.h>
#include <sys/ptrace.h>
#include <sys/proc_info.h>
#include <libproc.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <mach/exception_types.h>
#include <mach/mach_init.h>
#include <mach/mach_port.h>
#include <mach/mach_interface.h>
#include <mach/mach_traps.h>
#include <mach/mach_types.h>
#include <mach/mach_error.h>
#include <mach/task.h>
#include <mach/task_info.h>
#include <mach/thread_act.h>
#include <mach/thread_info.h>
#include <mach/vm_map.h>
#include <mach-o/loader.h>
#include <mach-o/nlist.h>
#include <errno.h>
#include <unistd.h>
#include <sys/sysctl.h>
#include <sys/fcntl.h>
#include <sys/proc.h>
#include <mach/i386/thread_status.h>
#include <sys/ucontext.h>
#include <mach/i386/_structs.h>
Go to the source code of this file.
Classes | |
struct | coredump_thread_state_flavor_t |
struct | tir_t |
Macros | |
#define | LOG_MACH_ERROR(name, rc) |
#define | HAS_LIBPROC |
#define | ADDR "%8x" |
#define | HEADER_SIZE 0x1000 |
#define | IMAGE_OFFSET 0x201000 |
#define | KERNEL_LOWER 0x80000000 |
#define | REG_PC ((dbg->bits == RZ_SYS_BITS_64) ? 16 : 10) |
#define | REG_FL ((dbg->bits == RZ_SYS_BITS_64) ? 17 : 9) |
#define | REG_SP (7) |
#define | MAX_TSTATE_FLAVORS 10 |
#define | DEFAULT_COREFILE_DEST "core.%u" |
#define | RZ_DEBUG_REASON_MACH_RCV_INTERRUPTED -2 |
#define ADDR "%8x" |
Definition at line 119 of file xnu_debug.h.
#define DEFAULT_COREFILE_DEST "core.%u" |
Definition at line 260 of file xnu_debug.h.
#define HAS_LIBPROC |
Definition at line 49 of file xnu_debug.h.
#define HEADER_SIZE 0x1000 |
Definition at line 120 of file xnu_debug.h.
#define IMAGE_OFFSET 0x201000 |
Definition at line 121 of file xnu_debug.h.
#define KERNEL_LOWER 0x80000000 |
Definition at line 122 of file xnu_debug.h.
#define LOG_MACH_ERROR | ( | name, | |
rc | |||
) |
Definition at line 17 of file xnu_debug.h.
#define MAX_TSTATE_FLAVORS 10 |
Definition at line 259 of file xnu_debug.h.
#define REG_FL ((dbg->bits == RZ_SYS_BITS_64) ? 17 : 9) |
Definition at line 129 of file xnu_debug.h.
#define REG_PC ((dbg->bits == RZ_SYS_BITS_64) ? 16 : 10) |
Definition at line 128 of file xnu_debug.h.
#define REG_SP (7) |
Definition at line 130 of file xnu_debug.h.
#define RZ_DEBUG_REASON_MACH_RCV_INTERRUPTED -2 |
Definition at line 261 of file xnu_debug.h.
task_t pid_to_task | ( | int | pid | ) |
Definition at line 498 of file xnu_debug.c.
References eprintf, err, pid, RZ_LOG_ERROR, rz_str_get_null(), task_dbg, task_for_pid_ios9pangu(), and task_for_pid_workaround().
Referenced by rz_xnu_get_cur_thread(), rz_xnu_update_thread_list(), validate_mach_message(), xnu_continue(), xnu_create_exception_thread(), xnu_dbg_maps(), xnu_dbg_modules(), xnu_generate_corefile(), xnu_get_vmmap_entries_for_pid(), xnu_map_protect(), xnu_restore_exception_ports(), xnu_step(), and xnu_stop().
Definition at line 133 of file xnu_debug.c.
References dbg, rz_debug_t::pid, pid, r, rz_debug_t::reason, RZ_DEBUG_REASON_SIGNAL, RZ_LOG_ERROR, rz_debug_reason_t::signum, xnu_create_exception_thread(), xnu_stop(), and xnu_wait_for_exception().
Definition at line 227 of file xnu_debug.c.
References dbg, eprintf, pid, pid_to_task(), rz_xnu_get_cur_thread(), rz_xnu_get_thread(), _xnu_thread::stepping, and xnu_clear_trace_bit().
char* xnu_corefile_default_location | ( | void | ) |
Definition at line 1225 of file xnu_debug.c.
References cmp(), dbg, eprintf, rz_debug_map_t::file, get_kernel_base(), i, info(), list(), regress::m, mach_vm_region_recurse(), moduleAt(), regress::modules, mr(), rz_debug_map_t::name, NULL, PFMT64x, rz_debug_t::pid, pid_to_task(), proc_regionfilename(), rz_debug_map_clone(), rz_debug_map_new(), rz_list_append(), rz_list_free(), rz_list_new(), rz_list_sort(), rz_str_lchr(), rz_str_rwx_i(), snprintf, strdup(), unparse_inheritance(), ut64(), xnu_dbg_modules(), xnu_map_free(), and xwrz_testwx.
Definition at line 160 of file xnu_debug.c.
References dbg, eprintf, NULL, pid, PT_DETACH, r, rz_list_free(), task_dbg, rz_debug_t::threads, and xnu_restore_exception_ports().
Definition at line 827 of file xnu_debug.c.
References calloc(), cleanup(), COMMAND_SIZE, count, dbg, dest, eprintf, error(), tir_t::flavors, free(), get_mach_header_sizes(), tir_t::header, header, tir_t::hoffset, i, rz_debug_t::maps, MAX_TSTATE_FLAVORS, memcpy(), NULL, rz_debug_t::pid, pid_to_task(), _xnu_thread::port, rz_buf_append_buf(), rz_buf_append_bytes(), rz_buf_free(), rz_buf_new_with_bytes(), rz_list_free(), rz_list_length(), rz_list_new(), tir_t::tstate_size, xnu_build_corefile_header(), xnu_collect_thread_state(), xnu_dealloc_threads(), xnu_get_vmmap_entries_for_pid(), xnu_thread_list(), and xnu_write_mem_maps_to_buffer().
RzDebugPid* xnu_get_pid | ( | int | pid | ) |
Definition at line 907 of file xnu_debug.c.
References EINVAL, eprintf, foo, free(), malloc(), memcpy(), cmd_descs_generate::nargs, NULL, pid, rz_debug_pid_new(), and uidFromPid().
Definition at line 538 of file xnu_debug.c.
References count, info(), n, pid, and pid_to_task().
Referenced by xnu_generate_corefile().
RzDebugInfo* xnu_info | ( | RzDebug * | dbg, |
const char * | arg | ||
) |
Definition at line 397 of file xnu_debug.c.
References dbg, eprintf, NULL, rz_debug_t::pid, proc, rdi, RZ_DBG_PROC_RUN, RZ_DBG_PROC_SLEEP, RZ_DBG_PROC_STOP, RZ_NEW0, strdup(), rz_debug_t::tid, and xnu_get_kinfo_proc().
int xnu_init | ( | void | ) |
RzDebugMap* xnu_map_alloc | ( | RzDebug * | dbg, |
ut64 | addr, | ||
int | size | ||
) |
Definition at line 346 of file xnu_debug.c.
References addr, dbg, DEBUG_MAP_TAG_ID, eprintf, NULL, _xnu_thread::port, rz_debug_map_get(), rz_debug_map_sync(), rz_xnu_get_thread(), rz_debug_t::tid, and ut64().
Definition at line 368 of file xnu_debug.c.
References addr, dbg, LOG_MACH_ERROR, _xnu_thread::port, rz_xnu_get_thread(), and rz_debug_t::tid.
Definition at line 486 of file xnu_debug.c.
References addr, dbg, LOG_MACH_ERROR, pid_to_task(), rz_debug_t::tid, and xwrz_testwx.
char* xnu_reg_profile | ( | RzDebug * | dbg | ) |
Definition at line 252 of file xnu_debug.c.
References rz_debug_t::bits, dbg, eprintf, NULL, RZ_SYS_BITS_32, and RZ_SYS_BITS_64.
Definition at line 315 of file xnu_debug.c.
References dbg, memcpy(), RZ_MIN, RZ_REG_TYPE_DRX, RZ_REG_TYPE_FLG, RZ_REG_TYPE_GPR, RZ_REG_TYPE_SEG, rz_xnu_get_cur_thread(), rz_xnu_get_thread(), rz_xnu_thread_get_drx(), rz_xnu_thread_get_gpr(), _xnu_thread::state, _xnu_thread::state_size, and type.
Definition at line 279 of file xnu_debug.c.
References rz_debug_t::bits, dbg, _xnu_thread::gpr, memcpy(), RZ_MIN, RZ_REG_TYPE_DRX, RZ_SYS_BITS_64, rz_xnu_get_cur_thread(), rz_xnu_get_thread(), rz_xnu_thread_set_drx(), rz_xnu_thread_set_gpr(), and type.
Definition at line 112 of file xnu_debug.c.
References dbg, eprintf, rz_debug_t::pid, pid_to_task(), rz_xnu_get_cur_thread(), rz_xnu_get_thread(), _xnu_thread::stepping, rz_debug_t::tid, and xnu_set_trace_bit().
Definition at line 194 of file xnu_debug.c.
References eprintf, pid, pid_to_task(), and task_suspend_count().
Referenced by xnu_attach().
Definition at line 453 of file xnu_debug.c.
References dbg, eprintf, _xnu_thread::gpr, list(), memcpy(), _xnu_thread::name, _xnu_thread::port, rz_debug_pid_free(), rz_debug_pid_new(), rz_list_append(), rz_xnu_thread_get_gpr(), rz_xnu_update_thread_list(), _xnu_thread::state_size, and rz_debug_t::threads.
Referenced by xnu_generate_corefile().
Definition at line 108 of file xnu_debug.c.
References dbg, pid, and xnu_wait_for_exception().