diff -ruN porting05/Makefile porting06/Makefile --- porting05/Makefile Sun Apr 12 12:09:59 2009 +++ porting06/Makefile Sun Apr 19 21:53:32 2009 @@ -6,6 +6,7 @@ OBJS += extintr.o OBJS += kozos.o command.o OBJS += stublib.o ppc-stub.o +OBJS += mcount.o logging.o LIB = libc.a TARGET ?= sample @@ -26,6 +27,9 @@ $(TARGET) : $(OBJS) $(LIB) $(CC) $(OBJS) -o $(TARGET) $(CFLAGS) $(LFLAGS) + +extintr.o : extintr.c + $(CC) -c $< $(CFLAGS) -pg .c.o : $< # $(CC) -S $< $(CFLAGS) diff -ruN porting05/command.c porting06/command.c --- porting05/command.c Sun Apr 12 12:09:59 2009 +++ porting06/command.c Sun Apr 19 21:53:32 2009 @@ -1,6 +1,7 @@ #include "kozos.h" #include "thread.h" #include "extintr.h" +#include "logging.h" #include "lib.h" @@ -67,7 +68,7 @@ { char *p; char buffer[128]; - int len, size; + int len, size, i, log; len = 0; send_write(index, "> "); @@ -105,13 +106,21 @@ kz_break(); } else if (!strncmp(buffer, "threads", 7)) { kz_thread *thp; - int i; for (i = 0; i < THREAD_NUM; i++) { thp = &threads[i]; if (!thp->id) continue; send_write(index, thp->name); send_write(index, "\n"); } + } else if (!strncmp(buffer, "log", 3)) { + logging_disable = 1; + log = logging_cur; + for (i = 0; i < LOGGING_BUF_SIZE; i++) { + ub_printf("%08x%c", logging_buf[log++], ((i % 8) == 7) ? '\n' : ' '); + if (log >= LOGGING_BUF_SIZE) + log = 0; + } + logging_disable = 0; } else if (!strncmp(buffer, "exit", 4)) { break; } diff -ruN porting05/logging.c porting06/logging.c --- porting05/logging.c Thu Jan 1 09:00:00 1970 +++ porting06/logging.c Sun Apr 19 21:53:32 2009 @@ -0,0 +1,15 @@ +#include "kozos.h" +#include "logging.h" + +int logging_disable = 0; +int logging_cur = 0; +int logging_buf[LOGGING_BUF_SIZE]; + +void logging(int addr) +{ + if (!logging_disable) { + logging_buf[logging_cur++] = addr; + if (logging_cur >= LOGGING_BUF_SIZE) + logging_cur = 0; + } +} diff -ruN porting05/logging.h porting06/logging.h --- porting05/logging.h Thu Jan 1 09:00:00 1970 +++ porting06/logging.h Sun Apr 19 21:53:32 2009 @@ -0,0 +1,9 @@ +#ifndef _KOZOS_LOGGING_H_INCLUDED_ +#define _KOZOS_LOGGING_H_INCLUDED_ + +#define LOGGING_BUF_SIZE 64 +extern int logging_disable; +extern int logging_cur; +extern int logging_buf[]; + +#endif diff -ruN porting05/mcount.s porting06/mcount.s --- porting05/mcount.s Thu Jan 1 09:00:00 1970 +++ porting06/mcount.s Sun Apr 19 21:53:32 2009 @@ -0,0 +1,31 @@ + .text + .globl _mcount + .type _mcount,@function +_mcount: + stwu 1,-48(1) + stw 3,16(1) + stw 4,20(1) + stw 5,24(1) + stw 6,28(1) + stw 7,32(1) + stw 8,36(1) + stw 9,40(1) + stw 10,44(1) + mflr 3 + stw 3,8(1) + bl logging + + lwz 9,8(1) + mtctr 9 + lwz 10,52(1) + mtlr 10 + lwz 3,16(1) + lwz 4,20(1) + lwz 5,24(1) + lwz 6,28(1) + lwz 7,32(1) + lwz 8,36(1) + lwz 9,40(1) + lwz 10,44(1) + addi 1,1,48 + bctr