All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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 const IssueSeverity dummy;
33  return m_severity ? *m_severity : dummy;
34 }
35 
37 
39 
40  auto msg = Gaudi::svcLocator()->as<IMessageSvc>();
41  auto scs = Gaudi::svcLocator()->service<IStatusCodeSvc>("StatusCodeSvc");
42 
43  const size_t depth = 21;
44  void* addresses[depth];
45 
46  std::string lib, fnc;
47  void* addr = nullptr;
49  if (System::backTrace(addresses, depth)) {
50 
51  for(size_t idx: {2, 3}) {
52  if (System::getStackLevel(addresses[idx], addr, fnc, lib) &&
53  fnc != "StatusCode::~StatusCode()") {
54 
55  if (scs) {
56  scs->regFnc(fnc, lib);
57  } else {
58  MsgStream log(msg, "StatusCode");
59  log << MSG::WARNING << "Unchecked in " << fnc
60  << " (" << lib << ")" << endmsg;
61  }
62  break;
63  }
64  }
65  }
66  }
67 }
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:36
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:177
static bool s_proc
"previous" element in the linked list
static GAUDI_API void enableChecking()
Definition: StatusCode.cpp:19
SmartIF< IFace > as()
Definition: ISvcLocator.h:106
static GAUDI_API bool checkingEnabled()
Definition: StatusCode.cpp:27
GAUDI_API int backTrace(void **addresses, const int depth)
STL class.
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
GAUDI_API ISvcLocator * svcLocator()
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:57
static bool s_checking
Global flag to control if StatusCode need to be checked.
Definition: StatusCode.h:180
T uncaught_exception(T...args)
static GAUDI_API void disableChecking()
Definition: StatusCode.cpp:23
std::shared_ptr< const IssueSeverity > m_severity
Pointer to a IssueSeverity.
Definition: StatusCode.h:178
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244