Alexandre Julliard : winedbg: Fix formatting of the flag register bits.

Alexandre Julliard julliard at winehq.org
Mon May 4 09:06:36 CDT 2009


Module: wine
Branch: master
Commit: b26ae69fcb81e2b579fae118a68dc25b20f5548e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b26ae69fcb81e2b579fae118a68dc25b20f5548e

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri May  1 18:28:49 2009 +0200

winedbg: Fix formatting of the flag register bits.

---

 programs/winedbg/be_i386.c   |   30 +++++++-----------------------
 programs/winedbg/be_x86_64.c |   31 ++++++++-----------------------
 2 files changed, 15 insertions(+), 46 deletions(-)

diff --git a/programs/winedbg/be_i386.c b/programs/winedbg/be_i386.c
index 3638463..ce2076c 100644
--- a/programs/winedbg/be_i386.c
+++ b/programs/winedbg/be_i386.c
@@ -197,8 +197,9 @@ static void be_i386_all_print_context(HANDLE hThread, const CONTEXT* ctx)
 
 static void be_i386_print_context(HANDLE hThread, const CONTEXT* ctx, int all_regs)
 {
+    static const char flags[] = "aVR-N--ODITSZ-A-P-C";
+    int i;
     char        buf[33];
-    char*       pt;
 
     dbg_printf("Register dump:\n");
 
@@ -208,28 +209,11 @@ static void be_i386_print_context(HANDLE hThread, const CONTEXT* ctx, int all_re
                (WORD)ctx->SegDs, (WORD)ctx->SegEs,
                (WORD)ctx->SegFs, (WORD)ctx->SegGs);
 
-    strcpy(buf, "   - 00      - - - ");
-    pt = buf + strlen(buf) - 1;
-    if (ctx->EFlags & 0x00000001) *pt-- = 'C'; /* Carry Flag */
-    if (ctx->EFlags & 0x00000002) *pt-- = '1';
-    if (ctx->EFlags & 0x00000004) *pt-- = 'P'; /* Parity Flag */
-    if (ctx->EFlags & 0x00000008) *pt-- = '-';
-    if (ctx->EFlags & 0x00000010) *pt-- = 'A'; /* Auxiliary Carry Flag */
-    if (ctx->EFlags & 0x00000020) *pt-- = '-';
-    if (ctx->EFlags & 0x00000040) *pt-- = 'Z'; /* Zero Flag */
-    if (ctx->EFlags & 0x00000080) *pt-- = 'S'; /* Sign Flag */
-    if (ctx->EFlags & 0x00000100) *pt-- = 'T'; /* Trap/Trace Flag */
-    if (ctx->EFlags & 0x00000200) *pt-- = 'I'; /* Interrupt Enable Flag */
-    if (ctx->EFlags & 0x00000400) *pt-- = 'D'; /* Direction Indicator */
-    if (ctx->EFlags & 0x00000800) *pt-- = 'O'; /* Overflow flags */
-    if (ctx->EFlags & 0x00001000) *pt-- = '1'; /* I/O Privilege Level */
-    if (ctx->EFlags & 0x00002000) *pt-- = '1'; /* I/O Privilege Level */
-    if (ctx->EFlags & 0x00004000) *pt-- = 'N'; /* Nested Task Flag */
-    if (ctx->EFlags & 0x00008000) *pt-- = '-';
-    if (ctx->EFlags & 0x00010000) *pt-- = 'R'; /* Resume Flag */
-    if (ctx->EFlags & 0x00020000) *pt-- = 'V'; /* Virtual Mode Flag */
-    if (ctx->EFlags & 0x00040000) *pt-- = 'a'; /* Alignment Check Flag */
-    
+    strcpy(buf, flags);
+    for (i = 0; buf[i]; i++)
+        if (buf[i] != '-' && !(ctx->EFlags & (1 << (sizeof(flags) - 2 - i))))
+            buf[i] = ' ';
+
     switch (get_selector_type(hThread, ctx, ctx->SegCs))
     {
     case AddrMode1616:
diff --git a/programs/winedbg/be_x86_64.c b/programs/winedbg/be_x86_64.c
index e822012..6f4bf7e 100644
--- a/programs/winedbg/be_x86_64.c
+++ b/programs/winedbg/be_x86_64.c
@@ -66,31 +66,16 @@ static void be_x86_64_single_step(CONTEXT* ctx, unsigned enable)
 static void be_x86_64_print_context(HANDLE hThread, const CONTEXT* ctx,
                                     int all_regs)
 {
-    char *pt, buf[33];
+    static const char flags[] = "aVR-N--ODITSZ-A-P-C";
+    char buf[33];
+    int i;
 
-    dbg_printf("Register dump:\n");
-    strcpy(buf, "   - 00      - - - ");
-    pt = buf + strlen(buf) - 1;
-    if (ctx->EFlags & 0x00000001) *pt-- = 'C'; /* Carry Flag */
-    if (ctx->EFlags & 0x00000002) *pt-- = '1';
-    if (ctx->EFlags & 0x00000004) *pt-- = 'P'; /* Parity Flag */
-    if (ctx->EFlags & 0x00000008) *pt-- = '-';
-    if (ctx->EFlags & 0x00000010) *pt-- = 'A'; /* Auxiliary Carry Flag */
-    if (ctx->EFlags & 0x00000020) *pt-- = '-';
-    if (ctx->EFlags & 0x00000040) *pt-- = 'Z'; /* Zero Flag */
-    if (ctx->EFlags & 0x00000080) *pt-- = 'S'; /* Sign Flag */
-    if (ctx->EFlags & 0x00000100) *pt-- = 'T'; /* Trap/Trace Flag */
-    if (ctx->EFlags & 0x00000200) *pt-- = 'I'; /* Interrupt Enable Flag */
-    if (ctx->EFlags & 0x00000400) *pt-- = 'D'; /* Direction Indicator */
-    if (ctx->EFlags & 0x00000800) *pt-- = 'O'; /* Overflow flags */
-    if (ctx->EFlags & 0x00001000) *pt-- = '1'; /* I/O Privilege Level */
-    if (ctx->EFlags & 0x00002000) *pt-- = '1'; /* I/O Privilege Level */
-    if (ctx->EFlags & 0x00004000) *pt-- = 'N'; /* Nested Task Flag */
-    if (ctx->EFlags & 0x00008000) *pt-- = '-';
-    if (ctx->EFlags & 0x00010000) *pt-- = 'R'; /* Resume Flag */
-    if (ctx->EFlags & 0x00020000) *pt-- = 'V'; /* Virtual Mode Flag */
-    if (ctx->EFlags & 0x00040000) *pt-- = 'a'; /* Alignment Check Flag */
+    strcpy(buf, flags);
+    for (i = 0; buf[i]; i++)
+        if (buf[i] != '-' && !(ctx->EFlags & (1 << (sizeof(flags) - 2 - i))))
+            buf[i] = ' ';
 
+    dbg_printf("Register dump:\n");
     dbg_printf(" rip:%016lx rsp:%016lx rbp:%016lx eflags:%08x (%s)\n",
                ctx->Rip, ctx->Rsp, ctx->Rbp, ctx->EFlags, buf);
     dbg_printf(" rax:%016lx rbx:%016lx rcx:%016lx rdx:%016lx\n",




More information about the wine-cvs mailing list