From: Tommi V. <tv...@de...> - 2002-01-13 20:42:04
|
Hi. The lcrash/cmds/cmd_stat.c:print_log_buf() routine is buggy, it always assumes the log buffer is 16kB. The default size is 16kB in UP, 32kB on SMP and 64kB on some NUMA setup. Anyway, I think the whole idea of hardcoding the length of the kernel define ugly. The dump should contain enough info to get the size of log_buf. The following is not tested, but should tell what I'm thinking of -- grab the next symbol, size of log_buf will be the difference. The "grab next symbol" part, or the "get size of this symbol" part, should probably be in libklib. Oh, does print_log_buf() handle the ring buffer nature of log_buf properly? --- cmd_stat.c.orig Thu Sep 13 03:37:48 2001 +++ cmd_stat.c Sun Jan 13 22:34:31 2002 @@ -3,8 +3,6 @@ */ #include <lcrash.h> -#define LOG_BUF_SIZE 16384 - void print_log_buf(FILE *ofp) { @@ -13,18 +11,22 @@ kaddr_t symaddr; syment_t *sp; - if (!(lbuf = (char *)malloc(LOG_BUF_SIZE))) { - return; - } - if (!(np = (char *)malloc(256))) { - free(lbuf); - return; - } if ((sp = kl_lkup_symname("log_buf"))) { symaddr = sp->s_addr; } else { fprintf(stderr, "Could not find the symbol \"log_buf\"\n"); - free(np); + return; + } + + if (!(sp = (syment_t *)kl_next_btnode(&sp->s_bt))) { + fprintf(stderr, "Could not find the size of symbol \"log_buf\"\n"); + return; + } + + if (!(lbuf = (char *)malloc(sp->s_addr - symaddr))) { + return; + } + if (!(np = (char *)malloc(256))) { free(lbuf); return; } -- tv@{{hq.yok.utu,havoc,gaeshido}.fi,{debian,wanderer}.org,stonesoft.com} double a,b=4,c;main(){for(;++a<2e6;c-=(b=-b)/a++);printf("%f\n",c);} |