asmlinkage int sys_ptrace(long request, long pid, long addr, long data) 
asmlinkage long sys_ptrace(long request, long pid, long addr, long data) 
asmlinkage int sys_ptrace(long request, long pid, long addr, long data){	struct task_struct *child;	int ret;	lock_kernel();	ret = -EPERM;	if (request == PTRACE_TRACEME) {		/* are we already being traced? */		if (current->ptrace & PT_PTRACED)			goto out;		/* set the ptrace bit in the process flags. */		current->ptrace |= PT_PTRACED;		ret = 0;		goto out;	}	ret = -ESRCH;	read_lock(&tasklist_lock);	child = find_task_by_pid(pid);	if (child)		get_task_struct(child);	read_unlock(&tasklist_lock);	if (!child)		goto out;	ret = -EPERM;	if (pid == 1)		/* you may not mess with init */		goto out_tsk;	if (request == PTRACE_ATTACH) {		ret = ptrace_attach(child);		goto out_tsk;	}	ret = ptrace_check_attach(child, request == PTRACE_KILL);	if (ret < 0)		goto out_tsk;	switch (request) {		case PTRACE_PEEKTEXT: /* read word at location addr. */ 		case PTRACE_PEEKDATA: {			unsigned long tmp;			ret = read_long(child, addr, &tmp);			if (ret < 0)				break ;			ret = put_user(tmp, (unsigned long *) data);			break ;		}	/* read the word at location addr in the USER area. */		case PTRACE_PEEKUSR: {			unsigned long tmp = 0;						if ((addr & 3) || addr < 0 || addr >= sizeof(struct user)) {				ret = -EIO;				break ;			}					        ret = 0;  /* Default return condition */			addr = addr >> 2; /* temporary hack. */			if (addr < H8300_REGS_NO)				tmp = h8300_get_reg(child, addr);			else {				switch(addr) {				case 49:					tmp = child->mm->start_code;					break ;				case 50:					tmp = child->mm->start_data;					break ;				case 51:					tmp = child->mm->end_code;					break ;				case 52:					tmp = child->mm->end_data;					break ;				default:					ret = -EIO;				}			}			if (!ret)				ret = put_user(tmp,(unsigned long *) data);			break ;		}      /* when I and D space are separate, this will have to be fixed. */		case PTRACE_POKETEXT: /* write the word at location addr. */		case PTRACE_POKEDATA:			ret = 0;			if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data))				break;			ret = -EIO;			break;		case PTRACE_POKEUSR: /* write the word at location addr in the USER area */			if ((addr & 3) || addr < 0 || addr >= sizeof(struct user)) {				ret = -EIO;				break ;			}			addr = addr >> 2; /* temporary hack. */			    			if (addr == PT_ORIG_ER0) {				ret = -EIO;				break ;			}			if (addr < H8300_REGS_NO) {				ret = h8300_put_reg(child, addr, data);				break ;			}			ret = -EIO;			break ;		case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */		case PTRACE_CONT: { /* restart after signal. */			ret = -EIO;			if (!valid_signal(data))				break ;			if (request == PTRACE_SYSCALL)				set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);			else				clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);			child->exit_code = data;			wake_up_process(child);			/* make sure the single step bit is not set. */			h8300_disable_trace(child);			ret = 0;		}/* * make the child exit.  Best I can do is send it a sigkill.  * perhaps it should be put in the status that it wants to  * exit. */		case PTRACE_KILL: {			ret = 0;			if (child->exit_state == EXIT_ZOMBIE) /* already dead */				break;			child->exit_code = SIGKILL;			h8300_disable_trace(child);			wake_up_process(child);			break;		}		case PTRACE_SINGLESTEP: {  /* set the trap flag. */			ret = -EIO;			if (!valid_signal(data))				break;			clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);			child->exit_code = data;			h8300_enable_trace(child);			wake_up_process(child);			ret = 0;			break;		}		case PTRACE_DETACH:	/* detach a process that was attached. */			ret = ptrace_detach(child, data);			break;		case PTRACE_GETREGS: { /* Get all gp regs from the child. */		  	int i;			unsigned long tmp;			for (i = 0; i < H8300_REGS_NO; i++) {			    tmp = h8300_get_reg(child, i);			    if (put_user(tmp, (unsigned long *) data)) {				ret = -EFAULT;				break;			    }			    data += sizeof(long);			}			ret = 0;			break;		}		case PTRACE_SETREGS: { /* Set all gp regs in the child. */			int i;			unsigned long tmp;			for (i = 0; i < H8300_REGS_NO; i++) {			    if (get_user(tmp, (unsigned long *) data)) {				ret = -EFAULT;				break;			    }			    h8300_put_reg(child, i, tmp);			    data += sizeof(long);			}			ret = 0;			break;		}		default:			ret = -EIO;			break;	}out_tsk:	put_task_struct(child);out:	unlock_kernel();	return ret;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/dfb7dac3af623a68262536437af008ed6aba4d88/ptrace.c/clean/arch/h8300/kernel/ptrace.c