winedbg

Eric Pouech eric.pouech at wanadoo.fr
Thu Aug 1 14:26:09 CDT 2002


as per Max request, here's a patch which adds $regs as an internal
variable
using p $regs will print the registers (as info regs would do)
the interesting part is that this can be used in a display command
display $regs

A+
-------------- next part --------------
Name:          wdbg_regs
ChangeLog:     added  as a variable for displaying all registers
License:       X11
GenDate:       2002/08/01 19:22:34 UTC
ModifiedFiles: debugger/dbg.y debugger/debugger.h debugger/info.c debugger/intvar.h debugger/registers.c debugger/types.c debugger/winedbg.c
AddedFiles:    
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/debugger/dbg.y,v
retrieving revision 1.61
diff -u -u -r1.61 dbg.y
--- debugger/dbg.y	30 Jul 2002 00:06:34 -0000	1.61
+++ debugger/dbg.y	1 Aug 2002 19:20:54 -0000
@@ -230,7 +230,7 @@
     | tINFO tSHARE tEOL		{ DEBUG_InfoShare(); }
     | tINFO tMODULE expr_value tEOL   { DEBUG_DumpModule( $3 ); DEBUG_FreeExprMem(); }
     | tINFO tQUEUE expr_value tEOL    { DEBUG_DumpQueue( $3 ); DEBUG_FreeExprMem(); }
-    | tINFO tREGS tEOL          { DEBUG_InfoRegisters(); }
+    | tINFO tREGS tEOL          { DEBUG_InfoRegisters(&DEBUG_context); }
     | tINFO tSEGMENTS expr_value tEOL { DEBUG_InfoSegments( $3, 1 ); DEBUG_FreeExprMem(); }
     | tINFO tSEGMENTS tEOL      { DEBUG_InfoSegments( 0, -1 ); }
     | tINFO tSTACK tEOL         { DEBUG_InfoStack(); }
Index: debugger/debugger.h
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/debugger/debugger.h,v
retrieving revision 1.40
diff -u -u -r1.40 debugger.h
--- debugger/debugger.h	30 Jul 2002 00:06:34 -0000	1.40
+++ debugger/debugger.h	1 Aug 2002 19:20:14 -0000
@@ -56,6 +57,8 @@
                           DT_BASIC_STRING,
                           /* this is for historical reasons... should take care of it RSN */
                           DT_BASIC_CONST_INT,
+                          /* not so basic, but handy */
+                          DT_BASIC_CONTEXT,
                           /* to be kept as last... sentinel entry... do not use */
                           DT_BASIC_LAST};
 
@@ -456,7 +459,7 @@
 extern void DEBUG_InitCVDataTypes(void);
 
   /* debugger/registers.c */
-extern void DEBUG_InfoRegisters(void);
+extern void DEBUG_InfoRegisters(const CONTEXT* ctx);
 extern BOOL DEBUG_ValidateRegisters(void);
 
   /* debugger/source.c */
Index: debugger/info.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/debugger/info.c,v
retrieving revision 1.26
diff -u -u -r1.26 info.c
--- debugger/info.c	2 Jun 2002 21:36:08 -0000	1.26
+++ debugger/info.c	30 Jul 2002 20:45:14 -0000
@@ -86,56 +86,63 @@
     case 'b':
         DEBUG_Printf(DBG_CHN_MESG, "Format specifier '%c' is meaningless in 'print' command\n", format);
     case 0:
-        if (default_format != NULL)
-	{
-            if (strstr(default_format, "%S") != NULL)
-	    {
-                char* 	ptr;
-                int	state = 0;
+        if (default_format == NULL) break;
 
-                /* FIXME: simplistic implementation for default_format being
-                 * foo%Sbar => will print foo, then string then bar
-                 */
-                for (ptr = default_format; *ptr; ptr++)
+        if (strstr(default_format, "%S") != NULL)
+        {
+            char* 	ptr;
+            int	state = 0;
+
+            /* FIXME: simplistic implementation for default_format being
+             * foo%Sbar => will print foo, then string then bar
+             */
+            for (ptr = default_format; *ptr; ptr++)
+            {
+                if (*ptr == '%')
+                {
+                    state++;
+                }
+                else if (state == 1)
                 {
-                    if (*ptr == '%')
+                    if (*ptr == 'S')
                     {
-                        state++;
-                    }
-                    else if (state == 1)
-		    {
-                        if (*ptr == 'S')
-                        {
-                            DBG_ADDR    addr;
+                        DBG_ADDR    addr;
 
-                            addr.seg = 0;
-                            addr.off = (long)res;
-                            DEBUG_nchar += DEBUG_PrintStringA(DBG_CHN_MESG, &addr, -1);
-                        }
-                        else
-                        {
-			    /* shouldn't happen */
-			    DEBUG_Printf(DBG_CHN_MESG, "%%%c", *ptr);
-			    DEBUG_nchar += 2;
-                        }
-                        state = 0;
-		    }
+                        addr.seg = 0;
+                        addr.off = (long)res;
+                        DEBUG_nchar += DEBUG_PrintStringA(DBG_CHN_MESG, &addr, -1);
+                    }
                     else
-		    {
-                        DEBUG_OutputA(DBG_CHN_MESG, ptr, 1);
-                        DEBUG_nchar++;
-		    }
+                    {
+                        /* shouldn't happen */
+                        DEBUG_Printf(DBG_CHN_MESG, "%%%c", *ptr);
+                        DEBUG_nchar += 2;
+                    }
+                    state = 0;
+                }
+                else
+                {
+                    DEBUG_OutputA(DBG_CHN_MESG, ptr, 1);
+                    DEBUG_nchar++;
                 }
-	    }
-            else if (strcmp(default_format, "%B") == 0)
-            {
-                DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "%s", res ? "true" : "false");
             }
+        }
+        else if (strcmp(default_format, "%B") == 0)
+        {
+            DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, "%s", res ? "true" : "false");
+        }
+        else if (strcmp(default_format, "%R") == 0)
+        {
+            if (value->cookie == DV_HOST)
+                DEBUG_InfoRegisters((CONTEXT*)value->addr.off);
             else
-	    {
-                DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, default_format, res);
-	    }
-	}
+                DEBUG_Printf(DBG_CHN_MESG, "NIY: info on register struct in debuggee address space\n");
+            DEBUG_nchar = 0;
+        }
+        else
+        {
+            DEBUG_nchar += DEBUG_Printf(DBG_CHN_MESG, default_format, res);
+        }
         break;
     }
 }
Index: debugger/intvar.h
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/debugger/intvar.h,v
retrieving revision 1.9
diff -u -u -r1.9 intvar.h
--- debugger/intvar.h	30 Jul 2002 00:06:34 -0000	1.9
+++ debugger/intvar.h	1 Aug 2002 19:14:13 -0000
@@ -64,10 +64,12 @@
 INTERNAL_VAR(di,			0,		&DEBUG_context.Edi,  	DT_BASIC_USHORTINT)
 INTERNAL_VAR(ebp,			0,		&DEBUG_context.Ebp,  	DT_BASIC_CONST_INT)
 INTERNAL_VAR(bp,			0,		&DEBUG_context.Ebp,  	DT_BASIC_USHORTINT)
 INTERNAL_VAR(es,			0,		&DEBUG_context.SegEs,  	DT_BASIC_CONST_INT)
 INTERNAL_VAR(ds,			0,		&DEBUG_context.SegDs,  	DT_BASIC_CONST_INT)
 INTERNAL_VAR(cs,			0,		&DEBUG_context.SegCs,	DT_BASIC_CONST_INT)
 INTERNAL_VAR(ss,			0,		&DEBUG_context.SegSs,  	DT_BASIC_CONST_INT)
 INTERNAL_VAR(fs,			0,		&DEBUG_context.SegFs,  	DT_BASIC_CONST_INT)
 INTERNAL_VAR(gs,			0,		&DEBUG_context.SegGs,  	DT_BASIC_CONST_INT)
+
+INTERNAL_VAR(regs,                      0,              (DWORD*)&DEBUG_context, DT_BASIC_CONTEXT)
 #endif
Index: debugger/registers.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/debugger/registers.c,v
retrieving revision 1.18
diff -u -u -r1.18 registers.c
--- debugger/registers.c	31 May 2002 23:06:47 -0000	1.18
+++ debugger/registers.c	1 Aug 2002 19:20:21 -0000
@@ -27,7 +27,7 @@
  *
  * Return Flag String.
  */
-char *DEBUG_Flags( DWORD flag, char *buf )
+static char *DEBUG_Flags( DWORD flag, char *buf )
 {
 #ifdef __i386__
     char *pt;
@@ -86,42 +86,42 @@
  *
  * Display registers information.
  */
-void DEBUG_InfoRegisters(void)
+void DEBUG_InfoRegisters(const CONTEXT* ctx)
 {
     DEBUG_Printf(DBG_CHN_MESG,"Register dump:\n");
 
 #ifdef __i386__
     /* First get the segment registers out of the way */
     DEBUG_Printf( DBG_CHN_MESG," CS:%04x SS:%04x DS:%04x ES:%04x FS:%04x GS:%04x",
-		  (WORD)DEBUG_context.SegCs, (WORD)DEBUG_context.SegSs,
-		  (WORD)DEBUG_context.SegDs, (WORD)DEBUG_context.SegEs,
-		  (WORD)DEBUG_context.SegFs, (WORD)DEBUG_context.SegGs );
+		  (WORD)ctx->SegCs, (WORD)ctx->SegSs,
+		  (WORD)ctx->SegDs, (WORD)ctx->SegEs,
+		  (WORD)ctx->SegFs, (WORD)ctx->SegGs );
     if (DEBUG_CurrThread->dbg_mode != MODE_32)
     {
         char flag[33];
 
         DEBUG_Printf( DBG_CHN_MESG,"\n IP:%04x SP:%04x BP:%04x FLAGS:%04x(%s)\n",
-		      LOWORD(DEBUG_context.Eip), LOWORD(DEBUG_context.Esp),
-		      LOWORD(DEBUG_context.Ebp), LOWORD(DEBUG_context.EFlags),
-		      DEBUG_Flags(LOWORD(DEBUG_context.EFlags), flag));
+		      LOWORD(ctx->Eip), LOWORD(ctx->Esp),
+		      LOWORD(ctx->Ebp), LOWORD(ctx->EFlags),
+		      DEBUG_Flags(LOWORD(ctx->EFlags), flag));
 	DEBUG_Printf( DBG_CHN_MESG," AX:%04x BX:%04x CX:%04x DX:%04x SI:%04x DI:%04x\n",
-		      LOWORD(DEBUG_context.Eax), LOWORD(DEBUG_context.Ebx),
-		      LOWORD(DEBUG_context.Ecx), LOWORD(DEBUG_context.Edx),
-		      LOWORD(DEBUG_context.Esi), LOWORD(DEBUG_context.Edi) );
+		      LOWORD(ctx->Eax), LOWORD(ctx->Ebx),
+		      LOWORD(ctx->Ecx), LOWORD(ctx->Edx),
+		      LOWORD(ctx->Esi), LOWORD(ctx->Edi) );
     }
     else  /* 32-bit mode */
     {
         char flag[33];
 
         DEBUG_Printf( DBG_CHN_MESG, "\n EIP:%08lx ESP:%08lx EBP:%08lx EFLAGS:%08lx(%s)\n",
-		      DEBUG_context.Eip, DEBUG_context.Esp,
-		      DEBUG_context.Ebp, DEBUG_context.EFlags,
-		      DEBUG_Flags(DEBUG_context.EFlags, flag));
+		      ctx->Eip, ctx->Esp,
+		      ctx->Ebp, ctx->EFlags,
+		      DEBUG_Flags(ctx->EFlags, flag));
 	DEBUG_Printf( DBG_CHN_MESG, " EAX:%08lx EBX:%08lx ECX:%08lx EDX:%08lx\n",
-		      DEBUG_context.Eax, DEBUG_context.Ebx,
-		      DEBUG_context.Ecx, DEBUG_context.Edx );
+		      ctx->Eax, ctx->Ebx,
+		      ctx->Ecx, ctx->Edx );
 	DEBUG_Printf( DBG_CHN_MESG, " ESI:%08lx EDI:%08lx\n",
-		      DEBUG_context.Esi, DEBUG_context.Edi );
+		      ctx->Esi, ctx->Edi );
     }
 #endif
 }
Index: debugger/types.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/debugger/types.c,v
retrieving revision 1.31
diff -u -u -r1.31 types.c
--- debugger/types.c	13 Jun 2002 21:37:41 -0000	1.31
+++ debugger/types.c	30 Jul 2002 20:41:55 -0000
@@ -340,6 +340,7 @@
    */
   DEBUG_InitCVDataTypes();
 
+  DEBUG_InitBasic(DT_BASIC_CONTEXT,NULL,4,0,"%R");
 }
 
 long long int
Index: debugger/winedbg.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/debugger/winedbg.c,v
retrieving revision 1.63
diff -u -u -r1.63 winedbg.c
--- debugger/winedbg.c	30 Jul 2002 00:06:34 -0000	1.63
+++ debugger/winedbg.c	1 Aug 2002 19:15:11 -0000
@@ -389,7 +389,7 @@
 	DEBUG_BackTrace(DEBUG_CurrTid, FALSE);
     } else {
 	/* This is a real crash, dump some info */
-	DEBUG_InfoRegisters();
+	DEBUG_InfoRegisters(&DEBUG_context);
 	DEBUG_InfoStack();
 #ifdef __i386__
 	if (DEBUG_CurrThread->dbg_mode == MODE_16) {


More information about the wine-patches mailing list