Skip to content

Commit 169585d

Browse files
committed
Disable stacktrace if not available
1 parent 3600dd8 commit 169585d

4 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/libserver/network/Server.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
#include <cassert>
2525
#include <ranges>
2626
#include <spdlog/spdlog.h>
27+
28+
#ifdef _GLIBCXX_HAVE_STACKTRACE
2729
#include <stacktrace>
30+
#endif
2831

2932
namespace server::network
3033
{

src/libserver/network/chatter/ChatterServer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
#include "libserver/util/Stream.hpp"
2222
#include "libserver/util/Util.hpp"
2323

24+
#ifdef _GLIBCXX_HAVE_STACKTRACE
2425
#include <stacktrace>
26+
#endif
2527

2628
#include <spdlog/spdlog.h>
2729

@@ -68,10 +70,12 @@ void ChatterServer::BeginHost(network::asio::ip::address_v4 address, uint16_t po
6870
{
6971
spdlog::error("Unhandled chatter server network exception: {}", x.what());
7072

73+
#ifdef _GLIBCXX_HAVE_STACKTRACE
7174
for (const auto& entry : std::stacktrace::current())
7275
{
7376
spdlog::error("[Stack] {}({}): {}", entry.source_file(), entry.source_line(), entry.description());
7477
}
78+
#endif
7579

7680
_server.End();
7781
}

src/libserver/network/command/CommandServer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
#include "libserver/util/Util.hpp"
2424

2525
#include <ranges>
26+
27+
#ifdef DISABLE_STACKTRACE
2628
#include <stacktrace>
29+
#endif
2730

2831
#include <spdlog/spdlog.h>
2932

@@ -134,10 +137,12 @@ void CommandServer::BeginHost(const asio::ip::address& address, uint16_t port)
134137
{
135138
spdlog::error("Unhandled command server network exception: {}", x.what());
136139

140+
#ifdef DISABLE_STACKTRACE
137141
for (const auto& entry : std::stacktrace::current())
138142
{
139143
spdlog::error("[Stack] {}({}): {}", entry.source_file(), entry.source_line(), entry.description());
140144
}
145+
#endif
141146

142147
_server.End();
143148
}

src/server/ServerInstance.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919

2020
#include "server/ServerInstance.hpp"
2121

22+
#ifdef _GLIBCXX_HAVE_STACKTRACE
2223
#include <stacktrace>
24+
#endif
2325

2426
namespace server
2527
{
@@ -28,10 +30,12 @@ namespace
2830
{
2931
void DumpStackTrace()
3032
{
33+
#ifdef _GLIBCXX_HAVE_STACKTRACE
3134
for (const auto& entry : std::stacktrace::current())
3235
{
3336
spdlog::error("[Stack] {}({}): {}", entry.source_file(), entry.source_line(), entry.description());
3437
}
38+
#endif
3539
}
3640

3741
} // anon namespace

0 commit comments

Comments
 (0)