Virtual Laboratory Environment

Version 2.0.2

A Modeling & Simulation Environment

debug model

Debugging Macros

To debug your model, you may use the DECLARE_DYNAMICSY_DBG instead of DECLARE_DYNAMICS and use some functions (TraceAlways, TraceModel etc.) to enable debugging of your model in the C++ source code.

Default, the debug file is located at $VLE_HOME/vle.log but it can be redirected to the standard output with the command line option --log-to- stdout.

Level Description Command line C++
0 Minimum debug: messages are always printed vle -v 0 or vle TraceAlways() or DTraceAlways()
1 Model Debugging: to be used by model developer vle -v 1 TraceModel() or DTraceModel()
2 Extension debugging: extension functions tracking (e.g. “compute” function of “DifferenceEquation” extension) vle -v 2 TraceExtension() or DTraceExtension()
3 DEVS debugging: DEVS functions tracking (e.g “internalTransition” of “Dynamics”) vle -v 3 TraceDevs() or DTraceDevs()

The level modes are cumulative. For example, if one uses mode 2, traces available at levels 0, 1 and 2 are printed into the log file.

For example the following atomic model will show always the string “MyModel constructor” but show the string “time is odd” only when time is odd and VLE is launched with vle -v x with x equal 1, 2 or 3.

#include <vle/devs/Dynamics.hpp>
#include <vle/devs/DynamicsDbg.hpp>
#include <vle/utils/Debug.hpp>
#include <vle/utils/Trace.hpp>

class MyModel : public vle::devs::Dynamics
    MyModel(const vle::devs::DynamicsInit& init
            const vle::devs::InitEvents& events)
        : vle::devs::Dynamics(init, events)
        TraceAlway("MyModel constructor");

    virtual void internalTransition(
                const vle::devs::Time& time)
        if (static_cast<int>(time) % 2 == 0)
            TraceModel("time is odd");

The DTrace* macros are removed when the compile mode Release is declared, on contrary of Trace* macros. To declare the compile mode Release use either: in the CMake configuration.

cmake -DCMAKE_BUILD_TYPE=Release ...
As options of any compiler :
Last updated on 29 Nov 2018, 15:39
Edit on GitHub