ia64/xen-unstable

changeset 16806:edc95d23493b

xenctx/x86: fix format for readability and add information
Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jan 18 15:27:02 2008 +0000 (2008-01-18)
parents 2d6a0ee25f2a
children 478c798b9937
files tools/xentrace/xenctx.c
line diff
     1.1 --- a/tools/xentrace/xenctx.c	Fri Jan 18 15:22:42 2008 +0000
     1.2 +++ b/tools/xentrace/xenctx.c	Fri Jan 18 15:27:02 2008 +0000
     1.3 @@ -29,6 +29,7 @@ int xc_handle = 0;
     1.4  int domid = 0;
     1.5  int frame_ptrs = 0;
     1.6  int stack_trace = 0;
     1.7 +int disp_all = 0;
     1.8  
     1.9  #if defined (__i386__)
    1.10  #if defined (__OpenBSD__)
    1.11 @@ -243,12 +244,23 @@ void print_flags(uint64_t flags)
    1.12  {
    1.13      int i;
    1.14  
    1.15 -    printf("flags: %08" PRIx64, flags);
    1.16 +    printf("\nflags: %08" PRIx64, flags);
    1.17      for (i = 21; i >= 0; i--) {
    1.18          char *s = flag_values[i][(flags >> i) & 1];
    1.19          if (s != NULL)
    1.20              printf(" %s", s);
    1.21      }
    1.22 +    printf("\n");
    1.23 +}
    1.24 +
    1.25 +void print_special(unsigned long *regs, const char *name, unsigned int mask)
    1.26 +{
    1.27 +    unsigned int i;
    1.28 +
    1.29 +    printf("\n");
    1.30 +    for (i = 0; mask; mask >>= 1, ++i)
    1.31 +        if (mask & 1)
    1.32 +            printf("%s%u: " FMT_SIZE_T "\n", name, i, (size_t)regs[i]);
    1.33  }
    1.34  #endif
    1.35  
    1.36 @@ -257,12 +269,10 @@ void print_ctx(vcpu_guest_context_t *ctx
    1.37  {
    1.38      struct cpu_user_regs *regs = &ctx1->user_regs;
    1.39  
    1.40 -    printf("eip: %08x ", regs->eip);
    1.41 +    printf("cs:eip: %04x:%08x ", regs->cs, regs->eip);
    1.42      print_symbol(regs->eip);
    1.43      print_flags(regs->eflags);
    1.44 -    printf("\n");
    1.45 -
    1.46 -    printf("esp: %08x\n", regs->esp);
    1.47 +    printf("ss:esp: %04x:%08x\n", regs->ss, regs->esp);
    1.48  
    1.49      printf("eax: %08x\t", regs->eax);
    1.50      printf("ebx: %08x\t", regs->ebx);
    1.51 @@ -273,47 +283,59 @@ void print_ctx(vcpu_guest_context_t *ctx
    1.52      printf("edi: %08x\t", regs->edi);
    1.53      printf("ebp: %08x\n", regs->ebp);
    1.54  
    1.55 -    printf(" cs: %08x\t", regs->cs);
    1.56 -    printf(" ds: %08x\t", regs->ds);
    1.57 -    printf(" fs: %08x\t", regs->fs);
    1.58 -    printf(" gs: %08x\n", regs->gs);
    1.59 +    printf(" ds:     %04x\t", regs->ds);
    1.60 +    printf(" es:     %04x\t", regs->es);
    1.61 +    printf(" fs:     %04x\t", regs->fs);
    1.62 +    printf(" gs:     %04x\n", regs->gs);
    1.63  
    1.64 +    if (disp_all) {
    1.65 +        print_special(ctx1->ctrlreg, "cr", 0x1d);
    1.66 +        print_special(ctx1->debugreg, "dr", 0xcf);
    1.67 +    }
    1.68  }
    1.69  #elif defined(__x86_64__)
    1.70  void print_ctx(vcpu_guest_context_t *ctx1)
    1.71  {
    1.72      struct cpu_user_regs *regs = &ctx1->user_regs;
    1.73  
    1.74 -    printf("rip: %08lx ", regs->rip);
    1.75 +    printf("rip: %016lx ", regs->rip);
    1.76      print_symbol(regs->rip);
    1.77      print_flags(regs->rflags);
    1.78 -    printf("\n");
    1.79 -    printf("rsp: %08lx\n", regs->rsp);
    1.80 -
    1.81 -    printf("rax: %08lx\t", regs->rax);
    1.82 -    printf("rbx: %08lx\t", regs->rbx);
    1.83 -    printf("rcx: %08lx\t", regs->rcx);
    1.84 -    printf("rdx: %08lx\n", regs->rdx);
    1.85 -
    1.86 -    printf("rsi: %08lx\t", regs->rsi);
    1.87 -    printf("rdi: %08lx\t", regs->rdi);
    1.88 -    printf("rbp: %08lx\n", regs->rbp);
    1.89 +    printf("rsp: %016lx\n", regs->rsp);
    1.90  
    1.91 -    printf(" r8: %08lx\t", regs->r8);
    1.92 -    printf(" r9: %08lx\t", regs->r9);
    1.93 -    printf("r10: %08lx\t", regs->r10);
    1.94 -    printf("r11: %08lx\n", regs->r11);
    1.95 +    printf("rax: %016lx\t", regs->rax);
    1.96 +    printf("rcx: %016lx\t", regs->rcx);
    1.97 +    printf("rdx: %016lx\n", regs->rdx);
    1.98  
    1.99 -    printf("r12: %08lx\t", regs->r12);
   1.100 -    printf("r13: %08lx\t", regs->r13);
   1.101 -    printf("r14: %08lx\t", regs->r14);
   1.102 -    printf("r15: %08lx\n", regs->r15);
   1.103 +    printf("rbx: %016lx\t", regs->rbx);
   1.104 +    printf("rsi: %016lx\t", regs->rsi);
   1.105 +    printf("rdi: %016lx\n", regs->rdi);
   1.106  
   1.107 -    printf(" cs:     %04x\t", regs->cs);
   1.108 -    printf(" ds:     %04x\t", regs->ds);
   1.109 -    printf(" fs:     %04x\t", regs->fs);
   1.110 -    printf(" gs:     %04x\n", regs->gs);
   1.111 +    printf("rbp: %016lx\t", regs->rbp);
   1.112 +    printf(" r8: %016lx\t", regs->r8);
   1.113 +    printf(" r9: %016lx\n", regs->r9);
   1.114  
   1.115 +    printf("r10: %016lx\t", regs->r10);
   1.116 +    printf("r11: %016lx\t", regs->r11);
   1.117 +    printf("r12: %016lx\n", regs->r12);
   1.118 +
   1.119 +    printf("r13: %016lx\t", regs->r13);
   1.120 +    printf("r14: %016lx\t", regs->r14);
   1.121 +    printf("r15: %016lx\n", regs->r15);
   1.122 +
   1.123 +    printf(" cs: %04x\t", regs->cs);
   1.124 +    printf(" ss: %04x\t", regs->ss);
   1.125 +    printf(" ds: %04x\t", regs->ds);
   1.126 +    printf(" es: %04x\n", regs->es);
   1.127 +
   1.128 +    printf(" fs: %04x @ %016lx\n", regs->fs, ctx1->fs_base);
   1.129 +    printf(" gs: %04x @ %016lx/%016lx\n", regs->gs,
   1.130 +           ctx1->gs_base_kernel, ctx1->gs_base_user);
   1.131 +
   1.132 +    if (disp_all) {
   1.133 +        print_special(ctx1->ctrlreg, "cr", 0x1d);
   1.134 +        print_special(ctx1->debugreg, "dr", 0xcf);
   1.135 +    }
   1.136  }
   1.137  #elif defined(__ia64__)
   1.138  
   1.139 @@ -742,6 +764,8 @@ void usage(void)
   1.140  #ifdef __ia64__
   1.141      printf("  -r LIST, --regs=LIST  display more registers.\n");
   1.142      printf("  -a --all          same as --regs=tlb,cr,ar,br,bk\n");
   1.143 +#else
   1.144 +    printf("  -a --all          display more registers\n");
   1.145  #endif
   1.146  }
   1.147  
   1.148 @@ -811,6 +835,10 @@ int main(int argc, char **argv)
   1.149              disp_bank_regs = 1;
   1.150              disp_tlb = 1;
   1.151              break;
   1.152 +#else
   1.153 +        case 'a':
   1.154 +            disp_all = 1;
   1.155 +            break;
   1.156  #endif
   1.157          case 'h':
   1.158              usage();