Debugger Woes

Robert Shearman R.J.Shearman at warwick.ac.uk
Thu Jan 1 12:10:11 CST 2004


Hi,

After the automatic glibc detection changes the Wine debugger stopped
loading symbols correctly, making it harder to debug programs. I only
recently noticed this due to lack of disk space and not compiling and
installing the whole tree on a cvs update.
However, I have now spent some time looking at the problem. By applying the
following patch to winedbg, I saw that the address for the ELF debugging
section was not being found properly.

Index: programs/winedbg/stabs.c
===================================================================
RCS file: /home/wine/wine/programs/winedbg/stabs.c,v
retrieving revision 1.11
diff -u -r1.11 stabs.c
--- programs/winedbg/stabs.c    15 Dec 2003 19:53:08 -0000      1.11
+++ programs/winedbg/stabs.c    1 Jan 2004 17:49:02 -0000
@@ -1625,6 +1625,7 @@
     do {
        if (!DEBUG_READ_MEM_VERBOSE((void*)dyn_addr, &dyn, sizeof(dyn)))
            goto leave;
+        WINE_TRACE("dyn.d_tag is %d\n", dyn.d_tag);
        dyn_addr += sizeof(dyn);
     } while (dyn.d_tag != DT_DEBUG && dyn.d_tag != DT_NULL);
     if (dyn.d_tag == DT_NULL) goto leave;

An example from loading "winedbg --debugmsg +winedbg notepad":
trace:winedbg:DEBUG_ReadExecutableDbgInfo dyn.d_tag is 1448084550
trace:winedbg:DEBUG_ReadExecutableDbgInfo dyn.d_tag is -997982209
trace:winedbg:DEBUG_ReadExecutableDbgInfo dyn.d_tag is 1457883477
trace:winedbg:DEBUG_ReadExecutableDbgInfo dyn.d_tag is 1455977869
...
trace:winedbg:DEBUG_ReadExecutableDbgInfo dyn.d_tag is 0

I believe these invalid values are being caused because we are mmap'ing
"wine" and reading in the values from the .dynamic section, but the
".dynamic" section hasn't been intialized by the ELF loader. This previously
wasn't as issue since "wine" would already have been loaded. However, now
"wine" exec's "wine-kthread" or "wine-pthead" as appropriate and then exits
and so is no longer in memory. This appears to have been anticipated with
the check further up in the stabs.c file that examines the "WINELOADER"
environment variable to find the file to mmap. If this is set to
"wine-pthread", for example, then the problem goes away. Hence the attached
patch.
Perhaps the real fix should be made to programs/winedbg/stabs.c. We could
either not use the ".dynamic" section somehow or use the dlsym rather than
mmap so that we properly initialize the ".dynamic" section.

Rob

P.S. above trace with patch applied:
trace:winedbg:DEBUG_ReadExecutableDbgInfo dyn.d_tag is 1
trace:winedbg:DEBUG_ReadExecutableDbgInfo dyn.d_tag is 1
trace:winedbg:DEBUG_ReadExecutableDbgInfo dyn.d_tag is 1
trace:winedbg:DEBUG_ReadExecutableDbgInfo dyn.d_tag is 12
trace:winedbg:DEBUG_ReadExecutableDbgInfo dyn.d_tag is 13
trace:winedbg:DEBUG_ReadExecutableDbgInfo dyn.d_tag is 4
trace:winedbg:DEBUG_ReadExecutableDbgInfo dyn.d_tag is 5
trace:winedbg:DEBUG_ReadExecutableDbgInfo dyn.d_tag is 6
trace:winedbg:DEBUG_ReadExecutableDbgInfo dyn.d_tag is 10
trace:winedbg:DEBUG_ReadExecutableDbgInfo dyn.d_tag is 11
trace:winedbg:DEBUG_ReadExecutableDbgInfo dyn.d_tag is 21
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wine.diff
Type: application/octet-stream
Size: 1110 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20040101/0564219f/wine.obj


More information about the wine-devel mailing list