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  static IssueSeverity dummy;
29  if (m_severity) return *m_severity;
30  else return dummy;
31 }
32 
34  if(UNLIKELY(s_checking)) {
35 
36  if (!m_checked && !GaudiException::s_proc && !std::uncaught_exception() ) {
37 
39 
40  SmartIF<IStatusCodeSvc> scs(Gaudi::svcLocator()->service("StatusCodeSvc"));
41 
42  const size_t depth = 21;
43  void* addresses[depth];
44 
45  std::string lib, fnc;
46  void* addr = 0;
48  if (System::backTrace(addresses, depth)) {
49 
50  if (System::getStackLevel(addresses[2], addr, fnc, lib)) {
51 
52  if (scs) {
53  scs->regFnc(fnc,lib);
54  } else {
55  if (msg) {
56  MsgStream log(msg,"StatusCode");
57  log << MSG::WARNING << "Unchecked in " << fnc << " " << lib << endmsg;
58  } else {
59  std::cout << MSG::WARNING << "Unchecked in " << fnc << " " << lib << std::endl;
60  }
61  }
62 
63  }
64 
65  }
66  }
67  }
68 }
69 
#define UNLIKELY(x)
Definition: Kernel.h:127
GAUDI_API const IssueSeverity & severity() const
Severity.
Definition: StatusCode.cpp:27
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
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:139
SeverityPtr m_severity
Pointer to a IssueSeverity.
Definition: StatusCode.h:149
static bool s_proc
"previous" element in the linked list
GAUDI_API ~StatusCode()
Destructor.
Definition: StatusCode.cpp:33
static GAUDI_API void enableChecking()
Definition: StatusCode.cpp:19
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:151
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