-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: direct support for
__dump_gcov
- the previous implementation for dumping gcov statistics wasn't robust enough - now, `__dump_gcov` is called directly from the signal handler and then `_exit` is called - this guarantees dumping of gcov statistics and immidiate module exit Signed-off-by: aw <[email protected]>
- Loading branch information
Showing
6 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
lib/staging/helpers/include/everest/staging/helpers/coverage.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
namespace everest::helpers { | ||
void install_signal_handlers_for_gcov(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <everest/staging/helpers/coverage.hpp> | ||
|
||
#include <atomic> | ||
|
||
#include <signal.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
extern "C" void __gcov_dump(); | ||
|
||
namespace { | ||
|
||
static std::atomic_flag going_to_terminate = ATOMIC_FLAG_INIT; | ||
|
||
void terminate_handler(int signal) { | ||
if (going_to_terminate.test_and_set()) { | ||
return; | ||
} | ||
|
||
__gcov_dump(); | ||
|
||
_exit(EXIT_FAILURE); | ||
}; | ||
|
||
} // namespace | ||
|
||
namespace everest::helpers { | ||
|
||
void install_signal_handlers_for_gcov() { | ||
struct sigaction action {}; | ||
action.sa_handler = &terminate_handler; | ||
// action.sa_mask should be zero, so no blocked signals within the signal handler | ||
// action.sa_flags should be fine with being zero | ||
sigaction(SIGINT, &action, nullptr); | ||
sigaction(SIGTERM, &action, nullptr); | ||
} | ||
|
||
} // namespace everest::helpers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters