From mboxrd@z Thu Jan 1 00:00:00 1970 From: George Dunlap Subject: Re: [PATCH v4 05/15] xenctx: Add command line option -D (--decode-as-ascii) Date: Wed, 19 Mar 2014 16:09:21 +0000 Message-ID: <5329C131.9080204@eu.citrix.com> References: <1395180940-23901-1-git-send-email-dslutz@verizon.com> <1395180940-23901-6-git-send-email-dslutz@verizon.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1395180940-23901-6-git-send-email-dslutz@verizon.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: Don Slutz , xen-devel@lists.xen.org Cc: Don Slutz , Ian Jackson , Ian Campbell , Jan Beulich , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On 03/18/2014 10:15 PM, Don Slutz wrote: > If specified, output ascii version of stack also. > > Here is an example: > > Stack: > ffffffff80048d19 0000000000200800 ffffffff803e7801 0000000000086800 .......... ......x>......h...... > 0000000000000000 ffffffff80430720 ffffffff803e722f 80008e000010019c ........ .C...../r>............. > 00000000ffffffff 0000000000000000 0000000000000000 0000000000200000 .......................... ..... > 0000000000000000 0000000000000000 ................ > > Signed-off-by: Don Slutz > --- > tools/xentrace/xenctx.c | 35 ++++++++++++++++++++++++++++++++++- > 1 file changed, 34 insertions(+), 1 deletion(-) > > diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c > index 62a8519..850e091 100644 > --- a/tools/xentrace/xenctx.c > +++ b/tools/xentrace/xenctx.c > @@ -38,6 +38,7 @@ static struct xenctx { > int multiple_pages; > int bytes_per_line; > int lines; > + int decode_as_ascii; > int all_vcpus; > int self_paused; > xc_dominfo_t dominfo; > @@ -665,6 +666,7 @@ 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[MAX_BYTES_PER_LINE/4]; > int i; > > if ( width ) > @@ -679,6 +681,9 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width) > printf("Stack:\n"); > for (i = 1; i < xenctx.lines + 1 && stack < stack_limit; i++) > { > + int j = 0; > + int k; > + > while ( stack < stack_limit && > stack < stack_pointer(ctx) + i * xenctx.bytes_per_line ) > { > @@ -686,10 +691,32 @@ static int print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width) > if ( !p ) > return -1; > word = read_stack_word(p, width); > + if ( xenctx.decode_as_ascii ) > + ascii[j++] = word; > printf(" "); > print_stack_word(word, width); > stack += width; > } > + printf(" "); > + if ( xenctx.decode_as_ascii ) > + { > + for (k = j; k < xenctx.bytes_per_line / width; k++) > + printf(" %*s", width*2, ""); It might be nice to have a comment here explaining what this is doing: maybe, "Line up ascii output if less than bytes_per_line were printed." Also, the printf(" ") line above should probably go under this for loop. It goes here logically, and it avoids printing trailing whitespace if decode_as_ascii is false. -George