Cannot call g_game.saveGameState() from gdb anymore
Before creating an issue, please ensure:
- [x] This is a bug in the software that resides in this repository, and not a support matter (use https://otland.net/forums/support.16/ for support)
- [x] This issue is reproducible without changes to the C++ code in this repository
Steps to reproduce (include any configuration/script required to reproduce)
- Compile as Debug or RelWithDebInfo
- Run server in gdb
- Signal server (e.g. SIGINT)
- call g_game.saveGameState()
Expected behaviour
Up until some point in the TFS1.3 development cycle, you could call saveGameState and have it operate as expected (the game state would be saved).
Actual behaviour
(gdb) call g_game.saveGameState()
One of the arguments you tried to pass to saveGameState could not be converted to what the function wants.
Environment
- Ubuntu 20.04
- Compiled with Debug or RelWithDebInfo (e.g.
cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo ..)
@Erza explained to me why this is occuring and suggested including __attribute__((used)) in game.cpp above void Game::saveGameState() - this does fix this particular issue for me, but it likely needs to be wrapped in a #ifndef _WIN32 check to be suitable for merge.
Alternatively, I assume there is a reason why this function is optimized out these days but was not previously. Perhaps the level of optimization can be adjusted instead.
I don't see how is this related to this repository, its hosting thing, as you mentioned, attribute is needed to make sure its not optimized out, but it's not a bug in code or anything.