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
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
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           cpid;
44a67f
	pid_t           ctid;
44a67f
44a67f
	pid_t           syspid;
44a67f
	pid_t           systid;
44a67f
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
44a67f
/* pid (or syspid) --> debug file descriptor */
44a67f
int __dbg_attach(pid_t);
44a67f
int __dbg_detach(int);
44a67f
44a67f
/* process creation/suspension/termination --> debug file descriptor */
44a67f
int __dbg_spawn(const char *, char **, char **);
b7fac7
int __dbg_fork(void);
44a67f
int __dbg_suspend(int);
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
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