forgottenserver icon indicating copy to clipboard operation
forgottenserver copied to clipboard

Cannot call g_game.saveGameState() from gdb anymore

Open thatmichaelguy opened this issue 3 years ago • 1 comments

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)

  1. Compile as Debug or RelWithDebInfo
  2. Run server in gdb
  3. Signal server (e.g. SIGINT)
  4. 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 ..)

thatmichaelguy avatar May 30 '22 19:05 thatmichaelguy

@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.

thatmichaelguy avatar May 30 '22 21:05 thatmichaelguy

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.

nekiro avatar Nov 10 '22 11:11 nekiro