OpenTTD
Macros | Functions | Variables
debug.h File Reference

Functions related to debugging. More...

#include "cpu.h"

Go to the source code of this file.

Macros

#define DEBUG(name, level,...)   if ((level) == 0 || _debug_ ## name ## _level >= (level)) debug(#name, __VA_ARGS__)
 Output a line of debugging information.
#define FILE_LINE   __FILE__, __LINE__
#define TIC()
#define TOC(str, count)

Functions

void CDECL debug (const char *dbg, const char *format,...) WARN_FORMAT(2
void CDECL char * DumpDebugFacilityNames (char *buf, char *last)
 Dump the available debug facility names in the help text.
void SetDebugString (const char *s)
 Set debugging levels by parsing the text in s.
const char * GetDebugString ()
 Print out the current debug-level.
void ShowInfo (const char *str)
void CDECL ShowInfoF (const char *str,...) WARN_FORMAT(1
void CDECL const char * GetLogPrefix ()
 Get the prefix for logs; if show_date_in_logs is enabled it returns the date, otherwise it returns nothing.

Variables

int _debug_driver_level
int _debug_grf_level
int _debug_map_level
int _debug_misc_level
int _debug_net_level
int _debug_sprite_level
int _debug_oldloader_level
int _debug_npf_level
int _debug_yapf_level
int _debug_freetype_level
int _debug_script_level
int _debug_sl_level
int _debug_gamelog_level
int _debug_desync_level
int _debug_console_level
uint32 _realtime_tick
 The real time in the game.

Detailed Description

Functions related to debugging.

Definition in file debug.h.

Macro Definition Documentation

#define DEBUG (   name,
  level,
  ... 
)    if ((level) == 0 || _debug_ ## name ## _level >= (level)) debug(#name, __VA_ARGS__)

Output a line of debugging information.

Parameters
nameCategory
levelDebugging level, higher levels means more detailed information.

Definition at line 39 of file debug.h.

Referenced by _GenerateWorld(), TCPListenHandler< ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED >::AcceptClient(), SmallSet< Tdir, items >::Add(), Squirrel::AddClassBegin(), TarScanner::AddFile(), AfterLoadGame(), AllocateMap(), BlitterFactory::BlitterFactory(), CompanyStationsWindow::BuildStationsList(), Squirrel::CallMethod(), Vehicle::CancelReservation(), ChangeWorkingDirectoryToExecutable(), CheckCaches(), CheckExternalFiles(), CheckForMissingSprites(), ClientNetworkGameSocketHandler::CloseConnection(), ServerNetworkGameSocketHandler::CloseConnection(), TCPListenHandler< ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED >::CloseListeners(), CompactSpriteCache(), Squirrel::CompileError(), NetworkAddress::Connect(), ConnectLoopProc(), AIInfo::Constructor(), GameInfo::Constructor(), Squirrel::CreateClassInstanceVM(), OrderList::DebugCheckSanity(), DecodeSingleSprite(), DetermineBasePaths(), DeterminePaths(), ScriptInstance::Died(), DoAutosave(), DoCommandPInternal(), DoLoad(), DoSave(), TarScanner::DoScan(), DoScanNewGRFFiles(), Blitter_32bppSimple::DrawColourMappingRect(), Blitter_32bppAnim::DrawColourMappingRect(), ErrorUnknownCallbackResult(), ExtractTar(), BaseSet< T, Tnum_files, Tsearch_in_tars >::FillSetDetails(), FinalisePriceBaseMultipliers(), CYapfBaseT< Types >::FindPath(), FioSeekTo(), FreeTypeFontCache::FreeTypeFontCache(), ClientNetworkGameSocketHandler::GameLoop(), GenerateWorld(), GetDriveableTrackdirBits(), StringParameters::GetInt64(), GetLanguageList(), Waypoint::GetNewGRFVariable(), GetRawSprite(), IndustriesScopeResolver::GetVariable(), IndustryTileScopeResolver::GetVariable(), RailTypeScopeResolver::GetVariable(), TownScopeResolver::GetVariable(), AirportTileScopeResolver::GetVariable(), CanalScopeResolver::GetVariable(), HouseScopeResolver::GetVariable(), GenericScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), ScopeResolver::GetVariable(), GfxLoadSprites(), GRFGetSizeOfDataSection(), grfmsg(), HandleCharMsg(), NetworkHTTPSocketHandler::HandleHeader(), HandleInvalidSpriteRequest(), NetworkContentSocketHandler::HandlePacket(), NetworkAdminSocketHandler::HandlePacket(), NetworkGameSocketHandler::HandlePacket(), NetworkUDPSocketHandler::HandleUDPPacket(), IConsoleAliasExec(), IConsoleCmdExec(), IncreaseStats(), InitQuickTimeIfNeeded(), IsGoodGRFConfigList(), IsHouseSpecValid(), Layouter::Layouter(), TCPListenHandler< ServerNetworkGameSocketHandler, PACKET_SERVER_FULL, PACKET_SERVER_BANNED >::Listen(), ListenLoopProc(), LoadChunk(), ScriptInstance::LoadCompatibilityScripts(), LoadFreeTypeFont(), LoadFromHighScore(), LoadGrfFile(), LoadGrfFileIndexed(), LoadMovieForMIDIFile(), LoadNewGRF(), LoadNewGRFFile(), LoadNewGRFSound(), LoadOldVehicle(), VideoDriver_Dedicated::MainLoop(), VideoDriver_SDL::MainLoop(), VideoDriver_Win32::MainLoop(), MakePCXImage(), NetworkAdminCompanyInfo(), NetworkCheckRestartMap(), NetworkCoreInitialize(), NetworkFindBroadcastIPs(), NetworkGameListAddItem(), NetworkGameListRemoveItem(), NetworkHTTPSocketHandler::NetworkHTTPSocketHandler(), NetworkServerSendChat(), NetworkShutDown(), NetworkStartUp(), NetworkUDPAdvertiseThread(), NetworkUDPBroadCast(), NetworkUDPClose(), NetworkUDPInitialize(), NetworkUDPQueryMasterServer(), NetworkUDPRemoveAdvertiseThread(), NetworkUDPSearchGame(), NetworkUpdateClientInfo(), CompanyStationsWindow::OnTick(), VehicleListWindow::OnTick(), openttd_main(), OTTDSHGetFolderPath(), MusicDriver_QtMidi::PlaySong(), MusicDriver_LibTimidity::PlaySong(), png_my_error(), png_my_warning(), PositionMainToolbar(), PositionNetworkChatWindow(), PositionNewsMessage(), PositionStatusbar(), ReadByteFromFile(), ReadSprite(), NetworkHTTPSocketHandler::Receive(), ServerNetworkAdminSocketHandler::Receive_ADMIN_CHAT(), ServerNetworkAdminSocketHandler::Receive_ADMIN_GAMESCRIPT(), ServerNetworkAdminSocketHandler::Receive_ADMIN_JOIN(), ServerNetworkAdminSocketHandler::Receive_ADMIN_PING(), ServerNetworkAdminSocketHandler::Receive_ADMIN_POLL(), ServerNetworkAdminSocketHandler::Receive_ADMIN_RCON(), ServerNetworkAdminSocketHandler::Receive_ADMIN_UPDATE_FREQUENCY(), ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(), ServerNetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER(), ServerNetworkUDPSocketHandler::Receive_CLIENT_GET_NEWGRFS(), ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(), ServerNetworkGameSocketHandler::Receive_CLIENT_MOVE(), ServerNetworkGameSocketHandler::Receive_CLIENT_RCON(), MasterNetworkUDPSocketHandler::Receive_MASTER_ACK_REGISTER(), MasterNetworkUDPSocketHandler::Receive_MASTER_SESSION_KEY(), ClientNetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS(), ClientNetworkGameSocketHandler::Receive_SERVER_FRAME(), ClientNetworkGameSocketHandler::Receive_SERVER_MOVE(), ClientNetworkUDPSocketHandler::Receive_SERVER_NEWGRFS(), ClientNetworkGameSocketHandler::Receive_SERVER_QUIT(), ClientNetworkUDPSocketHandler::Receive_SERVER_RESPONSE(), NetworkUDPSocketHandler::ReceiveInvalidPacket(), NetworkContentSocketHandler::ReceiveInvalidPacket(), NetworkAdminSocketHandler::ReceiveInvalidPacket(), NetworkGameSocketHandler::ReceiveInvalidPacket(), NetworkTCPSocketHandler::ReceivePacket(), NetworkUDPSocketHandler::ReceivePackets(), ScriptScanner::RegisterScript(), RemapNewGRFStringControlCode(), SquirrelStd::require(), FileReader::Reset(), AI::ResetConfig(), NetworkAddress::Resolve(), SafeLoad(), SaveFileToDisk(), SaveOrLoad(), IniFile::SaveToDisk(), SaveToHighScore(), BlitterFactory::SelectBlitter(), DriverFactoryBase::SelectDriverImpl(), AIScannerInfo::SelectRandomAI(), ServerNetworkAdminSocketHandler::Send(), NetworkGameSocketHandler::SendCommand(), ServerNetworkAdminSocketHandler::SendError(), ServerNetworkGameSocketHandler::SendError(), NetworkUDPSocketHandler::SendPacket(), NetworkTCPSocketHandler::SendPackets(), SetFallbackFont(), SetMIDITypeIfNeeded(), MusicDriver_QtMidi::SetVolume(), MusicDriver_ExtMidi::SetVolume(), ShowNewGrfVehicleError(), SlFixPointers(), SlIterateArray(), SlLoadCheckChunks(), SlLoadChunks(), SlNullPointers(), SlSaveChunk(), SlString(), MusicDriver_LibTimidity::Start(), VideoDriver_Dedicated::Start(), VideoDriver_SDL::Start(), VideoDriver_Win32::Start(), VideoDriver_Null::Start(), MusicDriver_QtMidi::Stop(), MusicDriver_QtMidi::StopSong(), strecpy(), BasePersistentStorageArray::SwitchMode(), SwitchNewGRFBlitter(), TTDPStringIDToOTTDStringIDMapping(), WarnCorruptSprite(), Backup< T >::~Backup(), and ServerNetworkAdminSocketHandler::~ServerNetworkAdminSocketHandler().

#define TIC ( )
Value:
{\
uint64 _xxx_ = ottd_rdtsc();\
static uint64 __sum__ = 0;\
static uint32 __i__ = 0;

Definition at line 91 of file debug.h.

#define TOC (   str,
  count 
)
Value:
__sum__ += ottd_rdtsc() - _xxx_;\
if (++__i__ == count) {\
DEBUG(misc, 0, "[%s] " OTTD_PRINTF64 " [avg: %.1f]", str, __sum__, __sum__/(double)__i__);\
__i__ = 0;\
__sum__ = 0;\
}\
}

Definition at line 96 of file debug.h.

Function Documentation

void CDECL char* DumpDebugFacilityNames ( char *  buf,
char *  last 
)

Dump the available debug facility names in the help text.

Parameters
bufStart address for storing the output.
lastLast valid address for storing the output.
Returns
Next free position in the output.

Definition at line 84 of file debug.cpp.

References endof, and strecpy().

Referenced by ShowHelp().

const char* GetDebugString ( )

Print out the current debug-level.

Just return a string with the values of all the debug categories.

Returns
string with debug-levels

Definition at line 233 of file debug.cpp.

References endof, lastof, seprintf(), and strecat().

void CDECL const char* GetLogPrefix ( )

Get the prefix for logs; if show_date_in_logs is enabled it returns the date, otherwise it returns nothing.

Returns
the prefix for logs (do not free), never NULL

Definition at line 256 of file debug.cpp.

References _settings_client, ClientSettings::gui, and GUISettings::show_date_in_logs.

Referenced by debug_print(), and IConsolePrint().

void SetDebugString ( const char *  s)

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.

Parameters
sText describing the wanted debugging levels.

Definition at line 179 of file debug.cpp.

References endof, and ShowInfoF().

Referenced by openttd_main().

Variable Documentation

uint32 _realtime_tick