diff --git a/src/debug/ptrace.c b/src/debug/ptrace.c new file mode 100644 index 0000000000000000000000000000000000000000..a6996250f4e0a590e08ae8d91a2b892fc4ab8df6 --- /dev/null +++ b/src/debug/ptrace.c @@ -0,0 +1,7 @@ +#include +#include + +NX_Error NX_Ptrace(enum __ptrace_request request, NX_I32 tid, void *addr, void *data) +{ + return NX_Syscall(NX_API_Ptrace, request, tid, addr, data); +} \ No newline at end of file diff --git a/src/include/nxos/debug.h b/src/include/nxos/debug.h index 29acbf799340119ec1ff98501d64fda2ff6d47cf..7cb722a6f8f3b914d47506894de302b017f82e60 100644 --- a/src/include/nxos/debug.h +++ b/src/include/nxos/debug.h @@ -13,12 +13,13 @@ #define __NXOS_DEBUG_H__ #include - +#include #ifdef __cplusplus extern "C" { #endif NX_Error NX_DebugLog(char *buf, NX_Size len); +NX_Error NX_Ptrace(enum __ptrace_request request, NX_I32 tid, void *addr, void *data); #ifdef __cplusplus } diff --git a/src/include/nxos/process.h b/src/include/nxos/process.h index 824246c810a5d0df115960af00f9575f3e9cf522..c461a8f54f011b6002a17714dd31b71b9b489454 100644 --- a/src/include/nxos/process.h +++ b/src/include/nxos/process.h @@ -43,6 +43,7 @@ extern "C" { #define NX_THREAD_CREATE_NORMAL 0x00 /* thread create with normal flag(no wait, no suspend, running) */ #define NX_THREAD_CREATE_SUSPEND 0x01 /* thread create with suspend flag(no running) */ #define NX_THREAD_CREATE_WAIT 0x02 /* thread create with wait thread exit(no return, must wait exit) */ +#define NX_THREAD_CREATE_DEBUG 0x04 /* thread create to be debugged by gdb */ #define NX_THREAD_DEFAULT_STACK_SZ 8192 /* default thread stack size */ diff --git a/src/include/nxos/ptrace.h b/src/include/nxos/ptrace.h new file mode 100644 index 0000000000000000000000000000000000000000..3d91d018250dfe8822254bf4ba67d26ac05714b4 --- /dev/null +++ b/src/include/nxos/ptrace.h @@ -0,0 +1,46 @@ +#ifndef __NXOS_PTRACE_H__ +#define __NXOS_PTRACE_H__ + + +enum __ptrace_request{ + + PTRACE_PEEKINT8 = 0, + + PTRACE_PEEKINT16 = 1, + + PTRACE_PEEKINT32 = 2, + + PTRACE_PEEKINT64 = 3, + + PTRACE_POKEINT8 = 4, + + PTRACE_POKEINT16 = 5, + + PTRACE_POKEINT32 = 6, + + PTRACE_POKEINT64 = 7, + + /* Continue the process. */ + PTRACE_CONT = 8, + + /* Kill the process. */ + PTRACE_KILL = 9, + + /* Single step the process. */ + PTRACE_SINGLESTEP = 10, + + /* Get all general purpose registers used by a processes. */ + PTRACE_GETREGS = 11, + + /* Set all general purpose registers used by a processes. */ + PTRACE_SETREGS = 12, + + /* Get all floating point registers used by a processes. */ + PTRACE_GETFPREGS = 13, + + /* Set all floating point registers used by a processes. */ + PTRACE_SETFPREGS = 14, + +}; + +#endif \ No newline at end of file diff --git a/src/include/nxos/signal.h b/src/include/nxos/signal.h index 6edace2c3745a08f3bcc2099d608ed5a555281b9..72729a98091d346ec13845183777c83a444b10a5 100644 --- a/src/include/nxos/signal.h +++ b/src/include/nxos/signal.h @@ -35,6 +35,7 @@ extern "C" { #define NX_SIGNAL_SEGV 14 /* segment fault */ #define NX_SIGNAL_ILLEGAL 15 /* illegal instruction */ #define NX_SIGNAL_INST 16 /* instruction aceesss */ +#define NX_SIGNAL_CHILD 17 /* child process */ /* ...-31 RESERVED */ #define NX_SIGNAL_ANONYMOUS 32 /* anonymous signal */ diff --git a/src/include/nxos/syscall.h b/src/include/nxos/syscall.h index 28d8af2d4a64210f3f0772669c865faa67ddf33f..806fb753bfdb5cbde893337848a86cc9241a23be 100644 --- a/src/include/nxos/syscall.h +++ b/src/include/nxos/syscall.h @@ -162,6 +162,7 @@ enum NX_SysApi NX_API_ConditionWaitTimeout, NX_API_ConditionSignal, /* 100 */ NX_API_ConditionBroadcast, + NX_API_Ptrace, }; #ifdef __cplusplus