diff --git a/include/Logger.h b/include/Logger.h index a8a3add..fa05349 100644 --- a/include/Logger.h +++ b/include/Logger.h @@ -5,8 +5,8 @@ #include #include void InitLog(); -#define DebugPrintTID(what) DebugPrintTIDInternal(what, __func__) -void DebugPrintTIDInternal(const std::string& what, const std::string& func); // prints the current thread id in debug mode, to make tracing of crashes and asserts easier +#define DebugPrintTID() DebugPrintTIDInternal(__func__) +void DebugPrintTIDInternal(const std::string& func); // prints the current thread id in debug mode, to make tracing of crashes and asserts easier void ConsoleOut(const std::string& msg); void QueueAbort(); void except(const std::string& toPrint); diff --git a/src/Console.cpp b/src/Console.cpp index 54c2cc5..a7926ac 100644 --- a/src/Console.cpp +++ b/src/Console.cpp @@ -47,6 +47,7 @@ void ConsoleOut(const std::string& msg){ } [[noreturn]] void OutputRefresh(){ + DebugPrintTID(); while(true){ std::this_thread::sleep_for(std::chrono::milliseconds(10)); ProcessOut(); @@ -104,6 +105,7 @@ void SetupConsole(){ } [[noreturn]] void ReadCin(){ + DebugPrintTID(); while (true){ int In = _getch(); if (In == 13 || In == '\n') { diff --git a/src/Init/Heartbeat.cpp b/src/Init/Heartbeat.cpp index bf10e16..a1bb1ab 100644 --- a/src/Init/Heartbeat.cpp +++ b/src/Init/Heartbeat.cpp @@ -29,6 +29,7 @@ std::string GenerateCall(){ return ret; } void Heartbeat(){ + DebugPrintTID(); std::string R,T; while(true){ R = GenerateCall(); @@ -56,4 +57,4 @@ void Heartbeat(){ void HBInit(){ std::thread HB(Heartbeat); HB.detach(); -} \ No newline at end of file +} diff --git a/src/Lua/LuaMain.cpp b/src/Lua/LuaMain.cpp index d155725..0ec5687 100644 --- a/src/Lua/LuaMain.cpp +++ b/src/Lua/LuaMain.cpp @@ -48,6 +48,7 @@ void FolderList(const std::string& Path,bool HotSwap){ } } [[noreturn]]void HotSwaps(const std::string& path){ + DebugPrintTID(); while(true){ for(Lua*Script : PluginEngine){ struct stat Info{}; diff --git a/src/Lua/LuaSystem.cpp b/src/Lua/LuaSystem.cpp index 47b2f9f..d97ab9a 100644 --- a/src/Lua/LuaSystem.cpp +++ b/src/Lua/LuaSystem.cpp @@ -162,6 +162,7 @@ void ExecuteAsync(Lua* lua,const std::string& FuncName){ SafeExecution(lua,FuncName); } void CallAsync(Lua* lua,const std::string& Func,int U){ + DebugPrintTID(); lua->StopThread = false; int D = 1000 / U; while(!lua->StopThread){ diff --git a/src/Network/Auth.cpp b/src/Network/Auth.cpp index b2f3e9a..3da2573 100644 --- a/src/Network/Auth.cpp +++ b/src/Network/Auth.cpp @@ -178,6 +178,7 @@ void Identify(SOCKET TCPSock){ } void TCPServerMain(){ + DebugPrintTID(); #ifdef __WIN32 WSADATA wsaData; if (WSAStartup(514, &wsaData)){ diff --git a/src/Network/StatMonitor.cpp b/src/Network/StatMonitor.cpp index b555547..9a2db80 100644 --- a/src/Network/StatMonitor.cpp +++ b/src/Network/StatMonitor.cpp @@ -30,6 +30,7 @@ void Monitor() { } [[noreturn]]void Stat(){ + DebugPrintTID(); while(true){ Monitor(); std::this_thread::sleep_for(std::chrono::seconds(1)); diff --git a/src/Network/TCPHandler.cpp b/src/Network/TCPHandler.cpp index 50364b8..c2c3408 100644 --- a/src/Network/TCPHandler.cpp +++ b/src/Network/TCPHandler.cpp @@ -56,6 +56,7 @@ void TCPRcv(Client*c){ TCPHandle(c,Buf); } void TCPClient(Client*c){ + DebugPrintTID(); Assert(c); if(c->GetTCPSock() == -1){ CI->RemoveClient(c); diff --git a/src/Network/VehicleData.cpp b/src/Network/VehicleData.cpp index d5b2827..4f91b34 100644 --- a/src/Network/VehicleData.cpp +++ b/src/Network/VehicleData.cpp @@ -245,6 +245,7 @@ void UDPParser(Client* c, std::string Packet) { GParser(c, Packet); } void LOOP() { + DebugPrintTID(); while (UDPSock != -1) { for (PacketData* p : DataAcks) { if (p != nullptr) { diff --git a/src/logger.cpp b/src/logger.cpp index 2fa24e2..daded17 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -10,11 +10,11 @@ #include #include -void DebugPrintTIDInternal(const std::string& what, const std::string& func) { +void DebugPrintTIDInternal(const std::string& func) { // we need to print to cout here as we might crash before all console output is handled, // due to segfaults or asserts. #ifdef DEBUG - std::cout << "(debug build) Thread '" << std::this_thread::get_id() << "' in " << func << " is " << what << std::endl; + std::cout << "(debug build) Thread '" << std::this_thread::get_id() << "' is " << func << std::endl; #endif // DEBUG } diff --git a/src/main.cpp b/src/main.cpp index 5b7fd09..1b74071 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,20 +3,18 @@ #include #include [[noreturn]] void loop(){ - DebugPrintTID("test loop"); + DebugPrintTID(); while(true){ std::cout.flush(); - Assert(false); std::this_thread::sleep_for(std::chrono::milliseconds(600)); } } int main(int argc, char* argv[]) { - DebugPrintTID("main"); + DebugPrintTID(); #ifdef DEBUG std::thread t1(loop); t1.detach(); #endif - Assert(false); ConsoleInit(); InitServer(argc,argv); InitConfig();