FARGOS/VISTA Object Management Environment Core  ..
FARGOS/VISTA Object Management Environment Core Table of Contents
OMEdebugInfo.h
Go to the documentation of this file.
1 #ifndef _OME_DEBUG_INFO_H
2 #define _OME_DEBUG_INFO_H "$Id: OMEdebugInfo.h 312 2020-03-21 21:25:35Z geoff $"
4 
11 
12 # include <OMEtype.h>
13 
18 # define OMEdebugMethodInvocations (2 << 0)
19 # define OMEdebugObjectCreate (2 << 1)
20 # define OMEdebugObjectDelete (2 << 2)
21 # define OMEdebugThreadDelete (2 << 3)
22 # define OMEdebugIncludeArguments (2 << 4)
23 # define OMEdebugEvents (2 << 5)
24 # define OMEdebugExceptions (2 << 6)
25 # define OMEdebugBlockedInvocations (2 << 7)
26 # define OMEdebugOIL2instructions (2 << 9)
27 # define OMEdebugBadParameter (2 << 10)
28 # define OMEdebugProfileCounters (2 << 11)
29 
30 
31 # define __OME_LOG_LEVEL_BASE 20
32 # define OMEdebugLogLevel0 (1 << (__OME_LOG_LEVEL_BASE + 0))
33 # define OMEdebugLogLevel1 (1 << (__OME_LOG_LEVEL_BASE + 1))
34 # define OMEdebugLogLevel2 (1 << (__OME_LOG_LEVEL_BASE + 2))
35 # define OMEdebugLogLevel3 (1 << (__OME_LOG_LEVEL_BASE + 3))
36 
37 // two aliases for everything...
38 # define OMEdebugEverything (~0)
39 # define OMEdebugAlways (~0)
40 # define OMEdebugNever (0)
41 
42 
43 extern OME_DLL_EXPORT int OMEsetDebugFlag(const char *flagName,
44  bool setFlag = 1) NONNULL_PARAMETERS(1);
45 
46 extern OME_DLL_EXPORT void OMEinitDebugFlag(const char *paramLine = nullptr);
47 
48 
52 protected:
54 
56 
57 
58  static void addToList(OMEprofileRecord *rec) {
59  rec->next = startOfList;
60  startOfList = rec;
61  }
62 
63  static void removeFromList(OMEprofileRecord *recToRemove) {
64  if (startOfList == recToRemove) {
65  startOfList = recToRemove->next; // fast path...
66  } else {
67  OMEprofileRecord *last = nullptr;
68  OMEprofileRecord *rec = startOfList;
69  while (rec != nullptr) {
70  if (rec == recToRemove) {
71  break;
72  }
73  last = rec;
74  rec = rec->next;
75  }
76  if (last == nullptr) {
77  startOfList = rec->next;
78  } else {
79  last->next = rec->next;
80  }
81  }
82  }
83 
84 
85 public:
87  next = nullptr;
88  }
89 
90  virtual ~OMEprofileRecord() {
91  removeFromList(this);
92  }
93 
94  virtual const char *getName(uint_fast32_t *retNameLen=nullptr) const = 0;
95 
96  virtual const OMEtype getValue() const = 0;
97 
98  virtual void setValue(const OMEtype &newV) = 0;
99 
100  static OMEarray *listDefinedCounters();
101 
102  static OMEassoc *getCounters();
103 
104  static const OMEtype getValueOfCounter(const char *name) NONNULL_PARAMETERS(1);
105 
108  template <typename STREAMTYPE> static STREAMTYPE &outputCounters(STREAMTYPE &o)
109  {
110  if (startOfList == nullptr) {
111  o << "No FARGOS/VISTA OME counters are defined.\n";
112  return (o);
113  }
114 
115  o << "Counter\t\t\t\tValue\n";
116 
117  for (OMEprofileRecord *rec = startOfList; rec != nullptr; rec = rec->next) {
118  uint_fast32_t s_len;
119  const char *cp = rec->getName(&s_len);
120  // NOTE: l must be a signed integer
121  int_fast32_t l = static_cast<int_fast32_t>(s_len);
122 
123  o << cp;
124  l = (4 * 8) - l; // 8 spaces/tab
125  do {
126  o << "\t";
127  l -= 8;
128  }
129  while (l > 0);
130  o << rec->getValue() << "\n";
131  }
132  return (o);
133  }
134 };
135 
136 
145 template <typename NUMTYPE>
147 {
148 public:
149 
150 
159  explicit OMEprofileCounter(const char *varName, NUMTYPE initVal=0,
161  SMV_StandaloneNumeric<NUMTYPE>(varName, mgr, initVal)
162  {
163  addToList(this);
164  }
165 
174  explicit OMEprofileCounter(const char *varName,
175  SharedMemoryVariableNode *parentNode, NUMTYPE initVal=0) NONNULL_CLASS_PARAMETERS(2) :
176  SMV_StandaloneNumeric<NUMTYPE>(varName, parentNode, initVal)
177  {
178  addToList(this);
179  }
180 
181  virtual ~OMEprofileCounter() {}
182 
183  virtual const char *getName(uint_fast32_t *retNameLen=nullptr) const override {
184  const char *result = SMV_StandaloneNumeric<NUMTYPE>::getName(retNameLen);
185  return (result);
186  }
187 
189  static_cast<SMV_StandaloneNumeric<NUMTYPE> &>(*this) = v;
190  return (*this);
191  }
192 
193  virtual const OMEtype getValue() const override
194  {
195  OMEtype result;
196  result = static_cast<const NUMTYPE>(*this);
197  return (result);
198  }
199 
200  virtual void setValue(const OMEtype &newV) override
201  {
202  static_cast<SMV_StandaloneNumeric<NUMTYPE> &>(*this) = static_cast<const NUMTYPE>(newV);
203  }
204 
208  virtual void incValue(NUMTYPE amt=1)
209  {
210  *this += amt;
211  }
212 
213  // virtual OMEprofileCounter &operator++(); // prefix ++
214 
215 
216 
217 }; // end class OMEprofileCounter<NUMTYPE>
218 
221 template <size_t MAXLEN>
223  public OMEprofileRecord,
224  public SMV_StandaloneString<MAXLEN>
225 {
226 public:
235  explicit OMEprofileString(const char *varName, const char *initVal, SharedMemoryVariableManager *mgr=&DEFAULT_sharedMemoryVariableManager) :
236  SMV_StandaloneString<MAXLEN>(varName, mgr)
237  {
238  if (initVal != nullptr) {
239  static_cast<SMV_StandaloneString<MAXLEN> &>(*this) = initVal;
240  }
241  addToList(this);
242  }
243 
252  explicit OMEprofileString(const char *varName, SharedMemoryVariableNode *parentNode,
253  const char *initVal=nullptr) :
254  SMV_StandaloneString<MAXLEN>(varName, parentNode)
255  {
256  if (initVal != nullptr) {
257  static_cast<SMV_StandaloneString<MAXLEN> &>(*this) = initVal;
258  }
259  addToList(this);
260  }
261 
262  virtual ~OMEprofileString() {}
263 
264  virtual const char *getName(uint_fast32_t *retNameLen=nullptr) const override {
265  const char *result = SMV_StandaloneString<MAXLEN>::getName(retNameLen);
266  return (result);
267  }
268 
269  virtual const OMEtype getValue() const override
270  {
271  OMEtype result;
272  result = static_cast<const char *>(*this);
273  return (result);
274  }
275 
277  static_cast<SMV_StandaloneString<MAXLEN> &>(*this) = v;
278  return (*this);
279  }
280 
281  virtual void setValue(const OMEtype &newV) override
282  {
283  static_cast<SMV_StandaloneString<MAXLEN> &>(*this) = static_cast<const char *>(newV);
284  }
285 
286 }; // end class OMEprofileString<MAXLEN>
287 
288 
290 
291 extern "C" OME_DLL_EXPORT void OMEnoteModuleComment(const char *commentText);
292 
293 extern "C" OME_DLL_EXPORT int32_t OMEshutdownRequested();
294 
300 
311 
312 # define OME_DEBUG_LEVEL_FLAG(l) (2 << (OME_LOG_LEVEL_BASE + l))
313 
314 # define NOTE_DEFAULT_NLM(s) __defaultMess = s
315 
316 //# define __CREATE_NLM __nlmRec = new OMEnlm(__defaultMess, &param, &__messID, &__catName, &paramInfo)
317 
318 # define DEFINE_NLM_MESSAGE(Lvl, MessID, AppName) \
319  if (((Lvl) == ~0) || ((Lvl) &OMEdebugFlag)) { \
320  OMEtype __messID, __nlmMessage; \
321  OMEarray param, paramInfo; \
322  OMEstring __defaultMess, __catName; \
323  uint32_t _paramSub = 0; \
324  __messID = MessID; \
325  __catName = AppName
326 
327 # define AND_OUTPUT_NLM(o, t) \
328  OMEnlm __nlmRec(__defaultMess, &param, &__messID, &__catName, &paramInfo); \
329  o << __nlmRec << t; \
330  }
331 
332 # define AND_ASSIGN_INTO(v) \
333  OMEnlm __nlmRec(__defaultMess, &param, &__messID, &__catName, &paramInfo); \
334  v = __nlmRec; \
335  }
336 
337 # define NEXT_NLM_PARAM param[_paramSub++]
338 
342 #endif
343 /* vim: set expandtab shiftwidth=4 tabstop=4: */
SharedMemoryVariable::getName
const char * getName(uint_fast32_t *retNameLen=nullptr) const OME_ALWAYS_INLINE
Get variable name.
Definition: shared_variable.hpp:135
OMEdebugLogLevel1
#define OMEdebugLogLevel1
Definition: OMEdebugInfo.h:33
l
Ïúíþ ð Ø ˜ ˜ __text __TEXT € __apple_names __DWARF __apple_objc __DWARF __apple_namespac__DWARF H X __apple_types __DWARF l
Definition: tmp3.o.cpp:1
OMEdebugThreadDelete
#define OMEdebugThreadDelete
Definition: OMEdebugInfo.h:21
OMEprofileCounter
Base class for application profiling counters or numerical system information.
Definition: OMEdebugInfo.h:146
OMEreleaseVersion
OME_DLL_EXPORT OMEprofileCounter< uint32_t > OMEreleaseVersion
Specifies FARGOS/VISTA Version release number.
s
const char s[]
Definition: t.cpp:4
OMEdebugFlag
SMV_StandaloneNumeric< uint32_t > OMEdebugFlag("debugFlag")
SIGINT
#define SIGINT
Definition: tmp.o.cpp:525
OMEprofileRecord::~OMEprofileRecord
virtual ~OMEprofileRecord()
Definition: OMEdebugInfo.h:90
LOG_COMPONENT_COUT
#define LOG_COMPONENT_COUT(component, lvl)
Convenience macro that uses LOG_COMPONENT_INTO to conditionally log a message to standard output.
Definition: logging_api.hpp:3022
SIGTERM
#define SIGTERM
Definition: tmp.o.cpp:536
OMEprofileString::OMEprofileString
OMEprofileString(const char *varName, SharedMemoryVariableNode *parentNode, const char *initVal=nullptr)
Initialize a string with a constant value.
Definition: OMEdebugInfo.h:252
dump_malloc_blocks
void dump_malloc_blocks(int age, int resetDumpTime)
Definition: test_malloc.c:199
OMEdebugObjectDelete
#define OMEdebugObjectDelete
Definition: OMEdebugInfo.h:20
OMEprofileString::OMEprofileString
OMEprofileString(const char *varName, const char *initVal, SharedMemoryVariableManager *mgr=&DEFAULT_sharedMemoryVariableManager)
Initialize a profiling string, possibly with an initial value.
Definition: OMEdebugInfo.h:235
OMEsetDebugFlag
int OMEsetDebugFlag(const char *flagName, bool setFlag)
Set or clear named debug flag.
Definition: OMEdebugInfo.cpp:117
SMV_StandaloneNumeric< uint32_t >
OMEassoc
Implements associative array of OMEtype elements.
Definition: OMEassoc.h:112
SIGPIPE
#define SIGPIPE
Definition: tmp.o.cpp:529
OMEprofileRecord::next
OMEprofileRecord * next
Definition: OMEdebugInfo.h:55
OMEstring
Implements text and binary string storage.
Definition: OMEstring.h:305
OMEprofileCounter::~OMEprofileCounter
virtual ~OMEprofileCounter()
Definition: OMEdebugInfo.h:181
SIGUSR1
#define SIGUSR1
Definition: tmp.o.cpp:542
OMEprofileRecord::outputCounters
static STREAMTYPE & outputCounters(STREAMTYPE &o)
Write a counter's value to an output stream.
Definition: OMEdebugInfo.h:108
OMEtype::value
union OMEtype::@26 value
OMEtype
Fundamental ANY type for FARGOS/VISTA Object Management Environment.
Definition: OMEbaseType.h:250
OMEprofileRecord::getValueOfCounter
static const OMEtype getValueOfCounter(const char *name) NONNULL_PARAMETERS(1)
Return the value of an named variable.
Definition: OMEdebugInfo.cpp:355
SharedMemoryVariableNode
Intermediate naming node for supporting variable naming hierarchies.
Definition: shared_variable.hpp:318
OMEprofileCounter::getValue
virtual const OMEtype getValue() const override
Retrieve the variable's value.
Definition: OMEdebugInfo.h:193
OMEdebugExceptions
#define OMEdebugExceptions
Definition: OMEdebugInfo.h:24
OMEshutdownRequested
int32_t OMEshutdownRequested()
Returns indication if the shutdown of the FARGOS/VISTA-based component has been requested.
Definition: OMEdebugInfo.cpp:68
OMEprofileRecord::listDefinedCounters
static OMEarray * listDefinedCounters()
Get a list of all available information variables.
Definition: OMEdebugInfo.cpp:321
OMEdebugMethodInvocations
#define OMEdebugMethodInvocations
Definition: OMEdebugInfo.h:18
OMEtype::s
class OMEstring * s
Definition: OMEbaseType.h:299
NONNULL_CLASS_PARAMETERS
#define NONNULL_CLASS_PARAMETERS(...)
Mark a function as never returning a null pointer.
Definition: compiler_hints.h:337
OMEdebugProfileCounters
#define OMEdebugProfileCounters
Definition: OMEdebugInfo.h:28
NONNULL_PARAMETERS
#define NONNULL_PARAMETERS(...)
Mark parameters to a function as not permitting null pointers.
Definition: compiler_hints.h:335
SMV_StandaloneString< 128 >
OMEinitDebugFlag
void OMEinitDebugFlag(const char *param)
Set initial default flags, then parse a line of debugging options and set/clear specified flags.
Definition: OMEdebugInfo.cpp:268
OMEadminProcessLabel
SMV_StandaloneString< 128 > OMEadminProcessLabel("adminProcessLabel")
OMEdebugOIL2instructions
#define OMEdebugOIL2instructions
Definition: OMEdebugInfo.h:26
OMEprofileString
Base type for system information represented as strings.
Definition: OMEdebugInfo.h:222
OMEprofileString::setValue
virtual void setValue(const OMEtype &newV) override
Definition: OMEdebugInfo.h:281
OMEstopReason
SMV_StandaloneString< 128 > OMEstopReason("stopReason")
OMEprofileString::getName
virtual const char * getName(uint_fast32_t *retNameLen=nullptr) const override
Definition: OMEdebugInfo.h:264
srcID
const char srcID[]
Definition: catSym.c:17
OME_STRING
@ OME_STRING
Definition: OMEmanifests.h:85
SIGUSR2
#define SIGUSR2
Definition: tmp.o.cpp:543
OMEdebugLogLevel3
#define OMEdebugLogLevel3
Definition: OMEdebugInfo.h:35
OMEprofileCounter::incValue
virtual void incValue(NUMTYPE amt=1)
A convenience function to increment a counter.
Definition: OMEdebugInfo.h:208
OMEdebugIncludeArguments
#define OMEdebugIncludeArguments
Definition: OMEdebugInfo.h:22
DEFAULT_sharedMemoryVariableManager
SharedMemoryVariableManager DEFAULT_sharedMemoryVariableManager
Default shared memory variable manager.
OMEprofileString::operator=
OMEprofileString< MAXLEN > & operator=(const char *v)
Definition: OMEdebugInfo.h:276
OMEvistaCPU
OME_DLL_EXPORT OMEprofileString< 32 > OMEvistaCPU
Specifies name of the underlying CPU architecture.
stringToArrayOfTokens
OME_FAST_CALL int stringToArrayOfTokens(OMEtype &result, const OMEstring &source, const char *delimeterList=nullptr, const int convertFlag=0)
Tokenizes a string and saves the parsed tokens as individual elements of an array.
Definition: utils.cpp:139
OMEprofileCounter::OMEprofileCounter
OMEprofileCounter(const char *varName, SharedMemoryVariableNode *parentNode, NUMTYPE initVal=0) NONNULL_CLASS_PARAMETERS(2)
Initialize a counter with a constant value.
Definition: OMEdebugInfo.h:174
OMEminorVersion
OME_DLL_EXPORT OMEprofileCounter< uint32_t > OMEminorVersion
Specifies FARGOS/VISTA Version minor number.
OMEdebugObjectCreate
#define OMEdebugObjectCreate
Definition: OMEdebugInfo.h:19
SIG_DFL
#define SIG_DFL
Definition: tmp.o.cpp:551
app
LogMaskType_t COMPONENT_LOG_MASK() app("app_logMask", &DEFAULT_sharedMemoryVariableManager, COMPONENT_LEVEL(app, defaultMask))
OMEtype.h
OME fundamental type implementation.
OMEprofileRecord
Base class for OME profiling variable.
Definition: OMEdebugInfo.h:51
OMEstopFlag
SMV_StandaloneNumeric< uint32_t > OMEstopFlag("stopFlag")
External flag used to trigger stop of a FARGOS/VISTA Object Management Environment.
shared_variable.hpp
FARGOS Shared Memory Variable routines.
OME_USED
const char srcID[] OME_USED
Definition: tick_time.cpp:24
flags
int flags
Definition: ethers.c:41
OMEprofileRecord::OMEprofileRecord
OMEprofileRecord()
Definition: OMEdebugInfo.h:86
OMEvistaOS
OME_DLL_EXPORT OMEprofileString< 32 > OMEvistaOS
Specifies name of underlying native operating system.
SharedMemoryVariableManager
Manager for collection of shared memory variables.
Definition: shared_variable.hpp:193
OMEprofileString::getValue
virtual const OMEtype getValue() const override
Definition: OMEdebugInfo.h:269
OMEprofileCounter::setValue
virtual void setValue(const OMEtype &newV) override
Set the variable's value.
Definition: OMEdebugInfo.h:200
MAX_MODULE_COMMENTS
#define MAX_MODULE_COMMENTS
Definition: OMEdebugInfo.cpp:33
LOG_COMPONENT_CERR
#define LOG_COMPONENT_CERR(component, lvl)
Convenience macro that uses LOG_COMPONENT_INTO to conditionally log a message to standard error.
Definition: logging_api.hpp:3030
OMEprofileRecord::removeFromList
static void removeFromList(OMEprofileRecord *recToRemove)
Definition: OMEdebugInfo.h:63
OMEdebugEvents
#define OMEdebugEvents
Definition: OMEdebugInfo.h:23
OMEdebugInfo.h
OME debug and profiling interfaces.
SMV_StandaloneNumeric::getAddress
NUMTYPE * getAddress() const OME_ALWAYS_INLINE
Get address of shared memory variable.
Definition: shared_variable.hpp:490
OME_DLL_EXPORT
#define OME_DLL_EXPORT
Definition: compiler_hints.h:464
trace_malloc
int trace_malloc
Definition: test_malloc.c:66
OMEarray
Implements sparse array of OMEtype elements.
Definition: OMEarray.h:75
OMEprofileCounter::OMEprofileCounter
OMEprofileCounter(const char *varName, NUMTYPE initVal=0, SharedMemoryVariableManager *mgr=&DEFAULT_sharedMemoryVariableManager) NONNULL_CLASS_PARAMETERS(2)
Initialize a counter with a potentially external source.
Definition: OMEdebugInfo.h:159
LOG_ENDLINE
#define LOG_ENDLINE
Closing clause for text line output using << operators.
Definition: logging_api.hpp:2956
OMEprofileCounter::getName
virtual const char * getName(uint_fast32_t *retNameLen=nullptr) const override
Return name of statistics variable.
Definition: OMEdebugInfo.h:183
OMEdisplayModuleComments
void OMEdisplayModuleComments()
Convenience function to display module comments on standard error.
Definition: OMEdebugInfo.cpp:83
OMEprofileRecord::addToList
static void addToList(OMEprofileRecord *rec)
Definition: OMEdebugInfo.h:58
OMEprofileCounter::operator=
OMEprofileCounter< NUMTYPE > & operator=(const NUMTYPE v)
Definition: OMEdebugInfo.h:188
OMEprofileRecord::startOfList
static OMEprofileRecord * startOfList
Definition: OMEdebugInfo.h:53
OMEdebugLogLevel2
#define OMEdebugLogLevel2
Definition: OMEdebugInfo.h:34
OMEnoteModuleComment
void OMEnoteModuleComment(const char *commentText)
Note a comment module which can be display on demand.
Definition: OMEdebugInfo.cpp:50
OMEadminStopReason
SMV_StandaloneString< 128 > OMEadminStopReason("adminStopReason")
OMEprofileString::~OMEprofileString
virtual ~OMEprofileString()
Definition: OMEdebugInfo.h:262
OMEmajorVersion
OME_DLL_EXPORT OMEprofileCounter< uint32_t > OMEmajorVersion
Specifies FARGOS/VISTA Version major number.
SA_SIGINFO
#define SA_SIGINFO
Definition: tmp.o.cpp:494
OMEdebugBlockedInvocations
#define OMEdebugBlockedInvocations
Definition: OMEdebugInfo.h:25
set_malloc_dump_time
void set_malloc_dump_time(unsigned long t, int blockSizeLimit)
Definition: test_malloc.c:266
OMEdebugEverything
#define OMEdebugEverything
Definition: OMEdebugInfo.h:38
SIG_IGN
#define SIG_IGN
Definition: tmp.o.cpp:554
OMEprofileRecord::getCounters
static OMEassoc * getCounters()
Get a snapshot of all counters.
Definition: OMEdebugInfo.cpp:337
logging_api.hpp
FARGOS Logging API.
Generated: Tue Jul 28 2020 16:03:25
Support Information