C++ source code debuggers
If you know roughly where a bug is occurring in the code, you can often
debug it by temporarily inserting printf or std::cout <<
statements in the code. But for more complex problems it can be more
informative and quicker in the long run to create a debugging build (i.e.,
one with debugging symbols and perhaps with compiler optimizations
disabled) and run the program in a debugger. This section provides
general information on running OOMMF in a debugger, including short
examples in three common debuggers: gdb, lldb, and Visual
Studio Debugger.
First edit the configuration files for debugging, as explained in
the Configuration files
section.
Then run
$ tclsh oommf.tcl pimake distclean
$ tclsh oommf.tcl pimake
to create a build of OOMMF with debugging symbols. After this you can
load an OOMMF executable into a debugger, run the
program, and examine its execution. (Remember to bypass
the oommf.tcl bootstrap.) There are many debuggers
available, some with multiple front-ends. But one overriding criterion
in selecting a debugger is to choose one that supports the debugging
symbol format output by your C++ compiler. To provide a brief
taste of this subject, we will look at three debuggers: GNU's venerable
gdb for use with g++, the lldb debugger packaged with
Xcode/clang++ on macOS, and the debugger built into Microsoft's
Visual Studio for use with Visual C++ cl binaries.
Subsections
OOMMF Documentation Team
September 27, 2024