All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
StatusCode.cpp
Go to the documentation of this file.
1 #define GAUDIKERNEL_STATUSCODE_CPP 1
2 
4 #include "GaudiKernel/System.h"
11 #include <fstream>
12 #include <iostream>
13 #include <sstream>
14 #include <stdlib.h>
15 #include <exception>
16 
17 bool StatusCode::s_checking(false);
18 
20  s_checking = true;
21 }
22 
24  s_checking = false;
25 }
26 
28  return s_checking;
29 }
30 
32  static IssueSeverity dummy;
33  if (m_severity) return *m_severity;
34  else return dummy;
35 }
36 
38 
39  if (!m_checked && !GaudiException::s_proc && !std::uncaught_exception() ) {
40 
42 
43  SmartIF<IStatusCodeSvc> scs(Gaudi::svcLocator()->service("StatusCodeSvc"));
44 
45  const size_t depth = 21;
46  void* addresses[depth];
47 
48  std::string lib, fnc;
49  void* addr = 0;
51  if (System::backTrace(addresses, depth)) {
52 
53  for(size_t idx: {2, 3})
54  if (System::getStackLevel(addresses[idx], addr, fnc, lib) &&
55  fnc != "StatusCode::~StatusCode()") {
56 
57  if (scs) {
58  scs->regFnc(fnc, lib);
59  } else {
60  MsgStream log(msg, "StatusCode");
61  log << MSG::WARNING << "Unchecked in " << fnc
62  << " (" << lib << ")" << endmsg;
63  }
64  break;
65  }
66 
67  }
68  }
69 }
GAUDI_API const IssueSeverity & severity() const
Severity.
Definition: StatusCode.cpp:31
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
void check()
Definition: StatusCode.cpp:37
GAUDI_API bool getStackLevel(void *addresses, void *&addr, std::string &fnc, std::string &lib)
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:178
SeverityPtr m_severity
Pointer to a IssueSeverity.
Definition: StatusCode.h:188
static bool s_proc
"previous" element in the linked list
static GAUDI_API void enableChecking()
Definition: StatusCode.cpp:19
static GAUDI_API bool checkingEnabled()
Definition: StatusCode.cpp:27
GAUDI_API int backTrace(void **addresses, const int depth)
GAUDI_API ISvcLocator * svcLocator()
static bool s_checking
Global flag to control if StatusCode need to be checked.
Definition: StatusCode.h:190
static GAUDI_API void disableChecking()
Definition: StatusCode.cpp:23
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244