[Logging] Add stack trace in code paths that shouldn't occur (#2453)

* [Logging] Add stack trace in code paths that shouldn't occur

* Update zone_store.cpp

* Windows workaround
This commit is contained in:
Chris Miles 2022-09-28 13:32:39 -05:00 committed by GitHub
parent f8e7576ae7
commit f357361474
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 4496 additions and 5 deletions

View File

@ -650,6 +650,7 @@ SET(common_headers
patches/uf_limits.h
patches/uf_ops.h
patches/uf_structs.h
stacktrace/backward.hpp
StackWalker/StackWalker.h
util/memory_stream.h
util/directory.h

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,7 @@
#include "zone_store.h"
#include "../common/content/world_content_service.h"
#include "stacktrace/backward.hpp"
ZoneStore::ZoneStore() = default;
ZoneStore::~ZoneStore() = default;
@ -82,11 +83,21 @@ const char *ZoneStore::GetZoneName(uint32 zone_id, bool error_unknown)
}
LogInfo(
"[GetZoneName] Failed to get zone name by zone_id [{}] error_unknown [{}]",
"[GetZoneName] Failed to get zone name by zone_id [{}] error_unknown [{}] printing stack",
zone_id,
(error_unknown ? "true" : "false")
);
// print stack when invalid input
if (zone_id == 0) {
backward::StackTrace st;
backward::TraceResolver e = {};
st.load_here(32);
backward::Printer p;
p.print(st);
}
return nullptr;
}

View File

@ -1,3 +1,5 @@
#include "../../common/zone_store.h"
void WorldserverCLI::TestCommand(int argc, char **argv, argh::parser &cmd, std::string &description)
{
description = "Test command";
@ -6,4 +8,5 @@ void WorldserverCLI::TestCommand(int argc, char **argv, argh::parser &cmd, std::
return;
}
zone_store.GetZoneName(0, false);
}

View File

@ -94,7 +94,7 @@ ZoneServer::~ZoneServer() {
}
}
bool ZoneServer::SetZone(uint32 in_zone_id, uint32 in_instance_id, bool is_static_zone) {
bool ZoneServer::SetZone(uint32 in_zone_id, uint32 in_instance_id, bool in_is_static_zone) {
is_booting_up = false;
std::string zone_short_name = ZoneName(in_zone_id, true);
@ -114,7 +114,7 @@ bool ZoneServer::SetZone(uint32 in_zone_id, uint32 in_instance_id, bool is_stati
) :
""
),
is_static_zone ? " (Static)" : ""
in_is_static_zone ? " (Static)" : ""
);
}
@ -130,7 +130,7 @@ bool ZoneServer::SetZone(uint32 in_zone_id, uint32 in_instance_id, bool is_stati
LSSleepUpdate(GetPrevZoneID());
}
is_static_zone = is_static_zone;
is_static_zone = in_is_static_zone;
strn0cpy(zone_name, zone_short_name.c_str(), sizeof(zone_name));
strn0cpy(long_name, zone_long_name.c_str(), sizeof(long_name));

View File

@ -40,7 +40,7 @@ public:
void SendEmoteMessage(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message, ...);
void SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message);
void SendKeepAlive();
bool SetZone(uint32 in_zone_id, uint32 in_instance_id = 0, bool is_static_zone = false);
bool SetZone(uint32 in_zone_id, uint32 in_instance_id = 0, bool in_is_static_zone = false);
void TriggerBootup(uint32 in_zone_id = 0, uint32 in_instance_id = 0, const char* admin_name = 0, bool is_static_zone = false);
void Disconnect() { auto handle = tcpc->Handle(); if (handle) { handle->Disconnect(); } }
void IncomingClient(Client* client);