Add Antithesis intrumentation (#5042)

* Copy Antithesis SDK version 0.4.0 to directory external/
* Add build option `voidstar` to enable instrumentation with Antithesis SDK
* Define instrumentation macros ASSERT and UNREACHABLE in terms of regular C assert
* Replace asserts with named ASSERT or UNREACHABLE
* Add UNREACHABLE to LogicError
* Document instrumentation macros in CONTRIBUTING.md
This commit is contained in:
Bronek Kozicki
2024-12-03 14:52:21 -05:00
committed by Ed Hennis
parent f64cf9187a
commit d7e949193f
261 changed files with 3827 additions and 1034 deletions

View File

@@ -21,9 +21,9 @@
#include <xrpl/basics/ResolverAsio.h>
#include <xrpl/beast/net/IPAddressConversion.h>
#include <xrpl/beast/net/IPEndpoint.h>
#include <xrpl/beast/utility/instrumentation.h>
#include <boost/asio.hpp>
#include <atomic>
#include <cassert>
#include <condition_variable>
#include <deque>
#include <locale>
@@ -48,7 +48,9 @@ public:
~AsyncObject()
{
// Destroying the object with I/O pending? Not a clean exit!
assert(m_pending.load() == 0);
ASSERT(
m_pending.load() == 0,
"ripple::AsyncObject::~AsyncObject : nothing pending");
}
/** RAII container that maintains the count of pending I/O.
@@ -153,8 +155,11 @@ public:
~ResolverAsioImpl() override
{
assert(m_work.empty());
assert(m_stopped);
ASSERT(
m_work.empty(),
"ripple::ResolverAsioImpl::~ResolverAsioImpl : no pending work");
ASSERT(
m_stopped, "ripple::ResolverAsioImpl::~ResolverAsioImpl : stopped");
}
//-------------------------------------------------------------------------
@@ -176,8 +181,10 @@ public:
void
start() override
{
assert(m_stopped == true);
assert(m_stop_called == false);
ASSERT(m_stopped == true, "ripple::ResolverAsioImpl::start : stopped");
ASSERT(
m_stop_called == false,
"ripple::ResolverAsioImpl::start : not stopping");
if (m_stopped.exchange(false) == true)
{
@@ -217,8 +224,12 @@ public:
resolve(std::vector<std::string> const& names, HandlerType const& handler)
override
{
assert(m_stop_called == false);
assert(!names.empty());
ASSERT(
m_stop_called == false,
"ripple::ResolverAsioImpl::resolve : not stopping");
ASSERT(
!names.empty(),
"ripple::ResolverAsioImpl::resolve : names non-empty");
// TODO NIKB use rvalue references to construct and move
// reducing cost.
@@ -235,7 +246,9 @@ public:
void
do_stop(CompletionCounter)
{
assert(m_stop_called == true);
ASSERT(
m_stop_called == true,
"ripple::ResolverAsioImpl::do_stop : stopping");
if (m_stopped.exchange(true) == false)
{
@@ -381,7 +394,9 @@ public:
HandlerType const& handler,
CompletionCounter)
{
assert(!names.empty());
ASSERT(
!names.empty(),
"ripple::ResolverAsioImpl::do_resolve : names non-empty");
if (m_stop_called == false)
{