Model debugging

From VLE

Jump to: navigation, search

Debugging Macros

Verbosité
Level Description Command C++
0 Minimal 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()

Notes:

  • Debug file is located at $VLE_HOME/vle.log
  • Debug modes are cumulative. For example, if one uses mode 2, traces available at levels 0, 1 and 2 are printed into the log file.
  • 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 :
      CFLAGS=-O3 -DNDEBUG


Define the models to debug

It can be useful to identify which atomic models one wants to debug.

Usually, to declare a dynamics, the macro DECLARE_DYNAMICS should be added into the c++ code. Another solution is to use the macro associated to the extension (e.g. the macro DECLARE_DIFFERENCE_EQUATION_MULTIPLE).

In order to produce debug traces, the suffix "_DBG" has to be added. If the dynamics declaration is DECLARE_DYNAMICS_DBG, the all debug levels are available. On the other hand, if the dynamics declaration is DECLARE_DIFFERENCE_EQUATION_MULTIPLE_DBG, only debug traces at level 2, 1 and 0 are available.

Examples

  • Model developer can use the macros TraceModel in the c++ code.
#include <vle/devs/Dynamics.hpp>
#include <vle/devs/DynamicsDbg.hpp>
#include <vle/utils/Debug.hpp>
#include <vle/utils/Trace.hpp>
 
class Agent : public devs::Dynamics
{
   [..]
 
   void devs::Time timeAdvance() const
   {
     DTraceModel("Hello from the timeAdvance function"); // use this macro to print 
     [...]                                       // a message into the log file
 
     DTraceModel((vle::fmt("the value of x is : %1%") % x)); // Use "fmt" in order  
                                                         // to produce parametrized messages
   }
 
   [..]
 
   double x;
};
 
DECLARE_DYNAMICS_DBG(Agent); //Debug traces of DEVS level (level 3) will be printed
  • Usage


This page was last modified on 7 September 2011, at 14:55. This page has been accessed 492 times.