CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   how to use gdb to debug openfoam? (https://www.cfd-online.com/Forums/openfoam-programming-development/108110-how-use-gdb-debug-openfoam.html)

houkensjtu October 15, 2012 07:15

how to use gdb to debug openfoam?
 
HI foamers!
Since I want to implement energy equation to original interFoam solver, I started from test the interFoam by debug tool--gdb.

For example, in order to read the value of rho1 and rho2, I break interFoam in gdb like:

b alphaEqn.H:26

and it do stops at that point. However if I try to output the the value of rho1 by "disp rho1", or other variable, usually the result was:

rho1 = (const Foam::dimensionedScalar &) @0x7fffffff8cd0: {
name_ = {<Foam::string> = {<std::basic_string<char, std::char_traits<char>, std::allocator<char> >> = {
static npos = <optimized out>,
_M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x8a5048 "rho"}}, static typeName = 0x7ffff550c960 "string", static debug = 0,
static null = {<std::basic_string<char, std::char_traits<char>, std::allocator<char> >> = {
static npos = <optimized out>,
_M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7ffff4d784d8 ""}}, static typeName = 0x7ffff550c960 "string", static debug = 0,
static null = <same as static member of an already seen type>}},
static typeName = 0x7ffff550cb92 "word", static debug = 2,
static null = {<Foam::string> = {<std::basic_string<char, std::char_traits<char>, std::allocator<char> >> = {static npos = <optimized out>,
..................

and it seems it's endless and I am totally confused both because I can't find the value of rho1 also I don't understand what these output I got means.

Can someone help?
Thanks in advance!

meindert October 15, 2012 10:08

Try

p rho1.v_

You may find it useful to look into gdbOF (http://openfoamwiki.net/index.php/Contrib_gdbOF) aswell.

houkensjtu October 16, 2012 02:05

Quote:

Originally Posted by meindert (Post 386690)
Try

p rho1.v_

You may find it useful to look into gdbOF (http://openfoamwiki.net/index.php/Contrib_gdbOF) aswell.

Thanks !
I think I need to learn more c++ before debugging source code ...


All times are GMT -4. The time now is 07:32.