Differences between revisions 5 and 6
| Deletions are marked like this. | Additions are marked like this. |
| Line 3: | Line 3: |
| Line 8: | Line 9: |
| i. Attach winedbg to the running application process (type something like "attach 0x12" if the pid of the process is 12). This should freeze the process. | i. Attach winedbg to the running application process (type something like "attach 0x12" if the pid of the process is 12). This should freeze the process. If the app was hung, you can get the backtrace now. Otherwise: |
| Line 13: | Line 14: |
|
Alternately, instad of info process / attach, you can do 'bt all' to get backtraces of all threads in all running processes. This is handy when debugging hangs. |
If you just want to get a backtrace of a hung process without figuring out how to attach to it: 1. Start your program as normal ('wine foo.exe'). Wait until it hangs. 1. Start winedbg [the Wine debugger] in a separate terminal ('winedbg'). 1. Then, in the winedbg prompt: i. Type 'bt all' to get a backtrace of all running processes. |
Backtraces
Getting a backtrace in Wine should be automatic when an app crashes. Sometimes, for various reasons, that doesn't happen.
You can trigger one manually by:
- Start your program as normal ('wine foo.exe').
Start winedbg [the Wine debugger] in a separate terminal ('winedbg').
- Then, in the winedbg prompt:
- Type 'info process' to get a list of running processes.
- Attach winedbg to the running application process (type something like "attach 0x12" if the pid of the process is 12). This should freeze the process. If the app was hung, you can get the backtrace now. Otherwise:
Type 'set $BreakOnFirstChance=0' so that winedbg will only break for unhandled exceptions, not for all of them (most are harmless).
- Type 'cont'.
- Wait for the program to crash.
If you just want to get a backtrace of a hung process without figuring out how to attach to it:
- Start your program as normal ('wine foo.exe'). Wait until it hangs.
Start winedbg [the Wine debugger] in a separate terminal ('winedbg').
- Then, in the winedbg prompt:
- Type 'bt all' to get a backtrace of all running processes.
If you cannot attach to a running process:
- start your app with 'wine winedbg foo.exe'
Type 'set $BreakOnFirstChance=0' so that winedbg will only break for unhandled exceptions, not for all of them (most are harmless).
- Type 'cont'.
- Wait for the program to crash.
A good backtrace contains function names and the values of the parameters as well as line numbers like this:
Backtrace:
=>0 0x7ea5e750 CreateWindowExW(exStyle=0, className=0x7ed94f50, windowName=0x7ed94f40, style=13565952, x=0, y=0, width=570, height=427, parent=(nil), menu=(nil), instance=0x7ed80000, data=(nil)) [/home/foobar/git/wine/dlls/user32/win.c:1555] in user32 (0x0033fe08)
1 0x7ed94c55 main+0xa5() [/home/foobar/git/wine/dlls/winecrt0/exe_main.c:48] in notepad (0x0033fe88)
2 0x7ed94b77 __wine_spec_exe_entry+0x57(peb=0x7ffdf000) [/home/foobar/git/wine/dlls/winecrt0/exe_entry.c:36] in notepad (0x0033feb8)
3 0x7b875ac5 start_process+0x55(peb=<register ESI not in topmost frame>) [/home/foobar/git/wine/dlls/kernel32/process.c:990] in kernel32 (0x0033fee8)
4 0x7bc6c814 call_thread_func+0xc() in ntdll (0x0033fef8)
5 0x7bc6e811 in ntdll (+0x5e811) (0x0033ffc8)
6 0x7bc4945a in ntdll (+0x3945a) (0x0033ffe8)
7 0xf7e6fc7d wine_call_on_stack+0x1d() in libwine.so.1 (0x00000000)
3 0x7b875ac5 start_process+0x55(peb=<register ESI not in topmost frame>) [/home/foobar/git/wine/dlls/kernel32/process.c:990] in kernel32 (0x0033fee8)
4 0x7bc6c814 call_thread_func+0xc() in ntdll (0x0033fef8)
5 0x7bc6e811 in ntdll (+0x5e811) (0x0033ffc8)
6 0x7bc4945a in ntdll (+0x3945a) (0x0033ffe8)
7 0xf7e6fc7d wine_call_on_stack+0x1d() in libwine.so.1 (0x00000000)
If your backtrace is missing information like the source file name and line number then you will need to compile from source.
