Debugging Wine thoughts

Marcus Meissner marcus at rennboot.centrumbabylon.cz
Thu Sep 11 06:41:35 CDT 2008


On Thu, Sep 11, 2008 at 01:20:42PM +0200, Markus Hitter wrote:
> 
> Am 10.09.2008 um 17:32 schrieb Stefan Dösinger:
> 
> > You can attach any debugger to a Win32 process running in Wine. This
> > includes Linux debuggers like gdb, [...]
> 
> As I didn't find hints on how to do this I tried myself:
> 
> ** First, start gdb in the C: directory
> 
> mah at piccard:/otherubuntu/home/mah/.wine/drive_c$ gdb
> GNU gdb 6.8-debian
> Copyright [...]
> This GDB was configured as "x86_64-linux-gnu".
> (gdb) file wine
> Reading symbols from /usr/local/bin/wine...done.
> (gdb) directory /otherubuntu/home/mah/wine/
> Source directories searched: /otherubuntu/home/mah/wine:$cdir:$cwd
> (gdb)
> 
> ** Then, run the app
> 
> (gdb) run windows/notepad.exe
> Starting program: /usr/local/bin/wine windows/notepad.exe
> [Thread debugging using libthread_db enabled]
> [New Thread 0xf7c628c0 (LWP 793)]
> [New Thread 0xf7c61b90 (LWP 796)]
> [Thread 0xf7c61b90 (LWP 796) exited]
> [New process 793]
> Executing new program: /usr/local/bin/wine-preloader
> warning: Cannot initialize thread debugging library: generic error
> warning: Cannot initialize thread debugging library: generic error
> [New process 793]
> Fontconfig warning: "/etc/fonts/conf.d/53-monospace-lcd-filter.conf",  
> line 17: invalid constant used : lcdlegacy
> Fontconfig warning: "/etc/fonts/conf.d/53-monospace-lcd-filter.conf",  
> line 17: invalid constant used : lcdlegacy
> Fontconfig warning: "/etc/fonts/conf.d/53-monospace-lcd-filter.conf",  
> line 17: invalid constant used : lcdlegacy
> 
> ** Notepad should be running here. Interrupt it from the command line  
> to have a look:
> 
> ^C
> Program received signal SIGINT, Interrupt.
> 0xf7fec430 in ?? ()
> (gdb) bt
> #0  0xf7fec430 in ?? ()
> #1  0x00000008 in ?? ()
> #2  0x7bc76516 in ?? ()
> #3  [...]
> (gdb) list
> 1	/*
> 2	 * Preloader for ld.so
> 3	 *
> 4	 * Copyright (C) [...]
> 
> As you see, listing appears to work in principle, while symbol lookup  
> doesn't.
> 
> It's no secret Wine runs multiple processes and Windows applications  
> run multiple threads, so you might want to look up how to handle this  
> in gdb:
> 
> http://sources.redhat.com/gdb/current/onlinedocs/gdb_5.html
> 
> My tries to break not into the preloader, but the actual Windows  
> application weren't successful so far, gdb's console appears to lock  
> up somehow when setting follow-fork-mode & friends.

Easy to do for most applications you use wine-pthread for debugging:

$ gdb wine-pthread
(gdb) break CreateWindowExW
Function "CreateWindowExW" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y

Breakpoint 1 (CreateWindowExW) pending.
(gdb) r notepad.exe
Starting program: /usr/bin/wine-pthread notepad.exe
[Thread debugging using libthread_db enabled]
[New Thread 0xf7d106c0 (LWP 9202)]
[Switching to Thread 0xf7d106c0 (LWP 9202)]

Breakpoint 1, CreateWindowExW (exStyle=0, className=0x7fcf7c70, windowName=0x7fcf7c60, 
    style=13565952, x=1, y=2, width=729, height=546, parent=0x0, menu=0x0, instance=0x7fcf0000, 
    data=0x0) at win.c:1401
1401        cs.lpCreateParams = data;
(gdb) 

Ciao, Marcus



More information about the wine-devel mailing list