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
[] = {
52 main(int argc __unused
, char **argv __unused
)
59 kv
= kvm_open(NULL
,NULL
,NULL
,O_RDWR
,"dnc");
62 i
= kvm_nlist(kv
,namelist
);
66 l1
= namelist
[0].n_value
;
67 kvm_read(kv
,l1
,&l2
,sizeof l2
);
70 kvm_read(kv
,l2
,&bb
,sizeof bb
);
74 if (bb
.ncounts
> MAXBB
)
75 errx(1, "found %lu counts above limit of %u",
77 kvm_read(kv
,bb
.lineno
,lineno
, bb
.ncounts
* sizeof lineno
[0]);
78 kvm_read(kv
,bb
.counts
,counts
, bb
.ncounts
* sizeof counts
[0]);
79 kvm_read(kv
,bb
.addr
, addr
, bb
.ncounts
* sizeof addr
[0]);
80 kvm_read(kv
,bb
.file
, file
, bb
.ncounts
* sizeof file
[0]);
81 kvm_read(kv
,bb
.func
, func
, bb
.ncounts
* sizeof func
[0]);
83 for (i
=0; i
< bb
.ncounts
; i
++) {
86 if (!func
[i
] && i
+1 < bb
.ncounts
)
91 for (i
=0; i
< bb
.ncounts
; i
++) {
96 if (!pn
[i
] && func
[i
]) {
97 kvm_read(kv
,func
[i
], buf
, sizeof buf
);
98 buf
[sizeof buf
-1] = 0;
100 for(j
=i
+1;j
<bb
.ncounts
;j
++)
101 if (func
[j
] == func
[i
]) {
108 if (!fn
[i
] && file
[i
]) {
109 kvm_read(kv
,file
[i
], buf
, sizeof buf
);
110 buf
[sizeof buf
-1] = 0;
112 for(j
=i
+1;j
<bb
.ncounts
;j
++)
113 if (file
[j
] == file
[i
]) {
121 if (i
+1 < bb
.ncounts
)
122 l4
= addr
[i
+1] - addr
[i
];
123 printf("%s %5lu %s %lu %lu %lu %lu\n",
124 fn
[i
], lineno
[i
], pn
[i
], addr
[i
], counts
[i
], l4
, counts
[i
] * l4
);
126 for(i
=0;i
<bb
.ncounts
;i
++) {
127 if (func
[i
] && pn
[i
])
129 if (file
[i
] && fn
[i
])