[Tutorial] How To Debug Your Script When Compiler Crashes - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (
https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] How To Debug Your Script When Compiler Crashes (
/showthread.php?tid=360899)
How To Debug Your Script When Compiler Crashes -
hansen111 - 19.07.2012
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
Re: How To Debug Your Script When Compiler Crashes -
L.Hudson - 19.07.2012
pretty smart and works
Re: How To Debug Your Script When Compiler Crashes -
Robert West - 19.07.2012
Yeh , good tutorial