0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-19 19:33:45 +02:00

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
if constexpr(RB_DEBUG_LEVEL)
valid_output(in, expected);
#endif
}
constexpr ircd::json::name_hash_t

View file

@ -484,14 +484,17 @@ try
dock.notify_all();
}};
#ifdef RB_DEBUG
util::timer timer;
util::timer timer
{
RB_DEBUG_LEVEL
};
if constexpr(RB_DEBUG_LEVEL)
log::debug
{
log, "%s enter",
loghead(*client),
};
#endif
if(!client->main())
{
@ -499,7 +502,8 @@ try
return;
}
#ifdef RB_DEBUG
if constexpr(RB_DEBUG_LEVEL)
{
char buf[64];
log::debug
{
@ -507,7 +511,7 @@ try
loghead(*client),
pretty(buf, timer.at<microseconds>(), true)
};
#endif
}
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:
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,7 +4568,8 @@ ircd::db::commit(database &d,
d.d->Write(opts, &batch)
};
#ifdef RB_DEBUG
if constexpr(RB_DEBUG_LEVEL)
{
char dbuf[192];
log::debug
{
@ -4578,7 +4579,7 @@ ircd::db::commit(database &d,
debug(dbuf, batch),
timer.at<microseconds>().count()
};
#endif
}
}
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
if constexpr(RB_DEBUG_LEVEL)
opts->dump_malloc_stats = true;
#endif
// 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,7 +273,8 @@ ircd::fs::support::dump_info()
support
};
#ifdef RB_DEBUG
if constexpr(RB_DEBUG_LEVEL)
{
const unique_mutable_buffer buf
{
PATH_MAX_LEN + 1
@ -281,9 +282,10 @@ ircd::fs::support::dump_info()
log::debug
{
log, "Current working directory: `%s'", cwd(buf)
log, "Current working directory: `%s'",
cwd(buf)
};
#endif
}
}
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
if constexpr(RB_DEBUG_MODS_HOOK_DLSYM)
ircd::log::debug
{
ircd::mods::log, "handle:%p symbol lookup '%s'",
handle,
symbol
};
#endif
return __libc_dlsym(handle, symbol);
}

View file

@ -2420,7 +2420,8 @@ noexcept try
if(timedout && ec == errc::operation_canceled)
ec = make_error_code(errc::timed_out);
#ifdef RB_DEBUG
if constexpr(RB_DEBUG_LEVEL)
{
const auto *const current_cipher
{
!ec?
@ -2438,7 +2439,7 @@ noexcept try
"<NO CIPHER>"_sv,
string(ecbuf, ec)
};
#endif
}
// Toggles the behavior of non-async functions; see func comment
if(!ec)
@ -2608,7 +2609,8 @@ noexcept try
}
}
#ifdef RB_DEBUG
if constexpr(RB_DEBUG_LEVEL)
{
thread_local char buf[16_KiB];
const critical_assertion ca;
log::debug
@ -2617,7 +2619,7 @@ noexcept try
common_name(opts),
openssl::print_subject(buf, cert)
};
#endif
}
return true;
}

View file

@ -726,7 +726,8 @@ noexcept try
assert(it != end(handshaking));
assert(openssl::get_app_data(*sock) == sock.get());
#ifdef RB_DEBUG
if constexpr(RB_DEBUG_LEVEL)
{
const auto *const current_cipher
{
!ec?
@ -747,7 +748,7 @@ noexcept try
"<NO CIPHER>"_sv,
string(ecbuf, ec)
};
#endif
}
handshaking.erase(it);
openssl::set_app_data(*sock, nullptr);

View file

@ -1361,7 +1361,8 @@ ircd::resource::response::response(client &client,
eptr = std::current_exception();
}
#ifdef RB_DEBUG
if constexpr(RB_DEBUG_LEVEL)
{
const log::level level
{
http::severity(http::category(code))
@ -1386,7 +1387,7 @@ ircd::resource::response::response(client &client,
string_view{},
what(eptr)
};
#endif
}
if(unlikely(eptr))
std::rethrow_exception(eptr);