gem5  v22.1.0.0
Macros
The Logger API.

These methods and macros provide access to gem5's logging system. More...

Macros

#define panic(...)   exit_message(::gem5::Logger::getPanic(), __VA_ARGS__)
 This implements a cprintf based panic() function. More...
 
#define fatal(...)   exit_message(::gem5::Logger::getFatal(), __VA_ARGS__)
 This implements a cprintf based fatal() function. More...
 
#define panic_if(cond, ...)
 Conditional panic macro that checks the supplied condition and only panics if the condition is true and allows the programmer to specify diagnostic printout. More...
 
#define fatal_if(cond, ...)
 Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condition is true and allows the programmer to specify diagnostic printout. More...
 
#define gem5_assert(cond, ...)
 The assert macro will function like a normal assert, but will use panic instead of straight abort(). More...
 
#define hack_once(...)    base_message_once(::gem5::Logger::getHack(), __VA_ARGS__)
 
#define warn_if_once(cond, ...)
 

Detailed Description

These methods and macros provide access to gem5's logging system.

Macro Definition Documentation

◆ fatal

#define fatal (   ...)    exit_message(::gem5::Logger::getFatal(), __VA_ARGS__)

This implements a cprintf based fatal() function.

fatal() should be called when the simulation cannot continue due to some condition that is the user's fault (bad configuration, invalid arguments, etc.) and not a simulator bug. fatal() might call exit, unlike panic().

Definition at line 190 of file logging.hh.

◆ fatal_if

#define fatal_if (   cond,
  ... 
)
Value:
do { \
if (GEM5_UNLIKELY(cond)) { \
fatal("fatal condition " # cond " occurred: %s", \
::gem5::csprintf(__VA_ARGS__)); \
} \
} while (0)
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:161

Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condition is true and allows the programmer to specify diagnostic printout.

Useful to replace if + fatal, or if + print + assert, etc.

Parameters
condCondition that is checked; if true -> fatal
...Printf-based format string with arguments, extends printout.

Definition at line 226 of file logging.hh.

◆ gem5_assert

#define gem5_assert (   cond,
  ... 
)
Value:
do { \
if (GEM5_UNLIKELY(!NDEBUG_DEFINED && !static_cast<bool>(cond))) { \
panic("assert(" #cond ") failed%s", _assertMsg(__VA_ARGS__)); \
} \
} while (0)
#define NDEBUG_DEFINED
Definition: logging.hh:289
const char * _assertMsg()
Definition: logging.hh:300

The assert macro will function like a normal assert, but will use panic instead of straight abort().

This allows to perform some cleaning up in ExitLogger::exit() before calling abort(). This macro will not check its condition in fast builds, but it must still be valid code.

Parameters
condCondition that is checked; if false -> panic
...Printf-based format string with arguments, extends printout.

Definition at line 318 of file logging.hh.

◆ hack_once

#define hack_once (   ...)     base_message_once(::gem5::Logger::getHack(), __VA_ARGS__)

Definition at line 254 of file logging.hh.

◆ panic

#define panic (   ...)    exit_message(::gem5::Logger::getPanic(), __VA_ARGS__)

This implements a cprintf based panic() function.

panic() should be called when something happens that should never ever happen regardless of what the user does (i.e., an acutal m5 bug). panic() might call abort which can dump core or enter the debugger.

Definition at line 178 of file logging.hh.

◆ panic_if

#define panic_if (   cond,
  ... 
)
Value:
do { \
if (GEM5_UNLIKELY(cond)) { \
panic("panic condition " # cond " occurred: %s", \
::gem5::csprintf(__VA_ARGS__)); \
} \
} while (0)

Conditional panic macro that checks the supplied condition and only panics if the condition is true and allows the programmer to specify diagnostic printout.

Useful to replace if + panic, or if + print + assert, etc.

Parameters
condCondition that is checked; if true -> panic
...Printf-based format string with arguments, extends printout.

Definition at line 204 of file logging.hh.

◆ warn_if_once

#define warn_if_once (   cond,
  ... 
)
Value:
do { \
if (GEM5_UNLIKELY(cond)) \
warn_once(__VA_ARGS__); \
} while (0)

Definition at line 279 of file logging.hh.


Generated on Wed Dec 21 2022 10:23:05 for gem5 by doxygen 1.9.1