Hello Wine Developers,

Besides the winedbg --gdb mode, I found a way to run gdb directly
on wine. I figured all or part of this text file I'm included could be
appended to section 1.8 of the Wine documentation where other
debuggers are discussed.

Thanks,
Andrew Look

This debugging document is meant to be appended to 
the Wine Developer's documentation, at:

http://www.winehq.org/docs/winedev-guide/dbg-others



1.8.9 Using GDB to debug Wine tests

From the wine build directory, GDB can be called in 
such a manner as to load wine's symbol table:

        cd wine64
        gdb ./loader/wine-pthread

At this point, breakpoints can be set in GDB on the 
wine source code files. However, breakpoints will
be set on future loads of the source code file.

        (gdb) break sock.c:430
        No source file named sock.c.
        Make breakpoint pending on future shared 
                library load? (y or [n]) y
        Breakpoint 1 (sock.c:430) pending.

Now, we can run the tests and have our breakpoint 
get loaded before execution. Using the 'run'
command with the desired .exe file of our test
will begin testing.

        (gdb) run ./dlls/ws2_32/tests/ws2_32_test.exe.so sock
        Starting program: /home/andrew/BRANCH_WINE/wine64/loader/
                wine-pthread ./dlls/ws2_32/tests/ws2_32_test.exe.so sock
        [Thread debugging using libthread_db enabled]
        [New Thread 0x7f5b46eae6e0 (LWP 6229)]
        Could not load Mozilla. HTML rendering will be disabled.
        err:process:__wine_kernel_init boot event wait timed out
        sock.c:1820: Test failed: getsockopt should fail for 
                UDP sockets but return value is 0x00000000
        sock.c:2322:  **** STARTING TEST 0 ****
        [New Thread 0x7f5b4456f950 (LWP 6255)]
        sock.c:409: simple_server (20) starting
        [New Thread 0x7f5b4445f950 (LWP 6256)]
        sock.c:597: simple_client (21): starting
        sock.c:418: simple_server (20) ready
        sock.c:600: simple_client (21): server ready
        [New Thread 0x7f5b4434f950 (LWP 6257)]
        sock.c:423: simple_server (20): waiting for client
        sock.c:597: simple_client (22): starting
        sock.c:600: simple_client (22): server ready
        sock.c:612: simple_client (21) connected
        [Switching to Thread 0x7f5b4456f950 (LWP 6255)]

Now, all of the normal GDB commands can be called 
to help analyze the program execution. 'backtrace'
is a good starting point to get an idea of the
context under which we are executing. 'info threads'
displays a representation of the current threads at
this breakpoint.

        Breakpoint 1, simple_server (par=0x7f5b44bfdc48) 
                at ../../../../wine-git/dlls/ws2_32/tests/sock.c:430
        430             ok ( mem->sock[0].peer.sin_addr.s_addr 
                == inet_addr ( gen->inet_addr ),
        (gdb) backtrace
        #0  simple_server (par=0x7f5b44bfdc48) at ../../../../
                wine-git/dlls/ws2_32/tests/sock.c:430
        #1  0x00007f5b45f80a54 in call_thread_func      
                (rtl_func=0x7f5b449f7510 <simple_server>, 
                arg=0x7f5b44bfdc48)
                at ../../../wine-git/dlls/ntdll/thread.c:413
        #2  0x00007f5b45f80c00 in start_thread (info=<value 
                optimized out>) at ../../../wine-git/dlls/
                ntdll/thread.c:489
        #3  0x00007f5b467493ea in start_thread () 
                from /lib/libpthread.so.0
        #4  0x00007f5b464b6cbd in clone () from /lib/libc.so.6
        #5  0x0000000000000000 in ?? ()

        (gdb) info threads
          4 Thread 0x7f5b4434f950 (LWP 6257)  0x00007f5b4675024b in
                connect () from /lib/libpthread.so.0
          3 Thread 0x7f5b4445f950 (LWP 6256)  0x00007f5b4674ff4b in
                read () from /lib/libpthread.so.0
        * 2 Thread 0x7f5b4456f950 (LWP 6255)  simple_server
                (par=0x7f5b44bfdc48) at ../../../../wine-git/dlls/
                ws2_32/tests/sock.c:430
          1 Thread 0x7f5b46eae6e0 (LWP 6229)  0x00007f5b4674ff4b in
                read () from /lib/libpthread.so.0

To inspect our current frame, 'info locals' displays 
local variables, 'info args' displays the values of
all arguments with which the current function was 
called. In debugging Wine 64 particularly, I found
'info registers' to be particularly useful for a low
level view of the execution.

        







Reply via email to