mirror of
https://github.com/matrix-construct/construct
synced 2024-09-26 02:18:53 +02:00
ircd::vg: Add stack register/deregister to interface.
ircd::vg: Use extern const bool for active(); minor reorg.
This commit is contained in:
parent
8759f9d209
commit
f6bc11b76a
6 changed files with 38 additions and 9 deletions
|
@ -14,7 +14,7 @@
|
|||
/// Valgrind memcheck hypercall suite
|
||||
namespace ircd::vg
|
||||
{
|
||||
bool active() noexcept;
|
||||
extern const bool active;
|
||||
size_t errors() noexcept;
|
||||
|
||||
bool defined(const const_buffer &) noexcept;
|
||||
|
@ -22,3 +22,9 @@ namespace ircd::vg
|
|||
void set_undefined(const const_buffer &) noexcept;
|
||||
void set_noaccess(const const_buffer &) noexcept;
|
||||
}
|
||||
|
||||
namespace ircd::vg::stack
|
||||
{
|
||||
uint add(const mutable_buffer &) noexcept;
|
||||
void del(const uint &id) noexcept;
|
||||
}
|
||||
|
|
|
@ -121,10 +121,10 @@ libircd_la_LIBADD = \
|
|||
libircd_la_SOURCES =#
|
||||
libircd_la_SOURCES += assert.cc
|
||||
libircd_la_SOURCES += info.cc
|
||||
libircd_la_SOURCES += vg.cc
|
||||
libircd_la_SOURCES += allocator.cc
|
||||
libircd_la_SOURCES += allocator_gnu.cc
|
||||
libircd_la_SOURCES += allocator_je.cc
|
||||
libircd_la_SOURCES += vg.cc
|
||||
libircd_la_SOURCES += exception.cc
|
||||
libircd_la_SOURCES += util.cc
|
||||
libircd_la_SOURCES += demangle.cc
|
||||
|
|
|
@ -70,7 +70,7 @@ ircd::db::database::allocator::mlock_enabled
|
|||
mlock_limit == -1UL
|
||||
|
||||
// mlock2() not supported by valgrind
|
||||
&& !vg::active()
|
||||
&& !vg::active
|
||||
};
|
||||
|
||||
decltype(ircd::db::database::allocator::mlock_current)
|
||||
|
|
|
@ -283,8 +283,8 @@ ircd::info::dump_cpu_info_x86()
|
|||
hardware::virtualized?
|
||||
"virtual"_sv:
|
||||
"physical"_sv,
|
||||
vg::active()?
|
||||
" valgrind "_sv:
|
||||
vg::active?
|
||||
" valgrind"_sv:
|
||||
""_sv,
|
||||
support,
|
||||
};
|
||||
|
|
29
ircd/vg.cc
29
ircd/vg.cc
|
@ -61,15 +61,38 @@ noexcept
|
|||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::vg::active()
|
||||
noexcept
|
||||
decltype(ircd::vg::active)
|
||||
ircd::vg::active{[]() -> bool
|
||||
{
|
||||
#ifdef HAVE_VALGRIND_VALGRIND_H
|
||||
return RUNNING_ON_VALGRIND;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}()};
|
||||
|
||||
//
|
||||
// vg::stack
|
||||
//
|
||||
|
||||
void
|
||||
ircd::vg::stack::del(const uint &id)
|
||||
noexcept
|
||||
{
|
||||
#ifdef HAVE_VALGRIND_MEMCHECK_H
|
||||
VALGRIND_STACK_DEREGISTER(id);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint
|
||||
ircd::vg::stack::add(const mutable_buffer &buf)
|
||||
noexcept
|
||||
{
|
||||
#ifdef HAVE_VALGRIND_MEMCHECK_H
|
||||
return VALGRIND_STACK_REGISTER(ircd::data(buf) + ircd::size(buf), ircd::data(buf));
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1339,7 +1339,7 @@ console_cmd__mem__get(opt &out, const string_view &line)
|
|||
bool
|
||||
console_cmd__vg(opt &out, const string_view &line)
|
||||
{
|
||||
if(vg::active())
|
||||
if(vg::active)
|
||||
out << "running on valgrind" << std::endl;
|
||||
else
|
||||
out << "bare metal" << std::endl;
|
||||
|
|
Loading…
Reference in a new issue