Skip to content

Commit e2efd5d

Browse files
committed
Merge branch 'develop' into cspell-tests
2 parents ee08bd2 + 7c11835 commit e2efd5d

18 files changed

+1061
-239
lines changed

.github/workflows/reusable-build-test-config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
101101

102102
- name: Prepare runner
103-
uses: XRPLF/actions/prepare-runner@65da1c59e81965eeb257caa3587b9d45066fb925
103+
uses: XRPLF/actions/prepare-runner@121d1de2775d486d46140b9a91b32d5002c08153
104104
with:
105105
enable_ccache: ${{ inputs.ccache_enabled }}
106106

cmake/Ccache.cmake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ set(CMAKE_VS_GLOBALS
4646
"TrackFileAccess=false"
4747
"UseMultiToolTask=true")
4848

49-
# By default Visual Studio generators will use /Zi, which is not compatible with
50-
# ccache, so tell it to use /Z7 instead.
51-
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>")
49+
# By default Visual Studio generators will use /Zi to capture debug information,
50+
# which is not compatible with ccache, so tell it to use /Z7 instead.
51+
if (MSVC)
52+
foreach (var_
53+
CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
54+
CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE)
55+
string (REPLACE "/Zi" "/Z7" ${var_} "${${var_}}")
56+
endforeach ()
57+
endif ()

cmake/XrplCompiler.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ if (MSVC)
4444
# omit debug info completely under CI (not needed)
4545
if (is_ci)
4646
string (REPLACE "/Zi" " " ${var_} "${${var_}}")
47+
string (REPLACE "/Z7" " " ${var_} "${${var_}}")
4748
endif ()
4849
endforeach ()
4950

cmake/XrplSettings.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@ if(is_linux)
6868
option(perf "Enables flags that assist with perf recording" OFF)
6969
option(use_gold "enables detection of gold (binutils) linker" ON)
7070
option(use_mold "enables detection of mold (binutils) linker" ON)
71+
# Set a default value for the log flag based on the build type.
72+
# This provides a sensible default (on for debug, off for release)
73+
# while still allowing the user to override it for any build.
74+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
75+
set(TRUNCATED_LOGS_DEFAULT ON)
76+
else()
77+
set(TRUNCATED_LOGS_DEFAULT OFF)
78+
endif()
79+
option(TRUNCATED_THREAD_NAME_LOGS
80+
"Show warnings about truncated thread names on Linux."
81+
${TRUNCATED_LOGS_DEFAULT}
82+
)
83+
if(TRUNCATED_THREAD_NAME_LOGS)
84+
add_compile_definitions(TRUNCATED_THREAD_NAME_LOGS)
85+
endif()
7186
else()
7287
# we are not ready to allow shared-libs on windows because it would require
7388
# export declarations. On macos it's more feasible, but static openssl

cspell.config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ words:
5959
- Btrfs
6060
- canonicality
6161
- checkme
62+
- choco
6263
- chrono
6364
- citardauq
6465
- clawback

include/xrpl/beast/core/CurrentThreadName.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#ifndef BEAST_CORE_CURRENT_THREAD_NAME_H_INCLUDED
66
#define BEAST_CORE_CURRENT_THREAD_NAME_H_INCLUDED
77

8+
#include <boost/predef.h>
9+
810
#include <string>
911
#include <string_view>
1012

@@ -16,6 +18,31 @@ namespace beast {
1618
void
1719
setCurrentThreadName(std::string_view newThreadName);
1820

21+
#if BOOST_OS_LINUX
22+
23+
// On Linux, thread names are limited to 16 bytes including the null terminator.
24+
// Maximum number of characters is therefore 15.
25+
constexpr std::size_t maxThreadNameLength = 15;
26+
27+
/** Sets the name of the caller thread with compile-time size checking.
28+
@tparam N The size of the string literal including null terminator
29+
@param newThreadName A string literal to set as the thread name
30+
31+
This template overload enforces that thread names are at most 16 characters
32+
(including null terminator) at compile time, matching Linux's limit.
33+
*/
34+
template <std::size_t N>
35+
void
36+
setCurrentThreadName(char const (&newThreadName)[N])
37+
{
38+
static_assert(
39+
N <= maxThreadNameLength + 1,
40+
"Thread name cannot exceed 15 characters");
41+
42+
setCurrentThreadName(std::string_view(newThreadName, N - 1));
43+
}
44+
#endif
45+
1946
/** Returns the name of the caller thread.
2047
2148
The name returned is the name as set by a call to setCurrentThreadName().

src/libxrpl/beast/core/CurrentThreadName.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#include <xrpl/beast/core/CurrentThreadName.h>
22

3-
#include <boost/predef.h>
4-
53
#include <string>
64
#include <string_view>
75

@@ -73,12 +71,32 @@ setCurrentThreadNameImpl(std::string_view name)
7371
#if BOOST_OS_LINUX
7472
#include <pthread.h>
7573

74+
#include <iostream>
75+
7676
namespace beast::detail {
7777

7878
inline void
7979
setCurrentThreadNameImpl(std::string_view name)
8080
{
81-
pthread_setname_np(pthread_self(), name.data());
81+
// truncate and set the thread name.
82+
char boundedName[maxThreadNameLength + 1];
83+
std::snprintf(
84+
boundedName,
85+
sizeof(boundedName),
86+
"%.*s",
87+
static_cast<int>(maxThreadNameLength),
88+
name.data());
89+
90+
pthread_setname_np(pthread_self(), boundedName);
91+
92+
#ifdef TRUNCATED_THREAD_NAME_LOGS
93+
if (name.size() > maxThreadNameLength)
94+
{
95+
std::cerr << "WARNING: Thread name \"" << name << "\" (length "
96+
<< name.size() << ") exceeds maximum of "
97+
<< maxThreadNameLength << " characters on Linux.\n";
98+
}
99+
#endif
82100
}
83101

84102
} // namespace beast::detail

src/libxrpl/resource/ResourceManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class ManagerImp : public Manager
140140
void
141141
run()
142142
{
143-
beast::setCurrentThreadName("Resource::Manager");
143+
beast::setCurrentThreadName("Resource::Mngr");
144144
for (;;)
145145
{
146146
logic_.periodicActivity();

src/test/app/HashRouter_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ class HashRouter_test : public beast::unit_test::suite
349349
h.set("hold_time", "alice");
350350
h.set("relay_time", "bob");
351351
auto const setup = setup_HashRouter(cfg);
352-
// The set function ignores values that don't covert, so the
352+
// The set function ignores values that don't convert, so the
353353
// defaults are left unchanged
354354
BEAST_EXPECT(setup.holdTime == 300s);
355355
BEAST_EXPECT(setup.relayTime == 30s);

src/test/app/MPToken_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,7 +2651,7 @@ class MPToken_test : public beast::unit_test::suite
26512651
STAmount const amt3{asset3, 10'000};
26522652

26532653
{
2654-
testcase("Test STAmount MPT arithmetics");
2654+
testcase("Test STAmount MPT arithmetic");
26552655
using namespace std::string_literals;
26562656
STAmount res = multiply(amt1, amt2, asset3);
26572657
BEAST_EXPECT(res == amt3);
@@ -2688,7 +2688,7 @@ class MPToken_test : public beast::unit_test::suite
26882688
}
26892689

26902690
{
2691-
testcase("Test MPTAmount arithmetics");
2691+
testcase("Test MPTAmount arithmetic");
26922692
MPTAmount mptAmt1{100};
26932693
MPTAmount const mptAmt2{100};
26942694
BEAST_EXPECT((mptAmt1 += mptAmt2) == MPTAmount{200});

0 commit comments

Comments
 (0)