Skip to content

[Debug] use a lambda to build up the log message

Florian Fischer requested to merge aj46ezos/emper:cleanup-debug3 into master

This hides the used std::stringstream from the context using the LOG macros. So we don't have to see the a huge messy std::stringstream object in gdb for example.

The use of a lambda is a ISO C++ alternative to GCC's statement expression.

This is hopefully the last MR dealing with our log system for now.

Why is this relevant

Normal debugoptimized build (log_level=Debug).
before:

(gdb) i locals
future = 0x7fffe8082be0
continuation = 0x7fffe400e940
completion = {first = 32, second = 0x7fffe8082be0}
cqe_data = 0x7fffe8082be0
tptr = {tptr = 140737086237664}
res = 32
tag = emper::io::PointerTags::Future
i = 0
__PRETTY_FUNCTION__ = "std::vector<Fiber*> emper::io::IoContext::reapCompletions() [with CallerEnvironment callerEnvironment = ANYWHERE]"
CQE_BATCH_COUNT = 16
maxRaceFreeCompleterAttempts = 1
reapedCompletions = {_M_elems = {{first = 32, second = 0x7fffe8082be0}, {first = 0,
      second = 0x0} <repeats 15 times>}}
continuationFibers = std::vector of length 0, capacity 1
cqes = {_M_elems = {0x7ffff7f341b0, 0x7ffff7f362f0, 0x7ffff7f362f0,
    0x7ffff7baac75 <malloc_consolidate+373>, 0x7fffe4000080, 0x7fffe4016, 0x0,
    0x55555556b9cc <std::__copy_move<false, true, std::random_access_iterator_tag>::__copy_m<Fiber**>(Fiber** const*, Fiber** const*, Fiber***)+74>, 0x0, 0x555555588ae8, 0x555555588b10, 0x555555588b08, 0x21,
    0x1, 0x7ffff79c9e00, 0x7ffff7bad3ac <_int_malloc+2732>}}
count = 1
globalCompleterAttempts = 0
sst =
    {<std::basic_iostream<char, std::char_traits<char> >> = {<std::basic_istream<char, std::char_traits<char> >> = {<std::basic_ios<char, std::char_traits<char> >> = <invalid address>,
      _vptr.basic_istream = <optimized out>,
      _M_gcount = <optimized out>}, <std::basic_ostream<char, std::char_traits<char> >> = {
      _vptr.basic_ostream = <optimized out>}, <No data fields>},
  _M_stringbuf = {<std::basic_streambuf<char, std::char_traits<char> >> = {
      _vptr.basic_streambuf = <optimized out>, _M_in_beg = <optimized out>,
      _M_in_cur = <optimized out>, _M_in_end = <optimized out>, _M_out_beg = <optimized out>,
      _M_out_cur = <optimized out>, _M_out_end = <optimized out>, _M_buf_locale = {static none = 0,
        static ctype = 1, static numeric = 2, static collate = 4, static time = 8,
        static monetary = 16, static messages = 32, static all = 63, _M_impl = <optimized out>,
        static _S_classic = 0x7ffff7f06ce0 <(anonymous namespace)::c_locale_impl>,
        static _S_global = 0x7ffff7f06ce0 <(anonymous namespace)::c_locale_impl>,
        static _S_categories = 0x7ffff7ef86c0 <__gnu_cxx::category_names>, static _S_once = 2,
        static _S_twinned_facets = {0x7ffff7f07718 <std::numpunct<char>::id>,
          0x7ffff7f075d8 <std::__cxx11::numpunct<char>::id>, 0x7ffff7f076e0 <std::collate<char>::id>,
          0x7ffff7f075c0 <std::__cxx11::collate<char>::id>,
          0x7ffff7f076f0 <std::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::id>,
          0x7ffff7f075d0 <std::__cxx11::time_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::id>,
          0x7ffff7f07728 <std::money_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::id>,
          0x7ffff7f075e8 <std::__cxx11::money_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::id>,
          0x7ffff7f07720 <std::money_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::id>,
          0x7ffff7f075e0 <std::__cxx11::money_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::id>, 0x7ffff7f07738 <std::moneypunct<char, false>::id>,
          0x7ffff7f075f8 <std::__cxx11::moneypunct<char, false>::id>,
          0x7ffff7f07730 <std::moneypunct<char, true>::id>,
          0x7ffff7f075f0 <std::__cxx11::moneypunct<char, true>::id>,
          0x7ffff7f076e8 <std::messages<char>::id>, 0x7ffff7f075c8 <std::__cxx11::messages<char>::id>,
          0x7ffff7f077d8 <std::numpunct<wchar_t>::id>,
--Type <RET> for more, q to quit, c to continue without paging--

after:

(gdb) i locals
future = 0x7fffe0082e80
continuation = 0x7fffe0082730
completion = {first = 32, second = 0x7fffe0082e80}
cqe_data = 0x7fffe0082e80
tptr = {tptr = 140736952020608}
res = 32
tag = emper::io::PointerTags::Future
i = 0
__PRETTY_FUNCTION__ = "std::vector<Fiber*> emper::io::IoContext::reapCompletions() [with CallerEnvironment callerEnvironment = EMPER]"
CQE_BATCH_COUNT = 16
maxRaceFreeCompleterAttempts = 1
reapedCompletions = {_M_elems = {{first = 32, second = 0x7fffe0082e80}, {first = 0, 
      second = 0x0} <repeats 15 times>}}
continuationFibers = std::vector of length 0, capacity 1
cqes = {_M_elems = {0x7ffff7f34280, 0x7fffe00827e0, 0x7fffe0082900, 0x7fffec001ed0, 0x0,
    0x7fffe00827df, 0x7fffe00827b0,
    0x7ffff7f9f9fc <std::pair<std::_Rb_tree_iterator<emper::io::Future*>, bool>::pair<std::_Rb_tree_iterator<emper::io::Future*>, bool, true>(std::_Rb_tree_iterator<emper::io::Future*>&&, bool&&)+54>,
    0x7fffe00015d0, 0x7fffe00827df, 0x7fffe00827e8, 0x7fffe0082800, 0x7fffe0082820,
    0x7ffff7f9f013 <std::_Rb_tree<emper::io::Future*, emper::io::Future*, std::_Identity<emper::io::Future*>, std::less<emper::io::Future*>, std::allocator<emper::io::Future*> >::_M_insert_unique<emper::io::Future* const&>(emper::io::Future* const&)+177>, 0x7fffe0082900, 0x7fffe0000ab8}}
count = 1
globalCompleterAttempts = 0

Merge request reports