gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 200 of file logging.hh.

◆ fatal_if

#define fatal_if (   cond,
  ... 
)
Value:
( \
GEM5_UNLIKELY(static_cast<bool>(cond)) ? \
fatal("fatal condition " # cond " occurred: %s", \
::gem5::csprintf(__VA_ARGS__)) : \
void(0) \
)

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 236 of file logging.hh.

◆ gem5_assert

#define gem5_assert (   cond,
  ... 
)
Value:
( \
GEM5_UNLIKELY(NDEBUG_DEFINED || static_cast<bool>(cond)) ? \
void(0) : \
[](const auto&... args) { \
auto msg = [&]{ \
if constexpr (sizeof...(args) == 0) return ""; \
else return std::string(": ") + csprintf(args...); \
}; \
panic("assert(" #cond ") failed%s", msg()); \
}(__VA_ARGS__) \
)

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().

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

Definition at line 317 of file logging.hh.

◆ hack_once

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

Definition at line 264 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 188 of file logging.hh.

◆ panic_if

#define panic_if (   cond,
  ... 
)
Value:
( \
GEM5_UNLIKELY(static_cast<bool>(cond)) ? \
panic("panic condition " # cond " occurred: %s", \
::gem5::csprintf(__VA_ARGS__)) : \
void(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 214 of file logging.hh.

◆ warn_if_once

#define warn_if_once (   cond,
  ... 
)
Value:
( \
static_cast<bool>(cond) ? \
warn_once(__VA_ARGS__) : \
void(0) \
)

Definition at line 290 of file logging.hh.

gem5::ArmISA::cond
cond
Definition: pcstate.hh:62
gem5::csprintf
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:161
NDEBUG_DEFINED
#define NDEBUG_DEFINED
Definition: logging.hh:302
std
Overload hash function for BasicBlockRange type.
Definition: misc.hh:2909
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:188

Generated on Sun Jul 30 2023 01:57:06 for gem5 by doxygen 1.8.17