diff options
author | Alex Williamson <alex.williamson@hp.com> | 2007-10-02 11:31:55 -0600 |
---|---|---|
committer | Alex Williamson <alex.williamson@hp.com> | 2007-10-02 11:31:55 -0600 |
commit | 3abc3aea3f93a6e14ce080457f1397f250677678 (patch) | |
tree | 7b89a7ab6031add1b1d8e6ad75c81d59e257e526 /tools/xentrace | |
parent | c0cf2ddd9191a34d5cb12e2d9bdb1470c9ced336 (diff) | |
parent | ac9ba8d39deffe57bf3068f365e8a079ac74b5e7 (diff) | |
download | xen-3abc3aea3f93a6e14ce080457f1397f250677678.tar.gz xen-3abc3aea3f93a6e14ce080457f1397f250677678.tar.bz2 xen-3abc3aea3f93a6e14ce080457f1397f250677678.zip |
merge with xen-unstable.hg (staging)
Diffstat (limited to 'tools/xentrace')
-rw-r--r-- | tools/xentrace/xenctx.c | 55 | ||||
-rw-r--r-- | tools/xentrace/xentrace.8 | 2 | ||||
-rw-r--r-- | tools/xentrace/xentrace_format | 89 |
3 files changed, 121 insertions, 25 deletions
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c index 912bcdf937..aa85025cf3 100644 --- a/tools/xentrace/xenctx.c +++ b/tools/xentrace/xenctx.c @@ -21,6 +21,7 @@ #include <argp.h> #include <signal.h> #include <string.h> +#include <inttypes.h> #include <getopt.h> #include "xenctrl.h" @@ -152,9 +153,9 @@ void print_symbol(size_t addr) return; if (addr==s->address) - printf("%s", s->name); + printf("%s ", s->name); else - printf("%s+%#x", s->name, (unsigned int)(addr - s->address)); + printf("%s+%#x ", s->name, (unsigned int)(addr - s->address)); } void read_symbol_table(const char *symtab) @@ -207,6 +208,46 @@ void read_symbol_table(const char *symtab) fclose(f); } +#if defined(__i386__) || defined(__x86_64__) +char *flag_values[22][2] = +{/* clear, set, bit# */ + { NULL, "c" }, // 0 Carry + { NULL, NULL }, // 1 + { NULL, "p" }, // 2 Parity + { NULL, NULL }, // 3 + { NULL, "a" }, // 4 Adjust + { NULL, NULL }, // 5 + { "nz", "z" }, // 6 Zero + { NULL, "s" }, // 7 Sign + { NULL, "tf" }, // 8 Trap + { NULL, "i" }, // 9 Interrupt (enabled) + { NULL, "d=b" }, // 10 Direction + { NULL, "o" }, // 11 Overflow + { NULL, NULL }, // 12 12+13 == IOPL + { NULL, NULL }, // 13 + { NULL, "nt" }, // 14 Nested Task + { NULL, NULL }, // 15 + { NULL, "rf" }, // 16 Resume Flag + { NULL, "v86" }, // 17 Virtual 8086 mode + { NULL, "ac" }, // 18 Alignment Check (enabled) + { NULL, "vif" }, // 19 Virtual Interrupt (enabled) + { NULL, "vip" }, // 20 Virtual Interrupt Pending + { NULL, "cid" } // 21 Cpuid Identification Flag +}; + +void print_flags(uint64_t flags) +{ + int i; + + printf("flags: %08" PRIx64, flags); + for (i = 21; i >= 0; i--) { + char *s = flag_values[i][(flags >> i) & 1]; + if (s != NULL) + printf(" %s", s); + } +} +#endif + #ifdef __i386__ void print_ctx(vcpu_guest_context_t *ctx1) { @@ -214,6 +255,7 @@ void print_ctx(vcpu_guest_context_t *ctx1) printf("eip: %08x ", regs->eip); print_symbol(regs->eip); + print_flags(regs->eflags); printf("\n"); printf("esp: %08x\n", regs->esp); @@ -240,6 +282,7 @@ void print_ctx(vcpu_guest_context_t *ctx1) printf("rip: %08lx ", regs->rip); print_symbol(regs->rip); + print_flags(regs->rflags); printf("\n"); printf("rsp: %08lx\n", regs->rsp); @@ -262,10 +305,10 @@ void print_ctx(vcpu_guest_context_t *ctx1) printf("r14: %08lx\t", regs->r14); printf("r15: %08lx\n", regs->r15); - printf(" cs: %08x\t", regs->cs); - printf(" ds: %08x\t", regs->ds); - printf(" fs: %08x\t", regs->fs); - printf(" gs: %08x\n", regs->gs); + printf(" cs: %04x\t", regs->cs); + printf(" ds: %04x\t", regs->ds); + printf(" fs: %04x\t", regs->fs); + printf(" gs: %04x\n", regs->gs); } #elif defined(__ia64__) diff --git a/tools/xentrace/xentrace.8 b/tools/xentrace/xentrace.8 index a5ec5c082d..c84e2e913b 100644 --- a/tools/xentrace/xentrace.8 +++ b/tools/xentrace/xentrace.8 @@ -131,4 +131,4 @@ collects the following events from the trace buffer: Mark A. Williamson <mark.a.williamson@intel.com> .SH "SEE ALSO" -xentrace_cpuinfo(1), xentrace_format(1) +xentrace_format(1) diff --git a/tools/xentrace/xentrace_format b/tools/xentrace/xentrace_format index 8a113aceb3..fe019b08d2 100644 --- a/tools/xentrace/xentrace_format +++ b/tools/xentrace/xentrace_format @@ -83,11 +83,24 @@ interrupted = 0 defs = read_defs(arg[0]) -# structure of trace record + prepended CPU id (as output by xentrace): -# CPU(I) TSC(Q) EVENT(L) D1(L) D2(L) D3(L) D4(L) D5(L) -# read CPU id separately to avoid structure packing problems on 64-bit arch. -CPUREC = "I" -TRCREC = "QLLLLLL" +# structure of trace record (as output by xentrace): +# HDR(I) {TSC(Q)} D1(I) D2(I) D3(I) D4(I) D5(I) +# +# HDR consists of EVENT:28:, n_data:3:, tsc_in:1: +# EVENT means Event ID +# n_data means number of data (like D1, D2, ...) +# tsc_in means TSC data exists(1) or not(0). +# if tsc_in == 0, TSC(Q) does not exists. +# +# CPU ID exists on trace data of EVENT=0x0001f003 +# +HDRREC = "I" +TSCREC = "Q" +D1REC = "I" +D2REC = "II" +D3REC = "III" +D4REC = "IIII" +D5REC = "IIIII" last_tsc = [0] @@ -96,19 +109,58 @@ i=0 while not interrupted: try: i=i+1 - line = sys.stdin.read(struct.calcsize(CPUREC)) + line = sys.stdin.read(struct.calcsize(HDRREC)) if not line: break - cpu = struct.unpack(CPUREC, line)[0] + event = struct.unpack(HDRREC, line)[0] + n_data = event >> 28 & 0x7 + tsc_in = event >> 31 + + d1 = 0 + d2 = 0 + d3 = 0 + d4 = 0 + d5 = 0 + + tsc = 0 + + if tsc_in == 1: + line = sys.stdin.read(struct.calcsize(TSCREC)) + if not line: + break + tsc = struct.unpack(TSCREC, line)[0] + + if n_data == 1: + line = sys.stdin.read(struct.calcsize(D1REC)) + if not line: + break + (d1) = struct.unpack(D1REC, line) + if n_data == 2: + line = sys.stdin.read(struct.calcsize(D2REC)) + if not line: + break + (d1, d2) = struct.unpack(D2REC, line) + if n_data == 3: + line = sys.stdin.read(struct.calcsize(D3REC)) + if not line: + break + (d1, d2, d3) = struct.unpack(D3REC, line) + if n_data == 4: + line = sys.stdin.read(struct.calcsize(D4REC)) + if not line: + break + (d1, d2, d3, d4) = struct.unpack(D4REC, line) + if n_data == 5: + line = sys.stdin.read(struct.calcsize(D5REC)) + if not line: + break + (d1, d2, d3, d4, d5) = struct.unpack(D5REC, line) + + # Event field is 28bit of 'uint32_t' in header, not 'long'. + event &= 0x0fffffff + if event == 0x1f003: + cpu = d1 - line = sys.stdin.read(struct.calcsize(TRCREC)) - if not line: - break - - (tsc, event, d1, d2, d3, d4, d5) = struct.unpack(TRCREC, line) - - # Event field is 'uint32_t', not 'long'. - event &= 0xffffffff #tsc = (tscH<<32) | tscL @@ -116,16 +168,17 @@ while not interrupted: if cpu >= len(last_tsc): last_tsc += [0] * (cpu - len(last_tsc) + 1) - elif tsc < last_tsc[cpu]: + elif tsc < last_tsc[cpu] and tsc_in == 1: print "TSC stepped backward cpu %d ! %d %d" % (cpu,tsc,last_tsc[cpu]) # provide relative TSC - if last_tsc[cpu] > 0: + if last_tsc[cpu] > 0 and tsc_in == 1: reltsc = tsc - last_tsc[cpu] else: reltsc = 0 - last_tsc[cpu] = tsc + if tsc_in == 1: + last_tsc[cpu] = tsc if mhz: tsc = tsc / (mhz*1000000.0) |