Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
132ccc4b
Commit
132ccc4b
authored
7 years ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
first tries
parent
67d07faf
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+3
-1
3 additions, 1 deletion
CMakeLists.txt
utils/SignalManager.cpp
+52
-2
52 additions, 2 deletions
utils/SignalManager.cpp
with
55 additions
and
3 deletions
CMakeLists.txt
+
3
−
1
View file @
132ccc4b
...
...
@@ -24,7 +24,7 @@ include_directories(${PASTIS_SOURCE_DIR}/packages/CLI11/include)
# Kokkos
set
(
KOKKOS_ENABLE_OPENMP ON CACHE BOOL
""
)
add_subdirectory
(
${
CMAKE
_SOURCE_DIR
}
/packages/kokkos
)
add_subdirectory
(
${
PASTIS
_SOURCE_DIR
}
/packages/kokkos
)
include_directories
(
${
Kokkos_INCLUDE_DIRS_RET
}
)
# Pastis utils
...
...
@@ -46,6 +46,8 @@ configure_file("${PASTIS_SOURCE_DIR}/pastis_config.hpp.in"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pastis_config.hpp"
@ONLY
)
link_libraries
(
"-rdynamic"
)
# ------------------- Source files --------------------
# Pastis binary
add_executable
(
...
...
This diff is collapsed.
Click to expand it.
utils/SignalManager.cpp
+
52
−
2
View file @
132ccc4b
...
...
@@ -4,6 +4,45 @@
#include
<rang.hpp>
#include
<iomanip>
#include
<execinfo.h>
#include
<cxxabi.h>
#include
<regex>
#include
<vector>
void
print_bt
()
{
const
int
size
=
20
;
void
*
buffer
[
size
];
int
ret
=
backtrace
(
buffer
,
size
);
char
**
ptr
=
backtrace_symbols
(
buffer
,
ret
);
std
::
vector
<
std
::
string
>
lines
;
for
(
int
i
=
0
;
i
<
ret
;
++
i
)
{
lines
.
push_back
(
ptr
[
i
]);
}
free
(
ptr
);
// abi::__cxa_demangle( "_Z16displayBacktracev", NULL, NULL, &status );
std
::
regex
mangled_function
(
R"(\(.*\+)"
);
for
(
const
auto
&
line
:
lines
)
{
std
::
cerr
<<
"demangling "
<<
line
<<
'\n'
;
std
::
smatch
matchex
;
int
status
=
-
1
;
if
(
std
::
regex_search
(
line
,
matchex
,
mangled_function
))
{
std
::
string
prefix
=
matchex
.
prefix
().
str
();
std
::
string
function
=
line
.
substr
(
matchex
.
position
()
+
1
,
matchex
.
length
()
-
2
);
std
::
string
suffix
=
matchex
.
suffix
().
str
();
std
::
cerr
<<
"Found "
<<
function
.
c_str
()
<<
'\n'
;
std
::
string
demangled
=
abi
::
__cxa_demangle
(
function
.
c_str
(),
NULL
,
NULL
,
&
status
);
std
::
cerr
<<
"status="
<<
status
<<
'\n'
;
std
::
cerr
<<
demangled
<<
'\n'
<<
'\n'
;
}
}
}
#warning must create a specific class for pausing and use enum class
#include
<string>
std
::
string
SignalManager
::
s_pause_on_error
=
"auto"
;
...
...
@@ -27,6 +66,7 @@ std::string SignalManager::signalName(int s)
void
SignalManager
::
pauseForDebug
()
{
std
::
cerr
<<
"
\n
======================================
\n
"
;
std
::
cerr
<<
rang
::
style
::
reset
<<
rang
::
fg
::
reset
...
...
@@ -50,6 +90,7 @@ void SignalManager::pauseForDebug()
void
SignalManager
::
handler
(
int
s
)
{
std
::
cerr
<<
"
\n
*** "
<<
rang
::
style
::
reset
<<
rang
::
fg
::
reset
...
...
@@ -62,18 +103,27 @@ void SignalManager::handler(int s)
<<
rang
::
style
::
reset
<<
" ***
\n
"
;
std
::
signal
(
SIGFPE
,
SIG_DFL
);
std
::
signal
(
SIGSEGV
,
SIG_DFL
);
std
::
signal
(
SIGTERM
,
SIG_DFL
);
std
::
signal
(
SIGINT
,
SIG_DFL
);
std
::
signal
(
SIGABRT
,
SIG_DFL
);
print_bt
();
SignalManager
::
pauseForDebug
();
if
((
ConsoleManager
::
isTerminal
(
std
::
cout
)
and
(
s_pause_on_error
==
"auto"
))
or
(
s_pause_on_error
==
"yes"
))
{
std
::
signal
(
SIGINT
,
SIG_DFL
);
SignalManager
::
pauseForDebug
();
}
else
{
std
::
exit
(
0
);
//
std::exit(0);
}
}
void
SignalManager
::
init
(
const
bool
&
enable
)
{
if
(
enable
)
{
std
::
signal
(
SIGFPE
,
SignalManager
::
handler
);
std
::
signal
(
SIGSEGV
,
SignalManager
::
handler
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment