1
This commit is contained in:
parent
ecc44f822b
commit
d19d9daa8f
@ -145,6 +145,8 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
gameserver${GAME_ID}
|
gameserver${GAME_ID}
|
||||||
behaviac_gcc_debug
|
behaviac_gcc_debug
|
||||||
|
boost_stacktrace_backtrace
|
||||||
|
boost_stacktrace_addr2line
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
|
@ -92,6 +92,9 @@ public:
|
|||||||
int SearchPickupObj();
|
int SearchPickupObj();
|
||||||
bool PickupObjIsValid();
|
bool PickupObjIsValid();
|
||||||
void AbandonPickup(int min_time, int max_time);
|
void AbandonPickup(int min_time, int max_time);
|
||||||
|
bool HasThrowItem(int slot);
|
||||||
|
bool CanThrowItem(int slot);
|
||||||
|
bool ThrowItem(int slot);
|
||||||
|
|
||||||
behaviac::EBTStatus RegisterEvents(behaviac::vector<BtEvent_e> events);
|
behaviac::EBTStatus RegisterEvents(behaviac::vector<BtEvent_e> events);
|
||||||
behaviac::EBTStatus ClearEvents();
|
behaviac::EBTStatus ClearEvents();
|
||||||
|
@ -1,34 +1,23 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
|
|
||||||
#include <execinfo.h>
|
#include <iostream>
|
||||||
|
|
||||||
#include "tracemgr.h"
|
#include "tracemgr.h"
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
#if __GNUC__ > 4
|
#define BOOST_STACKTRACE_USE_ADDR2LINE
|
||||||
static void ErrorCallback(void *data, const char *msg, int errnum)
|
#include <boost/stacktrace.hpp>
|
||||||
{
|
|
||||||
A8_ABORT();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void TraceMgr::Init(const std::string& filename)
|
void TraceMgr::Init(const std::string& filename)
|
||||||
{
|
{
|
||||||
filename_ = filename;
|
filename_ = filename;
|
||||||
#if __GNUC__ > 4
|
|
||||||
state_ = backtrace_create_state(filename_.c_str(),
|
|
||||||
0,
|
|
||||||
ErrorCallback,
|
|
||||||
nullptr);
|
|
||||||
if (!state_) {
|
|
||||||
A8_ABORT();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
log_file_ = fopen("backtrace.log", "w");
|
log_file_ = fopen("backtrace.log", "w");
|
||||||
if (!log_file_) {
|
if (!log_file_) {
|
||||||
A8_ABORT();
|
A8_ABORT();
|
||||||
}
|
}
|
||||||
|
PrintBackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TraceMgr::UnInit()
|
void TraceMgr::UnInit()
|
||||||
@ -41,33 +30,11 @@ void TraceMgr::UnInit()
|
|||||||
|
|
||||||
void TraceMgr::Trace(const std::string& hint)
|
void TraceMgr::Trace(const std::string& hint)
|
||||||
{
|
{
|
||||||
#if __GNUC__ > 4
|
|
||||||
fputs(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n", log_file_);
|
|
||||||
fputs(hint.c_str(), log_file_);
|
|
||||||
backtrace_print(state_, 0, log_file_);
|
|
||||||
fputs("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", log_file_);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TraceMgr::GetBackTrace()
|
void TraceMgr::PrintBackTrace()
|
||||||
{
|
{
|
||||||
const int BT_BUF_SIZE = 1024 * 10;
|
std::cout << boost::stacktrace::stacktrace();
|
||||||
|
|
||||||
std::string data;
|
|
||||||
|
|
||||||
void *buffer[BT_BUF_SIZE];
|
|
||||||
char **strings = nullptr;
|
|
||||||
int nptrs = backtrace(buffer, BT_BUF_SIZE);
|
|
||||||
strings = backtrace_symbols(buffer, nptrs);
|
|
||||||
if (strings) {
|
|
||||||
for (int i = 0; i < nptrs; i++) {
|
|
||||||
data += strings[i];
|
|
||||||
data += "\n";
|
|
||||||
}
|
|
||||||
free(strings);
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,10 +4,6 @@
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
#if __GNUC__ > 4
|
|
||||||
#include <backtrace.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class TraceMgr : public a8::Singleton<TraceMgr>
|
class TraceMgr : public a8::Singleton<TraceMgr>
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -21,13 +17,10 @@ class TraceMgr : public a8::Singleton<TraceMgr>
|
|||||||
void UnInit();
|
void UnInit();
|
||||||
|
|
||||||
void Trace(const std::string& hint);
|
void Trace(const std::string& hint);
|
||||||
std::string GetBackTrace();
|
void PrintBackTrace();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string filename_;
|
std::string filename_;
|
||||||
#if __GNUC__ > 4
|
|
||||||
backtrace_state* state_ = nullptr;
|
|
||||||
#endif
|
|
||||||
FILE* log_file_ = nullptr;
|
FILE* log_file_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user