Multiple improvements in debugging helpers

Add variadic style macro helpers that make debugging code disappear completely
  (also the paramethers evaluation) when debugging level is lower
Chained style << is now atomic like variadic style, still can't benefit
  of paramethers eveluation stripping
Reduced to minimum the difference between Android and other platform
  debugging code
Port debugging code to new helpers, expecially a few corner cases to
  test it, and as examples of how to use it.
This commit is contained in:
Gioacchino Mazzurco 2020-06-01 00:43:44 +02:00
parent 5f06651e54
commit aef87fb1f8
No known key found for this signature in database
GPG key ID: A1FBCA3872E87051
11 changed files with 365 additions and 205 deletions

View file

@ -507,25 +507,27 @@ private:
std::map<uint32_t,TokenRequestType> mActiveTokens;
#ifdef DEBUG_GXSIFACEHELPER
void locked_dumpTokens()
{
const uint16_t service_id = mGxs.serviceType();
const auto countSize = static_cast<size_t>(TokenRequestType::__MAX);
uint32_t count[countSize] = {0};
RsDbg() << __PRETTY_FUNCTION__ << "Service 0x" << std::hex << service_id
<< " (" << rsServiceControl->getServiceName(
RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(service_id) )
<< ") this=0x" << static_cast<void*>(this)
<< ") Active tokens (per type): ";
RsDbg rsdbg;
rsdbg << __PRETTY_FUNCTION__ << " Service 0x" << std::hex << service_id
<< " (" << rsServiceControl->getServiceName(
RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(service_id) )
<< ") this=0x" << static_cast<void*>(this)
<< ") Active tokens (per type): ";
// let's count how many token of each type we've got.
for(auto& it: mActiveTokens) ++count[static_cast<size_t>(it.second)];
for(uint32_t i=0; i < countSize; ++i)
RsDbg().uStream() /* << i << ":" */ << count[i] << " ";
RsDbg().uStream() << std::endl;
rsdbg /* << i << ":" */ << count[i] << " ";
}
#endif // def DEBUG_GXSIFACEHELPER
RS_SET_CONTEXT_DEBUG_LEVEL(1)
};