From acc1ecd2061646ad47af5a49b26604127b6a9b66 Mon Sep 17 00:00:00 2001 From: Scott Determan Date: Tue, 13 Dec 2022 19:13:54 -0500 Subject: [PATCH] Work around gdb bug by changing a template parameter: (#4332) There's a bug in gdb where unsigned template parameters cause issues with RTTI. This patch changes a template parameter from `size_t` to `int` to work around this gdb bug. --- src/ripple/protocol/SField.h | 2 +- src/ripple/protocol/STBitString.h | 34 ++++++++++++++++++------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/ripple/protocol/SField.h b/src/ripple/protocol/SField.h index f2663c9d36b..609eb55b1b6 100644 --- a/src/ripple/protocol/SField.h +++ b/src/ripple/protocol/SField.h @@ -45,7 +45,7 @@ class STAccount; class STAmount; class STIssue; class STBlob; -template +template class STBitString; template class STInteger; diff --git a/src/ripple/protocol/STBitString.h b/src/ripple/protocol/STBitString.h index 1819d54d1cf..45d1a3d6f05 100644 --- a/src/ripple/protocol/STBitString.h +++ b/src/ripple/protocol/STBitString.h @@ -25,9 +25,15 @@ namespace ripple { -template +// The template parameter could be an unsigned type, however there's a bug in +// gdb (last checked in gdb 12.1) that prevents gdb from finding the RTTI +// information of a template parameterized by an unsigned type. This RTTI +// information is needed to write gdb pretty printers. +template class STBitString final : public STBase { + static_assert(Bits > 0, "Number of bits must be positive"); + public: using value_type = base_uint; @@ -79,36 +85,36 @@ using STUInt128 = STBitString<128>; using STUInt160 = STBitString<160>; using STUInt256 = STBitString<256>; -template +template inline STBitString::STBitString(SField const& n) : STBase(n) { } -template +template inline STBitString::STBitString(const value_type& v) : value_(v) { } -template +template inline STBitString::STBitString(SField const& n, const value_type& v) : STBase(n), value_(v) { } -template +template inline STBitString::STBitString(SerialIter& sit, SField const& name) : STBitString(name, sit.getBitString()) { } -template +template STBase* STBitString::copy(std::size_t n, void* buf) const { return emplace(n, buf, *this); } -template +template STBase* STBitString::move(std::size_t n, void* buf) { @@ -136,14 +142,14 @@ STUInt256::getSType() const return STI_UINT256; } -template +template std::string STBitString::getText() const { return to_string(value_); } -template +template bool STBitString::isEquivalent(const STBase& t) const { @@ -151,7 +157,7 @@ STBitString::isEquivalent(const STBase& t) const return v && (value_ == v->value_); } -template +template void STBitString::add(Serializer& s) const { @@ -160,7 +166,7 @@ STBitString::add(Serializer& s) const s.addBitString(value_); } -template +template template void STBitString::setValue(base_uint const& v) @@ -168,20 +174,20 @@ STBitString::setValue(base_uint const& v) value_ = v; } -template +template typename STBitString::value_type const& STBitString::value() const { return value_; } -template +template STBitString::operator value_type() const { return value_; } -template +template bool STBitString::isDefault() const {