debug.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
19 #include <gtsam/base/FastMap.h>
20 #include <gtsam/global_includes.h>
21 #include <string>
22 
23 
24 // This file defines granular debugging flags that may be switched on and off
25 // at run time. Typical usage is 'if(ISDEBUG("myFunction"))' to check if the
26 // 'myFunction' flag is enabled, and SETDEBUG("myFunction", true) to enable
27 // this flag, or SETDEBUG("myFunction", false) to disable it.
28 //
29 // Debug flags are created automatically as they are accessed, so they can be
30 // used immediately without explicitly creating them. Each flag defaults to
31 // 'false', i.e. disabled.
32 //
33 // For these macro to have any effect, granular debugging must be enabled by
34 // defining GTSAM_ENABLE_DEBUG. If NDEBUG is not defined, then
35 // GTSAM_ENABLE_DEBUG will be automatically defined and thus granular
36 // debugging enabled.
37 
38 #ifndef NDEBUG
39 #ifndef GTSAM_ENABLE_DEBUG
40 #define GTSAM_ENABLE_DEBUG
41 #endif
42 #endif
43 
44 namespace gtsam {
45  GTSAM_EXTERN_EXPORT FastMap<std::string, ValueWithDefault<bool,false> > debugFlags;
46 
47  // Non-guarded use led to crashes, and solved in commit cd35db2
48  bool GTSAM_EXPORT guardedIsDebug(const std::string& s);
49  void GTSAM_EXPORT guardedSetDebug(const std::string& s, const bool v);
50 
51  // function to check if compiled version has debug information
52  bool GTSAM_EXPORT isDebugVersion();
53 }
54 
55 #undef ISDEBUG
56 #undef SETDEBUG
57 
58 #ifdef GTSAM_ENABLE_DEBUG
59 
60 #define ISDEBUG(S) (gtsam::guardedIsDebug(S))
61 #define SETDEBUG(S,V) ((void)(gtsam::guardedSetDebug(S,V)))
62 
63 #else
64 
65 #define ISDEBUG(S) (false)
66 #define SETDEBUG(S,V) ((void)false)
67 
68 #endif
69 
void guardedSetDebug(const std::string &s, const bool v)
Definition: debug.cpp:43
Included from all GTSAM files.
Array< int, Dynamic, 1 > v
RealScalar s
traits
Definition: chartTesting.h:28
A thin wrapper around std::map that uses boost&#39;s fast_pool_allocator.
bool isDebugVersion()
Definition: debug.cpp:50
bool guardedIsDebug(const std::string &s)
Definition: debug.cpp:35
GTSAM_EXPORT FastMap< std::string, ValueWithDefault< bool, false > > debugFlags
Definition: debug.cpp:28


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:09