Go to the documentation of this file.
48 #include <sys/types.h>
50 #ifdef HAVE_SYS_WAIT_H
51 # include <sys/wait.h>
54 # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
57 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
63 #include "tce_version_string.h"
65 #include "tce_config.h"
78 using std::set_unexpected;
112 ofstream* fileLog =
new ofstream;
114 if (!fileLog->is_open()) {
133 "Application initialization failed.");
225 const string fileName,
226 const int lineNumber,
227 const string functionName,
228 const string message,
229 const int neededVerbosity) {
239 *
logStream_ << fileName <<
":" << lineNumber <<
": ";
242 *
logStream_ <<
"In function \'" << functionName <<
"\': ";
277 <<
"Program aborted because of leaked unexpected exception. "
278 << std::endl << std::endl <<
279 "Information of the last thrown TCE exception: " << std::endl
302 const std::string& command) {
310 std::string fullCommand = command +
" 2>&1 ";
311 FILE* pipe = popen(fullCommand.c_str(),
"r");
317 int exitStatus = pclose(pipe);
339 const std::string& command,
340 std::vector<std::string>& outputLines,
341 std::size_t maxOutputLines,
342 bool includeStdErr) {
351 string shellCommand = command;
353 shellCommand +=
" 2>1";
355 FILE* pipe = popen(shellCommand.c_str(),
"r");
359 if (outputLines.size() < maxOutputLines) {
360 outputLines.push_back(
string(line));
364 int exitStatus = pclose(pipe);
420 struct sigaction action;
421 action.sa_flags = SA_SIGINFO;
424 sigemptyset(&action.sa_mask);
425 sigaction(signalNum, &action, NULL);
446 std::map<int, UnixSignalHandler*>::iterator it =
472 signal(signalNum, SIG_DFL);
511 return TCE_VERSION_STRING;
548 userRoot +
"/share/openasip/data/icons")) {
551 return string(TCE_INSTALLATION_ROOT);
static std::string installationRoot_
Path to the TCE installation root.
static std::ostream * errorStream_
The stream for user error notifications.
static UnixSignalHandler * getSignalHandler(int signalNum)
static void restoreSignalHandler(int signalNum)
static int runShellCommandAndGetOutput(const std::string &command, std::vector< std::string > &outputLines, std::size_t maxOutputLines=DEFAULT_MAX_OUTPUT_LINES, bool includeStdErr=false)
static void writeToErrorLog(const std::string fileName, const int lineNumber, const std::string functionName, const std::string message, const int neededVerbosity=0)
static void exitProgram(const int status=EXIT_SUCCESS)
static const int VERBOSE_LEVEL_DEFAULT
Default verbose level - do not print anything unnecessary.
static void setVerboseLevel(const int level=VERBOSE_LEVEL_DEFAULT)
static std::string lastExceptionInfo()
Returns information of the last thrown exception.
static void setCmdLineOptions(CmdLineOptions *options_)
static std::ostream & logStream()
static void setSignalHandler(int signalNum, UnixSignalHandler &handler)
#define WIFEXITED(stat_val)
static std::string errorLogFilePath()
static std::ostream * logStream_
The stream for debug logging.
#define assert(condition)
#define WEXITSTATUS(stat_val)
static bool initialized_
True when initialize() is called. Ensures that initialization is done only once.
static CmdLineOptions * cmdLineOptions()
const int MAX_OUTPUT_LINE_LENGTH
maximum length of an output line saved from popen() output in runShellCommandAndGetOutput()
static std::ostream * warningStream_
The stream for user error notifications.
virtual bool isVerboseSwitchDefined() const
static const int VERBOSE_LEVEL_INCREASED
Increased verbose level - print information about modules etc.
static int runShellCommandSilently(const std::string &command)
static CmdLineOptions * cmdLineOptions_
Holds command line options passed to program.
static MachInfoCmdLineOptions options
static std::map< int, UnixSignalHandler * > signalHandlers_
Signal handlers in a map associated by their signal numbers.
static bool isInstalled()
static std::ostream & errorStream()
static bool fileExists(const std::string fileName)
static std::string installationDir()
static int argc_
The original argc and argv given to the main program, if applicable.
static const int VERBOSE_LEVEL_SPAM
More Increased verbose level - spam about ddg heights of loops.
static std::ostream & warningStream()
static void unexpectedExceptionHandler()
static bool developerMode()
static std::string environmentVariable(const std::string &variable)
virtual void execute(int data, siginfo_t *info)=0
static int verboseLevel_
Verbose level directs how much output will be printed to console.
static void abortProgram() __attribute__((noreturn))
static std::string TCEVersionString()
static void signalRedirector(int data, siginfo_t *info, void *context)
virtual bool isVerboseSpamSwitchDefined() const
static bool shellCommandsExists(const std::string &commands)