How to debug custom SALOME module

Hi everyone,

I have created my custom C++ module using HELLO project as a template.
I am able to build it in both Release and Debug configurations.

Also, I discovered how to load it into SALOME, so everything is fine in Release mode. My module works as expected.

And my question is: how to debug the code of my module?

  1. SALOME crashes if only my module is built in DEBUG mode when I try to switch to the module in already started SALOME.

  2. After that, I had tried to build KERNEL and GUI in debug mode, it looks like I succussed with this, but now SALOME crashes at start-up time. I do not see the exception information under the logo)). But I think that it is caused by Release/Debug mix of run-time libraries.

What is the correct approach to develop (debug) custom modules in SALOME world?

Did you succeed? Would you like to share your experience

Not yet( I am still need some assistance.

Hi,

if you want to debug your module (other modules can stay in release mode):

  • start SALOME,
  • retrieve the pid of process SALOME_Session*
  • start gdb or any other debugger gui (e.g. gdbgui or QtCreator)
  • in your gdb session attach to the process.
    Note that you need to ensure that process tracking is enabled:
    cat /proc/sys/kernel/yama/ptrace_scope
    should return 0

More generally if you want to develop within SALOME, here is the approach you could use - I use it but other more advanced SALOME users may provide some additional tips/tricks.
This is illustrated below for Ubuntu 22.

Note that for Windows, you need to compile every module in debug with SAT, setting debug to yes in SALOME-9.12.0-windows.pyconf

# 0- Extract SALOME archive
tar zxf SALOME-9.12.0-native-UB22.04-SRC.tar.gz
cd SALOME-9.12.0-native-UB22.04-SRC

# 1- setup the developer mode
chmod u+x install_bin.sh
./install_bin.sh

# 2- generate a launcher which will use INSTALL directory instead of BINARIES-UB22.04
sat/sat launcher SALOME-9.12.0-native -n salome


# 3- generate a setup script aimed to set SALOME build and runtime environments
sat/sat environ SALOME-9.12.0-native

# 4- setup SALOME developer environment
source SALOME-9.12.0-native-UB22.04-SRC/env_build.sh

# 5- Prepare your sources and compile in DEBUG mode -  step 4 ensures that relevant environment variables are set.
#    Here you can iterate (make, make install)

# 6- edit file salome and append to it your module (see how this is done with  HELLO)

2 Likes

how to compile salome use sat?

To build SALOME with SAT, repeat steps 0-3. described in my previous reply.

Then, you need to apply the following prescription. Assuming that your module is named MYHELLO, you need to:

  • Describe your module in the SAT syntax, namely:

    • create a python description file PROJECT/products/MYHELLO.pyconf
      Since SAT implements a DAG, ensure that all dependencies are set in key: depends.

    • if MYHELLO compilation requires some advanced approach, implement a script in products/compil_scripts/MYHELLO.sh or products/compil_scripts/MYHELLO.bat

Note that you do have access to some environment variables which are set by SAT: (BUILD_DIR, PRODUCT_INSTALL, SOURCE_DIR, etc…) - look at some scripts

  • define all runtime environment variables in PROJECT/products/MYHELLO.pyconf (section environ)
  • add MYHELLO to PROJECT/applications/SALOME-9.12.0-{native,windows}.pyconf

Then,

  • extract the sources of your project (or module) to SOURCES/MYHELLO

  • you can then compile with : sat/sat compile SALOME-9.12.0-native -p MYHELLO --clean_all

  • Logs files, if any will be saved in LOGS/MYHELLO/{cmake, make, makeinstall, script}

But again, if you want to be efficient , better use first approach described in my first reply.

HTH.

i konw how debug it .first you need to compile debug mode.and you need to attach to process in vs.your need to add you project to gui project and you need need to set ASSEMBLYDEBUG in vs.