Skip to content
Open
Show file tree
Hide file tree
Changes from 198 commits
Commits
Show all changes
219 commits
Select commit Hold shift + click to select a range
c846586
creation of an object header that logs errors and warnings in a yaml …
amandinehry Apr 25, 2025
f1713fa
Set up ErrorHandling
amandinehry Apr 30, 2025
4e5250f
traits errors commented (to treat)
amandinehry Apr 30, 2025
94b775c
Set up test
amandinehry Apr 30, 2025
1cb8aa3
Modification to properly format the yaml so that it can be parsed if …
amandinehry Apr 30, 2025
9d5e16a
Test to add variadic arguments
amandinehry May 2, 2025
2f7660c
draft: retrieve data contexts info
amandinehry May 5, 2025
6036551
Added additional information in the yaml - not functional missing the…
amandinehry May 5, 2025
46b4904
First attempt at outputting exceptions
amandinehry May 7, 2025
e1aed93
Complete: code for outputting errors into yaml
amandinehry May 9, 2025
bc953be
Manage the text contained in the potential exception
amandinehry May 12, 2025
1a434bc
First attempt: Handling the text contained in the potential exception…
amandinehry May 14, 2025
acf4d99
Complete: yaml output for PVT tables error
amandinehry May 16, 2025
ee58884
YAML error message well formatted
amandinehry May 19, 2025
32a0237
Fix duplication error
amandinehry May 19, 2025
589270f
Add variadic parameters to GEOS_THROW_CTX_IF
amandinehry May 21, 2025
9b65581
Reorganization after operational tests
amandinehry May 21, 2025
b13f0a6
Apply the output error functionality in yaml to all geos errors
amandinehry May 21, 2025
6de2c6a
Latest update for exception handling (try/catch in main)
amandinehry May 27, 2025
5830aee
Add priority to the error message into the yaml file
amandinehry May 27, 2025
2b27c41
Update of the commit named "latest update for exception handling (try…
amandinehry May 27, 2025
86f793e
set priority
amandinehry May 27, 2025
8a8117e
errors cli modification: add --errors-output
amandinehry May 27, 2025
2c0f5aa
errors cli modification: add --errors-output
amandinehry May 27, 2025
eb2f691
Replace original macros
amandinehry May 27, 2025
7b5f293
Correction: replace original macros
amandinehry May 27, 2025
c07b502
Modification of the Optional function to accept arguments separated b…
amandinehry Jun 2, 2025
670ddfa
Reacting with the command line option -e / --errors-output
amandinehry Jun 2, 2025
d08a30f
Add the rank on which the error is catch for error and warning outputs
amandinehry Jun 3, 2025
5a6c1a0
Unit test to check if the contents of the yaml file match exactly wha…
amandinehry Jun 3, 2025
4928dcd
Add the "Exception" field into the message type enumeration
amandinehry Jun 4, 2025
02dcf50
Modify the macros corresponding to throw to allow the exception to be…
amandinehry Jun 4, 2025
59ac94d
Remove ASSERT dependency on LvArray
amandinehry Jun 4, 2025
835e444
Remove GEOS_THROW_(...) and GEOS_ERROR_(...) dependency on LvArray
amandinehry Jun 4, 2025
10a2627
Restore to its original state an input file that I used for my tests
amandinehry Jun 4, 2025
9bd9f30
Delete additionnal spaces
amandinehry Jun 4, 2025
c9fea30
Syntax fixes
amandinehry Jun 4, 2025
7fa2b74
Syntax fixes
amandinehry Jun 4, 2025
8a9ff29
xsd + revert comment
amandinehry Jun 4, 2025
c1e001e
xsd + check includes
amandinehry Jun 4, 2025
e31f17c
Merge remote-tracking branch 'upstream/develop' into feature/amandine…
amandinehry Jun 4, 2025
a0eefd2
Compilation error fix
amandinehry Jun 5, 2025
5caa099
Remove vscode config files
amandinehry Jun 5, 2025
7aee0c6
Remove empty comment lines and commented code
amandinehry Jun 10, 2025
80bb07b
Changes in macros names
amandinehry Jun 10, 2025
149789e
Change the loop syntax ito a for-each syntax to solve the issue of in…
amandinehry Jun 10, 2025
74de273
Add comments
amandinehry Jun 10, 2025
92e6854
Reorganization of declarations
amandinehry Jun 10, 2025
f910d0e
add g_ before global variables + add comment to the addToMsg() method
amandinehry Jun 10, 2025
67fce43
Fix in writing the stack trace in the yaml
amandinehry Jun 11, 2025
387687d
Merge remote-tracking branch 'origin/develop' into feature/amandinehr…
amandinehry Jun 11, 2025
5c801a5
Add an error msg when the call stack is not formatted as expected + r…
amandinehry Jun 11, 2025
e34c90d
Add comment in the write() function
amandinehry Jun 11, 2025
5c4fbcb
Modification of the streamMultilineYamlAttribute() function: no longe…
amandinehry Jun 11, 2025
75eff27
Modification of the streamMultilineYamlAttribute() method: take the i…
amandinehry Jun 11, 2025
dab2da5
Fix null pointer access on parent by using instance field instead
amandinehry Jun 11, 2025
0a95296
Add comments
amandinehry Jun 11, 2025
c4a002e
Just silently kill GEOS when a NotAnError is raised
amandinehry Jun 11, 2025
cbc5102
Removed the pointer to an Error Logger object (this is no longer usef…
amandinehry Jun 12, 2025
3318d85
Minor syntax modification
amandinehry Jun 12, 2025
343b830
Renaming ContextInfo in ErrorContext + minor correction on the format…
amandinehry Jun 12, 2025
e22e538
Minor modifications on the GEOS_THROW_IF_GT_MSG message
amandinehry Jun 12, 2025
8de9060
Using GEOS_LOG_RANK instead of GEOS_LOG
amandinehry Jun 12, 2025
6c762e7
Add an enumeration to secure the keys that can be entered for the map…
amandinehry Jun 12, 2025
d288490
Improved code comments
amandinehry Jun 13, 2025
99d9b5b
reverse the change from GEOS_LOG to GEOS_LOG_RANK +empty the object a…
amandinehry Jun 13, 2025
f929f97
minor changes syntax + remove isValidStackTrace() method and replace …
amandinehry Jun 13, 2025
709d8a4
Minor changes: string to string_view when it was possible + add an ad…
amandinehry Jun 16, 2025
051e85b
Remove try/catch in the createFile() and the flushCurrentErrorMsg() m…
amandinehry Jun 16, 2025
517782b
Renaming: flushCurrentErrorMsg() into flushErrorMsg()
amandinehry Jun 16, 2025
2e0e396
Change GEOS_LOG() to GEOS_LOG_RANK()
amandinehry Jun 18, 2025
a83a3a1
initialize the error message line by default
amandinehry Jun 19, 2025
9fe289a
Doxygen comments
amandinehry Jun 24, 2025
da7dc82
Comments added
amandinehry Jun 24, 2025
260133e
Sort contextual information by decreasing priority
amandinehry Jun 24, 2025
e0c876f
Simplification of the for loop which write context information
amandinehry Jun 24, 2025
e1a2128
Changes following comments received on my PR
amandinehry Jun 25, 2025
4811b6c
Unit test implemented
amandinehry Jun 25, 2025
4a8ea5b
evaluate MSG only one time in macros
amandinehry Jul 4, 2025
cee846a
✨ manage exit signals in GEOS, as errors + signal log messages no lon…
MelReyCG Jul 7, 2025
6c24825
💄 ajusting line break for consistency
MelReyCG Jul 7, 2025
9e46565
💄 add an option to reorder error msg parts, useful for signal msgs.
MelReyCG Jul 7, 2025
098c478
✨ capture external errors from stderr pipe in GEOS
MelReyCG Jul 7, 2025
7b1b383
✨ ♻️ adding detection location context information for signals & exte…
MelReyCG Jul 7, 2025
25c2418
💄 removing empty entries output from YAML
MelReyCG Jul 7, 2025
2ed4144
💄 adding detectionLocation YAML key
MelReyCG Jul 7, 2025
bdc07b2
💄 adding signal error metadata
MelReyCG Jul 7, 2025
2b38577
Merge commit '7e85e747ec65cd498ba0e9e4730f79d2692ed0bd' into feature/…
MelReyCG Jul 8, 2025
531e3e3
Merge branch 'feature/amandinehry/create-yaml-file-and-structure' int…
MelReyCG Jul 8, 2025
8077f10
sync with last feature/amandinehry/create-yaml-file-and-structure cha…
MelReyCG Jul 8, 2025
127f38e
Merge branch 'feature/amandinehry/create-yaml-file-and-structure' of …
amandinehry Jul 21, 2025
e9508f5
Merge remote-tracking branch 'upstream/develop' into feature/amandine…
amandinehry Jul 21, 2025
b001c07
Merge remote-tracking branch 'amandinehryFork/feature/amandinehry/cre…
MelReyCG Jul 21, 2025
7fc0ced
🔊 warn the deveveloppers that a yamlFile should not be written if not…
MelReyCG Jul 21, 2025
01c4fcf
Merge branch 'feature/amandinehry/create-yaml-file-and-structure' int…
MelReyCG Jul 21, 2025
35f7686
🐛 ⏪ set the --errorsOutput mandatory because of bug + revert optionpa…
MelReyCG Jul 23, 2025
31842a5
✏️ typo
MelReyCG Jul 25, 2025
ef37b51
🐛 do not try to output if not required
MelReyCG Jul 25, 2025
d1d998f
Merge branch 'feature/amandinehry/create-yaml-file-and-structure' int…
MelReyCG Jul 25, 2025
a1105e4
🎨 uncrustify
MelReyCG Aug 1, 2025
c118dd4
🎨 docs alignement
MelReyCG Aug 1, 2025
4215fad
🎨 format
MelReyCG Aug 1, 2025
507ac66
builder pattern for addContextInfo
MelReyCG Aug 1, 2025
7b4ec52
♻️ refactor of the test: keeping only necessary testing, separated te…
MelReyCG Aug 1, 2025
a01d8ac
🐛 bugfix for test, wrong global instance impacting
MelReyCG Aug 1, 2025
d4c465b
🎨 format
MelReyCG Aug 1, 2025
1e32d65
Merge remote-tracking branch 'origin/develop' into feature/amandinehr…
MelReyCG Aug 1, 2025
6d10e3a
⏪ restored "Rank N:" if error messages
MelReyCG Aug 1, 2025
e9cd64c
test
amandinehry Aug 7, 2025
c7031bf
Merge branch 'feature/amandinehry/create-yaml-file-and-structure' of …
amandinehry Aug 7, 2025
e07d0b7
uncomment the rmoveFile() function
amandinehry Aug 21, 2025
785636b
stack trace management
amandinehry Aug 21, 2025
dd3b844
Merge remote-tracking branch 'amandinehryFork/develop' into feature/a…
MelReyCG Aug 26, 2025
751f785
Merge branch 'feature/amandinehry/create-yaml-file-and-structure' int…
MelReyCG Aug 26, 2025
e0bad67
♻️ ✅ New GEOS_ERROR macros with context included + new unit macro uni…
MelReyCG Sep 15, 2025
ab40edc
✅ ♻️ Simplifying + testing macros (GEOS_ERROR_* and GEOS_ASSERT_*) + …
MelReyCG Sep 18, 2025
faa84fa
📝 adding macro docs
MelReyCG Sep 18, 2025
dd97f0e
✨ ✅ adding error cause in unit test
MelReyCG Sep 18, 2025
d708cac
♻️ reordered error & throw macro to group them
MelReyCG Sep 18, 2025
66ab5cb
♻️ ✅ uniformized warning macros
MelReyCG Sep 19, 2025
e6135b1
✅ 🐛 ⚡️ bugfix when callstack is empty + disable callstack for perfs
MelReyCG Sep 19, 2025
589fcfe
♻️ ✅ uniformized throw macros
MelReyCG Sep 19, 2025
6fc4b30
✅ removing _CTX macros from unit test
MelReyCG Sep 22, 2025
77f9fcb
🐛 use streamed cause string to support mpi pointers formatting (not s…
MelReyCG Sep 22, 2025
5747e7f
🐛 last mistake?
MelReyCG Sep 22, 2025
10eb969
♻️ removing all GEOS_*_CTX macros (as GEOS_ERROR, GEOS_WARNING, GEOS_…
MelReyCG Sep 22, 2025
2c5c5f5
🎨 UNCRUSTIFY
MelReyCG Sep 23, 2025
d1642e6
Merge remote-tracking branch 'origin/develop' into feature/amandinehr…
MelReyCG Sep 23, 2025
b3cbb99
Merge remote-tracking branch 'origin/develop' into feature/amandinehr…
MelReyCG Sep 23, 2025
5781a78
✨ allowing to re-throw with GEOS_THROW* macros
MelReyCG Sep 23, 2025
db75e45
📦 shema
MelReyCG Sep 23, 2025
e07ab72
♻️ removing unintended BASE::
MelReyCG Sep 23, 2025
1913059
🎨 uncrustify
MelReyCG Sep 25, 2025
6692dd2
🐛 fix stream reset
MelReyCG Sep 25, 2025
29f6fbe
⚰️ unused variable
MelReyCG Sep 25, 2025
d17972f
✨ removing last LVARRAY_* error logging macros
MelReyCG Sep 25, 2025
759e9bb
Merge remote-tracking branch 'origin/develop' into feature/amandinehr…
MelReyCG Sep 25, 2025
1b755b5
✨ removing last LVARRAY_* error logging macros
MelReyCG Sep 25, 2025
3786db4
✅ adapting test with error cause addition
MelReyCG Sep 25, 2025
efa89d8
🐛 GPU Macros Support
MelReyCG Sep 25, 2025
7915205
🎨 uncrustify
MelReyCG Sep 26, 2025
14eefee
Merge branch 'develop' into feature/amandinehry/create-yaml-file-and-…
MelReyCG Sep 26, 2025
9e42689
Merge remote-tracking branch 'origin/feature/amandinehry/create-yaml-…
MelReyCG Sep 26, 2025
500bbfd
🐛 GPU forgotten instruction
MelReyCG Sep 26, 2025
fa8fa54
🐛 added pragmas to manual shadow global logger instance
MelReyCG Sep 26, 2025
a29510b
Merge branch 'feature/amandinehry/create-yaml-file-and-structure-2' o…
MelReyCG Sep 26, 2025
c501a0f
🐛 wrong conversion on GPU
MelReyCG Sep 29, 2025
a07810f
Merge branch 'develop' into feature/amandinehry/create-yaml-file-and-…
MelReyCG Sep 29, 2025
c3faad6
🐛 control only line index of oneliner macros for GPU compiler support
MelReyCG Sep 30, 2025
c5fec68
Merge remote-tracking branch 'origin/develop' into feature/amandinehr…
MelReyCG Sep 30, 2025
01e75b6
📝 doc fixes
MelReyCG Oct 1, 2025
78ef785
🐛 unsupported string_view usage on GPU (lacks --expt-relaxed-constexpr)
MelReyCG Oct 1, 2025
ea8c125
Merge branch 'develop' into feature/amandinehry/create-yaml-file-and-…
MelReyCG Oct 1, 2025
28867bd
🐛 explicit inclusion for GPU
MelReyCG Oct 1, 2025
4b86fd1
Merge branch 'feature/amandinehry/create-yaml-file-and-structure-2' o…
MelReyCG Oct 1, 2025
7adce63
Merge branch 'develop' into feature/amandinehry/create-yaml-file-and-…
MelReyCG Oct 2, 2025
16a8522
🐛 solve a warning on GPU (dispatching on unsigned type)
MelReyCG Oct 2, 2025
56b13e6
🐛 compil bugfix attempt for debug target clang10, cuda11.8.89
MelReyCG Oct 3, 2025
1211de6
Merge branch 'develop' into feature/amandinehry/create-yaml-file-and-…
MelReyCG Oct 3, 2025
966e396
🐛 solve macro evaluation issue
MelReyCG Oct 3, 2025
bb54f06
📦 🐛 schema
MelReyCG Oct 3, 2025
399a54e
🐛 new attempt
MelReyCG Oct 3, 2025
d62d59b
🐛 tell compiler that variables may be unused
MelReyCG Oct 6, 2025
9b10107
🐛 silly test
MelReyCG Oct 7, 2025
e4685dc
Merge branch 'feature/amandinehry/create-yaml-file-and-structure-2' o…
MelReyCG Oct 7, 2025
53b37f1
🐛 silly test 2
MelReyCG Oct 7, 2025
3a89aae
🐛 2458463564th try to solve the clang cuda debug build: removal of al…
MelReyCG Oct 7, 2025
7da5144
🐛 forgotten ref
MelReyCG Oct 7, 2025
d0b9029
redefinition issue
MelReyCG Oct 7, 2025
11d12c2
🐛 redefine logger instance in unit test
MelReyCG Oct 7, 2025
976b469
🧪 testing resolved macro
MelReyCG Oct 7, 2025
1069205
Revert "🧪 testing resolved macro"
MelReyCG Oct 8, 2025
c2cfa19
🐛 changing type of CUDA format string
MelReyCG Oct 8, 2025
f0caa9f
🐛 🧪 removing potencially reserved blockIdx cuda keyword
MelReyCG Oct 8, 2025
850e4fd
🧪 disabling most of the jobs
MelReyCG Oct 8, 2025
837c7fb
Merge remote-tracking branch 'origin/develop' into feature/amandinehr…
MelReyCG Oct 8, 2025
7e25c50
🧪 disabling most of the jobs 2
MelReyCG Oct 8, 2025
60f2483
🧪 disabling most of the jobs 3
MelReyCG Oct 8, 2025
7e51e4e
⏪ revert nasty fix
MelReyCG Oct 8, 2025
2d7d300
🐛 fix rank displaying
MelReyCG Oct 8, 2025
f96fcf2
📝 return type docs
MelReyCG Oct 8, 2025
741c2bd
⏪ re enable all ci targets
MelReyCG Oct 8, 2025
21d17a2
Merge remote-tracking branch 'origin/feature/amandinehry/create-yaml-…
MelReyCG Oct 8, 2025
d9127d1
Merge remote-tracking branch 'amandinehryFork/feature/rey/signal-and-…
MelReyCG Oct 8, 2025
c4f4661
🐛 take into account new logger interface
MelReyCG Oct 8, 2025
7d0e307
solving strange linking issue
MelReyCG Oct 10, 2025
579aadd
🧪 re disable working ci targets
MelReyCG Oct 10, 2025
0aff50f
Revert "🧪 re disable working ci targets"
MelReyCG Oct 10, 2025
b5d5373
Merge branch 'develop' into feature/amandinehry/create-yaml-file-and-…
MelReyCG Oct 10, 2025
6892fbe
Merge branch 'feature/amandinehry/create-yaml-file-and-structure-2' i…
MelReyCG Oct 10, 2025
e3a68a6
🐛 ♻️ making rank parameter mandatory & clearer (try to fix CUDA CI ta…
MelReyCG Oct 10, 2025
2fe5021
Merge remote-tracking branch 'origin/develop' into feature/amandinehr…
MelReyCG Oct 13, 2025
f8fbc2c
Merge remote-tracking branch 'origin/feature/amandinehry/create-yaml-…
MelReyCG Oct 13, 2025
fd6b06b
Merge remote-tracking branch 'origin/develop' into feature/amandinehr…
MelReyCG Oct 14, 2025
3519ed2
🐛 fixing variable shadowing
MelReyCG Oct 14, 2025
529ab10
📦 schema \o/
MelReyCG Oct 14, 2025
b124508
⏪ revert geos::logger::internal variables->functions refactor (becaus…
MelReyCG Oct 15, 2025
d0b2314
Merge remote-tracking branch 'origin/feature/amandinehry/create-yaml-…
MelReyCG Oct 16, 2025
a115c05
🐛 applying base PR modif
MelReyCG Oct 20, 2025
b1fdcf9
Merge remote-tracking branch 'origin/develop' into feature/amandinehr…
MelReyCG Oct 20, 2025
0ea06d9
Merge branch 'feature/amandinehry/create-yaml-file-and-structure-2' i…
MelReyCG Oct 21, 2025
8cd54ab
💚 removing "make install" in ci jobs
MelReyCG Oct 22, 2025
c55dabb
Merge branch 'feature/amandinehry/create-yaml-file-and-structure-2' i…
MelReyCG Oct 22, 2025
865b3dd
📝 missing docs
MelReyCG Oct 22, 2025
f455e58
Merge remote-tracking branch 'origin/develop' into feature/rey/signal…
MelReyCG Nov 4, 2025
acc1520
🎨 uncrustify
MelReyCG Nov 4, 2025
f0fd71c
🧪 crash logs on Ubuntu (22.04, clang 15.0.7, open-mpi 4.1.2)
MelReyCG Nov 5, 2025
1feeb28
♻️ remove useless init
MelReyCG Nov 6, 2025
e5a11ca
🧪 more crash logs on Ubuntu (22.04, clang 15.0.7, open-mpi 4.1.2)
MelReyCG Nov 6, 2025
b13fd8f
🧪 👷 minimize CI testing
MelReyCG Nov 6, 2025
01995ae
🧪 🐛 don't look
MelReyCG Nov 6, 2025
4c0eda2
📝 ♻️ added extensive documentation & refactored the code to make it c…
MelReyCG Nov 7, 2025
6d2f969
📝 ♻️ added last documentations and moved cpp code a bit
MelReyCG Nov 7, 2025
f0903a8
flag bugfix
MelReyCG Nov 7, 2025
4399665
♻️ one lacking static
MelReyCG Nov 7, 2025
d91467a
🐛 compil fixes
MelReyCG Nov 7, 2025
4d11529
🎨 uncrustify
MelReyCG Nov 7, 2025
1599f16
🔇 remove logs that was for CI debugging
MelReyCG Nov 7, 2025
83f5b77
👷 reset CI targets to initial state
MelReyCG Nov 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/coreComponents/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Also provides commonly used components for such as logging, formatting, memory a
dependencies.
#]]


#
# Specify all headers
#
Expand All @@ -32,7 +31,6 @@ set( common_headers
format/LogPart.hpp
format/Format.hpp
format/StringUtilities.hpp
logger/Logger.hpp
BufferAllocator.hpp
DataLayouts.hpp
DataTypes.hpp
Expand All @@ -41,6 +39,8 @@ set( common_headers
GeosxMacros.hpp
MemoryInfos.hpp
logger/Logger.hpp
logger/ErrorHandling.hpp
logger/ExternalErrorHandler.hpp
MpiWrapper.hpp
Path.hpp
Span.hpp
Expand Down Expand Up @@ -76,6 +76,8 @@ set( common_sources
format/LogPart.cpp
format/StringUtilities.cpp
logger/Logger.cpp
logger/ErrorHandling.cpp
logger/ExternalErrorHandler.cpp
BufferAllocator.cpp
MemoryInfos.cpp
MpiWrapper.cpp
Expand Down
67 changes: 67 additions & 0 deletions src/coreComponents/common/GeosxMacros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,71 @@ void i_g_n_o_r_e( ARGS const & ... ) {}
#endif
#endif

/**
* @name Parameters processing internal macros
*
* These internal macros allow to craft macros with multiple count of parameters.
*/
///@{

/// internal macro for GEOS_DETAIL_MORE_THAN_ONE_ARG
#define GEOS_DETAIL_MORE_THAN_ONE_ARG_VALUE( _00, _01, _02, _03, _04, _05, _06, _07, \
_08, _09, _10, _11, _12, _13, _14, _15, \
_INDEX, ... ) _INDEX

/**
* @return 1 if variadic argument has more than 1 element, 0 otherwise.
* @note Undefined behaviour if variadic argument has more that 16 elements.
*/
#define GEOS_DETAIL_MORE_THAN_ONE_ARG( ... ) \
GEOS_DETAIL_MORE_THAN_ONE_ARG_VALUE( __VA_ARGS__, \
true, true, true, true, true, true, true, true, \
true, true, true, true, true, true, true, false, false )

/// @cond DO_NOT_DOCUMENT

/// internal macros for GEOS_DETAIL_FIRST_ARG
#define GEOS_DETAIL_FIRST_ARG_false( FIRST ) FIRST
#define GEOS_DETAIL_FIRST_ARG_true( FIRST, ... ) FIRST
#define GEOS_DETAIL_FIRST_ARG_FUNC( COND ) GEOS_DETAIL_FIRST_ARG_ ## COND
#define GEOS_DETAIL_FIRST_ARG_DISPATCH( COND, ... ) GEOS_DETAIL_FIRST_ARG_FUNC( COND )(__VA_ARGS__)

/// internal macros for GEOS_DETAIL_LAST_ARG
#define GEOS_DETAIL_REST_ARGS_false( FIRST )
#define GEOS_DETAIL_REST_ARGS_true( FIRST, ... ) __VA_ARGS__
#define GEOS_DETAIL_REST_ARGS_FUNC( COND ) GEOS_DETAIL_REST_ARGS_ ## COND
#define GEOS_DETAIL_REST_ARGS_DISPATCH( COND, ... ) GEOS_DETAIL_REST_ARGS_FUNC( COND )(__VA_ARGS__)

/// internal macros for GEOS_DETAIL_LAST_ARG_PREP
#define GEOS_DETAIL_REST_PREP_ARGS_false( FIRST )
#define GEOS_DETAIL_REST_PREP_ARGS_true( FIRST, ... ) , __VA_ARGS__
#define GEOS_DETAIL_REST_PREP_ARGS_FUNC( COND ) GEOS_DETAIL_REST_PREP_ARGS_ ## COND
#define GEOS_DETAIL_REST_PREP_ARGS_DISPATCH( COND, ... ) GEOS_DETAIL_REST_PREP_ARGS_FUNC( COND )(__VA_ARGS__)

/// @endcond

/**
* @return Return the first parameter of the variadic parameters (__VA_ARGS__).
* @note Undefined behaviour if variadic argument has more that 16 elements.
*/
#define GEOS_DETAIL_FIRST_ARG( ... ) GEOS_DETAIL_FIRST_ARG_DISPATCH( GEOS_DETAIL_MORE_THAN_ONE_ARG( __VA_ARGS__ ), \
__VA_ARGS__ )

/**
* @return Return the parameters following the first of the variadic parameters (__VA_ARGS__).
* @note Undefined behaviour if variadic argument has more that 16 elements.
*/
#define GEOS_DETAIL_REST_ARGS( ... ) GEOS_DETAIL_REST_ARGS_DISPATCH( GEOS_DETAIL_MORE_THAN_ONE_ARG( __VA_ARGS__ ), \
__VA_ARGS__ )

/**
* @return Return the parameters following the first of the variadic parameters (__VA_ARGS__),
* prepended with a comma when not empty.
* @note Undefined behaviour if variadic argument has more that 16 elements.
*/
#define GEOS_DETAIL_REST_PREP_ARGS( ... ) GEOS_DETAIL_REST_PREP_ARGS_DISPATCH( GEOS_DETAIL_MORE_THAN_ONE_ARG( __VA_ARGS__ ), \
__VA_ARGS__ )

///@}

#endif // GEOS_COMMON_GEOSXMACROS_HPP_
99 changes: 84 additions & 15 deletions src/coreComponents/common/initializeEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "LvArray/src/system.hpp"
#include "common/LifoStorageCommon.hpp"
#include "common/MemoryInfos.hpp"
#include "logger/ErrorHandling.hpp"
#include "logger/ExternalErrorHandler.hpp"
#include <umpire/TypedAllocator.hpp>
// TPL includes
#include <umpire/ResourceManager.hpp>
Expand Down Expand Up @@ -66,6 +68,88 @@ void setupLogger()
#else
logger::InitializeLogger();
#endif

{ // setup error handling (using LvArray helper system functions)
using ErrorContext = ErrorLogger::ErrorContext;

///// set Post-Handled Error behaviour /////
LvArray::system::setErrorHandler( []()
{
#if defined( GEOS_USE_MPI )
int mpi = 0;
MPI_Initialized( &mpi );
if( mpi )
{
MPI_Abort( MPI_COMM_WORLD, EXIT_FAILURE );
}
#endif
std::abort();
} );

///// set external error handling behaviour /////
ExternalErrorHandler::instance().setErrorHandling( []( string_view errorMsg,
string_view detectionLocation )
{
std::string const stackHistory = LvArray::system::stackTrace( true );

GEOS_LOG( GEOS_FMT( "***** ERROR\n"
"***** LOCATION: (external error, detected {})\n"
"{}\n{}",
detectionLocation, errorMsg, stackHistory ) );
if( ErrorLogger::global().isOutputFileEnabled() )
{
ErrorLogger::ErrorMsg error;
error.setType( ErrorLogger::MsgType::Error );
error.addToMsg( errorMsg );
error.setRank( ::geos::logger::internal::rank() );
error.addCallStackInfo( stackHistory );
error.addContextInfo(
ErrorContext{ { { ErrorContext::Attribute::DetectionLoc, string( detectionLocation ) } } } );

ErrorLogger::global().flushErrorMsg( error );
}

// we do not terminate the program as 1. the error could be non-fatal, 2. there may be more messages to output.
} );
ExternalErrorHandler::instance().enableStderrPipe( true );

///// set signal handling behaviour /////
LvArray::system::setSignalHandling( []( int const signal )
{
// Disable signal handling to prevent catching exit signal (infinite loop)
LvArray::system::setSignalHandling( nullptr );

// first of all, external error can await to be output, we must output them
ExternalErrorHandler::instance().flush( "before signal error output" );

// error message output
std::string const stackHistory = LvArray::system::stackTrace( true );
ErrorLogger::ErrorMsg error;
error.addSignalToMsg( signal );

GEOS_LOG( GEOS_FMT( "***** ERROR\n"
"***** SIGNAL: {}\n"
"***** LOCATION: (external error, captured by signal handler)\n"
"{}\n{}",
signal, error.m_msg, stackHistory ) );

if( ErrorLogger::global().isOutputFileEnabled() )
{
error.setType( ErrorLogger::MsgType::Error );
error.setRank( ::geos::logger::internal::rank() );
error.addCallStackInfo( stackHistory );
error.addContextInfo(
ErrorContext{ { { ErrorContext::Attribute::Signal, std::to_string( signal ) } }, 1 },
ErrorContext{ { { ErrorContext::Attribute::DetectionLoc, string( "signal handler" ) } }, 0 } );

ErrorLogger::global().flushErrorMsg( error );
}

// call program termination
LvArray::system::callErrorHandler();
} );

}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -77,21 +161,6 @@ void finalizeLogger()
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setupLvArray()
{
LvArray::system::setErrorHandler( []()
{
#if defined( GEOS_USE_MPI )
int mpi = 0;
MPI_Initialized( &mpi );
if( mpi )
{
MPI_Abort( MPI_COMM_WORLD, EXIT_FAILURE );
}
#endif
std::abort();
} );

LvArray::system::setSignalHandling( []( int const signal ) { LvArray::system::stackTraceHandler( signal, true ); } );

#if defined(GEOS_USE_FPE)
LvArray::system::setFPE();
#else
Expand Down
Loading
Loading