Replace various #ifdef RB_DEBUG with if constexpr for regression visibility.

This commit is contained in:
Jason Volk 2023-02-09 11:54:57 -08:00
parent 44acfb5deb
commit 762703698c
10 changed files with 132 additions and 125 deletions

View File

@ -92,9 +92,8 @@ __attribute__((always_inline, gnu_inline, artificial))
ircd::json::debug_valid_output(const string_view &in,
const size_t &expected)
{
#ifdef RB_DEBUG
valid_output(in, expected);
#endif
if constexpr(RB_DEBUG_LEVEL)
valid_output(in, expected);
}
constexpr ircd::json::name_hash_t

View File

@ -484,14 +484,17 @@ try
dock.notify_all();
}};
#ifdef RB_DEBUG
util::timer timer;
log::debug
util::timer timer
{
log, "%s enter",
loghead(*client),
RB_DEBUG_LEVEL
};
#endif
if constexpr(RB_DEBUG_LEVEL)
log::debug
{
log, "%s enter",
loghead(*client),
};
if(!client->main())
{
@ -499,15 +502,16 @@ try
return;
}
#ifdef RB_DEBUG
char buf[64];
log::debug
if constexpr(RB_DEBUG_LEVEL)
{
log, "%s leave %s",
loghead(*client),
pretty(buf, timer.at<microseconds>(), true)
};
#endif
char buf[64];
log::debug
{
log, "%s leave %s",
loghead(*client),
pretty(buf, timer.at<microseconds>(), true)
};
}
client->async();
}

View File

@ -4405,13 +4405,12 @@ ircd::db::throw_on_error::throw_on_error(const rocksdb::Status &status)
case Status::kNotFound:
throw not_found{};
#ifdef RB_DEBUG
//case Status::kCorruption:
case Status::kNotSupported:
case Status::kInvalidArgument:
debugtrap();
if constexpr(RB_DEBUG_LEVEL)
debugtrap();
[[fallthrough]];
#endif
[[unlikely]]
default:
@ -4556,9 +4555,10 @@ ircd::db::commit(database &d,
rocksdb::WriteBatch &batch,
const rocksdb::WriteOptions &opts)
{
#ifdef RB_DEBUG
ircd::timer timer;
#endif
ircd::timer timer
{
RB_DEBUG_LEVEL
};
const std::lock_guard lock{d.write_mutex};
const ctx::uninterruptible ui;
@ -4568,17 +4568,18 @@ ircd::db::commit(database &d,
d.d->Write(opts, &batch)
};
#ifdef RB_DEBUG
char dbuf[192];
log::debug
if constexpr(RB_DEBUG_LEVEL)
{
log, "[%s] %lu COMMIT %s in %ld$us",
d.name,
sequence(d),
debug(dbuf, batch),
timer.at<microseconds>().count()
};
#endif
char dbuf[192];
log::debug
{
log, "[%s] %lu COMMIT %s in %ld$us",
d.name,
sequence(d),
debug(dbuf, batch),
timer.at<microseconds>().count()
};
}
}
ircd::string_view

View File

@ -1042,9 +1042,8 @@ try
opts->stats_dump_period_sec = 0; // Disable noise
opts->statistics = this->stats;
#ifdef RB_DEBUG
opts->dump_malloc_stats = true;
#endif
if constexpr(RB_DEBUG_LEVEL)
opts->dump_malloc_stats = true;
// Disables the timer to delete unused files; this operation occurs
// instead with our compaction operations so we don't need to complicate.

View File

@ -273,17 +273,19 @@ ircd::fs::support::dump_info()
support
};
#ifdef RB_DEBUG
const unique_mutable_buffer buf
if constexpr(RB_DEBUG_LEVEL)
{
PATH_MAX_LEN + 1
};
const unique_mutable_buffer buf
{
PATH_MAX_LEN + 1
};
log::debug
{
log, "Current working directory: `%s'", cwd(buf)
};
#endif
log::debug
{
log, "Current working directory: `%s'",
cwd(buf)
};
}
}
bool

View File

@ -933,7 +933,6 @@ ircd::info::dump_sys_info()
fs::support::dump_info();
// Additional detected system parameters
//#ifdef RB_DEBUG
char buf[2][48];
log::logf
{
@ -948,7 +947,6 @@ ircd::info::dump_sys_info()
between(thp_enable, '[', ']'),
thp_size,
};
//#endif
}
#ifdef HAVE_SYS_UTSNAME_H

View File

@ -416,6 +416,7 @@ ircd_dl_signal_exception(int errcode,
//
#ifdef HAVE_DLFCN_H
#ifdef IRCD_MODS_HOOK_DLSYM
#define RB_DEBUG_MODS_HOOK_DLSYM 0
extern "C" void *
__libc_dlsym(void *, const char *);
@ -424,14 +425,13 @@ extern "C" void *
dlsym(void *const handle,
const char *const symbol)
{
#ifdef RB_DEBUG_MODS_HOOK_DLSYM
ircd::log::debug
{
ircd::mods::log, "handle:%p symbol lookup '%s'",
handle,
symbol
};
#endif
if constexpr(RB_DEBUG_MODS_HOOK_DLSYM)
ircd::log::debug
{
ircd::mods::log, "handle:%p symbol lookup '%s'",
handle,
symbol
};
return __libc_dlsym(handle, symbol);
}

View File

@ -2420,25 +2420,26 @@ noexcept try
if(timedout && ec == errc::operation_canceled)
ec = make_error_code(errc::timed_out);
#ifdef RB_DEBUG
const auto *const current_cipher
if constexpr(RB_DEBUG_LEVEL)
{
!ec?
openssl::current_cipher(*this):
nullptr
};
const auto *const current_cipher
{
!ec?
openssl::current_cipher(*this):
nullptr
};
char ecbuf[64];
log::debug
{
log, "%s handshake cipher:%s %s",
loghead(*this),
current_cipher?
openssl::name(*current_cipher):
"<NO CIPHER>"_sv,
string(ecbuf, ec)
};
#endif
char ecbuf[64];
log::debug
{
log, "%s handshake cipher:%s %s",
loghead(*this),
current_cipher?
openssl::name(*current_cipher):
"<NO CIPHER>"_sv,
string(ecbuf, ec)
};
}
// Toggles the behavior of non-async functions; see func comment
if(!ec)
@ -2608,16 +2609,17 @@ noexcept try
}
}
#ifdef RB_DEBUG
thread_local char buf[16_KiB];
const critical_assertion ca;
log::debug
if constexpr(RB_DEBUG_LEVEL)
{
log, "verify[%s] %s",
common_name(opts),
openssl::print_subject(buf, cert)
};
#endif
thread_local char buf[16_KiB];
const critical_assertion ca;
log::debug
{
log, "verify[%s] %s",
common_name(opts),
openssl::print_subject(buf, cert)
};
}
return true;
}

View File

@ -726,28 +726,29 @@ noexcept try
assert(it != end(handshaking));
assert(openssl::get_app_data(*sock) == sock.get());
#ifdef RB_DEBUG
const auto *const current_cipher
if constexpr(RB_DEBUG_LEVEL)
{
!ec?
openssl::current_cipher(*sock):
nullptr
};
const auto *const current_cipher
{
!ec?
openssl::current_cipher(*sock):
nullptr
};
char ecbuf[64];
log::debug
{
log, "%s %s handshook(%zd:%zu) cipher:%s %s",
loghead(*sock),
loghead(*this),
std::distance(cbegin(handshaking), it),
handshaking.size(),
current_cipher?
openssl::name(*current_cipher):
"<NO CIPHER>"_sv,
string(ecbuf, ec)
};
#endif
char ecbuf[64];
log::debug
{
log, "%s %s handshook(%zd:%zu) cipher:%s %s",
loghead(*sock),
loghead(*this),
std::distance(cbegin(handshaking), it),
handshaking.size(),
current_cipher?
openssl::name(*current_cipher):
"<NO CIPHER>"_sv,
string(ecbuf, ec)
};
}
handshaking.erase(it);
openssl::set_app_data(*sock, nullptr);

View File

@ -1361,32 +1361,33 @@ ircd::resource::response::response(client &client,
eptr = std::current_exception();
}
#ifdef RB_DEBUG
const log::level level
if constexpr(RB_DEBUG_LEVEL)
{
http::severity(http::category(code))
};
const log::level level
{
http::severity(http::category(code))
};
log::logf
{
log, level,
"%s HTTP %u `%s' %s in %s; %s content-length:%s head-length:%zu %s%s",
loghead(client),
uint(code),
client.request.head.path,
http::status(code),
rtime,
content_type,
ssize_t(content_length) >= 0?
lex_cast(content_length):
"chunked"_sv,
wrote_head,
eptr?
"error:"_sv:
string_view{},
what(eptr)
};
#endif
log::logf
{
log, level,
"%s HTTP %u `%s' %s in %s; %s content-length:%s head-length:%zu %s%s",
loghead(client),
uint(code),
client.request.head.path,
http::status(code),
rtime,
content_type,
ssize_t(content_length) >= 0?
lex_cast(content_length):
"chunked"_sv,
wrote_head,
eptr?
"error:"_sv:
string_view{},
what(eptr)
};
}
if(unlikely(eptr))
std::rethrow_exception(eptr);