Debug

Alert

Define an Alert function that goes to std::cerr in c++ or to Alert() in Javascript.

Note

This file is part of Empirical, https://github.com/devosoft/Empirical

Copyright

Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md

Date

2015-2017

Note

Status: RELEASE

namespace emp

If we are in emscripten, make sure to include the header.

Functions

void Alert(const std::string &msg)

Send msg to cerr if in C++, or show msg in an alert box if compiled to Javascript Input can be any number of arguments of any types as long as the can be converted to strings with emp::to_string().

template<typename ...TYPE_SET>
void CappedAlert(size_t cap, TYPE_SET... inputs)

A version of Alert that will cap how many times it can go off.

struct AlertObj
#include <alert.hpp>

An object that will automatically output a message during construction or destruction, usually for use in debugging to disentangle timings.

Public Functions

AlertObj(const std::string &_msg, bool _on_c = true, bool _on_d = false)
~AlertObj()
void Trigger()
void SetMessage(const std::string &_msg)

Public Members

std::string msg

Message for the alert to print.

bool on_construct

Should the message print automatically during construction?

bool on_destruct

Should the message print automatically during destruction?

Debugging Tools

Basic tools for use in developing high-assurance code.

Note

This file is part of Empirical, https://github.com/devosoft/Empirical

Copyright

Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md

Date

2015-2017

Note

Status: BETA

Defines

EMP_DEBUG_PRINT(...)
BlockRelease(BLOCK)

BlockRelease() will halt compilation if NDEBUG is on and EMP_NO_BLOCK is off. It is useful to include alongside debug code that you want to remember to remove when you are done debugging; it is automatically included with the emp_debug() function below. If you want to intentionally compile in release mode, make sure to define EMP_NO_BLOCK.

EMP_DEBUG(...)

The EMP_DEBUG macro executes its contents in debug mode, but otherwise ignores them.

emp_debug(...)

emp_debug() will print its contents as a message in debug mode and BLOCK release mode until it’s removed.

namespace emp

If we are in emscripten, make sure to include the header.

Functions

template<typename ...Ts>
void emp_debug_print(Ts&&... args)
void Depricated(const std::string &name, const std::string &desc = "")

Depricated() prints its contents exactly once to notify a user of a depricated function.

Errors

Warning

doxygenfile: Cannot find file “emp/debug/errors.hpp

Memory Tracking

A set of macros to track how many instances of specific classes are made.

One way of tracking memory leaks is to simply count instances of classes. The macros here simplify this process.

Note

This file is part of Empirical, https://github.com/devosoft/Empirical

Copyright

Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md

Date

2015-2019

Note

Status: BETA

To setup, every constructor for a class must incude EMP_TRACK_CONSTRUCT(CLASS_NAME), and every destructor must have EMP_TRACK_DESTRUCT(CLASS_NAME). Make sure to avoid implicit constructors/destructors or counts will be off.

To collect information, EMP_TRACK_COUNT(CLASS_NAME) will provide the current count for a specific class, and EMP_TRACK_STATUS will translate into a string providing information about all available classes.

Developer notes:

Defines

EMP_TRACK_CONSTRUCT(CLASS_NAME)
EMP_TRACK_DESTRUCT(CLASS_NAME)
EMP_TRACK_COUNT(CLASS_NAME)
EMP_TRACK_STATUS
namespace emp

If we are in emscripten, make sure to include the header.