Pouech Eric DMI AEI CAEN a �crit :
Ok, I'll take a look at this, but if where shouldn't
be using two pointer types we should be using
SymGetTypeInfo in all cases?

the only (two things) you have to do are: - if one cannot find the pointer type in the pointee's module, then create a winedbg's type for the pointer type and store this type in a lookup table - in type_get_info, extend the types supported by also searching the lookup table for the pointers type. the lookup table should contain pointee type and module of pointee. You could also extend step 1 by not adding a pointer that already exists. A+
does the attached (and quickly hacked) patch help ?
A+

--
Eric Pouech
cvs diff: Diffing .
Index: types.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/types.c,v
retrieving revision 1.10
diff -u -r1.10 types.c
--- types.c	31 Jan 2005 11:34:59 -0000	1.10
+++ types.c	6 Mar 2005 14:17:55 -0000
@@ -114,7 +114,7 @@
      */
     if (!types_get_info(&lvalue->type, TI_GET_SYMTAG, &tag) ||
         tag != SymTagPointerType ||
-        memory_read_value(lvalue, sizeof(result->addr.Offset), &result->addr.Offset) ||
+        !memory_read_value(lvalue, sizeof(result->addr.Offset), &result->addr.Offset) ||
         !types_get_info(&lvalue->type, TI_GET_TYPE, &result->type.id))
         return FALSE;
     result->type.module = lvalue->type.module;
@@ -305,7 +305,6 @@
         case SymTagPointerType:
             type.module = sym->ModBase;
             type.id = sym->TypeIndex;
-            types_get_info(&type, TI_GET_TYPE, &type_id);
             if (types_get_info(&type, TI_GET_TYPE, &type_id) && type_id == user->u.typeid)
             {
                 user->result = sym->TypeIndex;
@@ -318,6 +317,16 @@
     return ret;
 }
 
+static struct type_internal_pointer
+{
+    unsigned long       pointee;
+} internal_pointers[256];
+
+#define IP_IDX2TYPE(i)     (0xfffffe00 + i)
+#define IP_TYPE2IDX(i)     (i - 0xfffffe00)
+#define IP_FIRSTTYPE       (0xfffffe00)
+#define IP_LASTTYPE        (0xfffffe00 + 256 - 1)
+
 /******************************************************************
  *		types_find_pointer
  *
@@ -326,15 +335,36 @@
  */
 struct dbg_type types_find_pointer(const struct dbg_type* type)
 {
-    struct type_find_t  f;
     struct dbg_type     ret;
 
-    f.result = dbg_itype_none;
-    f.tag = SymTagPointerType;
-    f.u.typeid = type->id;
-    SymEnumTypes(dbg_curr_process->handle, type->module, types_cb, &f);
-    ret.module = type->module;
-    ret.id = f.result;
+    if (type->module != 0)
+    {
+        struct type_find_t  f;
+    
+        f.result = dbg_itype_none;
+        f.tag = SymTagPointerType;
+        f.u.typeid = type->id;
+        SymEnumTypes(dbg_curr_process->handle, type->module, types_cb, &f);
+        ret.module = type->module;
+        ret.id = f.result;
+    }
+    else
+    {
+        int i;
+
+        ret.id = dbg_itype_none;
+        ret.module = 0;
+        for (i = 0; i < sizeof(internal_pointers) / sizeof(internal_pointers[0]); i++)
+        {
+            if (!internal_pointers[i].pointee || 
+                internal_pointers[i].pointee == type->id)
+            {
+                internal_pointers[i].pointee = type->id;
+                ret.id = IP_IDX2TYPE(i);
+                break;
+            }
+        }
+    }
     return ret;
 }
 
@@ -646,10 +676,26 @@
     if (type->module != 0)
         return SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, ti, pInfo);
 
-    assert(type->id >= dbg_itype_first);
 /* helper to typecast pInfo to its expected type (_t) */
 #define X(_t) (*((_t*)pInfo))
 
+    if (type->id >= IP_FIRSTTYPE && type->id <= IP_LASTTYPE)
+    {
+        switch (ti)
+        {
+        case TI_GET_SYMTAG:     X(DWORD) = SymTagPointerType; break;
+        case TI_GET_LENGTH:     X(DWORD) = 4; break;
+        case TI_GET_TYPE:
+        case TI_GET_TYPEID:     X(DWORD) = internal_pointers[IP_TYPE2IDX(type->id)].pointee; break;
+        default:
+            WINE_FIXME("requesting %u on internal pointee %lx\n", ti, type->id);
+            return FALSE;
+        }
+        return TRUE;
+    }
+
+    assert(type->id >= dbg_itype_first);
+
     switch (type->id)
     {
     case dbg_itype_unsigned_int:

Reply via email to