-
Notifications
You must be signed in to change notification settings - Fork 0
Debugging
In general all classic debugging strategies remain valid to debug MueLu but some specific flags, functions and debugger instructions can help speed up the process!
Run GDB with input arguments:
gdb --args ./MueLu_UnitTests.exe --test-name=MakeTentative
If you need to break somewhere try:
(gdb) b myFile.cpp:lineWhereToStop
sometime this might not work due to dynamic libraries that are not loaded, so you can try putting a first break point in main.cpp and then adding more specific break points from there. You can also make a specific break points conditional on an expression with the following syntax:
cond breakpoint# conditional-expression
If you are using multiple breakpoints in the same run you can purposely set a variable to skip later conditional break points based on early program behavior, this can be done like this for a string called a:
call a.assign("ok");
To catch exceptions use:
(gdb) catch throw
Teuchos has some advanced printing capabilities and MueLu relies on it to print with various levels of details, see src/MueCentral/MueLu_VerbosityLevel.hpp for more details. I personally like to use the following in my code:
// Print from all processes
RCP<Teuchos::FancyOStream> fancy = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
fancy->setShowAllFrontMatter(false).setShowProcRank(true);
Teuchos::FancyOStream& out = *fancy;
// // Print from a particular rank
// const int procRank = Teuchos::GlobalMPISession::getRank();
// Teuchos::oblackholestream blackhole;
// std::ostream& out = ( procRank == 0 ? std::cout : blackhole );
// // Do not print anything
// Teuchos::oblackholestream blackhole;
// std::ostream& out = blackhole;
You can uncomment the appropriate lines to get the desired print behavior during run time. You could be fancier and use an environment variable to activate the right print level without recompiling.
Quite often objects and data are wrapped with Teuchos::RCP for convenient memory management, however this might lead to very large error messages that make debugging hard. You can currently find here a manual for Teuchos::RCP with information on debugging in section 5.11
Xpetra
MueLu
MueMex
Kokkos refactor
using git
building
debugging
checking code
unit-tests
cdash dashboard
nightly tests
memory checks