26 #ifndef SIM_AVRERROR_H 27 #define SIM_AVRERROR_H 31 #if defined(_MSC_VER) && !defined(SWIG) 32 #define ATTRIBUTE_NORETURN __declspec(noreturn) 33 #define ATTRIBUTE_PRINTF(string_arg, first_arg) 34 #elif defined(__GNUC__) 35 #ifndef ATTRIBUTE_NORETURN 36 #define ATTRIBUTE_NORETURN __attribute__((noreturn)) 38 #ifndef ATTRIBUTE_PRINTF 39 #define ATTRIBUTE_PRINTF(string_arg, first_arg) __attribute__ ((format (printf, string_arg, first_arg))) 42 #define ATTRIBUTE_NORETURN 43 #define ATTRIBUTE_PRINTF(string_arg, first_arg) 64 void SetTraceFile(
const char *name,
unsigned int maxlines = 0);
80 void vfwarning(
const char *file,
int line,
const char *fmt, ...)
83 void vferror(
const char *file,
int line,
const char *fmt, ...)
87 void vffatal(
const char *file,
int line,
const char *fmt, ...)
114 char *
getFormatString(
const char *prefix,
const char *file,
int line,
const char *fmtstr);
121 #define traceOut sysConHandler.traceOutStream() 130 void trioaccess(
const char *t,
unsigned char val);
132 #define avr_message(...) sysConHandler.vfmessage(__VA_ARGS__) 133 #define avr_warning(...) sysConHandler.vfwarning(__FILE__, __LINE__, ## __VA_ARGS__) 134 #define avr_failure(...) sysConHandler.vferror(__FILE__, __LINE__, ## __VA_ARGS__) 135 #define avr_error(...) sysConHandler.vffatal(__FILE__, __LINE__, ## __VA_ARGS__)
#define ATTRIBUTE_PRINTF(string_arg, first_arg)
char * getFormatString(const char *prefix, const char *file, int line, const char *fmtstr)
Creates the format string for formatting a message.
SystemConsoleHandler()
creates a SystemConsoleHandler instance
SystemConsoleHandler sysConHandler
The SystemConsoleHandler instance for common usage.
#define ATTRIBUTE_NORETURN
void SetUseExit(bool useExit=true)
Tells the handler, that exit/abort is to use instead of exceptions.
std::string traceFilename
file name for trace file (will be appended with file count!)
char formatStringBuffer[192]
Buffer for format strings to format a message.
bool traceEnabled
flag, true if trace is enabled
int traceFileCount
Counter for trace files.
void void void ATTRIBUTE_NORETURN void vffatal(const char *file, int line, const char *fmt,...) ATTRIBUTE_PRINTF(4
Format and send a error message to stderr and call exit or raise a exception.
void SetTraceFile(const char *name, unsigned int maxlines=0)
Sets the trace to file stream and enables tracing global.
void void void ATTRIBUTE_NORETURN void ATTRIBUTE_NORETURN void AbortApplication(int code)
Aborts application: uses abort or exception depending on useExitAndAbort.
Class, that handle messages to console and also exit/abort calls.
ATTRIBUTE_NORETURN void ExitApplication(int code)
Exits application: uses exit or exception depending on useExitAndAbort.
char messageStringBuffer[768]
Buffer for built message string itself, 4 times bigger than formatStringBuffer.
std::ostream * wrnStream
Stream, where warning and error messages are sent to.
void StopTrace(void)
Stops tracing global, close file, if set, redirect trace to nullStream.
std::ostream & traceOutStream(void)
Gives Access to trace stream.
unsigned int traceLines
how much lines are written on current trace file
int global_verbose_on
Verbose enable flag.
std::ostream * msgStream
Stream, where normal messages are sent to.
void SetWarningStream(std::ostream *s)
Sets the output stream, where warnings and errors are sent to.
bool GetTraceState(void)
Returns true, if tracing is global enabled.
bool traceToFile
flag, true if trace writes to filestream
bool global_suppress_memory_warnings
flag to suppress invalid memory usage warnings
void TraceNextLine(void)
Ends a trace line, performs reopen new filestream, if necessary.
void SetTraceStream(std::ostream *s)
Sets the trace to given stream and enables tracing global.
std::ostream * traceStream
Stream for trace output.
void void void vferror(const char *file, int line, const char *fmt,...) ATTRIBUTE_PRINTF(4
Format and send a error message to warning stream (default stderr)
std::ostream * nullStream
/dev/null! ;-)
void vfmessage(const char *fmt,...) ATTRIBUTE_PRINTF(2
Format and send a message to message stream (default stdout)
void SetMessageStream(std::ostream *s)
Sets the output stream, where messages are sent to.
bool useExitAndAbort
Flag, if exit/abort have to be used instead of exceptions.
std::ofstream * fileTraceStream
open file stream for trace
unsigned int traceLinesOnFile
how much lines will be written on one trace file 0->means endless
void trioaccess(const char *t, unsigned char val)
Helper function for writing trace (trace IO access)
void void vfwarning(const char *file, int line, const char *fmt,...) ATTRIBUTE_PRINTF(4
Format and send a warning message to warning stream (default stderr)