ia64/xen-unstable

changeset 16039:1ead02bab5c8

xenctx: Print EFLAGS for i386 and x86/64.
From: Peter Johnston <pjohnston@xensource.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Tue Oct 02 09:41:10 2007 +0100 (2007-10-02)
parents 60c898eeb17b
children 8426ac1a5df8
files tools/xentrace/xenctx.c
line diff
     1.1 --- a/tools/xentrace/xenctx.c	Tue Oct 02 09:35:37 2007 +0100
     1.2 +++ b/tools/xentrace/xenctx.c	Tue Oct 02 09:41:10 2007 +0100
     1.3 @@ -21,6 +21,7 @@
     1.4  #include <argp.h>
     1.5  #include <signal.h>
     1.6  #include <string.h>
     1.7 +#include <inttypes.h>
     1.8  #include <getopt.h>
     1.9  
    1.10  #include "xenctrl.h"
    1.11 @@ -152,9 +153,9 @@ void print_symbol(size_t addr)
    1.12          return;
    1.13  
    1.14      if (addr==s->address)
    1.15 -        printf("%s", s->name);
    1.16 +        printf("%s ", s->name);
    1.17      else
    1.18 -        printf("%s+%#x", s->name, (unsigned int)(addr - s->address));
    1.19 +        printf("%s+%#x ", s->name, (unsigned int)(addr - s->address));
    1.20  }
    1.21  
    1.22  void read_symbol_table(const char *symtab)
    1.23 @@ -207,6 +208,46 @@ void read_symbol_table(const char *symta
    1.24      fclose(f);
    1.25  }
    1.26  
    1.27 +#if defined(__i386__) || defined(__x86_64__)
    1.28 +char *flag_values[22][2] =
    1.29 +{/*  clear,     set,       bit# */
    1.30 +    { NULL,     "c"    }, // 0        Carry
    1.31 +    { NULL,     NULL   }, // 1
    1.32 +    { NULL,     "p"    }, // 2        Parity
    1.33 +    { NULL,     NULL   }, // 3
    1.34 +    { NULL,     "a"    }, // 4        Adjust
    1.35 +    { NULL,     NULL   }, // 5
    1.36 +    { "nz",     "z"    }, // 6        Zero
    1.37 +    { NULL,     "s"    }, // 7        Sign
    1.38 +    { NULL,     "tf"   }, // 8        Trap
    1.39 +    { NULL,     "i"    }, // 9        Interrupt (enabled)
    1.40 +    { NULL,     "d=b"  }, // 10       Direction
    1.41 +    { NULL,     "o"    }, // 11       Overflow
    1.42 +    { NULL,     NULL   }, // 12       12+13 == IOPL
    1.43 +    { NULL,     NULL   }, // 13
    1.44 +    { NULL,     "nt"   }, // 14       Nested Task
    1.45 +    { NULL,     NULL   }, // 15
    1.46 +    { NULL,     "rf"   }, // 16       Resume Flag
    1.47 +    { NULL,     "v86"  }, // 17       Virtual 8086 mode
    1.48 +    { NULL,     "ac"   }, // 18       Alignment Check (enabled)
    1.49 +    { NULL,     "vif"  }, // 19       Virtual Interrupt (enabled)
    1.50 +    { NULL,     "vip"  }, // 20       Virtual Interrupt Pending
    1.51 +    { NULL,     "cid"  }  // 21       Cpuid Identification Flag
    1.52 +};
    1.53 +
    1.54 +void print_flags(uint64_t flags)
    1.55 +{
    1.56 +    int i;
    1.57 +
    1.58 +    printf("flags: %08" PRIx64, flags);
    1.59 +    for (i = 21; i >= 0; i--) {
    1.60 +        char *s = flag_values[i][(flags >> i) & 1];
    1.61 +        if (s != NULL)
    1.62 +            printf(" %s", s);
    1.63 +    }
    1.64 +}
    1.65 +#endif
    1.66 +
    1.67  #ifdef __i386__
    1.68  void print_ctx(vcpu_guest_context_t *ctx1)
    1.69  {
    1.70 @@ -214,6 +255,7 @@ void print_ctx(vcpu_guest_context_t *ctx
    1.71  
    1.72      printf("eip: %08x ", regs->eip);
    1.73      print_symbol(regs->eip);
    1.74 +    print_flags(regs->eflags);
    1.75      printf("\n");
    1.76  
    1.77      printf("esp: %08x\n", regs->esp);
    1.78 @@ -240,6 +282,7 @@ void print_ctx(vcpu_guest_context_t *ctx
    1.79  
    1.80      printf("rip: %08lx ", regs->rip);
    1.81      print_symbol(regs->rip);
    1.82 +    print_flags(regs->rflags);
    1.83      printf("\n");
    1.84      printf("rsp: %08lx\n", regs->rsp);
    1.85  
    1.86 @@ -262,10 +305,10 @@ void print_ctx(vcpu_guest_context_t *ctx
    1.87      printf("r14: %08lx\t", regs->r14);
    1.88      printf("r15: %08lx\n", regs->r15);
    1.89  
    1.90 -    printf(" cs: %08x\t", regs->cs);
    1.91 -    printf(" ds: %08x\t", regs->ds);
    1.92 -    printf(" fs: %08x\t", regs->fs);
    1.93 -    printf(" gs: %08x\n", regs->gs);
    1.94 +    printf(" cs:     %04x\t", regs->cs);
    1.95 +    printf(" ds:     %04x\t", regs->ds);
    1.96 +    printf(" fs:     %04x\t", regs->fs);
    1.97 +    printf(" gs:     %04x\n", regs->gs);
    1.98  
    1.99  }
   1.100  #elif defined(__ia64__)