wine/ programs/winedbg/winedbg.c programs/wine ...

Alexandre Julliard julliard at wine.codeweavers.com
Fri Nov 18 06:05:45 CST 2005


ChangeSet ID:	21322
CVSROOT:	/opt/cvs-commit
Module name:	wine
Changes by:	julliard at winehq.org	2005/11/18 06:05:44

Modified files:
	programs/winedbg: winedbg.c symbol.c 
	dlls/dbghelp   : symbol.c dbghelp.c 

Log message:
	Eric Pouech <eric.pouech at wanadoo.fr>
	Now returning correct symbol flags (as native does) for function pmts
	& locals in dbghelp.
	Modified winedbg accordingly.

Patch: http://cvs.winehq.org/patch.py?id=21322

Old revision  New revision  Changes     Path
 1.40          1.41          +4 -0       wine/programs/winedbg/winedbg.c
 1.10          1.11          +24 -28     wine/programs/winedbg/symbol.c
 1.19          1.20          +3 -3       wine/dlls/dbghelp/symbol.c
 1.13          1.14          +2 -0       wine/dlls/dbghelp/dbghelp.c

Index: wine/programs/winedbg/winedbg.c
diff -u -p wine/programs/winedbg/winedbg.c:1.40 wine/programs/winedbg/winedbg.c:1.41
--- wine/programs/winedbg/winedbg.c:1.40	18 Nov 2005 12: 5:44 -0000
+++ wine/programs/winedbg/winedbg.c	18 Nov 2005 12: 5:44 -0000
@@ -56,6 +56,10 @@
  *      + all computations should be made on long long
  *              o expr computations are in int:s
  *              o bitfield size is on a 4-bytes
+ *      + array_index and deref should be the same function (or should share the same
+ *        core)
+ *      + segmented pointers are not correctly handled (and are hacked throughout the
+ *        code by testing against itype_none)
  * - execution:
  *      + set a better fix for gdb (proxy mode) than the step-mode hack
  *      + implement function call in debuggee
Index: wine/programs/winedbg/symbol.c
diff -u -p wine/programs/winedbg/symbol.c:1.10 wine/programs/winedbg/symbol.c:1.11
--- wine/programs/winedbg/symbol.c:1.10	18 Nov 2005 12: 5:44 -0000
+++ wine/programs/winedbg/symbol.c	18 Nov 2005 12: 5:44 -0000
@@ -67,7 +67,8 @@ static BOOL symbol_get_debug_start(DWORD
 struct sgv_data
 {
 #define NUMDBGV                 100
-    struct {
+    struct
+    {
         /* FIXME: NUMDBGV should be made variable */
         struct dbg_lvalue               lvalue;
         DWORD                           flags;
@@ -79,7 +80,7 @@ struct sgv_data
     int                         lineno;         /* in (opt): line number in filename where to look up symbol */
     unsigned                    bp_disp : 1,    /* in      : whether if we take into account func address or func first displayable insn */
                                 do_thunks : 1;  /* in      : whether we return thunks tags */
-    IMAGEHLP_STACK_FRAME        ihsf;           /* in      : frame for local & parameter variables look up */
+    ULONG64                     frame_offset;   /* in      : frame for local & parameter variables look up */
 };
 
 static BOOL CALLBACK sgv_cb(SYMBOL_INFO* sym, ULONG size, void* ctx)
@@ -109,15 +110,9 @@ static BOOL CALLBACK sgv_cb(SYMBOL_INFO*
         addr = (ULONG64)(DWORD_PTR)div->pval;
         cookie = DLV_HOST;
     }
-    else if (sym->Flags & SYMFLAG_FRAMEREL)
+    else if (sym->Flags & SYMFLAG_LOCAL) /* covers both local & parameters */
     {
-        ULONG   offset;
-        struct dbg_type type;
-
-        type.module = sym->ModBase;
-        type.id = sym->TypeIndex;
-        types_get_info(&type, TI_GET_OFFSET, &offset);
-        addr = sgv->ihsf.FrameOffset + offset;
+        addr = sgv->frame_offset + sym->Address;
     }
     else if (sym->Flags & SYMFLAG_THUNK)
     {
@@ -168,13 +163,14 @@ static BOOL CALLBACK sgv_cb(SYMBOL_INFO*
                    sgv->name, NUMDBGV);
         return FALSE;
     }
-    WINE_TRACE("==> %s %s%s%s%s%s%s\n", 
+    WINE_TRACE("==> %s %s%s%s%s%s%s%s\n", 
                sym->Name, 
                (sym->Flags & SYMFLAG_FUNCTION) ? "func " : "",
                (sym->Flags & SYMFLAG_FRAMEREL) ? "framerel " : "",
                (sym->Flags & SYMFLAG_REGISTER) ? "register " : "",
                (sym->Flags & SYMFLAG_REGREL) ? "regrel " : "",
                (sym->Flags & SYMFLAG_PARAMETER) ? "param " : "",
+               (sym->Flags & SYMFLAG_LOCAL) ? "local " : "",
                (sym->Flags & SYMFLAG_THUNK) ? "thunk " : "");
 
     /* always keep the thunks at end of the array */
@@ -217,6 +213,7 @@ enum sym_get_lval symbol_get_lvalue(cons
     SYMBOL_INFO*                si = (SYMBOL_INFO*)tmp;
     char                        buffer[512];
     DWORD                       opt;
+    IMAGEHLP_STACK_FRAME        ihsf;
 
     if (strlen(name) + 4 > sizeof(buffer))
     {
@@ -280,9 +277,10 @@ enum sym_get_lval symbol_get_lvalue(cons
     /* now grab local symbols */
     si->SizeOfStruct = sizeof(*si);
     si->MaxNameLen = 256;
-    if (stack_get_frame(si, &sgv.ihsf) && sgv.num < NUMDBGV)
+    if (stack_get_frame(si, &ihsf) && sgv.num < NUMDBGV)
     {
-        if (SymSetContext(dbg_curr_process->handle, &sgv.ihsf, NULL))
+        sgv.frame_offset = ihsf.FrameOffset;
+        if (SymSetContext(dbg_curr_process->handle, &ihsf, NULL))
             SymEnumSymbols(dbg_curr_process->handle, 0, name, sgv_cb, (void*)&sgv);
     }
 
@@ -307,14 +305,9 @@ enum sym_get_lval symbol_get_lvalue(cons
                 dbg_printf("[%d]: ", i + 1);
                 if (sgv.syms[i].flags & SYMFLAG_LOCAL)
                 {
-                    dbg_printf("local variable %sof %s\n", 
-                               sgv.syms[i].flags & SYMFLAG_REGISTER ? "(in a register) " : "",
-                               si->Name);
-                }
-                else if (sgv.syms[i].flags & SYMFLAG_PARAMETER)
-                {
-                    dbg_printf("parameter %sof %s\n", 
-                               sgv.syms[i].flags & SYMFLAG_REGISTER ? "(in a register) " : "",
+                    dbg_printf("%s %sof %s\n",
+                               sgv.syms[i].flags & SYMFLAG_PARAMETER ? "Parameter" : "Local variable",
+                               sgv.syms[i].flags & (SYMFLAG_REGISTER|SYMFLAG_REGREL) ? "(in a register) " : "",
                                si->Name);
                 }
                 else if (sgv.syms[i].flags & SYMFLAG_THUNK) 
@@ -362,6 +355,7 @@ BOOL symbol_is_local(const char* name)
     struct sgv_data             sgv;
     char                        tmp[sizeof(SYMBOL_INFO) + 256];
     SYMBOL_INFO*                si = (SYMBOL_INFO*)tmp;
+    IMAGEHLP_STACK_FRAME        ihsf;
 
     sgv.num        = 0;
     sgv.num_thunks = 0;
@@ -373,9 +367,12 @@ BOOL symbol_is_local(const char* name)
 
     si->SizeOfStruct = sizeof(*si);
     si->MaxNameLen = 256;
-    if (stack_get_frame(si, &sgv.ihsf) &&
-        SymSetContext(dbg_curr_process->handle, &sgv.ihsf, NULL))
+    if (stack_get_frame(si, &ihsf) &&
+        SymSetContext(dbg_curr_process->handle, &ihsf, NULL))
+    {
+        sgv.frame_offset = ihsf.FrameOffset;
         SymEnumSymbols(dbg_curr_process->handle, 0, name, sgv_cb, (void*)&sgv);
+    }
     return sgv.num > 0;
 }
 
@@ -565,8 +562,8 @@ static BOOL CALLBACK info_locals_cb(SYMB
     types_get_info(&type, TI_GET_TYPE, &type.id);
     types_print_type(&type, FALSE);
 
-    if (sym->Flags & SYMFLAG_LOCAL) explain = "local";
-    else if (sym->Flags & SYMFLAG_PARAMETER) explain = "parameter";
+    if (sym->Flags & SYMFLAG_PARAMETER) explain = "parameter";
+    else if (sym->Flags & SYMFLAG_LOCAL) explain = "local";
     else if (sym->Flags & SYMFLAG_REGISTER) explain = buf;
 
     if (sym->Flags & SYMFLAG_REGISTER)
@@ -589,11 +586,10 @@ static BOOL CALLBACK info_locals_cb(SYMB
             }
         }
     }
-    else if (sym->Flags & SYMFLAG_FRAMEREL)
+    else if (sym->Flags & SYMFLAG_LOCAL)
     {
         type.id = sym->TypeIndex;
-        types_get_info(&type, TI_GET_OFFSET, &v);
-        v += ((IMAGEHLP_STACK_FRAME*)ctx)->FrameOffset;
+        v = ((IMAGEHLP_STACK_FRAME*)ctx)->FrameOffset + sym->Address;
 
         if (!dbg_read_memory((void*)v, &val, sizeof(val)))
         {
Index: wine/dlls/dbghelp/symbol.c
diff -u -p wine/dlls/dbghelp/symbol.c:1.19 wine/dlls/dbghelp/symbol.c:1.20
--- wine/dlls/dbghelp/symbol.c:1.19	18 Nov 2005 12: 5:45 -0000
+++ wine/dlls/dbghelp/symbol.c	18 Nov 2005 12: 5:45 -0000
@@ -460,7 +460,7 @@ static void symt_fill_sym_info(const str
             case DataIsParam:
                 if (data->u.s.reg_id)
                 {
-                    sym_info->Flags |= SYMFLAG_LOCAL | SYMFLAG_REGISTER;
+                    sym_info->Flags |= SYMFLAG_REGISTER;
                     sym_info->Register = data->u.s.reg_id;
                     sym_info->Address = 0;
                 }
@@ -469,10 +469,10 @@ static void symt_fill_sym_info(const str
                     if (data->u.s.offset < 0)
                         sym_info->Flags |= SYMFLAG_LOCAL | SYMFLAG_FRAMEREL;
                     else
-                        sym_info->Flags |= SYMFLAG_PARAMETER | SYMFLAG_FRAMEREL;
+                        sym_info->Flags |= SYMFLAG_LOCAL | SYMFLAG_PARAMETER | SYMFLAG_FRAMEREL;
                     /* FIXME: needed ? moreover, it's i386 dependent !!! */
                     sym_info->Register = CV_REG_EBP;
-                    sym_info->Address = data->u.s.offset;
+                    sym_info->Address = data->u.s.offset / 8;
                 }
                 break;
             case DataIsGlobal:
Index: wine/dlls/dbghelp/dbghelp.c
diff -u -p wine/dlls/dbghelp/dbghelp.c:1.13 wine/dlls/dbghelp/dbghelp.c:1.14
--- wine/dlls/dbghelp/dbghelp.c:1.13	18 Nov 2005 12: 5:45 -0000
+++ wine/dlls/dbghelp/dbghelp.c	18 Nov 2005 12: 5:45 -0000
@@ -35,6 +35,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
  *        but those values are not directly usable from a debugger (that's why, I
  *        assume, that we have also to define constants for enum values, as 
  *        Codeview does BTW.
+ *      + SymEnumTypes should only return *user* defined types (UDT, typedefs...) not
+ *        all the types stored/used in the modules (like char*)
  *  - SymGetLine{Next|Prev} don't work as expected (they don't seem to work across
  *    functions, and even across function blocks...). Basically, for *Next* to work
  *    it requires an address after the prolog of the func (the base address of the 



More information about the wine-cvs mailing list