DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
wibmod
src
wibmod
WIB1
BUException
ExceptionBase.hh
Go to the documentation of this file.
1
#ifndef __EXCEPTIONBASE_HPP__
2
#define __EXCEPTIONBASE_HPP__ 1
3
4
#include <exception>
//for inheritance from std::exception
5
6
#include <string.h>
//for memcpy, strlen.
7
8
#include <string>
//std::string
9
10
#include <stdlib.h>
// for malloc
11
12
#include <stdio.h>
13
14
//For SYS_gettid()
15
//#define _GNU_SOURCE /* See feature_test_macros(7) */
16
#include <unistd.h>
17
#include <sys/syscall.h>
/* For SYS_xxx definitions */
18
19
//Backtrace code
20
#include <execinfo.h>
21
22
//abi demangling
23
#include <cxxabi.h>
24
25
namespace
BUException
{
26
27
//Macro for derived exception classes
28
#define ExceptionClassGenerator( ClassName , ClassDescription ) \
29
class ClassName : public BUException::exBase { \
30
public: \
31
ClassName() throw() {Init();} \
32
ClassName(const ClassName & rh) throw() : \
33
BUException::exBase(rh) {Init();Copy(rh);} \
34
ClassName & operator=(const ClassName & rh) throw() \
35
{Init();Copy(rh);return *this;} \
36
~ClassName() throw() {} \
37
const char * what() const throw() {return whatname;} \
38
private: \
39
void Init() \
40
{ \
41
strcpy(whatname,ClassDescription); \
42
} \
43
char whatname[sizeof(ClassDescription)]; \
44
};
45
46
47
class
exBase
:
public
std::exception {
48
public
:
49
//destructor
50
virtual
~exBase
()
throw
();
51
52
//Returns a stack trace of where the exception happened
53
const
char
*
StackTrace
()
const
throw
();
54
55
//Append info to the description message
56
void
Append
(
const
char
* buffer)
throw
();
57
void
Append
(std::string str){
Append
(str.c_str());};
58
const
char
*
Description
()
const
throw();
59
60
//Return the what string
61
virtual const
char
*
what
() const throw() = 0;
62
63
64
pid_t
GetPID
(){
return
PID
;};
65
66
protected
:
67
//Constructor is protected so only derived classes can call it
68
exBase
() throw() ;
69
//Copy function for base class internals (called by derived)
70
void
Copy
(const
exBase
& rh) throw();
71
exBase
(const
exBase
& rh) throw() {(void) rh;};
// have to cast to void to keep from unused param error
72
73
private
:
74
//assignment operator is private and not implemented
75
exBase
&
operator=
(
const
exBase
& rh)
throw
();
76
77
//Stack trace code
78
void
GenerateStackTrace
() throw();
79
void
AppendStackLine
(const
char
* line) throw();
//adds a eol char if possible
80
81
//Description internals
82
size_t
descriptionSize
;
83
size_t
descriptionUsed
;
84
char
*
descriptionBuffer
;
85
86
//Stack trace internals
87
size_t
stackSize
;
88
size_t
stackUsed
;
89
char
*
stackBuffer
;
90
91
pid_t
PID
;
92
};
93
}
94
95
96
97
98
#endif
BUException::exBase
Definition
ExceptionBase.hh:47
BUException::exBase::~exBase
virtual ~exBase()
Definition
ExceptionBase.cpp:41
BUException::exBase::stackBuffer
char * stackBuffer
Definition
ExceptionBase.hh:89
BUException::exBase::Append
void Append(const char *buffer)
Definition
ExceptionBase.cpp:94
BUException::exBase::AppendStackLine
void AppendStackLine(const char *line)
Definition
ExceptionBase_stacktrace.cpp:13
BUException::exBase::exBase
exBase()
Definition
ExceptionBase.cpp:6
BUException::exBase::stackSize
size_t stackSize
Definition
ExceptionBase.hh:87
BUException::exBase::StackTrace
const char * StackTrace() const
Definition
ExceptionBase_stacktrace.cpp:6
BUException::exBase::GenerateStackTrace
void GenerateStackTrace()
Definition
ExceptionBase_stacktrace.cpp:40
BUException::exBase::what
virtual const char * what() const =0
BUException::exBase::stackUsed
size_t stackUsed
Definition
ExceptionBase.hh:88
BUException::exBase::Description
const char * Description() const
Definition
ExceptionBase.cpp:120
BUException::exBase::Append
void Append(std::string str)
Definition
ExceptionBase.hh:57
BUException::exBase::descriptionUsed
size_t descriptionUsed
Definition
ExceptionBase.hh:83
BUException::exBase::GetPID
pid_t GetPID()
Definition
ExceptionBase.hh:64
BUException::exBase::PID
pid_t PID
Definition
ExceptionBase.hh:91
BUException::exBase::descriptionSize
size_t descriptionSize
Definition
ExceptionBase.hh:82
BUException::exBase::descriptionBuffer
char * descriptionBuffer
Definition
ExceptionBase.hh:84
BUException::exBase::operator=
exBase & operator=(const exBase &rh)
BUException::exBase::Copy
void Copy(const exBase &rh)
Definition
ExceptionBase.cpp:49
BUException
Definition
AddressTableException.hh:6
Generated on
for DUNE-DAQ by
1.17.0