wine/programs/winedbg debugger.h display.c sta ...

Alexandre Julliard julliard at wine.codeweavers.com
Tue Nov 29 05:06:42 CST 2005


ChangeSet ID:	21533
CVSROOT:	/opt/cvs-commit
Module name:	wine
Changes by:	julliard at winehq.org	2005/11/29 05:06:42

Modified files:
	programs/winedbg: debugger.h display.c stack.c symbol.c 

Log message:
	Eric Pouech <eric.pouech at wanadoo.fr>
	Replaced stack_get_frame with a pure symbol (and no longer stackframe)
	oriented API (stack_get_current_symbol).
	Reused the func name (stack_get_frame) for internal stack.c handling.

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

Old revision  New revision  Changes     Path
 1.35          1.36          +1 -1       wine/programs/winedbg/debugger.h
 1.8           1.9           +4 -4       wine/programs/winedbg/display.c
 1.19          1.20          +15 -22     wine/programs/winedbg/stack.c
 1.13          1.14          +9 -9       wine/programs/winedbg/symbol.c

Index: wine/programs/winedbg/debugger.h
diff -u -p wine/programs/winedbg/debugger.h:1.35 wine/programs/winedbg/debugger.h:1.36
--- wine/programs/winedbg/debugger.h:1.35	29 Nov 2005 11: 6:42 -0000
+++ wine/programs/winedbg/debugger.h	29 Nov 2005 11: 6:42 -0000
@@ -348,9 +348,9 @@ extern void             source_nuke_path
 extern void             stack_info(void);
 extern void             stack_backtrace(DWORD threadID);
 extern BOOL             stack_set_frame(int newframe);
-extern BOOL             stack_get_frame(SYMBOL_INFO* sym, IMAGEHLP_STACK_FRAME* ihsf);
 extern BOOL             stack_get_current_frame(IMAGEHLP_STACK_FRAME* ihsf);
 extern unsigned         stack_fetch_frames(void);
+extern BOOL             stack_get_current_symbol(SYMBOL_INFO* sym);
 
   /* symbol.c */
 extern enum sym_get_lval symbol_get_lvalue(const char* name, const int lineno, struct dbg_lvalue* addr, BOOL bp_disp);
Index: wine/programs/winedbg/display.c
diff -u -p wine/programs/winedbg/display.c:1.8 wine/programs/winedbg/display.c:1.9
--- wine/programs/winedbg/display.c:1.8	29 Nov 2005 11: 6:42 -0000
+++ wine/programs/winedbg/display.c	29 Nov 2005 11: 6:42 -0000
@@ -87,7 +87,7 @@ int display_add(struct expr *exp, int co
         displaypoints[i].func->SizeOfStruct = sizeof(SYMBOL_INFO);
         displaypoints[i].func->MaxNameLen = sizeof(displaypoints[i].func_buffer) -
             sizeof(*displaypoints[i].func);
-        if (!stack_get_frame(displaypoints[i].func, NULL))
+        if (!stack_get_current_symbol(displaypoints[i].func))
         {
             expr_free(displaypoints[i].exp);
             displaypoints[i].exp = NULL;
@@ -110,7 +110,7 @@ int display_info(void)
     memset(func, 0, sizeof(SYMBOL_INFO));
     func->SizeOfStruct = sizeof(SYMBOL_INFO);
     func->MaxNameLen = sizeof(buffer) - sizeof(*func);
-    if (!stack_get_frame(func, NULL)) return FALSE;
+    if (!stack_get_current_symbol(func)) return FALSE;
 
     for (i = 0; i < ndisplays; i++)
     {
@@ -174,7 +174,7 @@ int display_print(void)
     memset(func, 0, sizeof(SYMBOL_INFO));
     func->SizeOfStruct = sizeof(SYMBOL_INFO);
     func->MaxNameLen = sizeof(buffer) - sizeof(*func);
-    if (!stack_get_frame(func, NULL)) return FALSE;
+    if (!stack_get_current_symbol(func)) return FALSE;
 
     for (i = 0; i < ndisplays; i++)
     {
@@ -243,7 +243,7 @@ int display_enable(int displaynum, int e
     memset(func, 0, sizeof(SYMBOL_INFO));
     func->SizeOfStruct = sizeof(SYMBOL_INFO);
     func->MaxNameLen = sizeof(buffer) - sizeof(*func);
-    if (!stack_get_frame(func, NULL)) return FALSE;
+    if (!stack_get_current_symbol(func)) return FALSE;
 
     --displaynum;
     if (displaynum >= ndisplays || displaynum < 0 || 
Index: wine/programs/winedbg/stack.c
diff -u -p wine/programs/winedbg/stack.c:1.19 wine/programs/winedbg/stack.c:1.20
--- wine/programs/winedbg/stack.c:1.19	29 Nov 2005 11: 6:42 -0000
+++ wine/programs/winedbg/stack.c	29 Nov 2005 11: 6:42 -0000
@@ -82,7 +82,7 @@ static BOOL stack_set_frame_internal(int
     return TRUE;
 }
 
-static BOOL stack_get_frame_internal(int nf, IMAGEHLP_STACK_FRAME* ihsf)
+static BOOL stack_get_frame(int nf, IMAGEHLP_STACK_FRAME* ihsf)
 {
     ihsf->InstructionOffset = (unsigned long)memory_to_linear_addr(&dbg_curr_thread->frames[nf].addr_pc);
     ihsf->FrameOffset = (unsigned long)memory_to_linear_addr(&dbg_curr_thread->frames[nf].addr_frame);
@@ -95,7 +95,7 @@ BOOL stack_get_current_frame(IMAGEHLP_ST
      * If we don't have a valid backtrace, then just return.
      */
     if (dbg_curr_thread->frames == NULL) return FALSE;
-    return stack_get_frame_internal(dbg_curr_thread->curr_frame, ihsf);
+    return stack_get_frame(dbg_curr_thread->curr_frame, ihsf);
 }
 
 BOOL stack_set_frame(int newframe)
@@ -108,27 +108,20 @@ BOOL stack_set_frame(int newframe)
     return TRUE;
 }
 
-BOOL stack_get_frame(SYMBOL_INFO* symbol, IMAGEHLP_STACK_FRAME* ihsf)
+/******************************************************************
+ *		stack_get_current_symbol
+ *
+ * Retrieves the symbol information for the current frame element
+ */
+BOOL stack_get_current_symbol(SYMBOL_INFO* symbol)
 {
-    DWORD64     disp;
-    /*
-     * If we don't have a valid backtrace, then just return.
-     */
-    if (dbg_curr_thread->frames == NULL) return FALSE;
-
-    /*
-     * If we don't know what the current function is, then we also have
-     * nothing to report here.
-     */
-    if (!SymFromAddr(dbg_curr_process->handle,
-                     (unsigned long)memory_to_linear_addr(&dbg_curr_thread->frames[dbg_curr_thread->curr_frame].addr_pc),
-                     &disp, symbol))
-        return FALSE;
-    if (ihsf && !stack_get_current_frame(ihsf)) return FALSE;
+    IMAGEHLP_STACK_FRAME        ihsf;
+    DWORD64                     disp;
 
-    return TRUE;
+    if (!stack_get_current_frame(&ihsf)) return FALSE;
+    return SymFromAddr(dbg_curr_process->handle, ihsf.InstructionOffset,
+                       &disp, symbol);
 }
-
 /******************************************************************
  *		stack_fetch_frames
  *
@@ -214,7 +207,7 @@ static void stack_print_addr_and_args(in
 
     print_bare_address(&dbg_curr_thread->frames[nf].addr_pc);
 
-    stack_get_frame_internal(nf, &ihsf);
+    stack_get_frame(nf, &ihsf);
 
     /* grab module where symbol is. If we don't have a module, we cannot print more */
     im.SizeOfStruct = sizeof(im);
@@ -270,7 +263,7 @@ static unsigned backtrace(void)
         dbg_printf(")\n");
     }
     /* reset context to current stack frame */
-    stack_get_frame_internal(dbg_curr_thread->curr_frame, &ihsf);
+    stack_get_frame(dbg_curr_thread->curr_frame, &ihsf);
     SymSetContext(dbg_curr_process->handle, &ihsf, NULL);
     return nf;
 }
Index: wine/programs/winedbg/symbol.c
diff -u -p wine/programs/winedbg/symbol.c:1.13 wine/programs/winedbg/symbol.c:1.14
--- wine/programs/winedbg/symbol.c:1.13	29 Nov 2005 11: 6:42 -0000
+++ wine/programs/winedbg/symbol.c	29 Nov 2005 11: 6:42 -0000
@@ -595,17 +595,17 @@ static BOOL CALLBACK info_locals_cb(SYMB
 int symbol_info_locals(void)
 {
     IMAGEHLP_STACK_FRAME        ihsf;
-    char                        buffer[sizeof(SYMBOL_INFO) + 256];
-    SYMBOL_INFO*                si = (SYMBOL_INFO*)buffer;
+    ADDRESS                     addr;
+
+    stack_get_current_frame(&ihsf);
+    addr.Mode = AddrModeFlat;
+    addr.Offset = ihsf.InstructionOffset;
+    print_address(&addr, FALSE);
+    dbg_printf(": (%08lx)\n", (DWORD_PTR)ihsf.FrameOffset);
+    SymEnumSymbols(dbg_curr_process->handle, 0, NULL, info_locals_cb, (void*)(DWORD_PTR)ihsf.FrameOffset);
 
-    si->SizeOfStruct = sizeof(*si);
-    si->MaxNameLen = 256;
-    if (stack_get_frame(si, &ihsf))
-    {
-        dbg_printf("%s:\n", si->Name);
-        SymEnumSymbols(dbg_curr_process->handle, 0, NULL, info_locals_cb, &ihsf);
-    }
     return TRUE;
+
 }
 
 static BOOL CALLBACK symbols_info_cb(SYMBOL_INFO* sym, ULONG size, void* ctx)



More information about the wine-cvs mailing list