F´ Flight Software - C/C++ Documentation
devel
A framework for building embedded system applications to NASA flight quality standards.
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
z
Functions
a
b
c
d
g
h
i
m
o
p
r
s
t
v
w
Variables
Typedefs
a
b
c
d
e
f
g
h
l
o
p
r
s
t
u
w
Enumerations
Enumerator
a
b
c
f
h
i
n
o
p
s
v
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Functions
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Variables
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
w
Typedefs
c
e
s
t
u
w
Enumerations
b
c
d
g
h
m
o
q
s
t
u
w
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Related Symbols
a
b
c
d
f
g
h
l
p
r
s
t
u
Files
File List
File Members
All
_
a
b
c
d
f
g
h
i
l
m
n
p
r
s
t
u
v
Functions
c
i
m
p
s
u
Variables
_
b
c
f
i
l
p
r
s
Typedefs
b
c
f
i
n
p
s
u
Enumerations
Enumerator
a
b
c
d
f
g
h
p
r
s
t
Macros
_
a
c
d
f
g
h
i
l
m
p
r
s
t
u
v
►
F´ Flight Software - C/C++ Documentation
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Loading...
Searching...
No Matches
Assert.hpp
Go to the documentation of this file.
1
#ifndef FW_ASSERT_HPP
2
#define FW_ASSERT_HPP
3
4
#include <
FpConfig.hpp
>
5
6
// Return only the first argument passed to the macro.
7
#define FW_ASSERT_FIRST_ARG(ARG_0, ...) ARG_0
8
// Return all the arguments of the macro, but the first one
9
#define FW_ASSERT_NO_FIRST_ARG(ARG_0, ...) __VA_ARGS__
10
11
#if FW_ASSERT_LEVEL == FW_NO_ASSERT
12
// Users may override the NO_ASSERT case should they choose
13
#ifndef FW_ASSERT
14
#define FW_ASSERT(...) ((void)(FW_ASSERT_FIRST_ARG(__VA_ARGS__)))
15
#endif
16
#define FILE_NAME_ARG const CHAR*
17
#else
// ASSERT is defined
18
19
20
// Passing the __LINE__ argument at the end of the function ensures that
21
// the FW_ASSERT_NO_FIRST_ARG macro will never have an empty variadic variable
22
#if FW_ASSERT_LEVEL == FW_FILEID_ASSERT
23
#define FILE_NAME_ARG U32
24
#define FW_ASSERT(...) \
25
((void) ((FW_ASSERT_FIRST_ARG(__VA_ARGS__, 0)) ? (0) : \
26
(Fw::SwAssert(ASSERT_FILE_ID, FW_ASSERT_NO_FIRST_ARG(__VA_ARGS__, __LINE__)))))
27
#elif FW_ASSERT_LEVEL == FW_RELATIVE_PATH_ASSERT
28
#define FILE_NAME_ARG const CHAR*
29
#define FW_ASSERT(...) \
30
((void) ((FW_ASSERT_FIRST_ARG(__VA_ARGS__, 0)) ? (0) : \
31
(Fw::SwAssert(ASSERT_RELATIVE_PATH, FW_ASSERT_NO_FIRST_ARG(__VA_ARGS__, __LINE__)))))
32
#else
33
#define FILE_NAME_ARG const CHAR*
34
#define FW_ASSERT(...) \
35
((void) ((FW_ASSERT_FIRST_ARG(__VA_ARGS__, 0)) ? (0) : \
36
(Fw::SwAssert(__FILE__, FW_ASSERT_NO_FIRST_ARG(__VA_ARGS__, __LINE__)))))
37
#endif
38
#endif
// if ASSERT is defined
39
40
// F' Assertion functions can technically return even though the intention is for the assertion to terminate the program.
41
// This breaks static analysis depending on assertions, since the analyzer has to assume the assertion will return.
42
// When supported, annotate assertion functions as noreturn when statically analyzing.
43
#ifndef CLANG_ANALYZER_NORETURN
44
#ifndef __has_feature
45
#define __has_feature(x) 0
// Compatibility with non-clang compilers.
46
#endif
47
#if __has_feature(attribute_analyzer_noreturn)
48
#define CLANG_ANALYZER_NORETURN __attribute__((analyzer_noreturn))
49
#else
50
#define CLANG_ANALYZER_NORETURN
51
#endif
52
#endif
53
54
namespace
Fw
{
56
NATIVE_INT_TYPE
SwAssert
(
57
FILE_NAME_ARG
file,
58
NATIVE_UINT_TYPE
lineNo)
CLANG_ANALYZER_NORETURN
;
59
61
NATIVE_INT_TYPE
SwAssert
(
62
FILE_NAME_ARG
file,
63
FwAssertArgType
arg1,
64
NATIVE_UINT_TYPE
lineNo)
CLANG_ANALYZER_NORETURN
;
65
67
NATIVE_INT_TYPE
SwAssert
(
68
FILE_NAME_ARG
file,
69
FwAssertArgType
arg1,
70
FwAssertArgType
arg2,
71
NATIVE_UINT_TYPE
lineNo)
CLANG_ANALYZER_NORETURN
;
72
74
NATIVE_INT_TYPE
SwAssert
(
75
FILE_NAME_ARG
file,
76
FwAssertArgType
arg1,
77
FwAssertArgType
arg2,
78
FwAssertArgType
arg3,
79
NATIVE_UINT_TYPE
lineNo)
CLANG_ANALYZER_NORETURN
;
80
82
NATIVE_INT_TYPE
SwAssert
(
83
FILE_NAME_ARG
file,
84
FwAssertArgType
arg1,
85
FwAssertArgType
arg2,
86
FwAssertArgType
arg3,
87
FwAssertArgType
arg4,
88
NATIVE_UINT_TYPE
lineNo)
CLANG_ANALYZER_NORETURN
;
89
91
NATIVE_INT_TYPE
SwAssert
(
92
FILE_NAME_ARG
file,
93
FwAssertArgType
arg1,
94
FwAssertArgType
arg2,
95
FwAssertArgType
arg3,
96
FwAssertArgType
arg4,
97
FwAssertArgType
arg5,
98
NATIVE_UINT_TYPE
lineNo)
CLANG_ANALYZER_NORETURN
;
99
101
NATIVE_INT_TYPE
SwAssert
(
102
FILE_NAME_ARG
file,
103
FwAssertArgType
arg1,
104
FwAssertArgType
arg2,
105
FwAssertArgType
arg3,
106
FwAssertArgType
arg4,
107
FwAssertArgType
arg5,
108
FwAssertArgType
arg6,
109
NATIVE_UINT_TYPE
lineNo)
CLANG_ANALYZER_NORETURN
;
110
}
111
112
// Base class for declaring an assert hook
113
// Each of the base class functions can be overridden
114
// or used by derived classes.
115
116
namespace
Fw
{
117
// Base class for declaring an assert hook
118
class
AssertHook
{
119
public
:
120
AssertHook
() : previousHook(nullptr) {};
121
virtual
~AssertHook
() {};
122
// override this function to intercept asserts
123
virtual
void
reportAssert
(
124
FILE_NAME_ARG
file,
125
NATIVE_UINT_TYPE
lineNo,
126
NATIVE_UINT_TYPE
numArgs,
127
FwAssertArgType
arg1,
128
FwAssertArgType
arg2,
129
FwAssertArgType
arg3,
130
FwAssertArgType
arg4,
131
FwAssertArgType
arg5,
132
FwAssertArgType
arg6
133
);
134
// default reportAssert() will call this when the message is built
135
// override it to do another kind of print. printf by default
136
virtual
void
printAssert
(
const
CHAR
* msg);
137
// do assert action. By default, calls assert.
138
// Called after reportAssert()
139
virtual
void
doAssert
();
140
// register the hook
141
void
registerHook
();
142
// deregister the hook
143
void
deregisterHook
();
144
145
protected
:
146
private
:
147
// the previous assert hook
148
AssertHook
*previousHook;
149
};
118
class
AssertHook
{
…
};
150
}
151
152
#endif
// FW_ASSERT_HPP
CLANG_ANALYZER_NORETURN
#define CLANG_ANALYZER_NORETURN
Definition
Assert.hpp:50
FILE_NAME_ARG
#define FILE_NAME_ARG
Definition
Assert.hpp:16
NATIVE_INT_TYPE
PlatformIntType NATIVE_INT_TYPE
Definition
BasicTypes.h:51
CHAR
char CHAR
Definition
BasicTypes.h:28
NATIVE_UINT_TYPE
PlatformUIntType NATIVE_UINT_TYPE
Definition
BasicTypes.h:52
FwAssertArgType
PlatformAssertArgType FwAssertArgType
Definition
FpConfig.h:21
FpConfig.hpp
C++-compatible configuration header for fprime configuration.
Fw::AssertHook
Definition
Assert.hpp:118
Fw::AssertHook::reportAssert
virtual void reportAssert(FILE_NAME_ARG file, NATIVE_UINT_TYPE lineNo, NATIVE_UINT_TYPE numArgs, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, FwAssertArgType arg4, FwAssertArgType arg5, FwAssertArgType arg6)
destructor
Definition
Assert.cpp:118
Fw::AssertHook::deregisterHook
void deregisterHook()
Definition
Assert.cpp:160
Fw::AssertHook::~AssertHook
virtual ~AssertHook()
constructor
Definition
Assert.hpp:121
Fw::AssertHook::doAssert
virtual void doAssert()
Definition
Assert.cpp:149
Fw::AssertHook::registerHook
void registerHook()
Definition
Assert.cpp:155
Fw::AssertHook::AssertHook
AssertHook()
Definition
Assert.hpp:120
Fw::AssertHook::printAssert
virtual void printAssert(const CHAR *msg)
Definition
Assert.cpp:113
Fw
Definition
FppConstantsAc.hpp:98
Fw::SwAssert
NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, NATIVE_UINT_TYPE lineNo)
Assert with no arguments.
Definition
Assert.cpp:197
Fw
Types
Assert.hpp
Generated by
1.10.0