--- ac_clean/arch/um/Makefile Tue Apr 17 08:54:59 2001 +++ ac/arch/um/Makefile Tue Apr 17 20:07:35 2001 @@ -65,6 +65,9 @@ $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) archclean: + find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ + -o -name '*.gcov' \) -type f -print | xargs rm -f + rm -f gmon.out rm -f link.ld @$(MAKEBOOT) clean --- ac_clean/arch/um/include/kern_util.h Tue Apr 17 19:54:58 2001 +++ ac/arch/um/include/kern_util.h Tue Apr 17 20:08:40 2001 @@ -22,6 +22,9 @@ typedef long syscall_handler_t(struct sys_pt_regs regs); extern syscall_handler_t *sys_call_table[]; +#define ROUND_DOWN(addr) ((void *)(((unsigned long) addr) & PAGE_MASK)) +#define ROUND_UP(addr) ROUND_DOWN(((unsigned long) addr) + PAGE_SIZE - 1) + extern int kernel_fork(unsigned long flags, int (*fn)(void *), void * arg); extern unsigned long stack_sp(unsigned long page); extern int kernel_thread_proc(void *data); @@ -50,9 +53,7 @@ extern int do_proc_op(void *t, int proc_id); extern void free_stack(unsigned long stack); extern void add_input_request(int op, void (*proc)(int), void *arg); -extern char *current_comm(void); extern int sys_execve(char *file, char **argv, char **env); -extern void *current_sigstack(void *t); extern char *current_cmd(void); extern void timer_handler(int sig, void *sc, int usermode); extern int set_signals(int enable); @@ -115,6 +116,8 @@ extern void do_exitcalls(void); extern int get_restore_regs(void *t); extern int attach_debugger(int idle_pid, int pid); +extern void *round_up(unsigned long addr); +extern void *round_down(unsigned long addr); #endif /* --- ac_clean/arch/um/include/user_util.h Tue Apr 17 19:55:09 2001 +++ ac/arch/um/include/user_util.h Tue Apr 17 20:09:14 2001 @@ -75,7 +75,6 @@ int x); extern void stop_pid(int pid); extern void kill_pid(int pid); -extern void trap_pid(int pid); extern void usr1_pid(int pid); extern void cont_pid(int pid); extern int __personality(int); @@ -95,10 +94,8 @@ extern void set_timers(int set_signal); extern int clone_and_wait(int (*fn)(void *), void *arg, void *sp, int flags); extern int input_loop(void); -extern void usr1_and_wait(int pid); extern void set_handler(int sig, void (*handler)(int), int flags, ...); extern void set_sigstack(void *stack); -extern void (*set_signal_handler(int sig, void (*new_handler)(int)))(int); extern void continue_execing_proc(int pid); extern int linux_main(int argc, char **argv); extern void remap_data(void *segment_start, void *segment_end); @@ -148,6 +145,7 @@ extern char *get_umid(void); extern void ptrace_cont_pid(int pid); extern void create_pid_file(char *name); +extern void remap_profiling_buffers(void); #endif /* --- ac_clean/arch/um/kernel/Makefile Tue Apr 17 08:54:59 2001 +++ ac/arch/um/kernel/Makefile Tue Apr 17 20:09:41 2001 @@ -13,7 +13,8 @@ USER_CFLAGS := $(patsubst -I%,,$(CFLAGS)) USER_CFLAGS += -I../include -UNMAP_CFLAGS := $(patsubst -pg,,$(USER_CFLAGS)) +UNMAP_CFLAGS := $(patsubst -pg -DPROFILING,,$(USER_CFLAGS)) +UNMAP_CFLAGS := $(patsubst -fprofile-arcs -ftest-coverage,,$(UNMAP_CFLAGS)) ifeq ($(CONFIG_MODULES), y) DMODULES = -DCONFIG_MODULES --- ac_clean/arch/um/kernel/irq_user.c Tue Apr 17 08:54:59 2001 +++ ac/arch/um/kernel/irq_user.c Tue Apr 17 20:10:35 2001 @@ -41,6 +41,7 @@ tv.tv_usec = 0; fds = active_fd_mask; if((n = select(max_fd + 1, &fds, NULL, NULL, &tv)) < 0){ + if(errno == EINTR) continue; printk("sigio_handler : select returned %d, " "errno = %d\n", n, errno); break; --- ac_clean/arch/um/kernel/process.c Tue Apr 17 08:54:59 2001 +++ ac/arch/um/kernel/process.c Tue Apr 17 20:12:41 2001 @@ -16,6 +16,9 @@ #include #include #include +#ifdef PROFILING +#include +#endif #include "user_util.h" #include "kern_util.h" #include "user.h" @@ -31,11 +34,6 @@ kill(pid, SIGKILL); } -void trap_pid(int pid) -{ - kill(pid, SIGTRAP); -} - void usr1_pid(int pid) { kill(pid, SIGUSR1); @@ -121,6 +119,7 @@ t->pid = clone(t->tramp, (void *) t->temp_stack + page_size()/2, t->flags, (void *) t->stack); if(t->pid > 0) wait_for_stop(t->pid, SIGSTOP, PTRACE_CONT); + kill(getpid(), SIGKILL); exit(0); } @@ -148,7 +147,7 @@ while((err = waitpid(new_pid, &status, 0) < 0) && (errno == EINTR)) ; if(err < 0) panic("Waiting for outer trampoline failed - errno = %d", errno); - if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) + if(!WIFSIGNALED(status) || (WTERMSIG(status) != SIGKILL)) panic("outer trampoline didn't exit 0"); return(arg.pid); @@ -160,18 +159,6 @@ panic("ptrace failed in trace_myself"); } -void usr1_and_wait(int pid) -{ - sigset_t new_mask, old_mask; - - sigemptyset(&new_mask); - sigaddset(&new_mask, SIGUSR1); - sigprocmask(SIG_BLOCK, &new_mask, &old_mask); - usr1_pid(pid); - sigsuspend(&old_mask); - sigprocmask(SIG_SETMASK, &old_mask, NULL); -} - void signal_handler(void *task, unsigned long h, int sig) { void (*handler)(int, struct sigcontext); @@ -186,18 +173,6 @@ (*handler)(sig, sc); } -void (*set_signal_handler(int sig, void (*new_handler)(int)))(int) -{ - struct sigaction action; - void (*old_handler)(int); - - sigaction(sig, NULL, &action); - old_handler = action.sa_handler; - action.sa_handler = new_handler; - sigaction(sig, &action, NULL); - return(old_handler); -} - void continue_fork(void *task, int pid, struct sys_pt_regs *regs) { if(ptrace(PTRACE_CONT, pid, 0, SIGUSR1) < 0) @@ -348,6 +323,30 @@ vprintf(format, ap); while(1) sleep(10); } + +#ifdef PROFILING +void remap_profiling_buffers(void) +{ + unsigned long low = 1 << 31, high = 0; + + if((unsigned long) _gmonparam.kcount < low) + low = (unsigned long) _gmonparam.kcount; + if((unsigned long) _gmonparam.froms < low) + low = (unsigned long) _gmonparam.froms; + if((unsigned long) _gmonparam.tos < low) + low = (unsigned long) _gmonparam.tos; + + if((unsigned long) _gmonparam.kcount + _gmonparam.kcountsize > high) + high = (unsigned long) _gmonparam.kcount + + _gmonparam.kcountsize; + if((unsigned long) _gmonparam.froms + _gmonparam.fromssize > high) + high = (unsigned long) _gmonparam.froms + _gmonparam.fromssize; + if((unsigned long) _gmonparam.tos + _gmonparam.tossize > high) + high = (unsigned long) _gmonparam.tos + _gmonparam.tossize; + + remap_data((void *) round_down(low), (void *) round_up(high)); +} +#endif /* * Overrides for Emacs so that we follow Linus's tabbing style. --- ac_clean/arch/um/kernel/process_kern.c Tue Apr 17 08:54:59 2001 +++ ac/arch/um/kernel/process_kern.c Tue Apr 17 20:13:29 2001 @@ -475,20 +475,6 @@ return(PAGE_MASK); } -char *current_comm(void) -{ - return(current->comm); -} - -void *current_sigstack(void *t) -{ - struct task_struct *task; - - if(t == NULL) task = current; - else task = t; - return((void *) task->thread.kernel_stack); -} - unsigned long um_virt_to_phys(void *t, unsigned long addr) { struct task_struct *task; @@ -802,6 +788,16 @@ (*call)(); call++; } while (call < &__exitcall_end); +} + +void *round_up(unsigned long addr) +{ + return(ROUND_UP(addr)); +} + +void *round_down(unsigned long addr) +{ + return(ROUND_DOWN(addr)); } /* --- ac_clean/arch/um/kernel/time.c Tue Apr 17 08:54:59 2001 +++ ac/arch/um/kernel/time.c Tue Apr 17 20:16:02 2001 @@ -68,21 +68,11 @@ void set_timers(int set_signal) { - __sighandler_t handler; - struct sigaction action; - if(set_signal){ if(signal(SIGVTALRM, irq_handler) == SIG_ERR) panic("Couldn't set SIGVTALRM handler"); set_interval(ITIMER_VIRTUAL); } - handler = signal(SIGPROF, SIG_DFL); - action.sa_handler = handler; - sigemptyset(&action.sa_mask); - action.sa_flags = SA_RESTART; - action.sa_restorer = NULL; - if(sigaction(SIGPROF, &action, NULL) < 0) - panic("sigaction failed"); if(setitimer(ITIMER_PROF, &profile_interval, NULL) == -1) panic("setitimer ITIMER_PROF failed - errno = %d\n", errno); } --- ac_clean/arch/um/kernel/um_arch.c Tue Apr 17 19:55:16 2001 +++ ac/arch/um/kernel/um_arch.c Tue Apr 17 20:17:06 2001 @@ -61,7 +61,6 @@ block_signals(); pid = getpid(); - block_signals(); #ifdef __SMP__ cpu_tasks[0].pid = pid; cpu_tasks[0].task = current; @@ -95,9 +94,6 @@ static char *argv1_begin = NULL; static char *argv1_end = NULL; -#define ROUND_UP(addr) ROUND_DOWN(((unsigned long) addr) + PAGE_SIZE - 1) -#define ROUND_DOWN(addr) ((void *)(((unsigned long) addr) & PAGE_MASK)) - void set_cmdline(char *cmd) { strcpy(argv1_begin, "["); @@ -182,6 +178,9 @@ remap_data(ROUND_DOWN(&__bss_start), ROUND_UP(brk_start)); last_brk = (void *) brk_start; brk_fd = create_vm_file(0); +#ifdef CONFIG_GPROF + remap_profiling_buffers(); +#endif /* Create fake command line from argv[]. */ have_root = 0;