|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 08/12] xenctx: Add -d <daddr> option to dump memory at daddr as a stack.
From: Don Slutz <Don@xxxxxxxxxxxxxxx>
Signed-off-by: Don Slutz <Don@xxxxxxxxxxxxxxx>
---
tools/xentrace/xenctx.c | 85 ++++++++++++++++++++++++++++-------------------
1 files changed, 51 insertions(+), 34 deletions(-)
diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index 4dc6574..233f537 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -642,18 +642,21 @@ static int print_code(vcpu_guest_context_any_t *ctx, int
vcpu)
#define BYTES_PER_LINE 16
-static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
+static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width,
guest_word_t stk_addr)
{
- guest_word_t stack = stack_pointer(ctx);
+ guest_word_t stk_addr_start = stack_pointer(ctx);
+ guest_word_t stack;
guest_word_t stack_limit;
guest_word_t frame;
guest_word_t word;
- guest_word_t *p;
guest_word_t ascii[BYTES_PER_LINE/4];
unsigned char *bytep;
int i;
- stack_limit = ((stack_pointer(ctx) + XC_PAGE_SIZE)
+ if (stk_addr && !xenctx.frame_ptrs)
+ stk_addr_start = stk_addr;
+ stack = stk_addr_start;
+ stack_limit = ((stk_addr_start + XC_PAGE_SIZE)
& ~((guest_word_t) XC_PAGE_SIZE - 1));
if (xenctx.two_pages)
stack_limit += XC_PAGE_SIZE;
@@ -665,8 +668,8 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int
vcpu, int width)
print_stack_word(stack, width);
printf(":");
- while(stack < stack_limit && stack < stack_pointer(ctx) +
i*BYTES_PER_LINE) {
- p = map_page(ctx, vcpu, stack);
+ while(stack < stack_limit && stack < stk_addr_start +
i*BYTES_PER_LINE) {
+ void *p = map_page(ctx, vcpu, stack);
if (!p)
return -1;
word = read_stack_word(p, width);
@@ -700,16 +703,19 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int
vcpu, int width)
printf("Stack Trace:\n");
else
printf("Call Trace:\n");
- printf("%s ", width == 8
- ? " "
- : " ");
- printf("%c [<", xenctx.stack_trace ? '*' : ' ');
- print_stack_word(instr_pointer(ctx), width);
- printf(">]");
-
- print_symbol(instr_pointer(ctx));
- printf(" <--\n");
+ if (!stk_addr || xenctx.frame_ptrs) {
+ printf("%s ", width == 8
+ ? " "
+ : " ");
+ printf("%c [<", xenctx.stack_trace ? '*' : ' ');
+ print_stack_word(instr_pointer(ctx), width);
+ printf(">]");
+ print_symbol(instr_pointer(ctx));
+ printf(" <--\n");
+ }
if (xenctx.frame_ptrs) {
+ void *p;
+
stack = stack_pointer(ctx);
frame = frame_pointer(ctx);
while(frame && stack < stack_limit) {
@@ -755,9 +761,9 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int
vcpu, int width)
}
}
} else {
- stack = stack_pointer(ctx);
+ stack = stk_addr_start;
while(stack < stack_limit) {
- p = map_page(ctx, vcpu, stack);
+ void *p = map_page(ctx, vcpu, stack);
if (!p)
return -1;
word = read_stack_word(p, width);
@@ -781,7 +787,7 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int
vcpu, int width)
}
#endif
-static void dump_ctx(int vcpu)
+static void dump_ctx(int vcpu, guest_word_t stk_addr)
{
vcpu_guest_context_any_t ctx;
@@ -820,17 +826,21 @@ static void dump_ctx(int vcpu)
}
#endif
- print_ctx(&ctx);
+ if (!stk_addr) {
+ print_ctx(&ctx);
+ }
#ifndef NO_TRANSLATION
- if (print_code(&ctx, vcpu))
- return;
- if (is_kernel_text(instr_pointer(&ctx)))
- if (print_stack(&ctx, vcpu, guest_word_size))
- return;
+ if (!stk_addr) {
+ print_code(&ctx, vcpu);
+ if (is_kernel_text(instr_pointer(&ctx)))
+ print_stack(&ctx, vcpu, guest_word_size, stk_addr);
+ } else {
+ print_stack(&ctx, vcpu, guest_word_size, stk_addr);
+ }
#endif
}
-static void dump_all_vcpus(void)
+static void dump_all_vcpus(guest_word_t stk_addr)
{
xc_vcpuinfo_t vinfo;
int vcpu;
@@ -839,7 +849,7 @@ static void dump_all_vcpus(void)
if ( xc_vcpu_getinfo(xenctx.xc_handle, xenctx.domid, vcpu, &vinfo) )
continue;
if ( vinfo.online )
- dump_ctx(vcpu);
+ dump_ctx(vcpu, stk_addr);
}
}
@@ -855,31 +865,35 @@ static void usage(void)
printf(" frame pointers.\n");
printf(" -s SYMTAB, --symbol-table=SYMTAB\n");
printf(" read symbol table from SYMTAB.\n");
- printf(" -S --stack-trace print a complete stack trace.\n");
- printf(" -k, --kernel-start\n");
- printf(" set user/kernel split. (default
0xc0000000)\n");
- printf(" -a --all display more registers\n");
+ printf(" -S, --stack-trace print a complete stack trace.\n");
+ printf(" -k kaddr, --kernel-start=kaddr\n");
+ printf(" set user/kernel split at kaddr. (default
0xc0000000)\n");
+ printf(" -d daddr, --dump-as-stack=daddr\n");
+ printf(" dump memory as a stack at daddr.\n");
+ printf(" -a, --all display more registers\n");
printf(" -2, --two-pages assume the kernel was compiled with 8KiB
stacks.\n");
- printf(" -C --all-vcpus print info for all vcpus\n");
+ printf(" -C, --all-vcpus print info for all vcpus\n");
}
int main(int argc, char **argv)
{
int ch;
int ret;
- static const char *sopts = "fs:hak:SC2";
+ static const char *sopts = "fs:hak:SCd:2";
static const struct option lopts[] = {
{"stack-trace", 0, NULL, 'S'},
{"symbol-table", 1, NULL, 's'},
{"frame-pointers", 0, NULL, 'f'},
{"kernel-start", 1, NULL, 'k'},
{"two-pages", 0, NULL, '2'},
+ {"dump-as-stack", 1, NULL, 'd'},
{"all", 0, NULL, 'a'},
{"all-vcpus", 0, NULL, 'C'},
{"help", 0, NULL, 'h'},
{0, 0, 0, 0}
};
const char *symbol_table = NULL;
+ guest_word_t stk_addr = 0;
int vcpu = 0;
@@ -906,6 +920,9 @@ int main(int argc, char **argv)
case 'k':
kernel_start = strtoull(optarg, NULL, 0);
break;
+ case 'd':
+ stk_addr = strtoull(optarg, NULL, 0);
+ break;
case 'h':
usage();
exit(-1);
@@ -956,9 +973,9 @@ int main(int argc, char **argv)
}
if (xenctx.all_vcpus)
- dump_all_vcpus();
+ dump_all_vcpus(stk_addr);
else
- dump_ctx(vcpu);
+ dump_ctx(vcpu, stk_addr);
if (xenctx.self_paused) {
ret = xc_domain_unpause(xenctx.xc_handle, xenctx.domid);
--
1.7.1
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |