diff options
author | iap10@freefall.cl.cam.ac.uk <iap10@freefall.cl.cam.ac.uk> | 2005-02-12 00:50:27 +0000 |
---|---|---|
committer | iap10@freefall.cl.cam.ac.uk <iap10@freefall.cl.cam.ac.uk> | 2005-02-12 00:50:27 +0000 |
commit | ec12127c4e11f1ac472a9668d3aa78e44dca0685 (patch) | |
tree | 52fb2612217f52e3b2b82764133ca3c6ff799481 /tools/xentrace/xenctx.c | |
parent | a9170d635241167f93da3e727175c58425fd7e98 (diff) | |
download | xen-ec12127c4e11f1ac472a9668d3aa78e44dca0685.tar.gz xen-ec12127c4e11f1ac472a9668d3aa78e44dca0685.tar.bz2 xen-ec12127c4e11f1ac472a9668d3aa78e44dca0685.zip |
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
Diffstat (limited to 'tools/xentrace/xenctx.c')
-rw-r--r-- | tools/xentrace/xenctx.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c new file mode 100644 index 0000000000..4a65d53169 --- /dev/null +++ b/tools/xentrace/xenctx.c @@ -0,0 +1,84 @@ +/****************************************************************************** + * tools/xentrace/xenctx.c + * + * Tool for dumping the cpu context + * + * Copyright (C) 2005 by Intel Corp + * + * Author: Arun Sharma <arun.sharma@intel.com> + * Date: February 2005 + */ + +#include <time.h> +#include <stdlib.h> +#include <sys/mman.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <errno.h> +#include <argp.h> +#include <signal.h> + +#include "xc.h" + +#ifdef __i386__ +void +print_ctx(full_execution_context_t *ctx1) +{ + execution_context_t *ctx = &ctx1->cpu_ctxt; + + printf("eip: %08lx\t", ctx->eip); + printf("esp: %08lx\n", ctx->esp); + + printf("eax: %08lx\t", ctx->eax); + printf("ebx: %08lx\t", ctx->ebx); + printf("ecx: %08lx\t", ctx->ecx); + printf("edx: %08lx\n", ctx->edx); + + printf("esi: %08lx\t", ctx->esi); + printf("edi: %08lx\t", ctx->edi); + printf("ebp: %08lx\n", ctx->ebp); + + printf(" cs: %08lx\t", ctx->cs); + printf(" ds: %08lx\t", ctx->ds); + printf(" fs: %08lx\t", ctx->fs); + printf(" gs: %08lx\n", ctx->gs); + +} +#endif + +void dump_ctx(u32 domid, u32 vcpu) +{ + int ret; + xc_domaininfo_t info; + full_execution_context_t ctx; + + int xc_handle = xc_interface_open(); /* for accessing control interface */ + + ret = xc_domain_getfullinfo(xc_handle, domid, vcpu, &info, &ctx); + if (ret != 0) { + perror("xc_domain_getfullinfo"); + exit(-1); + } + print_ctx(&ctx); + xc_interface_close(xc_handle); +} + +int main(int argc, char **argv) +{ + int vcpu = 0; + + if (argc < 2) { + printf("usage: xenctx <domid> <optional vcpu>\n"); + exit(-1); + } + + if (argc == 3) + vcpu = atoi(argv[2]); + + dump_ctx(atoi(argv[1]), vcpu); + + return 0; +} |