From: Don Slutz Subject: [PATCH v8 18/20] xenctx: Add 16 bit output Date: Thu, 27 Mar 2014 15:05:45 -0400 Message-ID: <1395947147-5262-19-git-send-email-dslutz@verizon.com> References: <1395947147-5262-1-git-send-email-dslutz@verizon.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1395947147-5262-1-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: xen-devel@lists.xen.org Cc: Ian Campbell , Stefano Stabellini , George Dunlap , Ian Jackson , Don Slutz , Jan Beulich List-Id: xen-devel@lists.xenproject.org This output happens on !guest_protected_mode. The cpu is in 16 bit mode in this case. The "-m" option was not changed so that a 32 bit memory dump could still be done. For example: $ xenctx 3 cs:eip: f000:00006dee flags: 00000046 z p ss:esp: 0000:00001fea eax: 00000000 ebx: 0000e000 ecx: 00006de9 edx: 00000000 esi: 0000fff0 edi: 00000000 ebp: 00000000 ds: 0000 es: 0040 fs: 0000 gs: 0000 Code (instr addr 000f6dee) 66 53 66 e8 0f 65 00 00 66 5b 66 5e 66 5f 66 c3 fb 90 f3 90 fa 66 c3 eb 06 66 49 67 88 14 08 Stack: 7bf6 0000 8e30 0000 0246 812f 0000 0206 80e7 0080 0080 And: $ xenctx 3 -d 0x00001fea -m 0x00001fe8 -l 1 Memory (address 00001fe8): 7bf60000 8e300000 02460000 0000812f 80e70206 00800080 c2c2c2c2 c2c2c2c2 Stack: 7bf6 0000 8e30 0000 0246 812f 0000 0206 80e7 0080 0080 Note: the memory address is aligned to 32 bits. The unaligned output: $ xenctx 3 -m 0x00001fea -l 1 Memory (address 00001fea): 00007bf6 00008e30 812f0246 02060000 008080e7 c2c20080 c2c2c2c2 c2c2c2c2 Signed-off-by: Don Slutz --- tools/xentrace/xenctx.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c index 9aed57e..b7f6e0f 100644 --- a/tools/xentrace/xenctx.c +++ b/tools/xentrace/xenctx.c @@ -53,6 +53,7 @@ typedef enum type_of_addr_ { static const uint64_t cr_reg_mask[5] = { [2] = ~UINT64_C(0) }; static const uint64_t dr_reg_mask[8] = { [0 ... 3] = ~UINT64_C(0) }; typedef unsigned long long guest_word_t; +#define FMT_16B_WORD "%04llx" #define FMT_32B_WORD "%08llx" #define FMT_64B_WORD "%016llx" /* Word-length of the guest's own data structures */ @@ -776,7 +777,9 @@ static guest_word_t read_mem_word(vcpu_guest_context_any_t *ctx, int vcpu, static void print_stack_word(guest_word_t word, int width) { - if (width == 4) + if (width == 2) + printf(FMT_16B_WORD, word); + else if (width == 4) printf(FMT_32B_WORD, word); else printf(FMT_64B_WORD, word); @@ -1043,7 +1046,9 @@ static void dump_ctx(int vcpu) } if ( xenctx.do_stack ) { - print_stack(&ctx, vcpu, guest_word_size, xenctx.stk_addr); + print_stack(&ctx, vcpu, + !guest_protected_mode ? 2 : guest_word_size, + xenctx.stk_addr); return; } #endif @@ -1053,7 +1058,8 @@ static void dump_ctx(int vcpu) return; if ( !guest_protected_mode || kernel_addr(instr_pointer(&ctx)) >= KERNEL_TEXT_ADDR ) - if ( print_stack(&ctx, vcpu, guest_word_size, + if ( print_stack(&ctx, vcpu, + !guest_protected_mode ? 2 : guest_word_size, stack_pointer(&ctx)) ) return; #endif -- 1.8.4