*** 1.2	1992/10/30 20:29:08
--- kernel/exit.c	1992/11/01 13:59:36
***************
*** 347,353 ****
  	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
--- 347,353 ----
  	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.1	1992/10/22 15:09:27
--- kernel/fork.c	1992/11/01 13:59:36
***************
*** 122,128 ****
  	p->wait.task = p;
  	p->wait.next = NULL;
  	p->state = TASK_UNINTERRUPTIBLE;
! 	p->flags &= ~PF_PTRACED;
  	p->pid = last_pid;
  	if (p->pid > 1)
  		p->swappable = 1;
--- 122,128 ----
  	p->wait.task = p;
  	p->wait.next = NULL;
  	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/01 22:39:42
***************
*** 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/04 01:05:53
***************
*** 72,77 ****
--- 72,78 ----
  sigaction	= 16		# MUST be 16 (=len of sigaction)
  blocked		= (33*16)
  saved_kernel_stack = ((33*16)+4)
+ flags		= ((33*16)+8)
  
  /*
   * 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
--- 123,153 ----
  	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/10/22 14:05:03
***************
*** 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.2	1992/10/30 20:15:40
--- include/linux/sched.h	1992/10/30 19:43:23
***************
*** 141,146 ****
--- 141,147 ----
  	struct sigaction sigaction[32];
  	long blocked;	/* bitmap of masked signals */
  	unsigned long saved_kernel_stack;
+ 	unsigned int flags;	/* per process flags, defined below */
  /* various fields */
  	int exit_code;
  	int dumpable:1;
***************
*** 168,174 ****
  	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];
--- 169,174 ----
***************
*** 203,208 ****
--- 203,209 ----
  #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
***************
*** 211,216 ****
--- 212,218 ----
  #define INIT_TASK \
  /* state etc */	{ 0,15,15, \
  /* signals */	0,{{},},0,0, \
+ /* flags */	0, \
  /* ec,brk... */	0,0,0,0,0,0,0,0, \
  /* pid etc.. */	0,0,0,0, \
  /* suppl grps*/ {NOGROUP,}, \
***************
*** 222,228 ****
  /* rlimits */   { {0x7fffffff, 0x7fffffff}, {0x7fffffff, 0x7fffffff},  \
  		  {0x7fffffff, 0x7fffffff}, {0x7fffffff, 0x7fffffff}, \
  		  {0x7fffffff, 0x7fffffff}, {0x7fffffff, 0x7fffffff}}, \
- /* flags */	0, \
  /* math */	0, \
  /* rss */	2, \
  /* comm */	"swapper", \
--- 224,229 ----
