[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] xenalyze: Use types which have consistent sizes across 32- and 64-bit compiles
Always use [unsigned] long long for 64-bit, [unsigned] int for 32-bit. Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx> diff -r 009f6704a2b6 -r 9b3c5bb22b50 xenalyze.c --- a/xenalyze.c Wed Nov 17 12:45:01 2010 +0000 +++ b/xenalyze.c Mon Nov 22 11:41:15 2010 +0000 @@ -262,7 +262,7 @@ /* -- General info about a current record -- */ struct time_struct { unsigned long long time; - unsigned long s, ns; + unsigned int s, ns; }; #define DUMP_HEADER_MAX 256 @@ -1233,14 +1233,14 @@ flag_oos_fixup_evict:1; }; }; /* Miami + ; fixup & emulate */ - unsigned long error_code; /* Rio only */ + unsigned int error_code; /* Rio only */ /* Calculated */ int pf_case; /* Rio */ /* MMIO only */ unsigned long long gpa; - unsigned long data; + unsigned int data; /* Emulate only */ unsigned long long gl1e; /* Miami + */ @@ -1313,7 +1313,7 @@ struct { unsigned port:31, is_write:1; - unsigned long val; + unsigned int val; } io; struct pf_xen_extra pf_xen; struct { @@ -1326,7 +1326,7 @@ unsigned long long val; } msr; struct { - unsigned long event; + unsigned int event; uint32_t d[4]; } generic; struct { @@ -1888,7 +1888,7 @@ abs_cycles_to_time(atsc, &t); - printf("%lu.%09lu %lld\n", t.s, t.ns, y); + printf("%u.%09u %lld\n", t.s, t.ns, y); } /* -- Summary Code -- */ @@ -2430,7 +2430,7 @@ struct time_struct t; abs_cycles_to_time(P.interval.start_tsc, &t); - printf("%lu.%09lu", t.s, t.ns); + printf("%u.%09u", t.s, t.ns); } void interval_table_output(void) { @@ -2929,11 +2929,11 @@ union { struct { unsigned long long va; - unsigned long error_code; + unsigned int error_code; } x64; struct { - unsigned long va; - unsigned long error_code; + unsigned int va; + unsigned int error_code; } x32; }; }; @@ -3271,19 +3271,19 @@ switch(e->pf_case) { case PF_XEN_EMULATE: - printf(" %s pf_xen:emulate va %llx ec %lx eip %llx%s lvl %d corr %llx\n", + printf(" %s pf_xen:emulate va %llx ec %x eip %llx%s lvl %d corr %llx\n", h->dump_header, e->va, e->error_code, h->rip, find_symbol(h->rip), e->pt_level, e->corresponding_va); break; case PF_XEN_MMIO: - printf(" %s pf_xen:mmio va %llx ec %lx eip %llx%s data %lx\n", + printf(" %s pf_xen:mmio va %llx ec %x eip %llx%s data %x\n", h->dump_header, e->va, e->error_code, h->rip, find_symbol(h->rip), e->data); break; default: - printf(" %s pf_xen va %llx ec %lx eip %llx%s\n", + printf(" %s pf_xen va %llx ec %x eip %llx%s\n", h->dump_header, e->va, e->error_code, h->rip, find_symbol(h->rip)); break; @@ -3308,14 +3308,14 @@ if(opt.dump_all) { if(e->pf_case == PF_XEN_EMULATE) - printf("]%s pf_xen:emulate va %llx ec %lx level %d corr %llx e->pt_index[%d %d %d %d %d]\n", + printf("]%s pf_xen:emulate va %llx ec %x level %d corr %llx e->pt_index[%d %d %d %d %d]\n", ri->dump_header, e->va, e->error_code, e->pt_level, e->corresponding_va, e->pt_index[0], e->pt_index[1], e->pt_index[2], e->pt_index[3], e->pt_index[4]); else - printf("]%s pf_xen va %llx ec %lx e->pt_index[%d %d %d %d %d]\n", + printf("]%s pf_xen va %llx ec %x e->pt_index[%d %d %d %d %d]\n", ri->dump_header, e->va, e->error_code, e->pt_index[0], e->pt_index[1], e->pt_index[2], e->pt_index[3], @@ -3353,7 +3353,7 @@ || (opt.dump_all && o->count > 1)) { struct time_struct t; cycles_to_time(lat, &t); - printf(" [vla] d%dv%d vec %d ipis %d, latency %lld (%lu.%09lu s)\n", + printf(" [vla] d%dv%d vec %d ipis %d, latency %lld (%u.%09u s)\n", v->d->did, v->vid, o->vec, o->count, lat, t.s, t.ns); } @@ -3404,7 +3404,7 @@ { struct pf_xen_extra *e = &h->inflight.pf_xen; union { - unsigned long val; + unsigned int val; struct { unsigned vec:8, delivery_mode:3, @@ -3550,12 +3550,12 @@ union { struct { - unsigned long gpa; - unsigned long data; + unsigned int gpa; + unsigned int data; } x32; struct { unsigned long long gpa; - unsigned long data; + unsigned int data; } x64; } *r = (typeof(r))h->d; @@ -3585,7 +3585,7 @@ if(opt.dump_all) { if(e->mmio_data_valid) - printf("]%s mmio_assist %c gpa %llx data %lx\n", h->dump_header, + printf("]%s mmio_assist %c gpa %llx data %x\n", h->dump_header, mevt.write?'w':'r', e->gpa, e->data); else printf("]%s mmio_assist %c gpa %llx (no data)\n", h->dump_header, @@ -3664,13 +3664,13 @@ /* I/O Handling */ struct io_address { struct io_address *next; - unsigned long pa; - unsigned long va; + unsigned int pa; + unsigned int va; struct event_cycle_summary summary[2]; }; -void update_io_address(struct io_address ** list, unsigned long pa, int dir, - tsc_t arc_cycles, unsigned long va) { +void update_io_address(struct io_address ** list, unsigned int pa, int dir, + tsc_t arc_cycles, unsigned int va) { struct io_address *p, *q=NULL; /* Keep list in order */ @@ -3710,13 +3710,13 @@ for(; list; list=list->next) { if ( list->va ) { - PRINT_SUMMARY(list->summary[0], "%8lx@%8lx:[r] ", list->pa, list->va); - PRINT_SUMMARY(list->summary[1], "%8lx@%8lx:[w] ", list->pa, list->va); + PRINT_SUMMARY(list->summary[0], "%8x@%8x:[r] ", list->pa, list->va); + PRINT_SUMMARY(list->summary[1], "%8x@%8x:[w] ", list->pa, list->va); } else { - PRINT_SUMMARY(list->summary[0], "%8lx:[r] ", list->pa); - PRINT_SUMMARY(list->summary[1], "%8lx:[w] ", list->pa); + PRINT_SUMMARY(list->summary[0], "%8x:[r] ", list->pa); + PRINT_SUMMARY(list->summary[1], "%8x:[w] ", list->pa); } } } @@ -3725,7 +3725,7 @@ { if(opt.dump_cooked) { - printf(" %s io_write port %x val %lx\n", + printf(" %s io_write port %x val %x\n", h->dump_header, h->inflight.io.port, h->inflight.io.val); } @@ -3737,7 +3737,7 @@ { if(opt.dump_cooked) { - printf(" %s io_read port %x val %lx\n", + printf(" %s io_read port %x val %x\n", h->dump_header, h->inflight.io.port, h->inflight.io.val); } @@ -3751,8 +3751,8 @@ { union { struct { - unsigned long port; - unsigned long data; + unsigned int port; + unsigned int data; } x32; } *r = (typeof(r))h->d; @@ -3784,7 +3784,7 @@ if(opt.dump_all) { - printf(" %s io %s port %lx val %lx\n", + printf(" %s io %s port %x val %x\n", h->dump_header, mevt.write?"write":"read", r->x32.port, @@ -4111,7 +4111,7 @@ union { struct { unsigned cr; - unsigned long val; + unsigned int val; } x32; struct { unsigned cr; @@ -4290,17 +4290,17 @@ void hvm_vmcall_process(struct record_info *ri, struct hvm_data *h) { struct { - unsigned long eax; + unsigned int eax; } *r = (typeof(r))h->d; if(opt.dump_all) { if(r->eax < HYPERCALL_MAX) - printf(" %s vmcall %2lx (%s)\n", + printf(" %s vmcall %2x (%s)\n", h->dump_header, r->eax, hypercall_name[r->eax]); else - printf(" %s vmcall %2lx\n", + printf(" %s vmcall %2x\n", h->dump_header, r->eax); } @@ -4321,11 +4321,11 @@ if ( opt.dump_cooked || opt.dump_all ) { if(r->vec < HVM_TRAP_MAX) - printf(" %3lu.%09lu %s inj_exc trap %s ec %x\n", + printf(" %3u.%09u %s inj_exc trap %s ec %x\n", ri->t.s, ri->t.ns, pcpu_string(ri->cpu), hvm_trap_name[r->vec], r->ec); else - printf(" %3lu.%09lu %s inj_exc trap %u ec %x\n", + printf(" %3u.%09u %s inj_exc trap %u ec %x\n", ri->t.s, ri->t.ns, pcpu_string(ri->cpu), r->vec, r->ec); } @@ -4396,7 +4396,7 @@ /* Want absolute tsc to global tsc */ abs_cycles_to_time(h->exit_tsc, &t); - printf("d%dv%d %lu.%09lu %lld\n", + printf("d%dv%d %u.%09u %lld\n", h->v->d->did, h->v->vid, t.s, t.ns, rip); @@ -4472,14 +4472,14 @@ union { struct { unsigned ec; - unsigned long cr2; + unsigned int cr2; } x32; struct { unsigned ec; unsigned long long cr2; } x64; } *r = (typeof(r))h->d; - unsigned long ec; + unsigned int ec; unsigned long long cr2; int is_64 = 0; @@ -4494,7 +4494,7 @@ if ( opt.dump_cooked || opt.dump_all ) { - printf(" %3lu.%09lu %s pf_inject%s guest_cr2 %llx guest_ec %lx\n", + printf(" %3u.%09u %s pf_inject%s guest_cr2 %llx guest_ec %x\n", ri->t.s, ri->t.ns, pcpu_string(ri->cpu), is_64?"64":"", cr2, ec); @@ -4555,7 +4555,7 @@ abs_cycles_to_time(ri->tsc, &t); - printf("%dv%d %lu.%09lu %llu\n", + printf("%dv%d %u.%09u %llu\n", h->v->d->did, h->v->vid, t.s, t.ns, r->tsc); @@ -4656,7 +4656,7 @@ case TRC_HVM_REINJ_VIRQ: if ( opt.dump_cooked || opt.dump_all ) { - printf(" %3lu.%09lu %s inj_virq vec %u\n", + printf(" %3u.%09u %s inj_virq vec %u\n", ri->t.s, ri->t.ns, pcpu_string(ri->cpu), *(unsigned*)h->d); } @@ -4682,7 +4682,7 @@ } if ( opt.dump_cooked || opt.dump_all ) { - printf(" %3lu.%09lu %s destroy_proc cur_cr3 %llx\n", + printf(" %3u.%09u %s destroy_proc cur_cr3 %llx\n", ri->t.s, ri->t.ns, pcpu_string(ri->cpu), h->v->cr3.val); } break; @@ -4850,11 +4850,11 @@ abs_cycles_to_time(tsc, &t); - printf("%dv%d %lu.%09lu %d\n", + printf("%dv%d %u.%09u %d\n", d->did, v->vid, t.s, t.ns, runstate_graph[v->runstate.state]); - printf("%dv%d %lu.%09lu %d\n", + printf("%dv%d %u.%09u %d\n", d->did, v->vid, t.s, t.ns, runstate_graph[new_runstate]); @@ -4870,7 +4870,7 @@ abs_cycles_to_time(tsc, &t); cycles_to_time(tsc - v->runstate.tsc, &dt); - printf("%dv%d %lu.%09lu %lu.%09lu\n", + printf("%dv%d %u.%09u %u.%09u\n", d->did, v->vid, t.s, t.ns, dt.s, dt.ns); @@ -4921,12 +4921,12 @@ struct { union { struct { - unsigned long exit_reason; + unsigned int exit_reason; unsigned long long rip; } x64; struct { - unsigned long exit_reason; - unsigned long eip; + unsigned int exit_reason; + unsigned int eip; } x32; }; } *r; @@ -4980,9 +4980,9 @@ if(h->exit_reason > h->exit_reason_max) { - fprintf(warn, "h->exit_reason %lx > exit_reason_max %lx!\n", - (unsigned long)h->exit_reason, - (unsigned long)h->exit_reason_max); + fprintf(warn, "h->exit_reason %x > exit_reason_max %x!\n", + (unsigned int)h->exit_reason, + (unsigned int)h->exit_reason_max); error(ERR_RECORD, ri); return; } @@ -5036,7 +5036,7 @@ if ( t.time ) { - r=snprintf(c, len, "%3lu.%09lu", t.s, t.ns); + r=snprintf(c, len, "%3u.%09u", t.s, t.ns); c+=r; len-=r; } @@ -5091,7 +5091,7 @@ abs_cycles_to_time(tsc, &t); - printf("d%dv%d %lu.%09lu %lld\n", + printf("d%dv%d %u.%09u %lld\n", h->v->d->did, h->v->vid, t.s, t.ns, @@ -5509,12 +5509,12 @@ /* D'OH! Accidentally used mfn_t in the struct, so gmfns are always 64-bit... :-/ */ struct { - unsigned long gfn, va; + unsigned int gfn, va; } gpl2; #endif struct { unsigned long long gfn; - unsigned long va; + unsigned int va; } gpl3; struct { unsigned long long gfn, va; @@ -5729,15 +5729,15 @@ /* for PAE, guest_l1e may be 64 while guest_va may be 32; so put it first for alignment sake. */ struct { - unsigned long gl1e, va, flags; + unsigned int gl1e, va, flags; } gpl2; struct { unsigned long long gl1e; - unsigned long va, flags; + unsigned int va, flags; } gpl3; struct { unsigned long long gl1e, va; - unsigned long flags; + unsigned int flags; } gpl4; } *r = (typeof(r))ri->d; union shadow_event sevt = { .event = ri->event }; @@ -5831,7 +5831,7 @@ if ( opt.dump_cooked ) { if(e->mmio_data_valid) - printf(" %s %smmio %s va %llx eip %llx%s gpa %llx data %lx\n", + printf(" %s %smmio %s va %llx eip %llx%s gpa %llx data %x\n", h->dump_header, (e->pf_case==PF_XEN_FAST_MMIO)?"fast ":"", e->mmio_is_write?"write":"read", @@ -5858,7 +5858,7 @@ /* for PAE, guest_l1e may be 64 while guest_va may be 32; so put it first for alignment sake. */ struct { - unsigned long va; + unsigned int va; } gpl2; struct { unsigned long long va; @@ -5929,15 +5929,15 @@ /* for PAE, guest_l1e may be 64 while guest_va may be 32; so put it first for alignment sake. */ struct { - unsigned long gl1e, va, flags; + unsigned int gl1e, va, flags; } gpl2; struct { unsigned long long gl1e; - unsigned long va, flags; + unsigned int va, flags; } gpl3; struct { unsigned long long gl1e, va; - unsigned long flags; + unsigned int flags; } gpl4; } *r = (typeof(r))ri->d; union shadow_event sevt = { .event = ri->event }; @@ -6002,7 +6002,7 @@ h->post_process = shadow_propagate_postprocess; } -void shadow_fault_generic_dump(unsigned long event, uint32_t *d, char *prefix, +void shadow_fault_generic_dump(unsigned int event, uint32_t *d, char *prefix, char * dump_header) { char *evt_string, evt_number[10]; @@ -6225,7 +6225,7 @@ } * r = (typeof(r)) ri->d; union pv_event pevt = { .event = ri->event }; unsigned long long eip; - unsigned long eax; + unsigned int eax; if(pevt.x64) { eip = r->x64.eip; @@ -6242,11 +6242,11 @@ if(opt.dump_cooked || opt.dump_all) { if(eax < HYPERCALL_MAX) - printf(" %s hypercall %2lx (%s) eip %llx\n", + printf(" %s hypercall %2x (%s) eip %llx\n", ri->dump_header, eax, hypercall_name[eax], eip); else - printf(" %s hypercall %lx eip %llx\n", + printf(" %s hypercall %x eip %llx\n", ri->dump_header, eax, eip); } } @@ -6254,7 +6254,7 @@ void pv_trap_process(struct record_info *ri, struct pv_data *pv) { union { struct { - unsigned long eip; + unsigned int eip; unsigned trapnr:15, use_error_code:1, error_code:16; @@ -6303,7 +6303,7 @@ /* gpl2 is deprecated */ struct { unsigned long long pte; - unsigned long addr, eip; + unsigned int addr, eip; } gpl3; struct { unsigned long long pte; @@ -6358,7 +6358,7 @@ /* gpl2 is deprecated */ struct { unsigned long long val; - unsigned long va, flags; + unsigned int va, flags; } x32; struct { unsigned long long val; @@ -6698,11 +6698,11 @@ abs_cycles_to_time(tsc, &t); if ( next->p ) - printf("%dv%d %lu.%09lu %d\n", + printf("%dv%d %u.%09u %d\n", next->d->did, next->vid, t.s, t.ns, next->p->pid); - printf("%dv%d %lu.%09lu %d\n", + printf("%dv%d %u.%09u %d\n", next->d->did, next->vid, t.s, t.ns, p->pid); @@ -6762,7 +6762,7 @@ unsigned long long p1, p2; } * r = (typeof(r))ri->d; union { - unsigned long event; + unsigned int event; struct { unsigned lo:4, new_runstate:4, @@ -7139,25 +7139,25 @@ struct vcpu_data *prev, *next; struct record_info *ri = &p->ri; struct { - unsigned long prev_dom, prev_vcpu, next_dom, next_vcpu; + unsigned int prev_dom, prev_vcpu, next_dom, next_vcpu; } * r = (typeof(r))ri->d; if(opt.dump_cooked || opt.dump_all) - printf("%s sched_switch prev d%luv%lu next d%luv%lu\n", + printf("%s sched_switch prev d%uv%u next d%uv%u\n", ri->dump_header, r->prev_dom, r->prev_vcpu, r->next_dom, r->next_vcpu); if(r->prev_vcpu > MAX_CPUS) { - fprintf(warn, "%s: prev_vcpu %lu > MAX_VCPUS %d!\n", + fprintf(warn, "%s: prev_vcpu %u > MAX_VCPUS %d!\n", __func__, r->prev_vcpu, MAX_CPUS); return; } if(r->next_vcpu > MAX_CPUS) { - fprintf(warn, "%s: next_vcpu %lu > MAX_VCPUS %d!\n", + fprintf(warn, "%s: next_vcpu %u > MAX_VCPUS %d!\n", __func__, r->next_vcpu, MAX_CPUS); return; } @@ -7208,7 +7208,7 @@ if(runstate_cycles[i]) { struct time_struct t; cycles_to_time(runstate_cycles[i], &t); - printf(" %s: %lu.%09lu s\n", + printf(" %s: %u.%09u s\n", runstate_name[i], t.s, t.ns); } } @@ -7936,7 +7936,7 @@ if ( ri->t.time ) { - r=snprintf(c, len, "%3lu.%09lu", ri->t.s, ri->t.ns); + r=snprintf(c, len, "%3u.%09u", ri->t.s, ri->t.ns); c+=r; len-=r; } @@ -8085,7 +8085,7 @@ /* print info */ cycles = ri->tsc - p->volume.buffer_first_tsc; cycles_to_time(cycles, &t); - printf("Buffer time: %lu.%09lu (%lld cycles)\n", + printf("Buffer time: %u.%09u (%lld cycles)\n", t.s, t.ns, cycles); if(p->volume.buffer_size) printf("Rate: %lld cycles / byte\n", @@ -8094,7 +8094,7 @@ { cycles = ri->tsc - P.buffer_trace_virq_tsc; cycles_to_time(cycles, &t); - printf("trace_virq latency: %lu.%09lu (%lld cycles)\n", + printf("trace_virq latency: %u.%09u (%lld cycles)\n", t.s, t.ns, cycles); P.buffer_trace_virq_tsc = 0; } _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |