*** 1.3 1992/11/07 12:53:15 --- kernel/exit.c 1992/11/07 13:00:00 *************** *** 348,354 **** while (p = current->p_cptr) { current->p_cptr = p->p_osptr; p->p_ysptr = NULL; ! p->flags &= ~PF_PTRACED; if (task[1]) p->p_pptr = task[1]; else --- 348,354 ---- while (p = current->p_cptr) { current->p_cptr = p->p_osptr; p->p_ysptr = NULL; ! p->flags &= ~(PF_PTRACED|PF_TRACESYS); if (task[1]) p->p_pptr = task[1]; else *** 1.2 1992/11/07 12:53:15 --- kernel/fork.c 1992/11/07 12:56:55 *************** *** 121,127 **** *p = *current; p->kernel_stack_page = 0; p->state = TASK_UNINTERRUPTIBLE; ! p->flags &= ~PF_PTRACED; p->pid = last_pid; if (p->pid > 1) p->swappable = 1; --- 121,127 ---- *p = *current; p->kernel_stack_page = 0; p->state = TASK_UNINTERRUPTIBLE; ! p->flags &= ~(PF_PTRACED|PF_TRACESYS); p->pid = last_pid; if (p->pid > 1) p->swappable = 1; *** 1.1 1992/10/19 10:46:11 --- kernel/ptrace.c 1992/11/07 12:56:56 *************** *** 122,127 **** --- 122,129 ---- if (page & PAGE_PRESENT) { page &= 0xfffff000; page += (addr >> 10) & 0xffc; + /* we're bypassing pagetables, so we have to set the dirty bit ourselves */ + *(unsigned long *) page |= PAGE_DIRTY; page = *((unsigned long *) page); } if (!(page & PAGE_PRESENT)) { *************** *** 304,312 **** --- 306,319 ---- return -EIO; return 0; + case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ case PTRACE_CONT: { /* restart after signal. */ long tmp; + if (request == PTRACE_SYSCALL) + child->flags |= PF_TRACESYS; + else + child->flags &= ~PF_TRACESYS; child->signal = 0; if (data > 0 && data <= NSIG) child->signal = 1<<(data-1); *************** *** 336,341 **** --- 343,349 ---- case PTRACE_SINGLESTEP: { /* set the trap flag. */ long tmp; + child->flags &= ~PF_TRACESYS; tmp = get_stack_long(child, 4*EFL-MAGICNUMBER) | TRAP_FLAG; put_stack_long(child, 4*EFL-MAGICNUMBER,tmp); child->state = TASK_RUNNING; *************** *** 349,355 **** case PTRACE_DETACH: { /* detach a process that was attached. */ long tmp; ! child->flags &= ~PF_PTRACED; child->signal=0; child->state = 0; REMOVE_LINKS(child); --- 357,363 ---- case PTRACE_DETACH: { /* detach a process that was attached. */ long tmp; ! child->flags &= ~(PF_PTRACED|PF_TRACESYS); child->signal=0; child->state = 0; REMOVE_LINKS(child); *** 1.1 1992/10/19 10:46:11 --- kernel/sys_call.S 1992/11/07 13:08:47 *************** *** 72,77 **** --- 72,79 ---- sigaction = 16 # MUST be 16 (=len of sigaction) blocked = (33*16) saved_kernel_stack = ((33*16)+4) + kernel_stack_page = ((33*16)+8) + flags = ((33*16)+12) /* * offsets within sigaction *************** *** 122,129 **** movl $-ENOSYS,EAX(%esp) cmpl _NR_syscalls,%eax jae ret_from_sys_call ! call _sys_call_table(,%eax,4) movl %eax,EAX(%esp) # save the return value .align 4,0x90 ret_from_sys_call: movl EFLAGS(%esp),%eax # check VM86 flag: CS/SS are --- 124,154 ---- movl $-ENOSYS,EAX(%esp) cmpl _NR_syscalls,%eax jae ret_from_sys_call ! ! movl _current,%ebx ! testl $0x20,flags(%ebx) # PF_TRACESYS ! je 1f ! pushl $0 ! pushl %ebx ! pushl $5 # SIGTRAP ! call _send_sig ! addl $12,%esp ! call _schedule ! movl ORIG_EAX(%esp),%eax ! 1: call _sys_call_table(,%eax,4) movl %eax,EAX(%esp) # save the return value + movl _current,%eax + testl $0x20,flags(%eax) # PF_TRACESYS + je ret_from_sys_call + cmpl $0,signal(%eax) + jne ret_from_sys_call # ptrace would clear signal + pushl $0 + pushl %eax + pushl $5 # SIGTRAP + call _send_sig + addl $12,%esp + call _schedule + .align 4,0x90 ret_from_sys_call: movl EFLAGS(%esp),%eax # check VM86 flag: CS/SS are *** 1.1 1992/10/19 11:43:22 --- include/linux/ptrace.h 1992/11/07 13:03:29 *************** *** 19,24 **** --- 19,26 ---- #define PTRACE_ATTACH 0x10 #define PTRACE_DETACH 0x11 + #define PTRACE_SYSCALL 24 + /* use ptrace (3 or 6, pid, PT_EXCL, data); to read or write the processes registers. */ *** 1.3 1992/11/07 13:00:56 --- include/linux/sched.h 1992/11/07 13:05:20 *************** *** 152,157 **** --- 152,158 ---- long blocked; /* bitmap of masked signals */ unsigned long saved_kernel_stack; unsigned long kernel_stack_page; + unsigned int flags; /* per process flags, defined below */ /* various fields */ int exit_code; int dumpable:1; *************** *** 178,184 **** unsigned long min_flt, maj_flt; unsigned long cmin_flt, cmaj_flt; struct rlimit rlim[RLIM_NLIMITS]; - unsigned int flags; /* per process flags, defined below */ unsigned short used_math; unsigned short rss; /* number of resident pages */ char comm[8]; --- 179,184 ---- *************** *** 213,218 **** --- 213,219 ---- #define PF_ALIGNWARN 0x00000001 /* Print alignment warning msgs */ /* Not implemented yet, only for 486*/ #define PF_PTRACED 0x00000010 /* set if ptrace (0) has been called. */ + #define PF_TRACESYS 0x00000020 /* tracing system calls */ /* * INIT_TASK is used to set up the first task table, touch at *************** *** 221,226 **** --- 222,228 ---- #define INIT_TASK \ /* state etc */ { 0,15,15, \ /* signals */ 0,{{},},0,0,0, \ + /* flags */ 0, \ /* ec,brk... */ 0,0,0,0,0,0,0,0, \ /* pid etc.. */ 0,0,0,0, \ /* suppl grps*/ {NOGROUP,}, \ *************** *** 231,237 **** /* rlimits */ { {0x7fffffff, 0x7fffffff}, {0x7fffffff, 0x7fffffff}, \ {0x7fffffff, 0x7fffffff}, {0x7fffffff, 0x7fffffff}, \ {0x7fffffff, 0x7fffffff}, {0x7fffffff, 0x7fffffff}}, \ - /* flags */ 0, \ /* math */ 0, \ /* rss */ 2, \ /* comm */ "swapper", \ --- 233,238 ----