Debugging the Application

From KratosWiki
Jump to: navigation, search

Here we briefly address the debugging procedure. Usually, if you work in Windows, the programming environment such as Visual Studio, provides a built-in debugging tool. However, in Linux it is not the case. We recommend to use a simple debugging program KDbg, which is available for the free download.


FIRST OF ALL!!!! COMPILE KRATOS IN DEBUG!!!!!!! by executing the following:

To be changed in the cmake configure file:

-DCMAKE_BUILD_TYPE=Debug 

To be added in the cmake configure file:

-DDO_NOT_DEFINE_NDEBUG=ON
-DKRATOS_DEBUG=ON


In the Terminal ( Aplications -> Accesories -> Terminal) type:

rm Libs /*

/kratosR1/bjam install -debug

Afterwards, to debug your application you need to add the following line to your application code (we assume, that it is written in Python) somewhere in the beginning (before you start executing any functions):

  x = raw_input("stopped to allow debug: set breakpoints and press enter to continue");

When you execute the application, it will stop at this point, and you will be able to set the breakpoints in the c++ files that you want to debug, and that are being called by your python application.

1) Run KDbg

2) Goto "Executable" and browse python.exe

3) Goto Execution -> Arguements and set the working directory to your application directory and set the command line argument to your application name, e.g.

Working directory

  /kratosR1/applications/structural_application/test_examples/my_dream_application/

Command line argument

  my_application.py


4) Press the run shortcut

Now the following will be executed (once you have done step 3):

   /kratosR1/applications/structural_application/test_examples/my_dream_application/python.exe my_application.py

5) The line that we have added to my_application.py in the beginning, which was

  x = raw_input("stopped to allow debug: set breakpoints and press enter to continue")

enables us now to set the break points for the functions we want to debug.

5.1) Go to: File -> Open Source, choose the file you wish to set the breakpoints at. Set the breakpoints at the lines you are planning to debug, e.g. if you want to debug the function CalculateLocalSystem of the UpdatedLagrangianFluid element, set the break point right at the function definition.


  (o)   void UpdatedLagrangianFluid::CalculateLocalSystem(MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, ...)
  {
  KRATOS_TRY
  .///////
  }

To enter inside the internal function call press F10 or F11

6) Enjoy the debugging! (and do not forget that for this Kratos needs to be compiled in the DEBUG, which is done by running):


Look more of core dump

More information about unfavorable "core dump" error could be obtained as follow: 1) in command line that you are running your example type

ulimit -c unlimited

2) run python of example

2)run kdbg

3) choose python as executable

4) from file carpet choose core dump and then choose in your example file the core file

5) in stack window of Kdbg you can see more information of core dump

Personal tools
Categories