Skip to content

Commit

Permalink
MDT debugger update
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Jun 14, 2015
1 parent 7c89011 commit f8241b3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 39 deletions.
3 changes: 0 additions & 3 deletions usersguide-sphinx/source/faq.rst
Expand Up @@ -100,6 +100,3 @@ OMDev - OpenModelica Development Environment
lvprcsrv.exe is running, kill it and/or prevent it to start again
at reboot; it does not do anything really useful, not needed for
operation of web cameras or mice.

.. |image46| image:: media/image87.png
.. |image47| image:: media/image88.png
78 changes: 42 additions & 36 deletions usersguide-sphinx/source/mdtdebugger.rst
@@ -1,15 +1,21 @@
.. role:: bash(code)
:language: bash

MDT Debugger for Algorithmic Modelica
=====================================

The algorithmic code debugger, used for the algorithmic subset of the
Modelica language as well as the MetaModelica language is described in
Section 9.1. Using this debugger replaces debugging of algorithmic code
Section :numref:`eclipse-based-debugger-algorithms`.
Using this debugger replaces debugging of algorithmic code
by primitive means such as print statements or asserts which is complex,
time-consuming and error- prone. The usual debugging functionality found
in debuggers for procedural or traditional object-oriented languages is
supported, such as setting and removing breakpoints, stepping,
inspecting variables, etc. The debugger is integrated with Eclipse.

.. _eclipse-based-debugger-algorithms :

The Eclipse-based Debugger for Algorithmic Modelica
---------------------------------------------------

Expand All @@ -34,7 +40,9 @@ The debugger provides the following general functionalities:

- Suspend – interrupts the running program.

Figure 968. **Debugging functionality.**
.. figure :: media/mdt-debugger-overview.png
Debugging functionality.
Starting the Modelica Debugging Perspective
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -57,25 +65,28 @@ Create mos file

In order to debug Modelica code we need to load the Modelica files into
the OpenModelica Compiler. For this we can write a small script file
like this,

setCommandLineOptions({"+d=rml,noevalfunc","+g=MetaModelica"});
like this:

setEnvironmentVar("MODELICAUSERCFLAGS","-g");
.. omc-loadstring ::
loadFile("HelloWorld.mo");
function HelloWorld
input Real r;
output Real o;
algorithm
o := 2 * r;
end HelloWorld;
getErrorString();
.. omc-mos ::
HelloWorld(120.0);

getErrorString();
setCommandLineOptions({"+d=rml,noevalfunc","+g=MetaModelica"})
setCFlags(getCFlags() + " -g")
HelloWorld(120.0)
So lets say that we want to debug HelloWorld.mo. For that we must load
it into the compiler using the script file. Put all the Modelica files
there in the script file to be loaded. We should also initiate the
debugger by calling the starting function, in the above code
HelloWorld(120.0);
``HelloWorld(120.0)``;

Setting the debug configuration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -84,7 +95,9 @@ While the Modelica perspective is activated the user should click on the
bug icon on the toolbar and select Debug in order to access the dialog
for building debug configurations.

Figure 969. **Accessing the debug configuration dialog.**
.. figure :: media/mdt-debugger-config-1.png
Accessing the debug configuration dialog.
To create the debug configuration, right click on the classification
Modelica Development Tooling (MDT) GDB and select New as in figure
Expand All @@ -97,7 +110,9 @@ Note that we require Gnu Debugger (GDB) for debugging session. We must
specify the GDB location, also we must pass our script file as an
argument to OMC.

Figure 970. **Creating the Debug Configuration.**
.. figure :: media/mdt-debugger-config-2.png
Creating the Debug Configuration.
Setting/Deleting Breakpoints
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -106,33 +121,20 @@ The Eclipse interface allows to add/remove breakpoints. At the moment
only line number based breakpoints are supported. Other alternative to
set the breakpoints is; function breakpoints.

Figure 971. **Setting/deleting breakpoints.**
.. figure :: media/mdt-debugger-breakpoint.png
Setting/deleting breakpoints.
Starting the debugging session and enabling the debug perspective
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

|image46|
.. figure :: media/mdt-debugger-start-1.png
Figure 972. **Starting the debugging session.**
Starting the debugging session.
|image47|
.. figure :: media/mdt-debugger-start-2.png
Figure 973. **Eclipse will ask if the user wants to switch to the
debugging perspective.**

Debugging OpenModelica
~~~~~~~~~~~~~~~~~~~~~~

- Compile and create OpenModelica executable as usual.

- Go to /trunk/Compiler/boot

- Now run make –f Makefile.omdev.mingw (choose the right make file
depending on your platform), this will create a bootstrapped omc
and will replace the omc executable in /trunk/build/bin.

- Now in the debug configuration as explained in Section 9.1.1.2 choose
omc executable as the program.
Eclipse will ask if the user wants to switch to the debugging perspective.
The Debugging Perspective
~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -167,6 +169,10 @@ track of the variables values. If the value of any variable is changed
while stepping then that variable will be highlighted yellow (the
standard Eclipse way of showing the change).

Figure 974. **The debugging perspective.**
.. figure :: media/mdt-debugger-perspective.png
The debugging perspective.
.. figure :: media/mdt-debugger-switch-perspective.png
Figure 975. **Switching between perspectives.**
Switching between perspectives.

0 comments on commit f8241b3

Please sign in to comment.