WineDbg: types management

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

 



this patch shall enhance the info symbol command by also printing the actual type of a symbol
it also contains a complete rewrite of types dumping function so that:
- all members of a structure get actually displayed
- it becomes pointer neutral, so that one can compare output between different runs of the debugger

A+
--
Eric Pouech
Name:          wd_types
ChangeLog:     
	- added GetName() to retrieve type name
	- reimplemented DumpTypes so that it really dumps the types content
	- now printing type information in 'info sym'
License:       X11
GenDate:       2003/02/15 20:21:16 UTC
ModifiedFiles: programs/winedbg/types.c programs/winedbg/debugger.h
AddedFiles:    
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/types.c,v
retrieving revision 1.1
diff -u -u -r1.1 types.c
--- programs/winedbg/types.c	13 Sep 2002 17:54:28 -0000	1.1
+++ programs/winedbg/types.c	15 Feb 2003 11:11:34 -0000
@@ -617,7 +617,7 @@
 	    }
 	}
       m = (struct member *) DBG_alloc(sizeof(struct member));
-      if( m == FALSE )
+      if( m == NULL )
 	{
 	  return FALSE;
 	}
@@ -946,79 +946,87 @@
   return;
 }
 
-int
-DEBUG_DumpTypes(void)
+static void DEBUG_DumpAType(struct datatype* dt, BOOL deep)
 {
-  struct datatype * dt = NULL;
-  struct member * m;
-  int hash;
-  int nm;
-  char * name;
-  char * member_name;
+    char* name = (dt->name) ? dt->name : "--none--";
+
+/* EPP     DEBUG_Printf(DBG_CHN_MESG, "0x%08lx ", (unsigned long)dt); */
+    switch (dt->type)
+    {
+    case DT_BASIC:
+        DEBUG_Printf(DBG_CHN_MESG, "BASIC(%s)", name);
+        break;
+    case DT_POINTER:
+        DEBUG_Printf(DBG_CHN_MESG, "POINTER(%s)<", name);
+        DEBUG_DumpAType(dt->un.pointer.pointsto, FALSE);
+        DEBUG_Printf(DBG_CHN_MESG, ">");
+        break;
+    case DT_STRUCT:
+        DEBUG_Printf(DBG_CHN_MESG, "STRUCT(%s) %d {",
+                     name, dt->un.structure.size);
+        if (dt->un.structure.members != NULL)
+        {
+            struct member * m;
+            for (m = dt->un.structure.members; m; m = m->next)
+            {
+                DEBUG_Printf(DBG_CHN_MESG, " %s(%d", 
+                             m->name, m->offset / 8);
+                if (m->offset % 8 != 0)
+                    DEBUG_Printf(DBG_CHN_MESG, ".%d", m->offset / 8);
+                DEBUG_Printf(DBG_CHN_MESG, "/%d", m->size / 8);
+                if (m->size % 8 != 0)
+                    DEBUG_Printf(DBG_CHN_MESG, ".%d", m->size % 8);
+                DEBUG_Printf(DBG_CHN_MESG, ")");
+            }
+        }
+        DEBUG_Printf(DBG_CHN_MESG, " }");
+        break;
+    case DT_ARRAY:
+        DEBUG_Printf(DBG_CHN_MESG, "ARRAY(%s)[", name);
+        DEBUG_DumpAType(dt->un.array.basictype, FALSE);
+        DEBUG_Printf(DBG_CHN_MESG, "]");
+        break;
+    case DT_ENUM:
+        DEBUG_Printf(DBG_CHN_MESG, "ENUM(%s)", name);
+        break;
+    case DT_BITFIELD:
+        DEBUG_Printf(DBG_CHN_MESG, "BITFIELD(%s)", name);
+        break;
+    case DT_FUNC:
+        DEBUG_Printf(DBG_CHN_MESG, "FUNC(%s)(", name);
+        DEBUG_DumpAType(dt->un.funct.rettype, FALSE);
+        DEBUG_Printf(DBG_CHN_MESG, ")");
+        break;
+    default:
+        DEBUG_Printf(DBG_CHN_ERR, "Unknown type???");
+        break;
+    }
+    if (deep) DEBUG_Printf(DBG_CHN_MESG, "\n");
+}
+
+int DEBUG_DumpTypes(void)
+{
+    struct datatype * dt = NULL;
+    int hash;
 
-  for(hash = 0; hash < NR_TYPE_HASH + 1; hash++)
+    for (hash = 0; hash < NR_TYPE_HASH + 1; hash++)
     {
-      for( dt = type_hash_table[hash]; dt; dt = dt->next )
+        for (dt = type_hash_table[hash]; dt; dt = dt->next)
 	{
-	  name =  "none";
-	  if( dt->name != NULL )
-	    {
-	      name = dt->name;
-	    }
-	  switch(dt->type)
-	    {
-	    case DT_BASIC:
-	      DEBUG_Printf(DBG_CHN_MESG, "0x%08lx - BASIC(%s)\n",
-			   (unsigned long)dt, name);
-	      break;
-	    case DT_POINTER:
-	      DEBUG_Printf(DBG_CHN_MESG, "0x%08lx - POINTER(%s)(%08lx)\n",
-			   (unsigned long)dt, name, (unsigned long)dt->un.pointer.pointsto);
-	      break;
-	    case DT_STRUCT:
-	      member_name = "none";
-	      nm = 0;
-	      if( dt->un.structure.members != NULL
-		  && dt->un.structure.members->name != NULL )
-		{
-		  member_name = dt->un.structure.members->name;
-		  for( m = dt->un.structure.members; m; m = m->next)
-		    {
-		      nm++;
-		    }
-		}
-	      DEBUG_Printf(DBG_CHN_MESG, "0x%08lx - STRUCT(%s) %d %d %s\n",
-			   (unsigned long)dt, name, dt->un.structure.size, nm, member_name);
-	      break;
-	    case DT_ARRAY:
-	      DEBUG_Printf(DBG_CHN_MESG, "0x%08lx - ARRAY(%s)(%08lx)\n",
-			   (unsigned long)dt, name, (unsigned long)dt->un.array.basictype);
-	      break;
-	    case DT_ENUM:
-	      DEBUG_Printf(DBG_CHN_MESG, "0x%08lx - ENUM(%s)\n",
-			   (unsigned long)dt, name);
-	      break;
-	    case DT_BITFIELD:
-	      DEBUG_Printf(DBG_CHN_MESG, "0x%08lx - BITFIELD(%s)\n",
-			   (unsigned long)dt, name);
-	      break;
-	    case DT_FUNC:
-	      DEBUG_Printf(DBG_CHN_MESG, "0x%08lx - FUNC(%s)(%08lx)\n",
-			   (unsigned long)dt, name, (unsigned long)dt->un.funct.rettype);
-	      break;
-	    default:
-	      DEBUG_Printf(DBG_CHN_ERR, "Unknown type???\n");
-	      break;
-	    }
+            DEBUG_DumpAType(dt, TRUE);
 	}
     }
-  return TRUE;
+    return TRUE;
 }
 
-
 enum debug_type DEBUG_GetType(struct datatype * dt)
 {
   return dt->type;
+}
+
+const char* DEBUG_GetName(struct datatype * dt)
+{
+  return dt->name;
 }
 
 struct datatype *
Index: programs/winedbg/debugger.h
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/debugger.h,v
retrieving revision 1.5
diff -u -u -r1.5 debugger.h
--- programs/winedbg/debugger.h	11 Feb 2003 22:05:06 -0000	1.5
+++ programs/winedbg/debugger.h	15 Feb 2003 13:30:43 -0000
@@ -511,11 +509,13 @@
 extern int DEBUG_SetBitfieldParams(struct datatype * dt, int offset,
 				   int nbits, struct datatype * dt2);
 extern int DEBUG_CopyFieldlist(struct datatype * dt, struct datatype * dt2);
+extern const char* DEBUG_GetName(struct datatype * dt);
 extern enum debug_type DEBUG_GetType(struct datatype * dt);
 extern struct datatype * DEBUG_TypeCast(enum debug_type, const char *);
 extern int DEBUG_PrintTypeCast(const struct datatype *);
 extern int DEBUG_PrintType( const DBG_VALUE* addr );
 extern struct datatype * DEBUG_GetBasicType(enum debug_type_basic);
+extern int DEBUG_DumpTypes(void);
 
   /* debugger/winedbg.c */
 #define DBG_CHN_MESG	1

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux