|
[Sponsors] |
January 8, 2023, 00:35 |
Build entire Openfoam in debug mode
|
#21 |
Member
Rahul Vadrabade
Join Date: Apr 2018
Posts: 46
Rep Power: 8 |
Hi all,
I would suggest to build Openfoam entirely in debug mode from source code and then custom application/library (WM_COMPILE_OPTION=Debug). It will help to debug into Openfoam code base else you can only debug the custom application/library. However, please note that the building entire Openfoam in debug mode takes lot of time, disk space and memory. So, now it is upto the user to decide to build entire Openfoam to understand it's data structures or custom code in debug to validate only the library implementation. Thanks |
|
January 8, 2023, 00:44 |
|
#22 | |
Member
WY
Join Date: Mar 2020
Posts: 36
Rep Power: 6 |
Quote:
For my case, the main purpose is to debug a small function in one of the Source.C in my new library. So I think it might be unnecessary to recompile the whole OF package in debug mode. Like you said, it is time-consuming and take up large space. Maybe another more appropriate option to interactively debug a small part in OF is to rewrite that part in VS code using C++ language, insert breakpoints, and debugging. Ang suggestion is welcome! Thank you so much! |
||
January 8, 2023, 01:56 |
Wmake -debug
|
#23 |
Member
Rahul Vadrabade
Join Date: Apr 2018
Posts: 46
Rep Power: 8 |
Hi,
It is possible to just build your application library in debug mode with 'wmake -debug' and probably you need to rebuild solver in debug mode in same way. i hope it helps. |
|
January 9, 2023, 00:52 |
|
#24 | |
Member
WY
Join Date: Mar 2020
Posts: 36
Rep Power: 6 |
Quote:
Thanks for your reply! My new library structure looks like below (based on OF5): Code:
newfoam/src --- Make folder --- files --- options --- lnInclude folder --- various symbolic files for .C and .H --- fvOptions folder --- Class_1(Class_1.C, Class_1.H) --- Class_2(Class_2.C, Class_2.H) I use the following code to compile this library: Code:
#!/usr/bin/env bash # Parse arguments for library compilation without documentation by default . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments wmake libso src Code:
wmake -debug libso src I apologize if I ask an obvious question, I am a little bit confused here. |
||
January 9, 2023, 19:50 |
|
#25 |
Member
WY
Join Date: Mar 2020
Posts: 36
Rep Power: 6 |
Hi Rvadrabade,
I try to compile with debug flag only my customized library using the command: Code:
wmake -debug libso src Code:
unknown option: '-debug libso src' Usage: wmake [OPTION] [dir] wmake [OPTION] target [dir [MakeDir]] options: -silent | -s Quiet mode (does not echo commands) -all | -a wmake all sub-directories, running Allwmake if present -queue | -q wmakeCollect all sub-directories, running Allwmake if present -non-stop | -k Compile without stopping when errors occur -j Compile using all local cores/hyperthreads -j <N> | -j<N> Compile using N cores/hyperthreads -no-scheduler Compile without wmakeScheduler -update Update lnInclude directories, dep files, remove deprecated files and directories -help | -h Print the usage Thanks! |
|
January 9, 2023, 23:27 |
Debug mode availablity
|
#26 |
Member
Rahul Vadrabade
Join Date: Apr 2018
Posts: 46
Rep Power: 8 |
Hi,
Yes you are correct. I should have checked in Openfoam 5 version, where the flag is not added yet. However, the flag is available with Openfoam 2212 (https://develop.openfoam.com/Develop...er/wmake/wmake). I hope, you can look into the script and find a way. I will tell you if I found any lead. Further, i suggest to build entire Openfoam in debug mode on other system and start working on your topic. Meanwhile, you can continue exploring possibility of compiling single library/app in debug mode. It will save some time. |
|
January 10, 2023, 19:06 |
|
#27 | |
Member
WY
Join Date: Mar 2020
Posts: 36
Rep Power: 6 |
Quote:
Thanks for your suggestion! For OpenFOAM 5.x, I find the way to compile certain application or library into debug mode is to add the entry "-g" or "-ggdb3 -DFULLDEBUG" at the first line in Make/options. Take icoFoam solver as an example, the corresponding Make/option file is Code:
EXE_INC = \ -g \ # added to debug only icoFoam solver -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = \ -lfiniteVolume \ -lmeshTools So now with icoFoam (debug compiling) and OpenFoam 5.x (opt compiling), I try to use GDB in command line to debug it. And I find some commands of GDB cannot run normally. For example, the "step" command will not step into function but go next line (same as "next" command). I type "info sharedlibrary" to check the information of library, and I obtain: Code:
(gdb) info sharedlibrary From To Syms Read Shared Object Library 0x00007ffff7dd3f10 0x00007ffff7df4550 Yes /lib64/ld-linux-x86-64.so.2 0x00007ffff65106d0 0x00007ffff6ee3e44 Yes (*) /home/ying/OpenFOAM5/OpenFOAM-5.x/platforms/linux64GccDPInt32Opt/lib/libfiniteVolume.so 0x00007ffff58860c0 0x00007ffff5b12f36 Yes (*) /home/ying/OpenFOAM5/OpenFOAM-5.x/platforms/linux64GccDPInt32Opt/lib/libmeshTools.so 0x00007ffff4ea2180 0x00007ffff5388aaa Yes (*) /home/ying/OpenFOAM5/OpenFOAM-5.x/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so 0x00007ffff49efe50 0x00007ffff49f0bee Yes /lib/x86_64-linux-gnu/libdl.so.2 0x00007ffff46f2490 0x00007ffff47a19de Yes (*) /usr/lib/x86_64-linux-gnu/libstdc++.so.6 0x00007ffff42d3a80 0x00007ffff43921d5 Yes /lib/x86_64-linux-gnu/libm.so.6 0x00007ffff40b2ac0 0x00007ffff40c336d Yes (*) /lib/x86_64-linux-gnu/libgcc_s.so.1 0x00007ffff3ce0360 0x00007ffff3e58afc Yes /lib/x86_64-linux-gnu/libc.so.6 0x00007ffff3ab3ea0 0x00007ffff3abb072 Yes (*) /home/ying/OpenFOAM5/OpenFOAM-5.x/platforms/linux64GccDPInt32Opt/lib/openmpi-system/libPstream.so 0x00007ffff382b840 0x00007ffff3883464 Yes (*) /home/ying/OpenFOAM5/OpenFOAM-5.x/platforms/linux64GccDPInt32Opt/lib/libtriSurface.so 0x00007ffff353b600 0x00007ffff35b3eb2 Yes (*) /home/ying/OpenFOAM5/OpenFOAM-5.x/platforms/linux64GccDPInt32Opt/lib/libsurfMesh.so 0x00007ffff329bc00 0x00007ffff32e725d Yes (*) /home/ying/OpenFOAM5/OpenFOAM-5.x/platforms/linux64GccDPInt32Opt/lib/libfileFormats.so 0x00007ffff304ff90 0x00007ffff3063640 Yes (*) /lib/x86_64-linux-gnu/libz.so.1 0x00007ffff2d7e410 0x00007ffff2e0cc10 Yes (*) /usr/lib/x86_64-linux-gnu/libmpi.so.20 0x00007ffff2b42bb0 0x00007ffff2b511f1 Yes /lib/x86_64-linux-gnu/libpthread.so.0 0x00007ffff28c8d00 0x00007ffff291f1bf Yes (*) /usr/lib/x86_64-linux-gnu/libopen-rte.so.20 0x00007ffff2620a50 0x00007ffff2685586 Yes (*) /usr/lib/x86_64-linux-gnu/libopen-pal.so.20 0x00007ffff23fd200 0x00007ffff240070c Yes /lib/x86_64-linux-gnu/librt.so.1 0x00007ffff21c3700 0x00007ffff21ecd2a Yes (*) /usr/lib/x86_64-linux-gnu/libhwloc.so.5 0x00007ffff1fbbe70 0x00007ffff1fbc93a Yes /lib/x86_64-linux-gnu/libutil.so.1 0x00007ffff1db2e30 0x00007ffff1db7939 Yes (*) /usr/lib/x86_64-linux-gnu/libnuma.so.1 ---Type <return> to continue, or q <return> to quit--- 0x00007ffff1ba7eb0 0x00007ffff1bac272 Yes (*) /usr/lib/x86_64-linux-gnu/libltdl.so.7 0x00007ffff199d2a0 0x00007ffff19a31ac Yes /lib/x86_64-linux-gnu/libnss_compat.so.2 0x00007ffff1792070 0x00007ffff17990d9 Yes /lib/x86_64-linux-gnu/libnss_nis.so.2 0x00007ffff157a090 0x00007ffff15878a7 Yes /lib/x86_64-linux-gnu/libnsl.so.1 0x00007ffff1366350 0x00007ffff136cd8f Yes /lib/x86_64-linux-gnu/libnss_files.so.2 (*): Shared library is missing debugging information. Considering the partial debugging cannot dive deep into source code of OpenFOAM, I plan to recompile whole OpenFOAM-5.x in debug mode as you suggested. And then I can use VSCode to debug my library. This is really a tough decision, after investigating various possible debugging methods. I have already installed three different versions of OF on my pc (I use VMware-Ubuntu virtual machine)... Ang suggestion is welcome! |
||
January 11, 2023, 00:55 |
Meaning of flags
|
#28 |
Member
Rahul Vadrabade
Join Date: Apr 2018
Posts: 46
Rep Power: 8 |
Hi,
Excellent work and sharing your findings. Yes, your understanding is correct and then entire Openfoam need to be build in debug mode to navigate deep into base code. Further, -g and -ggdb3 are c++ debug flags which creates debug symbols in the compiled objects. -DFULLDEBUG is preprocessor directive which enables additional code compilation i.e if we define FULLDEBUG then extra code is compiles e.g do check https://github.com/OpenFOAM/OpenFOAM...orSpaceI.H#L95. Resource: https://www.cs.uic.edu/~jbell/Course...processor.html Thanks |
|
January 11, 2023, 22:35 |
|
#29 | |
Member
WY
Join Date: Mar 2020
Posts: 36
Rep Power: 6 |
Quote:
Thanks for your information! And thanks again for your VSCode debugging structure for OpenFOAM source code! |
||
January 16, 2023, 22:35 |
|
#30 | |
Member
WY
Join Date: Mar 2020
Posts: 36
Rep Power: 6 |
Quote:
Can I ask a general programming question in OF? I am studying the source code of a library which includes multiple Classes, and I am confused about the order of call and execution of various Classes. Does any part in source code give such information, like the Constructor part? And also each class define many functions (protected member functions, member functions), how can I know the order of call of these functions? I apologize for asking such a naive question. Thanks! |
||
January 17, 2023, 00:07 |
Callstack
|
#31 |
Member
Rahul Vadrabade
Join Date: Apr 2018
Posts: 46
Rep Power: 8 |
It is achieved with callstack. It is available in visual studio code. Add few breakpoints and star debugging. Check the callstack window. Please explore it.
|
|
Tags |
debugging, vscode |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
The udf.h headers are unable to open- in VISUAL STUDIO 13 | sanjeetlimbu | Fluent UDF and Scheme Programming | 4 | May 2, 2016 06:38 |
freelancer/pay:Coding solidworks flow simulation API using microsoft visual studio | Edreez | CFD Freelancers | 1 | December 8, 2015 12:18 |
Compiling Fluent UDF with Visual Studio | kamnaz | Fluent UDF and Scheme Programming | 0 | August 28, 2014 13:58 |
Error with visual studio installation | akshaymanikjade | FLUENT | 1 | January 31, 2013 00:30 |
error while compiling a udf | rahul | FLUENT | 10 | August 30, 2006 09:33 |