Hi to all
Can gdb (or some other debugger) trace or break at a chosen line in a solver where of course the solver is listed in the SIF and the SIF is the argument to ElmerSolver or ElmerSolver_mpi ?
Have a nice week-end
how to debug solvers
-
- Site Admin
- Posts: 4826
- Joined: 22 Aug 2009, 11:57
- Antispam: Yes
- Location: Espoo, Finland
- Contact:
Re: how to debug solvers
Yes, gdb also works for the Solvers that are loaded dynamically at run time. Also when debugging solvers it is a good idea to set the "max output level" to a high number (<=32) so that you get more information on what is going on. -Peter
Re: how to debug solvers
I should have deleted or closed this thread before any replies since we went through all this in my Sep 2021 threads. I should first make it a habit of searching through my previous threads or journals as my memory evidently fails.
Apologies to all
Apologies to all
Re: how to debug solvers
Except that I still cannot debug: After running
$ elmerf90 -O0 -g -DFULLDEBUG mySolver.so mySolver.F90
$ gdb ElmerSolver
(gdb) l mySolver.F90:1
yields
No source file mySolver.F90.
(The folder where these commands are run contains a file ELMERSOLVER_STARTINFO and a file case.sif. The contents of file ELMERSOLVER_STARTINFO are of course only case.sif and, file mySolver.F90 is of course contained in a solver of file case.sif)
Regards to all
$ elmerf90 -O0 -g -DFULLDEBUG mySolver.so mySolver.F90
$ gdb ElmerSolver
(gdb) l mySolver.F90:1
yields
No source file mySolver.F90.
(The folder where these commands are run contains a file ELMERSOLVER_STARTINFO and a file case.sif. The contents of file ELMERSOLVER_STARTINFO are of course only case.sif and, file mySolver.F90 is of course contained in a solver of file case.sif)
Regards to all
-
- Site Admin
- Posts: 4826
- Joined: 22 Aug 2009, 11:57
- Antispam: Yes
- Location: Espoo, Finland
- Contact:
Re: how to debug solvers
Hi
ElmerSolver takes care of the loading of "mySolver". What if you say:
(gdb) run
-Peter
ElmerSolver takes care of the loading of "mySolver". What if you say:
(gdb) run
-Peter
Re: how to debug solvers
(gdb) run or (gdb) r
indeed makes it run but you then have to do CNTL-C to stop it. Once it is stopped, you can now type
(gdb) l mySolver.F90:1
(gdb) b mySolver.F90:1
or whatever you want and the commands now work ! They don't complain about no source file anymore. They even work if you first typed
(gdb) k
right after it was stopped.
This is strange behaviour: If I wanted to run gdb myProg where myProg has nothing to do with Elmer and was compiled and linked with say C++ then I don't need to do (gdb) r in order to list its source code or set a breakpoint.
indeed makes it run but you then have to do CNTL-C to stop it. Once it is stopped, you can now type
(gdb) l mySolver.F90:1
(gdb) b mySolver.F90:1
or whatever you want and the commands now work ! They don't complain about no source file anymore. They even work if you first typed
(gdb) k
right after it was stopped.
This is strange behaviour: If I wanted to run gdb myProg where myProg has nothing to do with Elmer and was compiled and linked with say C++ then I don't need to do (gdb) r in order to list its source code or set a breakpoint.
-
- Site Admin
- Posts: 4826
- Joined: 22 Aug 2009, 11:57
- Antispam: Yes
- Location: Espoo, Finland
- Contact:
Re: how to debug solvers
Hi
Probably it has to do with mySolver being dynamically linked. It is not in memory before ElmerSolver is execured and the module is loaded at runtime. This helps in developing the multiphysics features but sometimes causes some headache. On some HPC platform we could never get the DLL's to work but luckily that was an exception.
-Peter
Probably it has to do with mySolver being dynamically linked. It is not in memory before ElmerSolver is execured and the module is loaded at runtime. This helps in developing the multiphysics features but sometimes causes some headache. On some HPC platform we could never get the DLL's to work but luckily that was an exception.
-Peter
Re: how to debug solvers
Correction on my last reply
gdb myProg for my C++ program myProg also does not display source files contained contained in one of the dll's it called. And the issue is not limited to gdb but to debugger arm ddt as well. In all cases, you have to run the program in order to display the source files. And in addition, it is required to compile the source files with the option -g -DFULLDEBUG.
So finally I can run
ddt mpirun -n 2 MyOpenFoamProg -parallel : -n 2 ElmerSolver_mpi case.sif
where case.sif contains solver MyElmerProg
and all source files are displayed.
Greatest thanks
gdb myProg for my C++ program myProg also does not display source files contained contained in one of the dll's it called. And the issue is not limited to gdb but to debugger arm ddt as well. In all cases, you have to run the program in order to display the source files. And in addition, it is required to compile the source files with the option -g -DFULLDEBUG.
So finally I can run
ddt mpirun -n 2 MyOpenFoamProg -parallel : -n 2 ElmerSolver_mpi case.sif
where case.sif contains solver MyElmerProg
and all source files are displayed.
Greatest thanks