9#include <framework/modules/core/TheKillerModule.h>
11#include <boost/algorithm/string.hpp>
27 setDescription(R
"DOC(This Modules kills basf2 as horribly as possible (or as selected)
29With this module you can kill basf2 in a variety of ways to test what happens if processing is interrupted by
40This error can occur in a selected event to test behavior during processing.)DOC");
44 "quick_exit, exit, exception, signal, segfault, buserror)", std::string(
"abort"));
46 "quick_exit and exit it is the return code, for signal it is the signal number", 0u);
61 else B2ERROR(
"Unknown method , choose one of (abort, terminate, quick_exit, exit, "
78 throw std::runtime_error(
"This is a runtime error kindly provided by TheKiller module.");
83#ifndef __clang_analyzer__
86 volatile int* foo {
nullptr};
92#ifndef __clang_analyzer__
94#if defined(__GNUC__) && defined(__x86_64__)
95 __asm__(
"pushf\norl $0x40000,(%rsp)\npopf");
97 auto* cptr = (
char*) malloc(
sizeof(
int) + 1);
98 auto* iptr = (
int*)(cptr + 1);
105 B2FATAL(
"Illegal method");
107 B2FATAL(
"This should never be called ...");
void setDescription(const std::string &description)
Sets the description of the module.
EMethod m_method
How to kill the event after parsing the string parameter.
void initialize() override
parse the method parameter
void event() override
kill if necessary
std::string m_methodStr
How to kill the event, one of (abort, terminate, quick_exit, exit, exception, signal,...
int m_event
Current event.
@ c_segfault
produce segfault
@ c_exception
raise std::runtime_error
@ c_terminate
call std::terminate
@ c_buserror
produce bus error
@ c_signal
raise signal(N)
@ c_quick_exit
call std::quick_exit
int m_eventToKill
In which event to kill the processing.
TheKillerModule()
Constructor: Sets the description, the properties and the parameters of the module.
unsigned int m_parameter
Optional parameter for the kill method: for quick_exit and exit it is the return code,...
Class to store variables with their name which were sent to the logging service.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.