Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around gdb bug by changing a template parameter: #4332

Merged
merged 1 commit into from
Dec 14, 2022
Merged
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
2 changes: 1 addition & 1 deletion src/ripple/protocol/SField.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Some fields have a different meaning for their
class STAccount;
class STAmount;
class STBlob;
template <std::size_t>
template <int>
class STBitString;
template <class>
class STInteger;
Expand Down
34 changes: 20 additions & 14 deletions src/ripple/protocol/STBitString.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@

namespace ripple {

template <std::size_t Bits>
// 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 <int Bits>
intelliot marked this conversation as resolved.
Show resolved Hide resolved
class STBitString final : public STBase
{
static_assert(Bits > 0, "Number of bits must be positive");

public:
using value_type = base_uint<Bits>;

Expand Down Expand Up @@ -79,36 +85,36 @@ using STUInt128 = STBitString<128>;
using STUInt160 = STBitString<160>;
using STUInt256 = STBitString<256>;

template <std::size_t Bits>
template <int Bits>
inline STBitString<Bits>::STBitString(SField const& n) : STBase(n)
{
}

template <std::size_t Bits>
template <int Bits>
inline STBitString<Bits>::STBitString(const value_type& v) : value_(v)
{
}

template <std::size_t Bits>
template <int Bits>
inline STBitString<Bits>::STBitString(SField const& n, const value_type& v)
: STBase(n), value_(v)
{
}

template <std::size_t Bits>
template <int Bits>
inline STBitString<Bits>::STBitString(SerialIter& sit, SField const& name)
: STBitString(name, sit.getBitString<Bits>())
{
}

template <std::size_t Bits>
template <int Bits>
STBase*
STBitString<Bits>::copy(std::size_t n, void* buf) const
{
return emplace(n, buf, *this);
}

template <std::size_t Bits>
template <int Bits>
STBase*
STBitString<Bits>::move(std::size_t n, void* buf)
{
Expand Down Expand Up @@ -136,22 +142,22 @@ STUInt256::getSType() const
return STI_UINT256;
}

template <std::size_t Bits>
template <int Bits>
std::string
STBitString<Bits>::getText() const
{
return to_string(value_);
}

template <std::size_t Bits>
template <int Bits>
bool
STBitString<Bits>::isEquivalent(const STBase& t) const
{
const STBitString* v = dynamic_cast<const STBitString*>(&t);
return v && (value_ == v->value_);
}

template <std::size_t Bits>
template <int Bits>
void
STBitString<Bits>::add(Serializer& s) const
{
Expand All @@ -160,28 +166,28 @@ STBitString<Bits>::add(Serializer& s) const
s.addBitString<Bits>(value_);
}

template <std::size_t Bits>
template <int Bits>
template <typename Tag>
void
STBitString<Bits>::setValue(base_uint<Bits, Tag> const& v)
{
value_ = v;
}

template <std::size_t Bits>
template <int Bits>
typename STBitString<Bits>::value_type const&
STBitString<Bits>::value() const
{
return value_;
}

template <std::size_t Bits>
template <int Bits>
STBitString<Bits>::operator value_type() const
{
return value_;
}

template <std::size_t Bits>
template <int Bits>
bool
STBitString<Bits>::isDefault() const
{
Expand Down