Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/FileChangeDetector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class FileChangeDetector
~FileChangeDetector()
{
_isThreadRunning = false;
_eventThread.join();
if(_eventThread.joinable())
_eventThread.join();
}

private:
Expand Down
11 changes: 1 addition & 10 deletions src/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

Logger::Logger(std::string module_name) :
_moduleName(std::move(module_name)),
_logFilePath(LogConfig::Get()->GetGlobalConfig().LogsRootFolder + _moduleName + ".log"),
_logCounter(0)
_logFilePath(LogConfig::Get()->GetGlobalConfig().LogsRootFolder + _moduleName + ".log")
{
//create possibly non-existing folders before opening log file
utils::EnsureFolders(_logFilePath);
Expand All @@ -31,11 +30,6 @@ Logger::~Logger()
{
LogConfig::Get()->UnsubscribeLogger(this);
LogRotationManager::Get()->UnregisterLogFile(_logFilePath);

// wait until all log messages are processed, as we have this logger
// referenced in the action lambda and deleting it would be bad
while (_logCounter != 0)
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}

bool Logger::Log(LogLevel level, std::string msg,
Expand All @@ -57,11 +51,8 @@ bool Logger::Log(LogLevel level, std::string msg,
auto const &level_config = LogConfig::Get()->GetLogLevelConfig(level);
if (_config.PrintToConsole || level_config.PrintToConsole)
PrintLogString(time_str, level, log_msg);

--_logCounter;
});

++_logCounter;
return true;
}

Expand Down
1 change: 0 additions & 1 deletion src/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class Logger : public samplog::ILogger
private:
std::string const _moduleName;
std::string const _logFilePath;
std::atomic<unsigned int> _logCounter;

Config _config;
};
42 changes: 24 additions & 18 deletions src/amx/amxdbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,27 @@ int AMXAPI dbg_LoadInfo(AMX_DBG *amxdbg, FILE *fp)
amx_Align32((uint32_t*)&amxdbg->linetbl[index].line);
} /* for */
#endif
ptr += dbghdr.lines * sizeof(AMX_DBG_LINE);

/* detect dbghdr.lines overflow */
while ((line = (AMX_DBG_LINE *)ptr)
&& (cell)line->address > (cell)(line - 1)->address) {
dbghdr.lines = -1;
#if BYTE_ORDER==BIG_ENDIAN
for (index = 0; index <= dbghdr.lines; index++) {
amx_AlignCell(&linetbl[index].address);
amx_Align32((uint32_t*)&linetbl[index].line);
line++;
} /* for */
#endif
ptr += ((uint32_t)dbghdr.lines + 1) * sizeof(AMX_DBG_LINE);
} /* while */
unsigned int biggest_possible_size = (
sizeof(AMX_DBG_HDR)
+ dbghdr.files * (sizeof(AMX_DBG_FILE) + 33)
+ dbghdr.lines * sizeof(AMX_DBG_LINE)
+ dbghdr.symbols * (sizeof(AMX_DBG_SYMBOL) + 33)
+ dbghdr.tags * (sizeof(AMX_DBG_TAG) + 33)
+ dbghdr.automatons * (sizeof(AMX_DBG_MACHINE) + 33)
+ dbghdr.states * (sizeof(AMX_DBG_STATE) + 33)
);
unsigned int lines_overflow_count = 0;

while(biggest_possible_size < dbghdr.size) {
biggest_possible_size += 0x10000 * sizeof(AMX_DBG_LINE);
++lines_overflow_count;
}

ptr += (
dbghdr.lines * sizeof(AMX_DBG_LINE)
+ lines_overflow_count * 0x10000 * sizeof(AMX_DBG_LINE)
);

/* symbol table (plus index tags) */
for (index = 0; index < dbghdr.symbols; index++) {
Expand Down Expand Up @@ -242,7 +248,7 @@ int AMXAPI dbg_LookupFile(AMX_DBG *amxdbg, ucell address, const char **filename)
return AMX_ERR_NONE;
}

int AMXAPI dbg_LookupLine(AMX_DBG *amxdbg, ucell address, int *line)
int AMXAPI dbg_LookupLine(AMX_DBG *amxdbg, ucell address, long *line)
{
int index;

Expand All @@ -256,7 +262,7 @@ int AMXAPI dbg_LookupLine(AMX_DBG *amxdbg, ucell address, int *line)
if (--index < 0)
return AMX_ERR_NOTFOUND;

*line = amxdbg->linetbl[index].line;
*line = (long)amxdbg->linetbl[index].line;
return AMX_ERR_NONE;
}

Expand All @@ -271,14 +277,14 @@ int AMXAPI dbg_LookupFunction(AMX_DBG *amxdbg, ucell address, const char **funcn
assert(amxdbg != NULL);
assert(funcname != NULL);
*funcname = NULL;
for (index = amxdbg->hdr->symbols - 1; index >= 0; index--) {
for (index = 0; index < amxdbg->hdr->symbols; index++) {
if (amxdbg->symboltbl[index]->ident == iFUNCTN
&& amxdbg->symboltbl[index]->codestart <= address
&& amxdbg->symboltbl[index]->codeend > address) {
break;
}
} /* for */
if (index < 0)
if (index >= amxdbg->hdr->symbols)
return AMX_ERR_NOTFOUND;

*funcname = amxdbg->symboltbl[index]->name;
Expand Down
2 changes: 1 addition & 1 deletion src/amx/amxdbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ int AMXAPI dbg_LoadInfo(AMX_DBG *amxdbg, FILE *fp);

int AMXAPI dbg_LookupFile(AMX_DBG *amxdbg, ucell address, const char **filename);
int AMXAPI dbg_LookupFunction(AMX_DBG *amxdbg, ucell address, const char **funcname);
int AMXAPI dbg_LookupLine(AMX_DBG *amxdbg, ucell address, int *line);
int AMXAPI dbg_LookupLine(AMX_DBG *amxdbg, ucell address, long *line);

int AMXAPI dbg_GetFunctionAddress(AMX_DBG *amxdbg, const char *funcname, const char *filename, ucell *address);
int AMXAPI dbg_GetLineAddress(AMX_DBG *amxdbg, long line, const char *filename, ucell *address);
Expand Down
5 changes: 1 addition & 4 deletions src/crashhandler_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ namespace
{
//only one signal will be allowed past this point
if (!IsFirstSignal())
{
while (true)
std::this_thread::sleep_for(std::chrono::seconds(1));
}
return;

const std::string err_msg = fmt::format(
"caught signal {:d} ({:s}) (errno: {}, signal code: {}, exit status: {})",
Expand Down