Blame include/sys/debug.h

045354
#ifndef _SYS_DEBUG_H
045354
#define _SYS_DEBUG_H
045354
44a67f
#include <stdint.h>
44a67f
#include <stddef.h>
44a67f
#include <signal.h>
44a67f
#include <unistd.h>
44a67f
045354
#ifdef __cplusplus
045354
extern "C" {
045354
#endif
045354
44a67f
/* debug states */
44a67f
enum __dbg_state {
44a67f
	__DBG_STATE_IDLE,
44a67f
	__DBG_STATE_REPLY_PENDING,
44a67f
44a67f
	__DBG_STATE_CREATE_THREAD,
44a67f
	__DBG_STATE_CREATE_PROCESS,
44a67f
44a67f
	__DBG_STATE_EXIT_THREAD,
44a67f
	__DBG_STATE_EXIT_PROCESS,
44a67f
44a67f
	__DBG_STATE_EXCEPTION,
44a67f
	__DBG_STATE_BREAKPOINT,
44a67f
	__DBG_STATE_SINGLE_STEP,
44a67f
44a67f
	__DBG_STATE_DLL_LOAD,
44a67f
	__DBG_STATE_DLL_UNLOAD,
44a67f
};
44a67f
45970c
/* debug process/session info */
45970c
enum __dbg_info {
45970c
	__DBG_INFO_IMAGE_RPATH,
45970c
	__DBG_INFO_IMAGE_APATH,
70e4b1
	__DBG_INFO_IMAGE_NPATH,
45970c
	__DBG_INFO_IMAGE_DPATH,
45970c
	__DBG_INFO_REPORTED_IMAGE_RPATH,
45970c
	__DBG_INFO_REPORTED_IMAGE_APATH,
45970c
	__DBG_INFO_REPORTED_IMAGE_NPATH,
45970c
	__DBG_INFO_REPORTED_IMAGE_DPATH,
70e4b1
	__DBG_INFO_CACHED_MODULE_LIST,
70e4b1
	__DBG_INFO_LOADER_MODULE_LIST,
70e4b1
	__DBG_INFO_DAEMON_MODULE_LIST,
70e4b1
	__DBG_INFO_MODULE_RPATH,
70e4b1
	__DBG_INFO_MODULE_APATH,
70e4b1
	__DBG_INFO_MODULE_NPATH,
70e4b1
	__DBG_INFO_MODULE_DPATH,
45970c
	__DBG_INFO_CAP,
45970c
};
45970c
44a67f
/* debug responses */
44a67f
#define __DBG_RESPONSE_CONTINUE                 (0x00010002)
44a67f
#define __DBG_RESPONSE_EXCEPTION_HANDLED        (0x00010001)
44a67f
#define __DBG_RESPONSE_EXCEPTION_NOT_HANDLED    (0x80010001)
44a67f
#define __DBG_RESPONSE_REPLY_LATER              (0x40010001)
44a67f
#define __DBG_RESPONSE_TERMINATE_PROCESS        (0x40010004)
44a67f
#define __DBG_RESPONSE_TERMINATE_THREAD         (0x40010003)
44a67f
44a67f
/* thread types */
44a67f
#define __DBG_THREAD_TYPE_UNKNOWN       0x00
44a67f
#define __DBG_THREAD_TYPE_PTHREAD       0x01
44a67f
#define __DBG_THREAD_TYPE_DAEMON        0x02
44a67f
#define __DBG_THREAD_TYPE_PTYREF        0x03
44a67f
#define __DBG_THREAD_TYPE_POLLER        0x04
44a67f
#define __DBG_THREAD_TYPE_WAITER        0x05
44a67f
#define __DBG_THREAD_TYPE_TIMER         0x06
44a67f
#define __DBG_THREAD_TYPE_BRIDGE        0x07
44a67f
#define __DBG_THREAD_TYPE_PIPEIN        0x08
44a67f
#define __DBG_THREAD_TYPE_PIPEOUT       0x09
44a67f
44a67f
#define __DBG_THREAD_TYPE_TTYANY        0x40
44a67f
#define __DBG_THREAD_TYPE_TTYSRV        0x41
44a67f
#define __DBG_THREAD_TYPE_TTYSVC        0x42
44a67f
#define __DBG_THREAD_TYPE_TTYASYNC      0x43
44a67f
#define __DBG_THREAD_TYPE_TTYCLIENT     0x44
44a67f
#define __DBG_THREAD_TYPE_TTYDEBUG      0x45
44a67f
#define __DBG_THREAD_TYPE_TTYCONN       0x46
44a67f
44a67f
/* exception source bits */
44a67f
#define __DBG_EXCEPTION_SOURCE_UNKNOWN  0x00
44a67f
#define __DBG_EXCEPTION_SOURCE_HARDWARE 0x01
44a67f
#define __DBG_EXCEPTION_SOURCE_SOFTWARE 0x02
44a67f
#define __DBG_EXCEPTION_SOURCE_KERNEL   0x04
44a67f
#define __DBG_EXCEPTION_SOURCE_USER     0x08
44a67f
bb1628
/* strace,ldso */
bb1628
struct __strace {
bb1628
	size_t		size;
bb1628
	const char *	loader;
bb1628
	int		fdlog;
bb1628
	uint32_t	flags;
bb1628
	uint32_t	sysmask[16];
bb1628
	uint32_t	dbgmask[16];
bb1628
	uint32_t	osmask [32];
bb1628
};
bb1628
44a67f
/* exception record */
44a67f
struct __erec {
44a67f
	uint32_t        exception_code;
44a67f
	uint32_t        exception_flags;
44a67f
	struct __erec * exception_record;
44a67f
	void *          exception_address;
44a67f
	uint32_t        exception_params;
44a67f
	uintptr_t       exception_info[0xf];
44a67f
};
44a67f
44a67f
/* debug event alpha definition */
44a67f
struct __dbg_event {
44a67f
	int             evttype;
44a67f
	int             evtzone;
44a67f
44a67f
	int32_t         estatus;
44a67f
	int32_t         eresponse;
44a67f
44a67f
	uint64_t        evtkey;
44a67f
	uint64_t        evtqpc;
44a67f
44a67f
	pid_t           syspid;
44a67f
	pid_t           systid;
44a67f
f5c641
	pid_t           child_syspid;
f5c641
	pid_t           child_systid;
f5c641
44a67f
	mcontext_t *    thread_context;
44a67f
	siginfo_t *     thread_siginfo;
44a67f
44a67f
	stack_t *       thread_cstack;
44a67f
	stack_t *       thread_astack;
44a67f
	sigset_t *      thread_sigmask;
44a67f
44a67f
	struct tstat *  thread_stat;
44a67f
	struct __teb *  thread_teb;
44a67f
	struct __tlca * thread_tlca;
44a67f
44a67f
	struct __erec * exception_record;
44a67f
	uint32_t        exception_priority;
44a67f
	uint32_t        exception_source;
44a67f
44a67f
	int             syscall_depth;
44a67f
	int             syscall_number;
44a67f
	intptr_t        syscall_result;
44a67f
        intptr_t        syscall_params[6];
44a67f
44a67f
	uint32_t *      thread_subsystem_key;
44a67f
	void *          thread_start_address;
44a67f
	int32_t *       thread_exit_code;
44a67f
44a67f
	uint32_t *      process_subsystem_key;
44a67f
	void *          process_image_handle;
44a67f
	void *          process_image_base;
44a67f
	int32_t *       process_exit_code;
44a67f
44a67f
	void *          module_image_handle;
44a67f
	void *          module_image_base;
44a67f
44a67f
	uint32_t        dbg_info_offset;
44a67f
	uint32_t        dbg_info_size;
44a67f
44a67f
	const char *    image_rpath;
44a67f
	const char *    image_apath;
44a67f
	const char *    image_npath;
44a67f
	const char *    image_dpath;
44a67f
};
44a67f
f81684
/* debug loaded module alpha definition */
f81684
struct __dbg_module_info {
f81684
	void *		module_base;
f81684
	void *		module_record;
f81684
f81684
	char *		module_name;
f81684
	void *		module_ctx;
f81684
f81684
	int		module_key;
f81684
	uint32_t	module_flags;
f81684
f81684
	uint64_t	module_qpc;
f81684
	uint64_t	module_reserved;
f81684
};
f81684
44a67f
/* pid (or syspid) --> debug file descriptor */
44a67f
int __dbg_attach(pid_t);
44a67f
int __dbg_detach(int);
44a67f
24e534
/* process creation/termination --> debug file descriptor */
bb1628
int __dbg_spawn(const char *, char **, char **, const struct __strace *);
b7fac7
int __dbg_fork(void);
44a67f
int __dbg_kill(int);
44a67f
4085aa
/* breakpoint via remote break-in, thread context manipulation, or lpc message */
4085aa
int __dbg_rbreak(int);
4085aa
int __dbg_tbreak(int);
4085aa
int __dbg_lbreak(int);
4085aa
cd305f
/* virtual memory */
cd305f
ssize_t __dbg_vm_read(int, void *, size_t, uintptr_t);
cd305f
ssize_t __dbg_vm_write(int, const void *, size_t, uintptr_t);
cd305f
5221bc
/* thread register context */
5221bc
int __dbg_regs_fetch(int, pid_t, mcontext_t *);
5221bc
int __dbg_regs_store(int, pid_t, const mcontext_t *);
5221bc
45970c
/* debug information */
45970c
ssize_t __dbg_info_get(int, pid_t, int, void *, size_t);
45970c
ssize_t __dbg_info_set(int, pid_t, int, const void *, size_t);
45970c
2d2bf1
/* suspend/resume thread; return previous suspend count (negative for an error) */
2d2bf1
int __dbg_suspend_thread(int, pid_t);
2d2bf1
int __dbg_resume_thread(int, pid_t);
2d2bf1
44a67f
/**
44a67f
 * query one (or all) pending debug event(s) for the given debug
44a67f
 *    file descriptor:
44a67f
 * in the 'one' case, the return value indicates the total number
44a67f
 *    of events that are pending for the given file descriptor;
44a67f
 * in the 'all' case, the third argument specifies the number
44a67f
 *    of elements in the user-provided buffer.
44a67f
**/
b7fac7
int __dbg_event_query_one(int, struct __dbg_event *);
c33a22
int __dbg_event_query_all(int, struct __dbg_event *, int);
44a67f
44a67f
/**
44a67f
 * first acquire (remove from the queue) the next pending debug event;
44a67f
 * later respond to the event, the default being __DBG_RESPONSE_CONTINUE.
44a67f
**/
b7fac7
int __dbg_event_acquire(int, struct __dbg_event *);
b7fac7
int __dbg_event_respond(int, struct __dbg_event *);
44a67f
44a67f
/* debug file descriptor --> common (or system) pid */
44a67f
int __dbg_query_cpid(int);
44a67f
int __dbg_query_syspid(int);
44a67f
44a67f
/* code of last debug operation error encountered by this pthread */
44a67f
int __dbg_common_error(void);
44a67f
int __dbg_native_error(void);
045354
045354
#ifdef __cplusplus
045354
}
045354
#endif
045354
045354
#endif