[PATCH 22/22] [WineDbg]: int 64

Eric Pouech eric.pouech at wanadoo.fr
Fri Nov 24 15:18:51 CST 2006


- added basic support for printing 64bit wide entities in
  winedbg

A+
---

 programs/winedbg/debugger.h |    1 +
 programs/winedbg/memory.c   |   16 ++++++++++------
 programs/winedbg/types.c    |   33 +++++++++++++++++++++------------
 3 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h
index e436956..b57da24 100644
--- a/programs/winedbg/debugger.h
+++ b/programs/winedbg/debugger.h
@@ -392,6 +392,7 @@ extern void             print_value(cons
 extern int              types_print_type(const struct dbg_type*, BOOL details);
 extern int              print_types(void);
 extern long int         types_extract_as_integer(const struct dbg_lvalue*);
+extern long long int    types_extract_as_longlong(const struct dbg_lvalue*);
 extern void             types_extract_as_address(const struct dbg_lvalue*, ADDRESS64*);
 extern BOOL             types_deref(const struct dbg_lvalue* value, struct dbg_lvalue* result);
 extern BOOL             types_udt_find_element(struct dbg_lvalue* value, const char* name, long int* tmpbuf);
diff --git a/programs/winedbg/memory.c b/programs/winedbg/memory.c
index 7a2a818..75e4d98 100644
--- a/programs/winedbg/memory.c
+++ b/programs/winedbg/memory.c
@@ -466,7 +466,7 @@ static void print_typed_basic(const stru
  */
 void print_basic(const struct dbg_lvalue* lvalue, int count, char format)
 {
-    long int    res;
+    long long int       res;
 
     if (lvalue->type.id == dbg_itype_none)
     {
@@ -474,7 +474,7 @@ void print_basic(const struct dbg_lvalue
         return;
     }
 
-    res = types_extract_as_integer(lvalue);
+    res = types_extract_as_longlong(lvalue);
 
     /* FIXME: this implies i386 byte ordering */
     switch (format)
@@ -482,13 +482,14 @@ void print_basic(const struct dbg_lvalue
     case 'x':
         if (lvalue->addr.Mode == AddrMode1616 || 
             lvalue->addr.Mode == AddrModeReal)
-            dbg_printf("0x%lx", res);
+            dbg_printf("0x%lx", (DWORD)(ULONG64)res);
         else
-            dbg_printf("0x%lx", res);
+            dbg_printf("0x%lx", (DWORD)(ULONG64)res);
         break;
 
     case 'd':
-        dbg_printf("%ld\n", res);
+        dbg_print_longlong(res, TRUE);
+        dbg_printf("\n");
         break;
 
     case 'c':
@@ -511,7 +512,10 @@ void print_basic(const struct dbg_lvalue
         dbg_printf("Format specifier '%c' is meaningless in 'print' command\n", format);
     case 0:
         if (lvalue->type.id == dbg_itype_segptr)
-            dbg_printf("%ld", res);
+        {
+            dbg_print_longlong(res, TRUE);
+            dbg_printf("\n");
+        }
         else 
             print_typed_basic(lvalue);
         break;
diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c
index da62669..08fcfaa 100644
--- a/programs/winedbg/types.c
+++ b/programs/winedbg/types.c
@@ -48,15 +48,14 @@ BOOL types_get_real_type(struct dbg_type
 }
 
 /******************************************************************
- *		types_extract_as_integer
+ *		types_extract_as_longlong
  *
  * Given a lvalue, try to get an integral (or pointer/address) value
  * out of it
  */
-long int types_extract_as_integer(const struct dbg_lvalue* lvalue)
+long long int types_extract_as_longlong(const struct dbg_lvalue* lvalue)
 {
-    long int            rtn;
-    LONGLONG            val;
+    LONGLONG            rtn;
     DWORD               tag, bt;
     DWORD64             size;
     struct dbg_type     type = lvalue->type;
@@ -87,30 +86,29 @@ long int types_extract_as_integer(const 
         {
         case btChar:
         case btInt:
-            if (!be_cpu->fetch_integer(lvalue, (unsigned)size, TRUE, &val))
+            if (!be_cpu->fetch_integer(lvalue, (unsigned)size, TRUE, &rtn))
                 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
-            rtn = (long)val;
             break;
         case btUInt:
-            if (!be_cpu->fetch_integer(lvalue, (unsigned)size, FALSE, &val))
+            if (!be_cpu->fetch_integer(lvalue, (unsigned)size, FALSE, &rtn))
                 RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
-            rtn = (DWORD)(DWORD64)val;
             break;
         case btFloat:
             RaiseException(DEBUG_STATUS_NOT_AN_INTEGER, 0, 0, NULL);
         }
         break;
     case SymTagPointerType:
-        if (!memory_read_value(lvalue, sizeof(void*), &rtn))
+        if (!be_cpu->fetch_integer(lvalue, sizeof(void*), FALSE, &rtn))
             RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
         break;
     case SymTagArrayType:
     case SymTagUDT:
-        if (!memory_read_value(lvalue, sizeof(rtn), &rtn))
+        if (!be_cpu->fetch_integer(lvalue, sizeof(unsigned), FALSE, &rtn))
             RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
         break;
     case SymTagEnum:
-        if (!memory_read_value(lvalue, sizeof(rtn), &rtn))
+        /* FIXME: we don't handle enum size */
+        if (!be_cpu->fetch_integer(lvalue, sizeof(unsigned), FALSE, &rtn))
             RaiseException(DEBUG_STATUS_INTERNAL_ERROR, 0, 0, NULL);
         break;
     case SymTagFunctionType:
@@ -126,6 +124,17 @@ long int types_extract_as_integer(const 
 }
 
 /******************************************************************
+ *		types_extract_as_integer
+ *
+ * Given a lvalue, try to get an integral (or pointer/address) value
+ * out of it
+ */
+long int types_extract_as_integer(const struct dbg_lvalue* lvalue)
+{
+    return types_extract_as_longlong(lvalue);
+}
+
+/******************************************************************
  *		types_extract_as_address
  *
  *
@@ -139,7 +148,7 @@ void types_extract_as_address(const stru
     else
     {
         addr->Mode = AddrModeFlat;
-        addr->Offset = types_extract_as_integer( lvalue );
+        addr->Offset = types_extract_as_longlong( lvalue );
     }
 }
 



More information about the wine-patches mailing list