winedbg and global variables

Richard Cohen richard.cohen at virgin.net
Wed Aug 6 11:08:12 CDT 2003


winedbg is getting the addresses of global symbols wrong - I'm running 
Debian testing/unstable.

||/ Name      Version          Description
+++-=========-================-======================================
ii  gcc       3.3-1            The GNU C compiler.
ii  binutils  2.14.90.0.4-0.1  The GNU assembler, linker and binary 
utilities.
ii  gcc-3.3   3.3.1-0pre0      The GNU C compiler

gcc 2.95 & 3.2 seem to behave the same. Perhaps it's a linker problem?
Anyway this patch fixes it (and it matches the existing comment).

Changelog
	+ Use the ELF sections for the addresses of globals, as the
	  STABS are likely to be wrong
-------------- next part --------------
diff -u programs/winedbg.1/hash.c programs/winedbg/hash.c
--- programs/winedbg.1/hash.c	2003-07-17 08:49:18.000000000 +0100
+++ programs/winedbg/hash.c	2003-08-06 16:42:18.000000000 +0100
@@ -225,7 +225,9 @@
                  * - a second time with the correct address
                  * SYM_INVALID is set for the first pass, and cleared in the second
                  * the code below gets most of information for both passes
-                 * latest GCC version seem to provide correct address in first pass,
+                 *
+                 * some GCC versions may provide the correct address in the first pass
+                 * but it does not seem to be sensible to rely on that.
                  */
                 if (nh->value.addr.seg == 0 && nh->value.addr.off == 0 && c != 0)
                 {
diff -u programs/winedbg.1/stabs.c programs/winedbg/stabs.c
--- programs/winedbg.1/stabs.c	2003-05-05 20:01:02.000000000 +0100
+++ programs/winedbg/stabs.c	2003-07-21 20:35:19.000000000 +0100
@@ -980,16 +980,17 @@
            *
            * With a.out or mingw, they actually do make some amount of sense.
            */
-          new_value.addr.seg = 0;
           new_value.type = DEBUG_ParseStabType(ptr);
-          new_value.addr.off = (unsigned long)load_offset + stab_ptr->n_value;
+          new_value.addr.seg = 0;
 	  new_value.cookie = DV_TARGET;
 
           stab_strcpy(symname, sizeof(symname), ptr);
 #ifdef __ELF__
+          new_value.addr.off = 0;
           curr_sym = DEBUG_AddSymbol( symname, &new_value, currpath,
                                       SYM_WINE | SYM_DATA | SYM_INVALID );
 #else
+          new_value.addr.off = (unsigned long)load_offset + stab_ptr->n_value;
           curr_sym = DEBUG_AddSymbol( symname, &new_value, currpath,
                                       SYM_WINE | SYM_DATA );
 #endif


More information about the wine-patches mailing list