direct-io.hg

changeset 3802:b1a798ce6dbf

bitkeeper revision 1.1189 (420d52d34bmxozCOzbUs5pmo2zfT-w)

Subject: [PATCH] xenctx.patch

Does this sound interesting? I found it useful to debug looping guests.
A gdb stub would be nicer - but this one is lighter weight.
-Arun
Tool for dumping the cpu context
# xenctx 1 0
eip: c01dfeab esp: c1603c98
eax: 00000020 ebx: c0432e10 ecx: 00000ee6 edx: 000001f7
esi: c0432d60 edi: 00000296 ebp: c0432d60
cs: 00000060 ds: 00000068 fs: 00000000 gs: 00000033

Signed-off-by: Arun Sharma <arun.sharma@intel.com>
Signed-off-by: ian@xensource.com
author iap10@freefall.cl.cam.ac.uk
date Sat Feb 12 00:50:27 2005 +0000 (2005-02-12)
parents 69f8d9612f8d
children 856c8d422f0d
files .rootkeys tools/xentrace/xenctx.c xen/arch/x86/dom0_ops.c
line diff
     1.1 --- a/.rootkeys	Sat Feb 12 00:48:04 2005 +0000
     1.2 +++ b/.rootkeys	Sat Feb 12 00:50:27 2005 +0000
     1.3 @@ -846,6 +846,7 @@ 41d58ba6qyr2BkTcH2WlNBYLRyl2Yw tools/xcs
     1.4  41d58ba6ijEF6fedqRO5vFu7uCirZg tools/xcs/xcsdump.c
     1.5  403a3edbrr8RE34gkbR40zep98SXbg tools/xentrace/Makefile
     1.6  40a107afN60pFdURgBv9KwEzgRl5mQ tools/xentrace/formats
     1.7 +420d52d2_znVbT4JAPIU36vQOme83g tools/xentrace/xenctx.c
     1.8  4050c413PhhLNAYk3TEwP37i_iLw9Q tools/xentrace/xentrace.8
     1.9  403a3edbVpV2E_wq1zeEkJ_n4Uu2eg tools/xentrace/xentrace.c
    1.10  403a3edblCUrzSj0mmKhO5HOPrOrSQ tools/xentrace/xentrace_format
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/xentrace/xenctx.c	Sat Feb 12 00:50:27 2005 +0000
     2.3 @@ -0,0 +1,84 @@
     2.4 +/******************************************************************************
     2.5 + * tools/xentrace/xenctx.c
     2.6 + *
     2.7 + * Tool for dumping the cpu context
     2.8 + *
     2.9 + * Copyright (C) 2005 by Intel Corp
    2.10 + *
    2.11 + * Author: Arun Sharma <arun.sharma@intel.com>
    2.12 + * Date:   February 2005
    2.13 + */
    2.14 +
    2.15 +#include <time.h>
    2.16 +#include <stdlib.h>
    2.17 +#include <sys/mman.h>
    2.18 +#include <stdio.h>
    2.19 +#include <sys/types.h>
    2.20 +#include <sys/stat.h>
    2.21 +#include <fcntl.h>
    2.22 +#include <unistd.h>
    2.23 +#include <errno.h>
    2.24 +#include <argp.h>
    2.25 +#include <signal.h>
    2.26 +
    2.27 +#include "xc.h"
    2.28 +
    2.29 +#ifdef __i386__
    2.30 +void
    2.31 +print_ctx(full_execution_context_t *ctx1)
    2.32 +{
    2.33 +    execution_context_t *ctx = &ctx1->cpu_ctxt;
    2.34 +
    2.35 +    printf("eip: %08lx\t", ctx->eip);
    2.36 +    printf("esp: %08lx\n", ctx->esp);
    2.37 +
    2.38 +    printf("eax: %08lx\t", ctx->eax);
    2.39 +    printf("ebx: %08lx\t", ctx->ebx);
    2.40 +    printf("ecx: %08lx\t", ctx->ecx);
    2.41 +    printf("edx: %08lx\n", ctx->edx);
    2.42 +
    2.43 +    printf("esi: %08lx\t", ctx->esi);
    2.44 +    printf("edi: %08lx\t", ctx->edi);
    2.45 +    printf("ebp: %08lx\n", ctx->ebp);
    2.46 +
    2.47 +    printf(" cs: %08lx\t", ctx->cs);
    2.48 +    printf(" ds: %08lx\t", ctx->ds);
    2.49 +    printf(" fs: %08lx\t", ctx->fs);
    2.50 +    printf(" gs: %08lx\n", ctx->gs);
    2.51 +
    2.52 +}
    2.53 +#endif
    2.54 +
    2.55 +void dump_ctx(u32 domid, u32 vcpu)
    2.56 +{
    2.57 +    int ret;
    2.58 +    xc_domaininfo_t info;
    2.59 +    full_execution_context_t ctx;
    2.60 +
    2.61 +    int xc_handle = xc_interface_open(); /* for accessing control interface */
    2.62 +
    2.63 +    ret = xc_domain_getfullinfo(xc_handle, domid, vcpu, &info, &ctx);
    2.64 +    if (ret != 0) {
    2.65 +        perror("xc_domain_getfullinfo");
    2.66 +        exit(-1);
    2.67 +    }
    2.68 +    print_ctx(&ctx);
    2.69 +    xc_interface_close(xc_handle);
    2.70 +}
    2.71 +
    2.72 +int main(int argc, char **argv)
    2.73 +{
    2.74 +    int vcpu = 0;
    2.75 +
    2.76 +    if (argc < 2) {
    2.77 +        printf("usage: xenctx <domid> <optional vcpu>\n");
    2.78 +        exit(-1);
    2.79 +    }
    2.80 +
    2.81 +    if (argc == 3)
    2.82 +        vcpu = atoi(argv[2]);
    2.83 +
    2.84 +    dump_ctx(atoi(argv[1]), vcpu);
    2.85 +
    2.86 +    return 0;
    2.87 +}
     3.1 --- a/xen/arch/x86/dom0_ops.c	Sat Feb 12 00:48:04 2005 +0000
     3.2 +++ b/xen/arch/x86/dom0_ops.c	Sat Feb 12 00:50:27 2005 +0000
     3.3 @@ -348,11 +348,17 @@ void arch_getdomaininfo_ctxt(
     3.4      struct exec_domain *ed, full_execution_context_t *c)
     3.5  { 
     3.6      int i;
     3.7 +    unsigned long vmx_domain = ed->arch.arch_vmx.flags;
     3.8 +    extern void save_vmx_execution_context(execution_context_t *);
     3.9  
    3.10      c->flags = 0;
    3.11      memcpy(&c->cpu_ctxt, 
    3.12             &ed->arch.user_ctxt,
    3.13             sizeof(ed->arch.user_ctxt));
    3.14 +
    3.15 +    if (vmx_domain)
    3.16 +        save_vmx_execution_context(&c->cpu_ctxt);
    3.17 +
    3.18      if ( test_bit(EDF_DONEFPUINIT, &ed->ed_flags) )
    3.19          c->flags |= ECF_I387_VALID;
    3.20      if ( KERNEL_MODE(ed, &ed->arch.user_ctxt) )