Changed how i dump to file.

This commit is contained in:
KimLS 2015-02-07 12:51:54 -08:00
parent b5d33c7cbe
commit 00eb526876
8 changed files with 35 additions and 61 deletions

View File

@ -20,10 +20,12 @@ TARGET_LINK_LIBRARIES(eqlaunch common ${PERF_LIBS} debug ${MySQL_LIBRARY_DEBUG}
IF(MSVC)
SET_TARGET_PROPERTIES(eqlaunch PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
TARGET_LINK_LIBRARIES(eqlaunch "Ws2_32.lib")
TARGET_LINK_LIBRARIES(eqlaunch "rpcrt4")
ENDIF(MSVC)
IF(MINGW)
TARGET_LINK_LIBRARIES(eqlaunch "WS2_32")
TARGET_LINK_LIBRARIES(eqlaunch "rpcrt4")
ENDIF(MINGW)
IF(UNIX)
@ -34,6 +36,7 @@ IF(UNIX)
TARGET_LINK_LIBRARIES(eqlaunch "rt")
ENDIF(NOT DARWIN)
TARGET_LINK_LIBRARIES(eqlaunch "pthread")
TARGET_LINK_LIBRARIES(eqlaunch "uuid")
ADD_DEFINITIONS(-fPIC)
ENDIF(UNIX)

View File

@ -69,6 +69,10 @@ int main(int argc, char *argv[]) {
Log.Out(Logs::Detail, Logs::Launcher, "Could not set signal handler");
return 1;
}
if (signal(SIGBREAK, CatchSignal) == SIG_ERR) {
Log.Out(Logs::Detail, Logs::Launcher, "Could not set signal handler");
return 1;
}
#ifndef WIN32
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
Log.Out(Logs::Detail, Logs::Launcher, "Could not set signal handler");
@ -187,7 +191,7 @@ void CatchSignal(int sig_num) {
Log.Out(Logs::Detail, Logs::Launcher, "Caught signal %d", sig_num);
RunLoops = false;
_eqp_dump_file("eqlaunch");
}

View File

@ -3,6 +3,8 @@
#ifdef EQPERF_ENABLED
#include <string>
#include <fstream>
#include <time.h>
#include "eqp_profile_event.h"
#include "eqp_profiler_node.h"
@ -13,11 +15,24 @@
#define _eqpn(x) EQP::CPU::ST::Event eqp_comb(eq_perf_event_, __LINE__) (__PRETTY_FUNCTION__, x);
#define _eqp_clear() EQP::CPU::ST::GetProfiler().Clear()
#define _eqp_dump(strm, count) EQP::CPU::ST::GetProfiler().Dump(strm, count)
#define _eqp_dump_file(name) char time_str[128]; \
time_t result = time(nullptr); \
strftime(time_str, sizeof(time_str), "%Y_%m_%d_%H:%M:%S", localtime(&result)); \
std::string prof_name = "./profile/"; \
prof_name += name; \
prof_name += "_"; \
prof_name += time_str; \
prof_name += ".log"; \
std::ofstream profile_out(prof_name, std::ofstream::out); \
if(profile_out.good()) { \
_eqp_dump(profile_out, 10); \
}
#else
#define _eqp EQP::CPU::MT::Event eqp_comb(eq_perf_event_, __LINE__) (__PRETTY_FUNCTION__);
#define _eqpn(x) EQP::CPU::MT::Event eqp_comb(eq_perf_event_, __LINE__) (__PRETTY_FUNCTION__, x);
#define _eqp_clear() EQP::CPU::MT::GetProfiler().Clear()
#define _eqp_dump(strm, count) EQP::CPU::MT::GetProfiler().Dump(strm, count)
#define _eqp_dump_file()
#endif
namespace EQP

View File

@ -38,20 +38,7 @@ bool run_server = true;
void CatchSignal(int sig_num)
{
#ifdef EQPERF_ENABLED
char time_str[128];
time_t result = time(nullptr);
strftime(time_str, sizeof(time_str), "%Y_%m_%d__%H_%M_%S", localtime(&result));
std::string prof_name = "./profile/login_";
prof_name += time_str;
prof_name += ".log";
std::ofstream profile_out(prof_name, std::ofstream::out);
if(profile_out.good()) {
_eqp_dump(profile_out, 10);
}
#endif
_eqp_dump_file("loginserver");
}
int main()

View File

@ -47,20 +47,7 @@ void CatchSignal(int sig_num) {
if(worldserver)
worldserver->Disconnect();
#ifdef EQPERF_ENABLED
char time_str[128];
time_t result = time(nullptr);
strftime(time_str, sizeof(time_str), "%Y_%m_%d__%H_%M_%S", localtime(&result));
std::string prof_name = "./profile/queryserv_";
prof_name += time_str;
prof_name += ".log";
std::ofstream profile_out(prof_name, std::ofstream::out);
if(profile_out.good()) {
_eqp_dump(profile_out, 10);
}
#endif
_eqp_dump_file("queryserv");
}
int main() {

View File

@ -38,20 +38,7 @@ EQEmuLogSys Log;
void CatchSignal(int sig_num)
{
#ifdef EQPERF_ENABLED
char time_str[128];
time_t result = time(nullptr);
strftime(time_str, sizeof(time_str), "%Y_%m_%d__%H_%M_%S", localtime(&result));
std::string prof_name = "./profile/shared_memory_";
prof_name += time_str;
prof_name += ".log";
std::ofstream profile_out(prof_name, std::ofstream::out);
if(profile_out.good()) {
_eqp_dump(profile_out, 10);
}
#endif
_eqp_dump_file("shared_memory");
}
void OnExit() {

View File

@ -19,13 +19,13 @@
#include "../common/eqemu_logsys.h"
#include "../common/global_define.h"
#include "clientlist.h"
#include "../common/opcodemgr.h"
#include "../common/eq_stream_factory.h"
#include "../common/rulesys.h"
#include "../common/servertalk.h"
#include "../common/platform.h"
#include "../common/crash.h"
#include "clientlist.h"
#include "database.h"
#include "ucsconfig.h"
#include "chatchannel.h"
@ -56,20 +56,7 @@ void CatchSignal(int sig_num) {
if(worldserver)
worldserver->Disconnect();
#ifdef EQPERF_ENABLED
char time_str[128];
time_t result = time(nullptr);
strftime(time_str, sizeof(time_str), "%Y_%m_%d__%H_%M_%S", localtime(&result));
std::string prof_name = "./profile/ucs_";
prof_name += time_str;
prof_name += ".log";
std::ofstream profile_out(prof_name, std::ofstream::out);
if(profile_out.good()) {
_eqp_dump(profile_out, 10);
}
#endif
_eqp_dump_file("ucs");
}
std::string GetMailPrefix() {

View File

@ -21,9 +21,7 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include "../common/global_define.h"
#include "../common/eqemu_logsys.h"
#include "../common/queue.h"
@ -34,7 +32,6 @@
#include "../common/version.h"
#include "../common/eqtime.h"
#include "../common/timeoutmgr.h"
#include "../common/opcodemgr.h"
#include "../common/guilds.h"
#include "../common/eq_stream_ident.h"
@ -43,6 +40,7 @@
#include "../common/crash.h"
#include "client.h"
#include "worlddb.h"
#ifdef _WINDOWS
#include <process.h>
#define snprintf _snprintf
@ -147,6 +145,10 @@ int main(int argc, char** argv) {
Log.Out(Logs::General, Logs::World_Server, "Could not set signal handler");
return 1;
}
if (signal(SIGBREAK, CatchSignal) == SIG_ERR) {
Log.Out(Logs::General, Logs::World_Server, "Could not set signal handler");
return 1;
}
#ifndef WIN32
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
Log.Out(Logs::General, Logs::World_Server, "Could not set signal handler");
@ -511,6 +513,8 @@ void CatchSignal(int sig_num) {
if(zoneserver_list.worldclock.saveFile(WorldConfig::get()->EQTimeFile.c_str())==false)
Log.Out(Logs::General, Logs::World_Server,"Failed to save time file.");
RunLoops = false;
_eqp_dump_file("world");
}
void UpdateWindowTitle(char* iNewTitle) {