11 static void bts_trace(
const char *fname);
12 static void printone(FILE *fd,
int depth,
char *str,
struct bts_rec *rec,
int src);
13 static void printboth(FILE *fd,
int depth,
char *str,
struct bts_rec *rec);
25 .symfile =
"/boot/vmlinux-syms-2.6.18-xenU",
32 .symfile =
"/boot/xen-syms-3.0-unstable",
43 int main(
int argc,
char **argv)
47 while ((ch = getopt(argc, argv,
"dIU:")) != -1) {
64 fprintf(stderr,
"Usage: bts-trace [-dI] [-U userbin] filename ...\n");
74 if (
symlist_init(symmap,
sizeof(symmap)/
sizeof(symmap[0])))
90 #define F_IS_INLINED 1
97 int *isinlined, uint32_t *lo, uint32_t *hi);
100 bts_trace(
const char *file)
105 uint32_t curlo = 0, curhi = ~0;
106 int currangedepth = 0;
110 fprintf(stderr,
"Could not open stream\n");
122 if (tot == 0 && recs[0].
from == UINT64_MAX &&
123 recs[0].
to == UINT64_MAX && recs[0].
format == UINT64_MAX) {
125 fprintf(stderr,
"Dump file in extended format\n");
130 callstack[0].
name = strdup(
"<TOP>");
135 uint32_t addr = recs[
i].to;
146 fprintf(stderr,
"[%d]: Ignoring inlined function ",
148 printone(stderr, 0,
"", &recs[i], 0);
149 fprintf(stderr,
"\n");
153 fprintf(stderr,
"[%d]: Found function ", depth);
154 printone(stderr, 0,
"", &recs[i], 0);
155 fprintf(stderr,
"\n");
157 printone(stdout, depth,
"Call to ", &recs[i], 0);
158 fprintf(stdout,
"\n");
159 callstack[depth].
calladdr = recs[
i].from;
161 callstack[depth].
name = name;
163 if (lo != 0 || hi != 0) {
164 callstack[depth].
loaddr = curlo = lo;
165 callstack[depth].
hiaddr = curhi = hi;
166 currangedepth = depth;
168 fprintf(stderr,
"[%d]: Range is [0x%x-0x%x]\n",
169 depth, curlo, curhi);
174 "WARNING: no range info for func@0x%x\n",
197 fprintf(stderr,
"Compare 0x%x:\n", addr);
198 for (d = depth - 1; d >= 0; d--) {
199 uint32_t raddr = callstack[d].
calladdr;
201 fprintf(stderr,
" rstack[%d]=0x%x (in %s)\n",
202 d, raddr, callstack[d].name);
203 if (addr > raddr && addr <= raddr+5) {
205 fprintf(stderr,
"[%d]: Found return to depth %d (%x in %s) ",
206 depth, d, raddr, callstack[d].name);
207 printone(stderr, 0,
"", &recs[i], 0);
208 fprintf(stderr,
"\n");
210 printone(stdout, depth,
"Return from ", &recs[i], 1);
211 fprintf(stdout,
"\n");
213 if (callstack[depth].name)
214 free(callstack[depth].name);
217 curlo = callstack[d].
loaddr;
218 curhi = callstack[d].
hiaddr;
221 fprintf(stderr,
"[%d]: Range is [0x%x-0x%x]\n",
222 depth, curlo, curhi);
234 "[%d]: checking branch 0x%x against range [0x%x-0x%x] (from depth %d (%s))\n",
235 depth, addr, curlo, curhi, currangedepth,
236 callstack[currangedepth].name);
237 if (addr < curlo || addr >= curhi) {
238 printboth(stdout, depth,
"*** branch ", &recs[i]);
239 printf(
" out of range [0x%x-0x%x]\n", curlo, curhi-1);
256 printone(FILE *fd,
int depth,
char *str,
struct bts_rec *rec,
int src)
266 fprintf(fd,
"%s%s", str, buf);
268 fprintf(fd,
" (bctr=%012llu)", rec->
format);
272 printboth(FILE *fd,
int depth,
char *str,
struct bts_rec *rec)
274 char buf1[256], buf2[256];
285 fprintf(fd,
"%sfrom %s to %s", str, buf1, buf2);
287 fprintf(fd,
" (bctr=%012llu)", rec->
format);
void symlist_string(uint32_t, char *, int)
static uint64_t unsigned int i
void symlist_gdb_string(uint32_t, char *, int)
int bts_read(BTSFD, struct bts_rec *, int)
int symlist_isfunc_2(uint32_t addr, char **namep, int *isinlined, uint32_t *lo, uint32_t *hi)
BTSFD bts_open(const char *)
int main(int argc, char **argv)
int symlist_init(struct symmap[], int)