|
OpenTTD Source 20260911-master-gee2b2ac12a
|
Functions related to debugging. More...
#include "cpu.h"#include <chrono>#include "debug_type.h"#include "core/enum_type.hpp"#include "core/format.hpp"Go to the source code of this file.
Data Structures | |
| struct | TicToc |
| TicToc profiling. More... | |
| struct | TicToc::State |
| Persistent state for TicToc profiling. More... | |
Macros | |
| #define | Debug(facility, severity, format_string, ...) |
| Output a line of debugging information. | |
| #define | ShowInfo(format_string, ...) |
Typedefs | |
| using | SetDebugStringErrorFunc = void(std::string_view) |
Functions | |
| bool | IsVisibleSeverity (Facility facility, Severity severity) |
| Test if debug severity is visible for the given facility. | |
| void | DebugPrint (Facility facility, Severity severity, std::string &&message) |
| Internal function for outputting the debug line. | |
| void | DumpDebugFacilityNames (std::back_insert_iterator< std::string > &output_iterator) |
| Dump the available debug facility names in the help text. | |
| void | SetDebugString (std::string_view s, SetDebugStringErrorFunc error_func) |
| Set debugging levels by parsing the text in s. | |
| std::string | GetDebugString () |
| Print out the current debug-level. | |
| void | ShowInfoI (std::string_view str) |
| std::string | GetLogPrefix (bool force=false) |
| Get the prefix for logs. | |
| void | DebugSendRemoteMessages () |
| Send the queued Debug messages to either NetworkAdminConsole or IConsolePrint from the GameLoop thread to prevent concurrent accesses to both the NetworkAdmin's packet queue as well as IConsolePrint's buffers. | |
| void | DebugReconsiderSendRemoteMessages () |
| Reconsider whether we need to send debug messages to either NetworkAdminConsole or IConsolePrint. | |
Functions related to debugging.
Definition in file debug.h.
| #define Debug | ( | facility, | |
| severity, | |||
| format_string, | |||
| ... ) |
Output a line of debugging information.
| facility | The debug facility. |
| severity | The maximum debug level this message should be shown at. When the debug level for this category is set lower, then the message will not be shown. |
| format_string | The formatting string of the message. |
Definition at line 37 of file debug.h.
Referenced by _GenerateWorld(), _ValidateSignatureFile(), TCPListenHandler< Tsocket, EnumPacketType, Tfull_packet, Tban_packet >::AcceptClient(), SmallSet< Tdir, items >::Add(), Squirrel::AddClassBegin(), BaseMedia< Tbase_set >::AddFile(), ScriptScanner::AddFile(), SocialIntegrationFileScanner::AddFile(), TarScanner::AddFile(), AfterLoadGame(), Map::Allocate(), AllocateWaterRegions(), BlitterFactory::BlitterFactory(), CompanyStationsWindow::BuildStationsList(), Squirrel::CallMethod(), Vehicle::CancelReservation(), ChangeWorkingDirectoryToExecutable(), TCPConnecter::CheckActivity(), CheckCaches(), CheckClientAndServerName(), QueryNetworkGameSocketHandler::CheckConnection(), CheckExternalFiles(), ServerNetworkGameSocketHandler::CheckNextClientToSendMap(), ClientNetworkGameSocketHandler::CloseConnection(), ServerNetworkGameSocketHandler::CloseConnection(), TCPListenHandler< Tsocket, EnumPacketType, Tfull_packet, Tban_packet >::CloseListeners(), CocoaSetupApplication(), Squirrel::CompileError(), ClientNetworkStunSocketHandler::Connect(), ClientNetworkTurnSocketHandler::Connect(), NetworkHTTPRequest::Connect(), TCPConnecter::Connect(), ClientNetworkCoordinatorSocketHandler::ConnectFailure(), ClientNetworkCoordinatorSocketHandler::ConnectSuccess(), ClientNetworkCoordinatorSocketHandler::ConnectToServer(), Squirrel::CreateClassInstanceVM(), VideoDriver_SDL_Base::CreateMainSurface(), VideoDriver_SDL_Base::CreateMainWindow(), CurlSetOption(), DebugOutputCallback(), DecodeSingleSprite(), DeleteEntriesFromSpriteCache(), DetermineBasePaths(), DeterminePaths(), DetermineSaveLoadFormat(), ScriptInstance::Died(), DoAutoOrNetsave(), ScriptInstance::DoCommandCallback(), DoSave(), TarScanner::DoScan(), DoScanNewGRFFiles(), Blitter_32bppAnim::DrawColourMappingRect(), Blitter_32bppSimple::DrawColourMappingRect(), ErrorUnknownCallbackResult(), ExtractTar(), FillLanguageList(), FinalisePriceBaseMultipliers(), CoreTextFontCacheFactory::FindFallbackFont(), Win32FontCacheFactory::FindFallbackFont(), CYapfBaseT< Types >::FindPath(), FindStartupDisplay(), FioRemove(), FontConfigFindFallbackFont(), WaterRegion::ForceUpdate(), FormatString(), ClientNetworkGameSocketHandler::GameLoop(), TextfileWindow::GetHyperlink(), ClientNetworkCoordinatorSocketHandler::GetListing(), GetNetworkRevisionString(), Waypoint::GetNewGRFVariable(), NetworkAddress::GetPeerAddress(), GetRawSprite(), NetworkAddress::GetSockAddress(), GetSpriteCountForFile(), GetStringWithArgs(), X25519AuthorizedKeyClientHandler::GetValidSecretKeyAndUpdatePublicKey(), AirportTileScopeResolver::GetVariable(), CanalScopeResolver::GetVariable(), GenericScopeResolver::GetVariable(), HouseScopeResolver::GetVariable(), IndustriesScopeResolver::GetVariable(), IndustryTileScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), RailTypeScopeResolver::GetVariable(), RoadTypeScopeResolver::GetVariable(), ScopeResolver::GetVariable(), TownScopeResolver::GetVariable(), GfxLoadSprites(), GRFGetSizeOfDataSection(), GrfMsgI(), HandleCharMsg(), HandleInvalidSpriteRequest(), NetworkAdminSocketHandler::HandlePacket(), NetworkContentSocketHandler::HandlePacket(), NetworkCoordinatorSocketHandler::HandlePacket(), NetworkGameSocketHandler::HandlePacket(), NetworkTurnSocketHandler::HandlePacket(), NetworkUDPSocketHandler::HandleUDPPacket(), HttpThread(), IConsoleAliasExec(), IConsoleCmdExec(), IncreaseStats(), OpenGLBackend::Init(), VideoDriver_SDL_Base::Initialize(), OTTD_CocoaView::internalHandleKeycode:unicode:pressed:modifiers:, InvalidateWaterRegion(), IsGoodGRFConfigList(), IsHouseSpecValid(), ItemizeBidi(), TCPListenHandler< Tsocket, EnumPacketType, Tfull_packet, Tban_packet >::Listen(), ListenLoopProc(), AIPLChunkHandler::Load(), GSDTChunkHandler::Load(), SoundLoader_Opus::Load(), SoundLoader_Wav::Load(), LoadChunk(), ScriptInstance::LoadCompatibilityScript(), DLSFile::LoadFile(), FreeTypeFontCacheFactory::LoadFont(), LoadFromHighScore(), LoadGrfFile(), LoadGrfFileIndexed(), LoadNewGRF(), LoadNewGRFFileFromFile(), LoadNewGRFSound(), Vehicle::LoadOldVehicle, LoadSpriteTables(), CommandHelperBase::LogCommandExecution(), BaseSet< T >::LogError(), ScreenshotProvider_Pcx::MakeImage(), VideoDriver_Cocoa::MakeWindow(), MoveWaypointsToBaseStations(), NetworkAdminCompanyNew(), NetworkCheckRestartMapYear(), NetworkClient_Connected(), NetworkClientConnectGame(), NetworkClientJoinGame(), NetworkCoreInitialize(), NetworkFindBroadcastIPs(), NetworkGameLoop(), NetworkHTTPInitialize(), NetworkQueryServer(), NetworkServerSendChat(), NetworkServerStart(), NetworkShutDown(), NetworkStartUp(), NetworkTextMessage(), NetworkUDPBroadCast(), NetworkUDPClose(), NetworkUDPInitialize(), NetworkUDPSearchGame(), NetworkUpdateClientInfo(), NetworkStunConnecter::OnConnect(), NetworkTurnConnecter::OnConnect(), TCPClientConnecter::OnConnect(), TCPQueryConnecter::OnConnect(), NetworkStunConnecter::OnFailure(), NetworkSurveyHandler::OnFailure(), NetworkTurnConnecter::OnFailure(), TCPClientConnecter::OnFailure(), TCPQueryConnecter::OnFailure(), CompanyStationsWindow::OnGameTick(), VehicleListWindow::OnGameTick(), NetworkSurveyHandler::OnReceiveData(), TCPConnecter::OnResolved(), OpenBankFile(), openttd_main(), OSOpenBrowser(), MusicDriver_FluidSynth::PlaySong(), MusicDriver_Win32::PlaySong(), PositionMainToolbar(), PositionNetworkChatWindow(), PositionNewsMessage(), PositionStatusbar(), Gamelog::PrintDebug(), RandomBytesWithFallback(), ReadByteFromFile(), DLSFile::ReadDLSInstrument(), DLSFile::ReadDLSInstrumentList(), DLSFile::ReadDLSRegion(), DLSFile::ReadDLSRegionList(), DLSFile::ReadDLSWave(), DLSFile::ReadDLSWaveList(), ReadSprite(), NetworkHTTPRequest::Receive(), ServerNetworkAdminSocketHandler::ReceiveAdminAuthenticationResponse(), ServerNetworkAdminSocketHandler::ReceiveAdminChat(), ServerNetworkAdminSocketHandler::ReceiveAdminExternalChat(), ServerNetworkAdminSocketHandler::ReceiveAdminGameScript(), ServerNetworkAdminSocketHandler::ReceiveAdminJoin(), ServerNetworkAdminSocketHandler::ReceiveAdminJoinSecure(), ServerNetworkAdminSocketHandler::ReceiveAdminPing(), ServerNetworkAdminSocketHandler::ReceiveAdminPoll(), ServerNetworkAdminSocketHandler::ReceiveAdminRemoteConsoleCommand(), ServerNetworkAdminSocketHandler::ReceiveAdminUpdateFrequency(), ServerNetworkGameSocketHandler::ReceiveClientAck(), ServerNetworkGameSocketHandler::ReceiveClientAuthenticationResponse(), ServerNetworkGameSocketHandler::ReceiveClientChat(), ServerNetworkGameSocketHandler::ReceiveClientCommand(), ServerNetworkGameSocketHandler::ReceiveClientError(), ServerNetworkUDPSocketHandler::ReceiveClientFindServer(), ServerNetworkGameSocketHandler::ReceiveClientGameInfo(), ServerNetworkGameSocketHandler::ReceiveClientGetMap(), ServerNetworkGameSocketHandler::ReceiveClientIdentify(), ServerNetworkGameSocketHandler::ReceiveClientJoin(), ServerNetworkGameSocketHandler::ReceiveClientMapOk(), ServerNetworkGameSocketHandler::ReceiveClientMove(), ServerNetworkGameSocketHandler::ReceiveClientNewGRFsChecked(), ServerNetworkGameSocketHandler::ReceiveClientQuit(), ServerNetworkGameSocketHandler::ReceiveClientRemoteConsoleCommand(), ServerNetworkGameSocketHandler::ReceiveClientSetName(), ClientNetworkCoordinatorSocketHandler::ReceiveGameCoordinatorConnectFailed(), ClientNetworkCoordinatorSocketHandler::ReceiveGameCoordinatorConnecting(), ClientNetworkCoordinatorSocketHandler::ReceiveGameCoordinatorDirectConnect(), ClientNetworkCoordinatorSocketHandler::ReceiveGameCoordinatorError(), ClientNetworkCoordinatorSocketHandler::ReceiveGameCoordinatorListing(), ClientNetworkCoordinatorSocketHandler::ReceiveGameCoordinatorNewGRFLookup(), ClientNetworkCoordinatorSocketHandler::ReceiveGameCoordinatorRegisterAck(), ClientNetworkCoordinatorSocketHandler::ReceiveGameCoordinatorStunRequest(), ClientNetworkCoordinatorSocketHandler::ReceiveGameCoordinatorTurnConnect(), NetworkAdminSocketHandler::ReceiveInvalidPacket(), NetworkContentSocketHandler::ReceiveInvalidPacket(), NetworkCoordinatorSocketHandler::ReceiveInvalidPacket(), NetworkGameSocketHandler::ReceiveInvalidPacket(), NetworkStunSocketHandler::ReceiveInvalidPacket(), NetworkTurnSocketHandler::ReceiveInvalidPacket(), NetworkUDPSocketHandler::ReceiveInvalidPacket(), NetworkTCPSocketHandler::ReceivePacket(), NetworkUDPSocketHandler::ReceivePackets(), CombinedAuthenticationClientHandler::ReceiveRequest(), X25519AuthenticationHandler::ReceiveRequest(), CombinedAuthenticationServerHandler::ReceiveResponse(), X25519AuthenticationHandler::ReceiveResponse(), ClientNetworkGameSocketHandler::ReceiveServerAuthenticationRequest(), ClientNetworkGameSocketHandler::ReceiveServerBanned(), QueryNetworkGameSocketHandler::ReceiveServerBanned(), ClientNetworkGameSocketHandler::ReceiveServerChat(), ClientNetworkGameSocketHandler::ReceiveServerCheckNewGRFs(), ClientNetworkGameSocketHandler::ReceiveServerClientInfo(), ClientNetworkGameSocketHandler::ReceiveServerClientJoined(), ClientNetworkGameSocketHandler::ReceiveServerCommand(), ClientNetworkGameSocketHandler::ReceiveServerConfigurationUpdate(), ClientNetworkTurnSocketHandler::ReceiveServerConnected(), ClientNetworkGameSocketHandler::ReceiveServerEnableEncryption(), ClientNetworkGameSocketHandler::ReceiveServerError(), ClientNetworkTurnSocketHandler::ReceiveServerError(), QueryNetworkGameSocketHandler::ReceiveServerError(), ClientNetworkGameSocketHandler::ReceiveServerErrorQuit(), ClientNetworkGameSocketHandler::ReceiveServerExternalChat(), ClientNetworkGameSocketHandler::ReceiveServerFrame(), ClientNetworkGameSocketHandler::ReceiveServerFull(), QueryNetworkGameSocketHandler::ReceiveServerFull(), QueryNetworkGameSocketHandler::ReceiveServerGameInfo(), ClientNetworkGameSocketHandler::ReceiveServerMapBegin(), ClientNetworkGameSocketHandler::ReceiveServerMapDone(), ClientNetworkGameSocketHandler::ReceiveServerMapSize(), ClientNetworkGameSocketHandler::ReceiveServerMove(), ClientNetworkGameSocketHandler::ReceiveServerNewGame(), ClientNetworkGameSocketHandler::ReceiveServerQuit(), ClientNetworkGameSocketHandler::ReceiveServerRemoteConsoleCommand(), ClientNetworkUDPSocketHandler::ReceiveServerResponse(), ClientNetworkGameSocketHandler::ReceiveServerShutdown(), ClientNetworkGameSocketHandler::ReceiveServerSync(), ClientNetworkGameSocketHandler::ReceiveServerWaitForMap(), ClientNetworkGameSocketHandler::ReceiveServerWelcome(), ClientNetworkCoordinatorSocketHandler::Register(), ScriptScanner::RegisterScript(), SoundResampler_Soxr::Resample(), FileReader::Reset(), AI::ResetConfig(), Game::ResetConfig(), NetworkAddress::Resolve(), TCPConnecter::Resolve(), SocialIntegration::RunCallbacks(), SafeLoad(), SaveFileToDisk(), SaveOrLoad(), IniFile::SaveToDisk(), SaveToHighScore(), ScanPath(), RandomAccessFile::SeekTo(), BlitterFactory::SelectBlitter(), DriverFactoryBase::SelectDriverImpl(), AIScannerInfo::SelectRandomAI(), ServerNetworkAdminSocketHandler::Send(), ClientNetworkGameSocketHandler::SendAck(), ServerNetworkAdminSocketHandler::SendAuthRequest(), ServerNetworkGameSocketHandler::SendAuthRequest(), ClientNetworkGameSocketHandler::SendAuthResponse(), ClientNetworkGameSocketHandler::SendChat(), ServerNetworkGameSocketHandler::SendChat(), ServerNetworkGameSocketHandler::SendClientInfo(), ClientNetworkGameSocketHandler::SendCommand(), NetworkGameSocketHandler::SendCommand(), ServerNetworkGameSocketHandler::SendCommand(), ServerNetworkGameSocketHandler::SendConfigUpdate(), ServerNetworkGameSocketHandler::SendEnableEncryption(), ClientNetworkGameSocketHandler::SendError(), ServerNetworkAdminSocketHandler::SendError(), ServerNetworkGameSocketHandler::SendError(), ServerNetworkGameSocketHandler::SendErrorQuit(), ServerNetworkGameSocketHandler::SendExternalChat(), QueryNetworkGameSocketHandler::SendGameInfo(), ServerNetworkGameSocketHandler::SendGameInfo(), ClientNetworkGameSocketHandler::SendGetMap(), ClientNetworkGameSocketHandler::SendIdentify(), ClientNetworkGameSocketHandler::SendJoin(), ServerNetworkGameSocketHandler::SendJoin(), ServerNetworkGameSocketHandler::SendMap(), ClientNetworkGameSocketHandler::SendMapOk(), ClientNetworkGameSocketHandler::SendMove(), ServerNetworkGameSocketHandler::SendMove(), ServerNetworkGameSocketHandler::SendNewGame(), ServerNetworkGameSocketHandler::SendNewGRFCheck(), ClientNetworkGameSocketHandler::SendNewGRFsOk(), NetworkUDPSocketHandler::SendPacket(), NetworkTCPSocketHandler::SendPackets(), ClientNetworkGameSocketHandler::SendQuit(), ServerNetworkGameSocketHandler::SendQuit(), ClientNetworkGameSocketHandler::SendRCon(), ServerNetworkGameSocketHandler::SendRConResult(), ClientNetworkCoordinatorSocketHandler::SendReceive(), CombinedAuthenticationServerHandler::SendRequest(), CombinedAuthenticationClientHandler::SendResponse(), X25519AuthenticationHandler::SendResponse(), ClientNetworkCoordinatorSocketHandler::SendServerUpdate(), ClientNetworkGameSocketHandler::SendSetName(), ServerNetworkGameSocketHandler::SendShutdown(), ServerNetworkGameSocketHandler::SendSync(), ServerNetworkGameSocketHandler::SendWait(), ServerNetworkGameSocketHandler::SendWelcome(), ServerNetworkGameSocketHandler::ServerNetworkGameSocketHandler(), MusicDriver_ExtMidi::SetVolume(), MusicDriver_FluidSynth::SetVolume(), ShowNewGrfVehicleError(), SlCompatTableHeader(), SlFixPointers(), SlIterateArray(), SlLoadCheckChunks(), SlLoadChunks(), SlNullPointers(), SlSaveChunk(), SlTableHeader(), MusicDriver_DMusic::Start(), MusicDriver_FluidSynth::Start(), MusicDriver_Win32::Start(), SoundDriver_XAudio2::Start(), VideoDriver_Dedicated::Start(), VideoDriver_Null::Start(), VideoDriver_SDL_Base::Start(), VideoDriver::StartGameThread(), StartNewThread(), MusicDriver_Win32::StopSong(), strecpy(), ClientNetworkStunSocketHandler::Stun(), ClientNetworkCoordinatorSocketHandler::StunResult(), BasePersistentStorageArray::SwitchMode(), TimerCallback(), VideoDriver_SDL_Base::ToggleFullscreen(), NetworkSurveyHandler::Transmit(), FontCache::TryFallback(), TTDPStringIDToOTTDStringIDMapping(), ClientNetworkTurnSocketHandler::Turn(), UpdateGroupChildren(), ValidateChecksum(), TCPListenHandler< Tsocket, EnumPacketType, Tfull_packet, Tban_packet >::ValidateClient(), ValidateSchema(), ValidateSignature(), VerifyProgram(), VerifyShader(), WarnCorruptSprite(), NetworkHTTPRequest::WinHttpCallback(), Backup< T >::~Backup(), and ServerNetworkAdminSocketHandler::~ServerNetworkAdminSocketHandler().
| #define ShowInfo | ( | format_string, | |
| ... ) |
Internal function for outputting the debug line.
| facility | The facility category/classification of the debug message. |
| severity | The severity of the debug level; lower is more likely to be shown. |
| message | The message to output. |
Definition at line 88 of file debug.cpp.
References _debug_facilities, _debug_remote_console, _debug_remote_console_mutex, _debug_remote_console_queue, Autosave, Critical, Desync, FioFOpenFile(), GetLogPrefix(), lock, and Random.
Referenced by StringConsumer::LogError().
| void DebugReconsiderSendRemoteMessages | ( | ) |
Reconsider whether we need to send debug messages to either NetworkAdminConsole or IConsolePrint.
The former is when they have enabled console handling whereas the latter depends on the gui.developer setting's value.
This is to be called from the GameLoop thread.
Definition at line 231 of file debug.cpp.
References _debug_remote_console, _settings_client, Automatic, Console, and ServerNetworkAdminSocketHandler::IterateActive().
Referenced by LoadFromConfig(), ServerNetworkAdminSocketHandler::ReceiveAdminUpdateFrequency(), and ServerNetworkAdminSocketHandler::~ServerNetworkAdminSocketHandler().
| void DebugSendRemoteMessages | ( | ) |
Send the queued Debug messages to either NetworkAdminConsole or IConsolePrint from the GameLoop thread to prevent concurrent accesses to both the NetworkAdmin's packet queue as well as IConsolePrint's buffers.
This is to be called from the GameLoop thread.
Definition at line 207 of file debug.cpp.
References _debug_facilities, _debug_remote_console, _debug_remote_console_mutex, _debug_remote_console_queue, _debug_remote_console_queue_spare, _settings_client, CC_DEBUG, IConsolePrint(), lock, and NetworkAdminConsole().
| void DumpDebugFacilityNames | ( | std::back_insert_iterator< std::string > & | output_iterator | ) |
Dump the available debug facility names in the help text.
| output_iterator | The iterator to write the string to. |
Definition at line 65 of file debug.cpp.
References _debug_facilities, and End.
Referenced by ShowHelp().
| std::string GetDebugString | ( | ) |
Print out the current debug-level.
Just return a string with the values of all the debug categories.
Definition at line 172 of file debug.cpp.
References _debug_facilities, _debug_level, and End.
Referenced by ConDebugLevel().
| std::string GetLogPrefix | ( | bool | force | ) |
Get the prefix for logs.
If show_date_in_logs or force is enabled it returns the date, otherwise it returns an empty string.
| force | Whether to force the prefix on. |
Definition at line 191 of file debug.cpp.
References _settings_client.
Referenced by DebugPrint(), and IConsolePrint().
Test if debug severity is visible for the given facility.
| facility | The debug facility. |
| severity | The debug severity. |
true iff the debug severity level for the facility is visible. Definition at line 25 of file debug.h.
References _debug_level.
Referenced by _GenerateWorld(), VideoDriver_SDL_OpenGL::AllocateContext(), CheckCaches(), CYapfBaseT< Types >::FindPath(), HttpThread(), Squirrel::Initialize(), CommandHelperBase::InternalExecuteValidateTestAndPrepExec(), TCPConnecter::OnResolved(), SetupDebugOutput(), MusicDriver_DMusic::Start(), MusicDriver_Win32::Start(), and StateGameLoop().
| void SetDebugString | ( | std::string_view | s, |
| SetDebugStringErrorFunc | error_func ) |
Set debugging levels by parsing the text in s.
For setting individual levels a string like "net=3,grf=6" should be used. If the string starts with a number, the number is used as global debugging level.
| s | Text describing the wanted debugging levels. |
| error_func | The function to call if a parse error occurs. |
Definition at line 122 of file debug.cpp.
References _debug_facilities, _debug_level, StringConsumer::AnyBytesLeft(), StringConsumer::ReadUntilCharNotIn(), StringConsumer::SkipUntilCharIn(), and StringConsumer::TryReadIntegerBase().
Referenced by ConDebugLevel(), and openttd_main().