Difference between revisions of "DebuggingCrashes"
m (9 revisions) |
(Reformat and update) |
||
Line 1: | Line 1: | ||
− | |||
− | '''''How to debug crashes with no crash log or hangs''''' |
||
− | |||
− | =Debugging Crashes= |
||
− | |||
− | How to debug crashes with no crash log or hangs |
||
− | |||
− | {maketoc} |
||
− | |||
When TTDPatch or TTD crash without producing a crash log file (crash###.txt), it is very hard for the developers to figure out what went wrong or how to fix it. The same applies for when TTD stops responding and hangs, so that you have to kill it with the task manager. |
When TTDPatch or TTD crash without producing a crash log file (crash###.txt), it is very hard for the developers to figure out what went wrong or how to fix it. The same applies for when TTD stops responding and hangs, so that you have to kill it with the task manager. |
||
Line 14: | Line 5: | ||
The process to get this information uses a debugger, a program that can catch crashes and interrupt a hung process in a controlled manner. If you've never used a debugger before, don't worry, we have step-by-step instructions here to tell you how to use it. |
The process to get this information uses a debugger, a program that can catch crashes and interrupt a hung process in a controlled manner. If you've never used a debugger before, don't worry, we have step-by-step instructions here to tell you how to use it. |
||
− | If you need help at any time, the best choice is to visit the [irc://irc.oftc.net/tycoon |
+ | If you need help at any time, the best choice is to visit the [irc://irc.oftc.net/tycoon #tycoon] IRC channel, or use the chat applet on TT-Forums. There's usually a patch developer there who can help you. |
==Install a debugger== |
==Install a debugger== |
||
− | First you need to install a debugger, if you don't have it already. Download [http://www.ollydbg.de/ |
+ | First you need to install a debugger, if you don't have it already. Download [http://www.ollydbg.de/ OllyDbg] and install it. |
− | Run it once, and open the |
+ | Run it once, and open the "Debugging options" dialog. |
+ | [[File:Options.png]] |
||
− | </center> |
||
− | Now open the |
+ | Now open the "Exceptions" tab, and check the "Integer division by 0" and "All FPU exceptions" boxes. |
+ | [[File:Options2.png]] |
||
− | </center> |
||
− | Click |
+ | Click "OK" and quit. OllyDbg is now set up properly for debugging TTD/TTDPatch. |
==Debugging a crash== |
==Debugging a crash== |
||
Line 34: | Line 25: | ||
If the game crashes, but does not create a crash log, you need to have the debugger catch the crash. There are two possible ways of doing this. If the crash happens before you get to the TTD title screen, or if the following instructions do not work or do not catch the crash, try those in the next section below. |
If the game crashes, but does not create a crash log, you need to have the debugger catch the crash. There are two possible ways of doing this. If the crash happens before you get to the TTD title screen, or if the following instructions do not work or do not catch the crash, try those in the next section below. |
||
− | This requires that you can |
+ | This requires that you can Alt-Tab or Alt-Esc out of TTD back to Windows. If you can't Alt-Tab out, try running TTD in windowed mode. Note that you will not be able to save your game when it happens (but it would crash anyway so that's no different to what you had before). |
* Start TTD normally |
* Start TTD normally |
||
− | * When TTD shows the title screen, press |
+ | * When TTD shows the title screen, press Alt-Tab or Alt-Esc to return to Windows |
− | * Start |
+ | * Start OllyDbg |
− | * Select File|Attach, then choose |
+ | * Select File|Attach, then choose "Transport Tycoon Deluxe" (it should have TTDLOADW.OVL in the name and path columns), then click "Attach" |
+ | : [[File:attach.png]] |
||
− | |||
⚫ | |||
− | </center> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
* Reproduce the steps that caused the crash last time |
* Reproduce the steps that caused the crash last time |
||
− | * At the time of the crash, |
+ | * At the time of the crash, OllyDbg should start flashing in the task bar |
− | * Click on it there to bring up the window, maximize |
+ | * Click on it there to bring up the window, maximize OllyDbg, and take a screenshot |
− | Submit this screenshot to the patch developers. It is best to go to the [irc://irc. |
+ | Submit this screenshot to the patch developers. It is best to go to the [irc://irc.oftc.net/tycoon #tycoon] IRC channel or the forum chat applet right away, with the windows still open, to see if the patch developers need any further information at this point. |
− | When done, simply close |
+ | When done, simply close OllyDbg. This will also close TTD. |
==Debugging a crash (alternate)== |
==Debugging a crash (alternate)== |
||
Line 58: | Line 48: | ||
First, open your ttdpatch.cfg in Notepad, and enter the following line somewhere: |
First, open your ttdpatch.cfg in Notepad, and enter the following line somewhere: |
||
− | <pre> |
+ | <pre>debugswitches r</pre> |
With this, TTD/TTDPatch will no longer start up normally, so be sure to remove it again when you're done with this procedure. |
With this, TTD/TTDPatch will no longer start up normally, so be sure to remove it again when you're done with this procedure. |
||
Line 64: | Line 54: | ||
Now start TTDPatch. It will do the normal steps and then show the following warning: |
Now start TTDPatch. It will do the normal steps and then show the following warning: |
||
− | <pre> |
+ | <pre>Couldn't execute TTDLOADW.OVL: DEBUG SWITCH</pre> |
− | At this point, start |
+ | At this point, start OllyDbg. Select File|Open, browse to your TTD folder, and open TTDLOADW.OVL. |
− | * You will now get an |
+ | * You will now get an "Entry point alert" warning. Simply click "OK". |
− | * Now press F9 or the |
+ | * Now press F9 or the "run" button [[File:runbutton.png]] to start TTDPatch and TTD. |
* Reproduce the steps that caused the crash last time |
* Reproduce the steps that caused the crash last time |
||
− | * At the time of the crash, |
+ | * At the time of the crash, OllyDbg should start flashing in the task bar |
− | * Click on it there to bring up the window, maximize |
+ | * Click on it there to bring up the window, maximize OllyDbg, and take a screenshot |
− | Submit this screenshot to the patch developers. It is best to go to the [irc://irc. |
+ | Submit this screenshot to the patch developers. It is best to go to the [irc://irc.oftc.net/tycoon #tycoon] IRC channel or the forum chat applet right away, with the windows still open, to see if the patch developers need any further information at this point. |
− | When done, simply close |
+ | When done, simply close OllyDbg. This will also close TTD. Press any key in the TTDPatch window to close it as well. |
==Debugging a hang== |
==Debugging a hang== |
||
− | Follow this procedure if TTD stops responding for a long time. This requires that you can |
+ | Follow this procedure if TTD stops responding for a long time. This requires that you can Alt-Tab or Alt-Esc out of TTD back to Windows. If you can't Alt-Tab out, try running TTD in windowed mode. Note that you will not be able to save your game when it happens (but it would hang anyway so that's no different to what you had before). |
* Reproduce what you were doing when TTD stopped responding |
* Reproduce what you were doing when TTD stopped responding |
||
− | * When TTD stops responding again, press |
+ | * When TTD stops responding again, press Alt-Tab or Alt-Esc to return to Windows |
− | * Start |
+ | * Start OllyDbg |
− | * Select File|Attach, then choose |
+ | * Select File|Attach, then choose "Transport Tycoon Deluxe" (it should have TTDLOADW.OVL in the name and path columns), then click "Attach" |
+ | [[File:attach.png]] |
||
− | </center> |
||
− | You will now get an |
+ | You will now get an "Entry point alert" warning. Simply click "OK". At this point the window should look like this (click on thumbnail for full size view): |
+ | [[File:postattach.png]] |
||
− | src="img/wiki_up/postattach_t.jpg" ]</center> |
||
− | Note the |
+ | Note the "EIP" line on the right. After 8 hex digits, it will say something with either "NTDLL" or "KERNEL32", depending on your Windows version. If it doesn't, ask for help at this point. |
− | Now select |
+ | Now select "Debug|Execute till user code" or press Alt-F9, and check the EIP line again. It should say "TTDLOADW" after the 8 hex digits: |
+ | [[File:ttdloadw.png]] |
||
− | </center> |
||
Note that the letters/digits don't matter, just check that it says TTDLOADW. If it doesn't, something is probably not working, so ask for help at this point. |
Note that the letters/digits don't matter, just check that it says TTDLOADW. If it doesn't, something is probably not working, so ask for help at this point. |
||
− | At this point, take a screenshot of the entire |
+ | At this point, take a screenshot of the entire OllyDbg window and submit it to the patch developers. It is best to go to the [irc://irc.oftc.net/tycoon tycoon] IRC channel or the forum chat applet right away, with the windows still open, to see if the patch developers need any further information at this point. |
+ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | <center>[[File:debug1.png]]</center> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | src="img/wiki_up/debug_thumb.png" ]</center> |
||
⚫ | If this happens, something went wrong with OllyDbg. Submit the screenshot as normal, but then please contact [mailto:Ollydbg@t-online.de?subject=Have%20question|Oleh Yuschuk], and tell him you can reproduce the problem DaleStan reported. Please do everything he asks of you, so this issue may be resolved as quickly as possible. |
||
⚫ | |||
+ | [[Category:TTDPatch Development]] |
||
⚫ | If this happens, something went wrong with |
Revision as of 17:36, 30 July 2011
When TTDPatch or TTD crash without producing a crash log file (crash###.txt), it is very hard for the developers to figure out what went wrong or how to fix it. The same applies for when TTD stops responding and hangs, so that you have to kill it with the task manager.
If a crash log is produced, simply forward it to the patch developers. This document explains how to get the information that's usually in the crash log to the patch developers so they may attempt to figure out what the problem is in the absense of a crash log.
The process to get this information uses a debugger, a program that can catch crashes and interrupt a hung process in a controlled manner. If you've never used a debugger before, don't worry, we have step-by-step instructions here to tell you how to use it.
If you need help at any time, the best choice is to visit the #tycoon IRC channel, or use the chat applet on TT-Forums. There's usually a patch developer there who can help you.
Install a debugger
First you need to install a debugger, if you don't have it already. Download OllyDbg and install it.
Run it once, and open the "Debugging options" dialog.
Now open the "Exceptions" tab, and check the "Integer division by 0" and "All FPU exceptions" boxes.
Click "OK" and quit. OllyDbg is now set up properly for debugging TTD/TTDPatch.
Debugging a crash
If the game crashes, but does not create a crash log, you need to have the debugger catch the crash. There are two possible ways of doing this. If the crash happens before you get to the TTD title screen, or if the following instructions do not work or do not catch the crash, try those in the next section below.
This requires that you can Alt-Tab or Alt-Esc out of TTD back to Windows. If you can't Alt-Tab out, try running TTD in windowed mode. Note that you will not be able to save your game when it happens (but it would crash anyway so that's no different to what you had before).
- Start TTD normally
- When TTD shows the title screen, press Alt-Tab or Alt-Esc to return to Windows
- Start OllyDbg
- Select File|Attach, then choose "Transport Tycoon Deluxe" (it should have TTDLOADW.OVL in the name and path columns), then click "Attach"
- You will now get an "Entry point alert" warning. Simply click "OK".
- Continue to run TTD by pressing the "F9" key or clicking the "run" button .
- Now return to TTD in the task bar or with Alt-Tab
- Reproduce the steps that caused the crash last time
- At the time of the crash, OllyDbg should start flashing in the task bar
- Click on it there to bring up the window, maximize OllyDbg, and take a screenshot
Submit this screenshot to the patch developers. It is best to go to the #tycoon IRC channel or the forum chat applet right away, with the windows still open, to see if the patch developers need any further information at this point.
When done, simply close OllyDbg. This will also close TTD.
Debugging a crash (alternate)
If the above instructions don't catch the crash, especially if the crash happens before the title window comes up, try this method.
First, open your ttdpatch.cfg in Notepad, and enter the following line somewhere:
debugswitches r
With this, TTD/TTDPatch will no longer start up normally, so be sure to remove it again when you're done with this procedure.
Now start TTDPatch. It will do the normal steps and then show the following warning:
Couldn't execute TTDLOADW.OVL: DEBUG SWITCH
At this point, start OllyDbg. Select File|Open, browse to your TTD folder, and open TTDLOADW.OVL.
- You will now get an "Entry point alert" warning. Simply click "OK".
- Now press F9 or the "run" button to start TTDPatch and TTD.
- Reproduce the steps that caused the crash last time
- At the time of the crash, OllyDbg should start flashing in the task bar
- Click on it there to bring up the window, maximize OllyDbg, and take a screenshot
Submit this screenshot to the patch developers. It is best to go to the #tycoon IRC channel or the forum chat applet right away, with the windows still open, to see if the patch developers need any further information at this point.
When done, simply close OllyDbg. This will also close TTD. Press any key in the TTDPatch window to close it as well.
Debugging a hang
Follow this procedure if TTD stops responding for a long time. This requires that you can Alt-Tab or Alt-Esc out of TTD back to Windows. If you can't Alt-Tab out, try running TTD in windowed mode. Note that you will not be able to save your game when it happens (but it would hang anyway so that's no different to what you had before).
- Reproduce what you were doing when TTD stopped responding
- When TTD stops responding again, press Alt-Tab or Alt-Esc to return to Windows
- Start OllyDbg
- Select File|Attach, then choose "Transport Tycoon Deluxe" (it should have TTDLOADW.OVL in the name and path columns), then click "Attach"
You will now get an "Entry point alert" warning. Simply click "OK". At this point the window should look like this (click on thumbnail for full size view):
Note the "EIP" line on the right. After 8 hex digits, it will say something with either "NTDLL" or "KERNEL32", depending on your Windows version. If it doesn't, ask for help at this point.
Now select "Debug|Execute till user code" or press Alt-F9, and check the EIP line again. It should say "TTDLOADW" after the 8 hex digits:
Note that the letters/digits don't matter, just check that it says TTDLOADW. If it doesn't, something is probably not working, so ask for help at this point.
At this point, take a screenshot of the entire OllyDbg window and submit it to the patch developers. It is best to go to the tycoon IRC channel or the forum chat applet right away, with the windows still open, to see if the patch developers need any further information at this point.
When done, simply close OllyDbg. This will also close TTD.
Final notes
- When using OllyDbg to debug crashes or hangs, it is very much advisable, although not absolutely required, to start TTD in windowed mode, not full-screen mode.
- For unknown reasons, OllyDbg sometimes fails to provide us as much information as we would like. Sometimes, the screenshot will look like this (click on thumbnail for full size view):
If this happens, something went wrong with OllyDbg. Submit the screenshot as normal, but then please contact Yuschuk, and tell him you can reproduce the problem DaleStan reported. Please do everything he asks of you, so this issue may be resolved as quickly as possible.