debugging yade

Asked by Bettina Suhr

Dear all,

I would like to debug some part of yade, which is written in python. Is this possible using kdevelop? Or using some other tool?

I use ubuntu 20.04 and installed kdevelop 5.5.0. After downloading current yade source files from GitLab, I compiled it using debug flags.
Following the instructions from [1], I can now start a debug session from within kdevelop. The debugger in action is gdb (which can deal with c++, but not with python, when I understand correctly). So, I can set breakpoints in the c++ code and debugging works as expected.
However, I would like to debug parts of yade, which are written in python. Any suggestions how to do this?

Thanks in advance and best regards,
Bettina

[1] https://yade-dem.org/wiki/Debugging_using_Kdevelop

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Robert Caulk
Solved:
Last query:
Last reply:
Revision history for this message
Robert Caulk (rcaulk) said :
#1

One of the simplest ways to debug python is to use

import pdb

then insert:

pdb.set_trace()

Where you want to stop and examine the scope.

Otherwise, you should be able to add breakpoints in your IDE similar to how you do it with C++.

Cheers,

Robert

Revision history for this message
Bettina Suhr (bettina-suhr) said :
#2

Hi Robert,

Thanks for the suggestion to use pdb

I tried the approach and added import pdb and pdb.set_trace() to export.py in function textClumps()
After running make install, I ran yade with the save-load-clumps.py example and could use pdb in yade as expected.

I would like to use the debugger to better understand the clump breakage algorithm implemented in trunk/py/bf/bf.py.
Therefore, I added the import pdb and pdb.set_trace() in bf.py and ran the example clumps-breakage/uniaxial_clump.py in yade.
The calculation stopped, where I set the pdb.set_trace() command, but I didn’t get a (pdb) prompt, as I did before.
Whatever I type in the shell, e.g. ll, gives me a syntax error.

Any idea what could be the problem here?

Thanks,
Bettina

~/Yade20220610DEBUG/install/bin/yade-Unknown uniaxial_clump.py
Welcome to Yade Unknown
Using python version: 3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0]
TCP python prompt on localhost:9000, auth cookie `scuads'
XMLRPC info provider on http://localhost:21000
Running script uniaxial_clump.py
[[ ^L clears screen, ^U kills line. F12 controller, F11 3D view (press "h" in 3D view for help), F10 both, F9 generator, F8 plot. ]]

In [1]> /home/bettinasuhr/Yade20220610DEBUG/install/lib/x86_64-linux-gnu/yade-Unknown/py/yade/bf/bf.py(91)checkFailure()
-> if weibull: # I just modify potential sigma_eff before checking conditions
In [1]*** SyntaxError: invalid syntax

Revision history for this message
Karol Brzezinski (kbrzezinski) said :
#3

Hi Bettina,

Unfortunately, I cannot help with the debugging issue.

However, I will be happy to answer any questions related to the implementation of the clump breakage algorithm. You can also contact me via email provided in the paper describing this algorithm [1].

When it comes to the line from your message [2]:
> if weibull: # I just modify potential sigma_eff before checking conditions

It conditionally turns on the scale effect on the strength of the particle. There is a coefficient that increases strength based on Weibull distribution parameters. However, it was easier for us to decrease stress instead of modifying the strength.

Best wishes,
Karol

[1] https://doi.org/10.1016/j.triboint.2022.107661
[2] https://gitlab.com/yade-dev/trunk/-/blob/master/py/bf/bf.py#L90

Revision history for this message
Bettina Suhr (bettina-suhr) said :
#4

Hi Karol,

Thank you very much for your kind offer. I might come back to it.
At the moment, I’m trying to define/break different clumps to learn how to set the different parameters of the algorithm.

Best regards,
Bettina

Revision history for this message
Best Robert Caulk (rcaulk) said :
#5

>>Any idea what could be the problem here?

pdb has its limits. Especially in boost wrapped environments like this.

If you are serious about debugging then you should look at using VSCode to get a fully functional workspace at breakpoints inside the project.

If you install it and try, then maybe we can work through getting it set up together.

Revision history for this message
Bettina Suhr (bettina-suhr) said :
#6

Hi Robert,

Thank your for your answer and for your kind offer.
For what I’m doing now this is probably too much effort. I will use print command instead.

Best regards,
Bettina

Revision history for this message
Bettina Suhr (bettina-suhr) said :
#7

Thanks Robert Caulk, that solved my question.