2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
9 * $FreeBSD: src/usr.sbin/kernbb/kernbb.c,v 1.11.2.1 2001/07/19 04:17:03 kris Exp $
10 * $DragonFly: src/usr.sbin/kernbb/kernbb.c,v 1.3 2003/11/16 15:17:36 eirikn Exp $
36 struct nlist namelist[] = {
37 { .n_name = "bbhead" },
52 main(int argc __unused, char **argv __unused)
60 kv = kvm_open(NULL,NULL,NULL,O_RDWR,"dnc");
63 i = kvm_nlist(kv,namelist);
67 l1 = namelist[0].n_value;
68 kvm_read(kv,l1,&l2,sizeof l2);
71 kvm_read(kv,l2,&bb,sizeof bb);
75 if (bb.ncounts > MAXBB)
76 errx(1, "found %lu counts above limit of %u",
78 kvm_read(kv,bb.lineno,lineno, bb.ncounts * sizeof lineno[0]);
79 kvm_read(kv,bb.counts,counts, bb.ncounts * sizeof counts[0]);
80 kvm_read(kv,bb.addr, addr, bb.ncounts * sizeof addr[0]);
81 kvm_read(kv,bb.file, file, bb.ncounts * sizeof file[0]);
82 kvm_read(kv,bb.func, func, bb.ncounts * sizeof func[0]);
84 for (i=0; i < bb.ncounts; i++) {
87 if (!func[i] && i+1 < bb.ncounts)
92 for (i=0; i < bb.ncounts; i++) {
97 if (!pn[i] && func[i]) {
98 kvm_read(kv,func[i], buf, sizeof buf);
99 buf[sizeof buf -1] = 0;
101 for(j=i+1;j<bb.ncounts;j++)
102 if (func[j] == func[i]) {
109 if (!fn[i] && file[i]) {
110 kvm_read(kv,file[i], buf, sizeof buf);
111 buf[sizeof buf -1] = 0;
113 for(j=i+1;j<bb.ncounts;j++)
114 if (file[j] == file[i]) {
122 if (i+1 < bb.ncounts)
123 l4 = addr[i+1] - addr[i];
124 printf("%s %5lu %s %lu %lu %lu %lu\n",
125 fn[i], lineno[i], pn[i], addr[i], counts[i], l4, counts[i] * l4);
127 for(i=0;i<bb.ncounts;i++) {
128 if (func[i] && pn[i])
130 if (file[i] && fn[i])