isledecomp / isle

A work-in-progress decompilation of LEGO Island (1997)
1.79k stars 89 forks source link

Add new script to compare the stack layout #1112

Closed jonschz closed 1 month ago

jonschz commented 1 month ago

I have written a script that compares all references to the stack between the original and the recompiled binary. This is especially useful for BETA10, where it can be hard to tell if the order of variables on the stack is wrong or if there is an actual logic error in the recomp (the wrong variable is read or written). The script may also help understand how msvc decides the stack order since the analysis is much faster now. The names of the variables are pulled from the debug info.

Looking forward to your feedback - especially whether the built-in explanations are clear and/or how they could be improved.

Example outputs Here is the (slightly abbreviated) output for a modified version of LegoCarBuildAnimPresenter::FUN_10079160() that matches up to the order of stack variables (rename root to aaaroot as declared here): https://github.com/isledecomp/isle/blob/974cd7ce7c727d21652c8383f0c58910fce87602/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp#L261 grafik

Here is the abbreviated output for ther same function as it is on master right now, with a slight structural mismatch: grafik grafik Note how ebp - 0x18 is listed under not seen since its only appearance is in the structural mismatch. It could also be that it only appears in the middle of a perfectly matching block which - those are always omitted from the output (like in reccmp).

Here is the abbreviated output for the same function with an intentional logic error - counter++ is replaced by i++ in the following line: https://github.com/isledecomp/isle/blob/974cd7ce7c727d21652c8383f0c58910fce87602/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp#L326 grafik

Limitations

jonschz commented 1 month ago

~I have found another issue. Will comment when I have resolved it.~

Edit: bug found, should be good now

disinvite commented 1 month ago

This looks great!