HDK
|
#include <debug.h>
Classes | |
struct | _Node |
struct | _Traits |
struct | Helper |
struct | ScopeHelper |
struct | TimedScopeHelper |
struct | TimedScopeHelper< false > |
Static Public Member Functions | |
template<class T > | |
static void | Enable (T val) |
template<class T > | |
static void | Disable (T val) |
Mark debugging as disabled for enum value val . More... | |
template<class T > | |
static void | EnableAll () |
template<class T > | |
static void | DisableAll () |
Mark debugging as disabled for all enum values of type T . More... | |
template<class T > | |
static bool | IsEnabled (T val) |
template<class T > | |
static bool | IsCompileTimeEnabled () |
template<class T > | |
static size_t | GetNumDebugCodes () |
static TF_API std::vector < std::string > | SetDebugSymbolsByName (const std::string &pattern, bool value) |
static TF_API bool | IsDebugSymbolNameEnabled (const std::string &name) |
True if the specified debug symbol is set. More... | |
static TF_API std::string | GetDebugSymbolDescriptions () |
static TF_API std::vector < std::string > | GetDebugSymbolNames () |
Get a listing of all debug symbols. More... | |
static TF_API std::string | GetDebugSymbolDescription (const std::string &name) |
static TF_API void | SetOutputFile (FILE *file) |
template<class T > | |
static void | _RegisterDebugSymbol (T enumVal, char const *name, char const *descrip) |
static TF_API void | _RegisterDebugSymbolImpl (_Node *addr, char const *enumName, char const *descrip) |
Friends | |
class | Tf_DebugSymbolRegistry |
Enum-based debugging messages.
The TfDebug
class encapsulates a simple enum-based conditional debugging message system. It is meant as a tool for developers, and NOT as a means of issuing diagnostic messages to end-users. (This is not strictly true. The TfDebug class is extremely useful and has many properties that make its use attractive for issuing messages to end-users. However, for this purpose, please use the TF_INFO
macro which more clearly indicates its intent.)
The features of TfDebug
are:
The use of the facility is simple:
The code in the header file declares the debug symbols to use. Under the hood, this creates an enum with the values given in the argument to TF_DEBUG_CODES, along with a first and last sentinel values and passes that to TF_DEBUG_RANGE.
If you need to obtain the enum type name, use decltype(SOME_ENUM_VALUE).
In the source file, the indicated debugging messages are printed only if the debugging symbols are enabled. Effectively, the construct
is translated to
The implications are that msgExpr
is only evaluated if symbol MY_E1
symbol is enabled.
To totally disable TF_DEBUG output for a set of codes at compile time, declare the codes using TF_CONDITIONALLY_COMPILE_TIME_ENABLED_DEBUG_CODES(condition, ...) where ... is all the debug codes. If 'condition' is false at compile time then all TF_DEBUG().Msg()s for these codes are elminated at compile time, so they have zero cost.
Most commonly debug symbols are inactive by default, but can be turned on either by an environment variable TF_DEBUG
, or interactively once a program has started.
Description strings may be associated with debug codes as follows:
|
static |
|
inlinestatic |
Mark debugging as enabled for enum value val
.
The default state for all debugging symbols is disabled. Note that the template parameter is deduced from val:
|
inlinestatic |
|
static |
Get a description for the specified debug symbol.
A short description of the debug symbol is returned. This is the same description string that is embedded in the return value of GetDebugSymbolDescriptions.
|
static |
Get a description of all debug symbols and their purpose.
A single string describing all registered debug symbols along with short descriptions is returned.
|
static |
Get a listing of all debug symbols.
|
inlinestatic |
|
inlinestatic |
|
static |
True if the specified debug symbol is set.
|
inlinestatic |
True if debugging is enabled for the enum value val
.
Note that not only must the specific enum value val
be marked as enabled, but the enum type T
must be globally enabled; this is controlled by the first argument to the TF_CONDITIONALLY_COMPILE_TIME_ENABLED_DEBUG_CODES()
macro.
|
static |
Set registered debug symbols matching pattern
to value
.
All registered debug symbols matching pattern
are set to value
. The only matching is an exact match with pattern
, or if pattern
ends with an '*' as is otherwise a prefix of a debug symbols. The names of all debug symbols set by this call are returned as a vector.
Direct debug output to either stdout or stderr.
Note that file MUST be either stdout or stderr. If not, issue an error and do nothing. Debug output is issued to stdout by default. If the environment variable TF_DEBUG_OUTPUT_FILE is set to 'stderr', then output is issued to stderr by default.