Skip to content
Commit 9179dcd2 authored by Oliver Kellogg's avatar Oliver Kellogg
Browse files

#4 Fix Debug enable/disable...

#4 Fix Debug enable/disable mechanism and convert uDebug / DEBUG usages to logDebug[0..5]

umbrello/debug/debug_utils.{h,cpp}
- Document restriction on where this file shall be #included (impl files
  only, not headers).
- In class Tracer:
  - At function registerClass change type of arguments `name' and
    `filePath' to const char *.
    For elaboration see comment at struct ClientInfo_POD in cpp file.
  - At members m_instance, m_classes, m_states change prefix from "m_"
    to "s_" to reflect their staticness.
  - Change members s_classes and s_states from pointer to value.

umbrello/debug/debug_utils.h
- Make #define DBG_SRC soft by preceding it with #ifndef DBG_SRC.
  This lets client classes choose the own names defining DBG_SRC prior
  to the #include "debug_utils.h".
  This #include shall only be placed in cpp files, not in header files.
- At #define DEBUG_N change the parameter name to latin1str to better
  express the intended usage.
- At #define IS_DEBUG_ENABLED remove parameter, it is no longer needed
  due to extended use of DBG_SRC.
- Remove #define DBG_REG_IMPL introduced in commit 86a322d6 and revert
  to defining DEBUG_REGISTER and DEBUG_REGISTER_DISABLED separately.
  Reason: When using a macro parameter for stringification the pre-
  processor does not perform prior substitutions on the actual
  parameter.
- In #define DEBUG_REGISTER and DEBUG_REGISTER_DISABLED constructor
  src##Tracer(), on calling Tracer::registerClass provide arguments #src
  and __FILE__ without QLatin1String conversions.

umbrello/debug/debug_utils.cpp
- New struct ClientInfo_POD carries information for MapType but uses C
  language plain old data (char pointers instead of QString). This is
  necessary due to usage in __static_initialization_and_destruction_0
  (see documentation at struct).
- New static g_clientInfo is an array of ClientInfo_POD dimensioned
  using #define MAX_TRACERCLIENTS.
- New static int n_clients counts up the active entries in g_clientInfo.
- In function Tracer::instance, if s_instance is null then transfer
  the content of g_clientInfo (C) to s_classes (C++).
- In function Tracer::isEnabled, if s_classes does not contain the
  given name then return true. For info see documentation in function.
- In function Tracer::registerClass fill g_clientInfo instead of
  s_classes.
  Reason: This function is called during static initialization.

umbrello/uml.h
- In macros logDebug0 to logDebug5 test
    Tracer::instance()->isEnabled(DBG_SRC)
  as precondition for calling UMLApp::app()->logDebug().

Some or all of the following changes in other cpp files:

- Add #define DBG_SRC prior to #include "debug_utils.h" in cpp files
  hosting non Q_OBJECT classes.
- Replace DEBUG_N(name) usages by DEBUG() when possible due to prior
  defined DBG_SRC.
- Add DEBUG_REGISTER calls.
- In lib/cppparser files replace custom debug source defines (such as
  DBG_DRV, DBG_LEXER) by standard DEBUG() (made possible due to added
  DBG_SRC).
- Replace uDebug() and selected DEBUG() stream usages by logDebug0 to
  logDebug5 macro calls from uml.h.
parent 4aaf3d9b
Pipeline #130746 passed with stage
in 14 minutes and 25 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment