Hi,
I don't know if this is the place to ask this, but anyway here it goes:
I'm trying to debug a windows application using wine.
The app is compiled with mingw (www.mingw.org), and I tried using -gstabs and -ggdb debug info but same problem happens.
The problem is:
1) Using winedbg as server for remote gdb debugger, when execution stops (sigfault, or whatever), and I type 'bt' in the gdb client, no debug info is shown, just lines like this one:
#0 0xdeaf1005 in ?? ()
2) Running 'wine <myapp.exe>' and then using gdb client to debug the process with the 'attach' command, when execution stops (sigfault, or whatever), and I type 'bt' in the gdb client, debug info IS shown, but line numbering shows always just the first line in the function. For example, say I have this function: void f() { int a=123; *(char *)0=a; }
then when sigfault is caught, gdb shows backtrace like this:
#0 0x0040130b in f() () at f.cpp:2
even though exception occurs in line 4.
Either way, I can't debug a windows app correctly. May I be doing something wrong. I've read the docs and followed instructions for DDD, KDbg, and just plain gbd. I'm using latest wine 2004 rpm under Redhat 9.
Any help greatly appreciated.
Thanks, Leo.
Here is my debugging tip:
printf is your friend.
If you can narrow down the error to the function at which it occurs, place a printf, or fprintf to stderr, after every line of code. The last message that is printed should get you a lot closer to your error.
On Friday 30 January 2004 09:57, Leo wrote:
Hi,
I don't know if this is the place to ask this, but anyway here it goes:
I'm trying to debug a windows application using wine.
The app is compiled with mingw (www.mingw.org), and I tried using -gstabs and -ggdb debug info but same problem happens.
The problem is:
- Using winedbg as server for remote gdb debugger, when execution stops
(sigfault, or whatever), and I type 'bt' in the gdb client, no debug info is shown, just lines like this one:
#0 0xdeaf1005 in ?? ()
- Running 'wine <myapp.exe>' and then using gdb client to debug the
process with the 'attach' command, when execution stops (sigfault, or whatever), and I type 'bt' in the gdb client, debug info IS shown, but line numbering shows always just the first line in the function. For example, say I have this function: void f() { int a=123; *(char *)0=a; }
then when sigfault is caught, gdb shows backtrace like this:
#0 0x0040130b in f() () at f.cpp:2
even though exception occurs in line 4.
Either way, I can't debug a windows app correctly. May I be doing something wrong. I've read the docs and followed instructions for DDD, KDbg, and just plain gbd. I'm using latest wine 2004 rpm under Redhat 9.
Any help greatly appreciated.
Thanks, Leo.
Leo a écrit :
Hi,
I don't know if this is the place to ask this, but anyway here it goes:
I'm trying to debug a windows application using wine.
set WINELOADER environment variable to point to your wine binary before running winedbg A+
Eric Pouech wrote:
Leo a écrit :
Hi,
I don't know if this is the place to ask this, but anyway here it goes:
I'm trying to debug a windows application using wine.
set WINELOADER environment variable to point to your wine binary before running winedbg A+
Hello, thanks for your reply.
Do you successfully debug windows apps with wine + gdb ?
I've tried setting that env variable, but it's even worse in method 1 bellow.
I'm pasting the xterm outputs for my attempts:
METHOD 1: ==========
==First xterm:
[leo@LeoLux 2]$ export WINELOADER=/usr/bin/wine-pthread [leo@LeoLux 2]$ winedbg -- --gdb --no-start a.exe Using wine_path: /usr/bin/wine-pthread target remote localhost:33199 0000000a:0000000b: create process 'F:\tmp\2\a.exe'/0x4063003c @00401000 (0<0>) 0000000a:0000000b: create thread I @00401000 0000000a:0000000b: loads DLL C:\WINDOWS\SYSTEM\ntdll.dll @400a0000 (0<0>) 0000000a:0000000b: loads DLL C:\WINDOWS\SYSTEM\kernel32.dll @40330000 (0<0>) 0000000a:0000000b: loads DLL C:\WINDOWS\SYSTEM\msvcrt.dll @40860000 (0<0>) err:wineconsole:WINECON_Fatal Couldn't find a decent font, aborting
0000000a:0000000b: exit process (0) wine-pthread: gdbproxy.c:1625: packet_query: Assertion `gdbctx->process && gdbctx->process->threads' failed. wine: Unhandled exception (thread 0009), starting debugger... WineDbg starting on pid 8 No debug information in ELF '/usr/bin/wine-pthread' ((nil)) Breakpoint 1 at 0x4000cfc0 No debug information in ELF '/usr/lib/wine/libwine.so.1' (0x40034000) No debug information in ELF '/lib/tls/libpthread.so.0' (0x4004d000) No debug information in ELF '/lib/libdl.so.2' (0x4005b000) No debug information in ELF '/lib/tls/libm.so.6' (0x4005f000) No debug information in ELF '/lib/ld-linux.so.2' (0x40000000) No debug information in ELF '/usr/lib/wine/wine/ntdll.dll.so' (0x40082000) No debug information in ELF '/usr/lib/wine/libwine_unicode.so.1' (0x400f8000) No debug information in ELF '/lib/libnss_files.so.2' (0x40018000) No debug information in ELF '/usr/lib/wine/wine/kernel32.dll.so' (0x40300000) No debug information in ELF '/usr/lib/wine/wine/winedbg.exe.so' (0x40642000) No debug information in ELF '/usr/lib/wine/wine/advapi32.dll.so' (0x407b0000) No debug information in 32bit DLL 'C:\WINDOWS\SYSTEM\winedbg.exe' (0x40650000) No debug information in 32bit DLL 'C:\WINDOWS\SYSTEM\NTDLL.DLL' (0x400a0000) No debug information in 32bit DLL 'C:\WINDOWS\SYSTEM\KERNEL32.DLL' (0x40330000) No debug information in 32bit DLL 'C:\WINDOWS\SYSTEM\ADVAPI32.DLL' (0x407c0000) Unhandled exception: assertion failed in 32-bit code (0xffffe002). In 32-bit mode. 0xffffe002 (NTDLL.DLL.memcpy+0xbdf81a22): *** Invalid address 0xffffe002 (NTDLL.DLL.memcpy+0xbdf81a22) -- no code -- Wine-dbg>
== Second xterm:
[leo@LeoLux 2]$ export WINELOADER=/usr/bin/wine-pthread [leo@LeoLux 2]$ gdb wine-pthread GNU gdb Red Hat Linux (5.3post-0.20021129.18rh) Copyright 2003 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu"... (gdb) target remote localhost:33199 Remote debugging using localhost:33199 Ignoring packet error, continuing... Ignoring packet error, continuing... Couldn't establish connection to remote target Malformed response to offset query, timeout (gdb)
METHOD 2: ==========
==First xterm:
[leo@LeoLux 2]$ export WINELOADER=/usr/bin/wine-pthread [leo@LeoLux 2]$ wine-pthread a.exe & [1] 2780 [leo@LeoLux 2]$
==Second xterm:
[leo@LeoLux 2]$ export WINELOADER=/usr/bin/wine-pthread [leo@LeoLux 2]$ gdb a.exe GNU gdb Red Hat Linux (5.3post-0.20021129.18rh) Copyright 2003 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu"... (gdb) attach 2780 Attaching to program: /home/leo/tmp/2/a.exe, process 2780 0xffffe002 in ?? () (gdb) c Continuing.
Program received signal SIGSEGV, Segmentation fault. 0x0040130b in f() () at a.cpp:11 11 { (gdb) bt #0 0x0040130b in f() () at a.cpp:11 #1 0x00401347 in main () at a.cpp:21 #2 0x00401182 in _image_base__ () #3 0x00401018 in _image_base__ () #4 0x4038e077 in ?? () (gdb)
Backtrace indicates files line numbers for first line in each function. Obviously line 11 in a.cpp above doesn't have a valid statement.
a.cpp is:
#include <stdlib.h> // #include <sys/time.h> // #include <sys/times.h> // #include <unistd.h> #include <windows.h>
void f() { // this is line 11 int a=0; for (int i=0; i<10; i++) a*=2;
*(char *)0=0;
}
main() { // this is line 21 Sleep(10000); f(); }
Hello, thanks for your reply.
Do you successfully debug windows apps with wine + gdb ?
yes
I've tried setting that env variable, but it's even worse in method 1 bellow.
I'm pasting the xterm outputs for my attempts:
there are several unrelated errors/issues you need to fix first.
METHOD 1:
==First xterm: err:wineconsole:WINECON_Fatal Couldn't find a decent font, aborting
that's the first issue. Your a.exe app is a CUI app. You first need to set wineconsole to make it work (basically it doesn't find a fixed font with decent size). It's been a while since we hadn't gotten this error... and the rest of the debugging session fails because your debuggee needs the console up & running (and dies prematurely) this should work ok even without the --no-start flag
METHOD 2:
gdb a.exe
gdb doesn't know nothing about windows application. You should run it with gdb wine-pthread (as I assume your system is -pthread) However, if your a.exe has been compiled with a win32 compiler, you won't get any symbol from it (except if the compiler is mingw)
A+
Eric Pouech wrote:
Hello, thanks for your reply.
Do you successfully debug windows apps with wine + gdb ?
yes
Great! Please don't go! :)
I've tried setting that env variable, but it's even worse in method 1 bellow.
I'm pasting the xterm outputs for my attempts:
there are several unrelated errors/issues you need to fix first.
METHOD 1:
==First xterm: err:wineconsole:WINECON_Fatal Couldn't find a decent font, aborting
that's the first issue. Your a.exe app is a CUI app. You first need to set wineconsole to make it work (basically it doesn't find a fixed font with decent size). It's been a while since we hadn't gotten this error... and the rest of the debugging session fails because your debuggee needs the console up & running (and dies prematurely) this should work ok even without the --no-start flag
Ok, that's fixed (no console problem), but then another error happens (see the log bellow).
METHOD 2:
gdb a.exe
gdb doesn't know nothing about windows application. You should run it with gdb wine-pthread (as I assume your system is -pthread)
Yes, I tried that too (gdb wine, and gdb wine-pthread), but I don't get debug info for my program (just the wine exec).
However, if your a.exe has been compiled with a win32 compiler, you won't get any symbol from it (except if the compiler is mingw)
Yes, my compiler is mingw, and I've tried -gstabs and -ggdb debug formats.
Logs with the WINECONSOLE set:
METHOD1: =========
== First xterm:
[leo@LeoLux 2]$ export WINECONSOLE=/usr/bin/wineconsole [leo@LeoLux 2]$ export WINELOADER=/usr/bin/wine-pthread [leo@LeoLux 2]$ winedbg -- --gdb --no-start a.exe Using wine_path: /usr/bin/wine-pthread target remote localhost:34369 0000002e:0000002f: create process 'F:\tmp\2\a.exe'/0x4063003c @00401000 (0<0>) 0000002e:0000002f: create thread I @00401000 0000002e:0000002f: loads DLL C:\WINDOWS\SYSTEM\ntdll.dll @400a0000 (0<0>) 0000002e:0000002f: loads DLL C:\WINDOWS\SYSTEM\kernel32.dll @40330000 (0<0>) 0000002e:0000002f: loads DLL C:\WINDOWS\SYSTEM\msvcrt.dll @40860000 (0<0>) Unknown option '--use-event=8'
Wine 20040121
Usage: wine [options] [--] program_name [arguments] The -- has to be used if you specify arguments (of the program)
Options: --debugmsg name Turn debugging-messages on or off --dll name This option is no longer supported --help,-h Show this help message --version,-v Display the Wine version
The program winedbg does not exit at this point, just stays there.
== Second xterm:
[leo@LeoLux 2]$ export WINELOADER=/usr/bin/wine-pthread [leo@LeoLux 2]$ export WINECONSOLE=/usr/bin/wineconsole [leo@LeoLux 2]$ gdb /usr/bin/wine-pthread GNU gdb Red Hat Linux (5.3post-0.20021129.18rh) Copyright 2003 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu"... (no debugging symbols found)... (gdb) target remote localhost:34369 Remote debugging using localhost:34369 Ignoring packet error, continuing... Ignoring packet error, continuing...
Ignoring packet error, continuing... Couldn't establish connection to remote target Malformed response to offset query, timeout (gdb) (gdb) c The program is not being run. (gdb) q [leo@LeoLux 2]$
METHOD 2: ==========
== First xterm:
[leo@LeoLux 2]$ export WINECONSOLE=/usr/bin/wineconsole [leo@LeoLux 2]$ export WINELOADER=/usr/bin/wine-pthread [leo@LeoLux 2]$ /usr/bin/wine-pthread ./a.exe & [1] 2573 [leo@LeoLux 2]$
==Second xterm:
[leo@LeoLux 2]$ export WINECONSOLE=/usr/bin/wineconsole [leo@LeoLux 2]$ export WINELOADER=/usr/bin/wine-pthread [leo@LeoLux 2]$ gdb wine-pthread GNU gdb Red Hat Linux (5.3post-0.20021129.18rh) Copyright 2003 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu"... (no debugging symbols found)... (gdb) attach 2573 Attaching to program: /usr/bin/wine-pthread, process 2573 Reading symbols from /usr/lib/wine/libwine.so.1... (no debugging symbols found)...done. Loaded symbols for /usr/lib/wine/libwine.so.1 Reading symbols from /lib/tls/libpthread.so.0...(no debugging symbols found)... done. [New Thread 1074271616 (LWP 2573)] Loaded symbols for /lib/tls/libpthread.so.0 Reading symbols from /lib/tls/libc.so.6...(no debugging symbols found)...done. Loaded symbols for /lib/tls/libc.so.6 Reading symbols from /lib/libdl.so.2...(no debugging symbols found)...done. Loaded symbols for /lib/libdl.so.2 Reading symbols from /lib/tls/libm.so.6...(no debugging symbols found)...done. Loaded symbols for /lib/tls/libm.so.6 Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done. Loaded symbols for /lib/ld-linux.so.2 Reading symbols from /usr/lib/wine/wine/ntdll.dll.so... (no debugging symbols found)...done. Loaded symbols for /usr/lib/wine/wine/ntdll.dll.so Reading symbols from /usr/lib/wine/libwine_unicode.so.1... (no debugging symbols found)...done. Loaded symbols for /usr/lib/wine/libwine_unicode.so.1 Reading symbols from /lib/libnss_files.so.2...(no debugging symbols found)... done. Loaded symbols for /lib/libnss_files.so.2 Reading symbols from /usr/lib/wine/wine/kernel32.dll.so... (no debugging symbols found)...done. Loaded symbols for /usr/lib/wine/wine/kernel32.dll.so Reading symbols from /usr/lib/wine/wine/msvcrt.dll.so... (no debugging symbols found)...done. Loaded symbols for /usr/lib/wine/wine/msvcrt.dll.so 0xffffe002 in ?? () (gdb) c Continuing.
Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 1074271616 (LWP 2573)] 0x0040130b in ?? () (gdb) bt #0 0x0040130b in ?? () #1 0x00401347 in ?? () #2 0x00401182 in ?? () #3 0x00401018 in ?? () #4 0x4038e077 in SetThreadExecutionState () from /usr/lib/wine/wine/kernel32.dll.so (gdb)
See, in this backtrace I get debug info for the wine executable. If I run gdb ./a.exe instead of gdb /usr/bin/wine-pthread, I do get (wrong) debug info:
[leo@LeoLux 2]$ gdb ./a.exe GNU gdb Red Hat Linux (5.3post-0.20021129.18rh) Copyright 2003 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux-gnu"... (gdb) attach 2579 Attaching to program: /home/leo/tmp/2/a.exe, process 2579 0xffffe002 in ?? () (gdb) c Continuing.
Program received signal SIGSEGV, Segmentation fault. 0x0040130b in f() () at a.cpp:11 11 { (gdb) bt #0 0x0040130b in f() () at a.cpp:11 #1 0x00401347 in main () at a.cpp:21 #2 0x00401182 in _image_base__ () #3 0x00401018 in _image_base__ () #4 0x4038e077 in ?? () (gdb)
I think method 2 seems best (I get debug info), but wrong line numbers.
What am I doing wrong?
Also, I've tried tu run the tests above with WINELOADER=/usr/bin/wine, and run wine instead of wine-pthread but same thing happens.
Thanks.
Logs with the WINECONSOLE set:
that shouldn't matter. The issue you got is linked to the wineconsole's fonts configuration. You shouldn't need to use WINECONSOLE env var. And setting it won't solve your issues.
METHOD1:
== First xterm:
[leo@LeoLux 2]$ export WINECONSOLE=/usr/bin/wineconsole [leo@LeoLux 2]$ export WINELOADER=/usr/bin/wine-pthread [leo@LeoLux 2]$ winedbg -- --gdb --no-start a.exe Using wine_path: /usr/bin/wine-pthread target remote localhost:34369 0000002e:0000002f: create process 'F:\tmp\2\a.exe'/0x4063003c @00401000 (0<0>) 0000002e:0000002f: create thread I @00401000 0000002e:0000002f: loads DLL C:\WINDOWS\SYSTEM\ntdll.dll @400a0000 (0<0>) 0000002e:0000002f: loads DLL C:\WINDOWS\SYSTEM\kernel32.dll @40330000 (0<0>) 0000002e:0000002f: loads DLL C:\WINDOWS\SYSTEM\msvcrt.dll @40860000 (0<0>) Unknown option '--use-event=8'
this is still a wineconsole configuration problem. I still think your wineconsole isn't properly setup. I'd bet wineconsole -- --backend=user wcmd will fail (while it should work)
Note also since you're running with --no-start, you need, before entering the 'target remote' command to: 1/ tell gdb which file it's going to debug (the wine loader) with the 'file' command 2/ use 'sharedlibrary' command I strongly suggest that you don't use the --no-start command (winedbg will do everything you need).
METHOD 2:
== First xterm:
[leo@LeoLux 2]$ export WINECONSOLE=/usr/bin/wineconsole [leo@LeoLux 2]$ export WINELOADER=/usr/bin/wine-pthread [leo@LeoLux 2]$ /usr/bin/wine-pthread ./a.exe & [1] 2573 [leo@LeoLux 2]$
==Second xterm:
[leo@LeoLux 2]$ export WINELOADER=/usr/bin/wine-pthread
this one is not needed for gdb (only for winedbg)
Reading symbols from /usr/lib/wine/libwine.so.1... (no debugging symbols found)...done.
where did you get wine from. looks like all modules are stripped.
See, in this backtrace I get debug info for the wine executable. If I run gdb ./a.exe instead of gdb /usr/bin/wine-pthread, I do get (wrong) debug info:
again, gdb doesn't understand win32 modules, so it won't work with .exe (you need to specify the wine loader as the program to debug under gdb) A+