[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v4 05/15] xenctx: Add command line option -D (--decode-as-ascii)



On 03/19/14 12:09, George Dunlap wrote:
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 <Don@xxxxxxxxxxxxxxx>
---
  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."


Ok.

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.


Will do.  Thanks,
    -Don Slutz

 -George



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.