[Tutorial] How To Debug Your Script When Compiler Crashes
#1

Why do we need this tutorial
Im writing this short tutorial to help scripters when they encounter a pawn compiler crash when trying to compile a script. This can be devastating because the compiler you rely on to give you info about your errors will simply stop working without a crashlog.

The reasons for the compiler crash in my experience can come from a number of logical or unlogical cases. It can be cases of missing brackets or something completely different. The latest case you can read about in the link below which also shows a screenshot of the compiler crashing:
https://sampforum.blast.hk/showthread.php?tid=360150


The problem is in your script
In all the cases i have experienced compiler crashes the problem have been in the script, it has not been the result of a corruption in the pawncc.exe / pawno.exe files. Having said that it is not certain its a script error per say as you can see in the link above.

Finding the problem in the script
There is no magic trick or magic button (at least not at this time) that can find the line(s) that crashes the compiler so we have to attack the problem in a practical way:

1) Start by splitting up your code in half by commenting OUT half of your code by using /* ... */:

Code:
/*
// First half of my code
bla bla bla
bla bla bla
bla bla bla
bla bla bla
*/

// Second half of my code
bla bla bla
bla bla bla
bla bla bla
bla bla bla
2) Hit compile and try to compile the half you left uncommented.

3) Step 2 will have 1 out of 2 possible outcomes, either the compiler crashes or it will compile normally.

3.1) If the compiler crashes again we now know the problem is in the half you left uncommented.

- Now you devide the uncommented half again using the same method.
- Continue these steps until the compiler does not crash but give normal output (Dont worry about errors in your script at this point)
- When this is achieved we have found the problem to be in the last section you commented OUT just before the successful compile.
- Using this method you can narrow the problem down to 1 line.

3.2) If the compiler does not crash and give normal output (errors) the problem is in the half you just commented OUT. (Dont worry about errors in your script at this point)

- Now you devide the section that contains the problem in half again using the same method
- Continue these steps until the compiler crashes again
- When this is achieved we have found the problem to be in the last section you commented IN just before the compiler crashed.
- Using this method you can narrow the problem down to 1 line.

These steps should hopefully leave you with the line(s) that crashes the compiler. At this point it might be obvious what is wrong with the code or it might not, in any case you have found the line(s) that crashes the compiler which was the goal of this tutorial.

Read here for more compiler crashes and problems:
https://sampforum.blast.hk/showthread.php?tid=355877
Reply


Messages In This Thread
How To Debug Your Script When Compiler Crashes - by hansen111 - 19.07.2012, 11:39
Re: How To Debug Your Script When Compiler Crashes - by L.Hudson - 19.07.2012, 12:11
Re: How To Debug Your Script When Compiler Crashes - by Robert West - 19.07.2012, 12:22

Forum Jump:


Users browsing this thread: 1 Guest(s)