/* * Return the address of the saved pc in frame. */ CORE_ADDR addr_of_pc(struct frame_info *frame) { #ifdef KERNELDEBUG static CORE_ADDR tstart, tend, istart, iend; CORE_ADDR pc; unsigned long addr; if (kernel_debugging && frame->next) { if (tstart == 0) { tstart = ksym_lookup("Xdiv"); tend = ksym_lookup("Xsyscall"); istart = ksym_lookup("Vclk"); iend = ksym_lookup("doreti"); } pc = FRAME_SAVED_PC(frame->next); if (tstart <= pc && pc < tend) { struct trapframe *tfr = (struct trapframe *) (frame->next->frame + 8); return ((CORE_ADDR)&tfr->tf_eip); } if (istart <= pc && pc < iend) { struct intrframe *ifr = (struct intrframe *) (frame->next->frame + 8); return ((CORE_ADDR)&ifr->if_eip); } } #endif return ((CORE_ADDR)(frame->next->frame + 4)); }
void sampling_stats(int **hitcountp, int **symid_list) { int i, symid; /* init data */ sort(sampled_pc, MAX_SAMPLING_COUNT, sizeof(sampled_pc[0]), cmp_addr); for (i = 0; i < MAX_KSYM; i++) { ksym_hitcount[i] = 0; ksymid_sortedlist[i] = i; } /* calculation total hit for each ksym */ for (i = 0; i < MAX_SAMPLING_COUNT; i++) { symid = ksym_lookup(sampled_pc[i]); if (symid < 0) continue; ksym_hitcount[symid]++; } /* create a list from highest hit to lowest hit */ sort(ksymid_sortedlist, ksym_total(), sizeof(ksymid_sortedlist[0]), cmp_symhit); /* output the result */ *hitcountp = ksym_hitcount; *symid_list = ksymid_sortedlist; }
/* * Return the current proc. masterprocp points to * current proc which points to current u area. */ static struct pcb * fetch_cpcb() { struct pcb *p; static CORE_ADDR curpcb_addr; if (!curpcb_addr) curpcb_addr = ksym_lookup("curpcb"); if (READMEM(curpcb_addr, &p)) error("cannot read curpcb pointer at 0x%x\n", curpcb_addr); return (p); }