From: Don Slutz Subject: [PATCH v2 03/12] xenctx: Output ascii version of stack also. Date: Wed, 6 Nov 2013 15:08:11 -0500 Message-ID: <1383768500-4245-4-git-send-email-dslutz@terremark.com> References: <1383768500-4245-1-git-send-email-dslutz@terremark.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1383768500-4245-1-git-send-email-dslutz@terremark.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org, George Dunlap , Ian Jackson , Stefano Stabellini , Ian Campbell , Jan Beulich Cc: Don Slutz List-Id: xen-devel@lists.xenproject.org From: Don Slutz Signed-off-by: Don Slutz --- tools/xentrace/xenctx.c | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-) diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c index 06a8850..dabce16 100644 --- a/tools/xentrace/xenctx.c +++ b/tools/xentrace/xenctx.c @@ -640,6 +640,8 @@ static int print_code(vcpu_guest_context_any_t *ctx, int vcpu) return 0; } +#define BYTES_PER_LINE 32 + static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width) { guest_word_t stack = stack_pointer(ctx); @@ -647,6 +649,8 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width) 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) @@ -656,15 +660,36 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width) printf("\n"); printf("Stack:\n"); for (i=1; i<10 && stack < stack_limit; i++) { - while(stack < stack_limit && stack < stack_pointer(ctx) + i*32) { + int j = 0; + int k; + + while(stack < stack_limit && stack < stack_pointer(ctx) + i*BYTES_PER_LINE) { p = map_page(ctx, vcpu, stack); if (!p) return -1; word = read_stack_word(p, width); + ascii[j++] = word; printf(" "); print_stack_word(word, width); stack += width; } + printf(" "); + for (k = j; k < BYTES_PER_LINE/width; k++) + printf("%s ", width == 8 + ? " " + : " "); + for (k = 0; k < j; k++) { + int l; + + bytep = (unsigned char*)&ascii[k]; + for (l = 0; l < width; l++) { + if ((*bytep < 127) && (*bytep >= 32)) + printf("%c", *bytep); + else + printf("."); + bytep++; + } + } printf("\n"); } printf("\n"); -- 1.7.1