Open japjitsingh opened 1 year ago
Hello @simsor, @citronneur
I accidentally reverted my second commit, so we see 3 new commits. (2nd commit, revert, 2nd commit) Sorry about that.
The latest commit resolves #12 which occurs when stepping backwards, and mildly improves code readability and design.
As per my understanding of the plugin, when stepping backwards:
In terms of original code implementation, the stepping backwards functionality is achieved by the following steps:
The code centering around m_backwardsSingleStep seems a bit of a "hack". I have introduced some changes to the code that eliminates m_backwardsSingleStep while keeping all functionality intact.
The changed code flow is as follows:
Some other changes that were made to ensure proper functionality:
In conclusion: the commit gets rid of m_backwardsSingleStep and significantly simplifies the DebuggerManager::onResume() function. Instead of relying on a boolean value, backward-step-into simply changes the direction of the execution and uses the same code as that of the normal step-into. Breakpoint event is not used and we will not get the "unknown debugger breakpoint" errors while stepping backwards.
Thank you for the great plugin, and please keep up the astounding work! :grin:
Japjit
This commit resolves #14.
The bug relates to calling Cursor::ReplayBackward with -1 for the stepCount argument. The C++ code examples in the ttd-bindings repository mistakenly calls Cursor::ReplayForward with -1. It should be called with -2. Although Cursor::ReplayForward works normally, using the same argument for Cursor::ReplayBackward does nothing.
The fix can be confirmed by looking at the code for Python bindings in the ttd-bindings repository.
It correctly adds the following line:
m.attr("MAX_STEP") = 0xFFFFFFFFFFFFFFFE;
which as an int (later casted to an unsigned long long) equates to -2.Any calls to continue code execution is then achieved by using _pyTTD.MAXSTEP as seen in example_api.py.