DebuggingCrashes

From TTWiki
Revision as of 18:52, 15 October 2006 by dmccoy (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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.

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 [1] 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 [2] and install it.

Run it once, and oped the "Debugging options" dialog.

Now check the "Integer division by 0" and "All FPU exceptions" boxes.

Click "OK" and quit. ))OllyDbg[[]]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[[]]Alt-Tab[[ or ))Alt-Esc[[]]Alt-Esc[[ out of TTD back to Windows. If you can't ))Alt-Tab[[]]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[[]]Alt-Tab[[ or ))Alt-Esc[[]]Alt-Esc[[ to return to Windows
  • Start ))OllyDbg[[]]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[[]]Alt-Tab[[
  • Reproduce the steps that caused the crash last time
  • At the time of the crash, ))OllyDbg[[]]OllyDbg[[ should start flashing in the task bar
  • Click on it there to bring up the window, and take a screenshot

Submit this screenshot to the patch developers. It is best to go to the [3] 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[[]]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[[]]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[[]]OllyDbg[[ should start flashing in the task bar
  • Click on it there to bring up the window, and take a screenshot

Submit this screenshot to the patch developers. It is best to go to the [4] 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[[]]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[[]]Alt-Tab[[ or ))Alt-Esc[[]]Alt-Esc[[ out of TTD back to Windows. If you can't ))Alt-Tab[[]]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[[]]Alt-Tab[[ or ))Alt-Esc[[]]Alt-Esc[[ to return to Windows
  • Start ))OllyDbg[[]]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):

src="img/wiki_up/postattach_t.jpg" ]

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[[]]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 click until it says TTDLOADW. If it does not say TTDLOADW, it's probably not working, so ask for help at this point.

At this point, take a screenshot of the entire ))OllyDbg[[]]OllyDbg[[ window and submit it to the patch developers. It is best to go to the [5] 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[[]]OllyDbg[[. This will also close TTD.