Debugging code using gdb

Hello,

Right now, I know how to debug code using gdb with help of visual studio code, however, I can not figure it out how to start debugging the codes in GUI and check the memory, can you advise me, please?

Thank you in advance!

Are you on a Windows or Linux system?
If you have Linux, you should have gdb already as part of the OS, or install it using your package manager.
If you are on Windows, gdb is available as a conda-forge package - with the mfix environment activated, do conda install -c conda-forge gdb
or, if using miniforge/mamba, mamba install gdb

GDB on Windows does not work well. There is no core file facility, so postmortem debugging is impossible, and you cannot attach to a running process the way you can on Linux. But you can build a batch-mode solver and execute it inside of gdb:

C:> gdb .\mfixsolver.exe
(gdb) run -f myproj.mfx

The interactive solver is implemented as a Python module so it’s a little trickier to debug. In that case the binary you are debugging is the Python interpreter itself, and
you would do

C:> gdb python
(gdb) run -m mfixgui.pymfix -f myproj.mfx
1 Like

Thank you for your fast reply.

can you bear with me at this point? How can i attach it to a running process?

After I wrote the following command

C:> gdb .\mfixsolver.exe
(gdb) run -f run_1.mfx

I got the following

and for the second command, I got the following

I am confused, can you advise me on how to proceed?

The messages from gdb are telling you that in the first instance, there is no mfixsolver.exe in the current directory. I assumed you had built a custom solver (batch).

The second one doesn’t work because you are in the (base) conda environment. You have to do this with the MFiX environment active, as I mentioned.

On Linux the solver is called mfixsolver rather than mfixsolver.exe. I mistakenly thought you were on a Windows platform. So for the batch solver,

gdb ./mfixsolver

for a custom built batch mfixsolver in the current project dir

I am following the same procedures you have mentioned

I am in the directory, and the mfix solver is available, however, I am getting the following error
“not in executable format:file format not recognized”

Solved based on the following discussion.

1 Like