Page 1 of 1
debug issues
Posted: Mon Sep 15, 2014 3:35 pm
by abokhanc
Hi all,
I'm adding a utility to ABINIT but i ran into some segmentation faults. What is the easiest way to debug those? I tried to reconfigure with --enable-debug=verbose but that did not do anything for me, so how would i start a debug mode? Is there a way not to re-compile the whole abinit package but rather just my part with like a -traceback flag?
Re: debug issues
Posted: Mon Sep 15, 2014 3:54 pm
by Jordan
The flag I would recommand (at least) to debug a code with segmentation fault are
Code: Select all
-g -O0 -check all -Wall -traceback
for intel compiler or
Code: Select all
-g -O0 -fcheck=all -Wall -fbacktrace
for gnu compiler.
Note that the whole abinit package is tested with the -fcheck=all flag.
configuring abinit with -enable-debug=verbose might not be the best since it produces a lot of debug information (there are sentinels to know in what function/part of the code the problem is).
The options for --enable-debug are
Code: Select all
no : strip debugging symbols
yes : keep debugging symbols and allow for user-defined flags
basic : add '-g' option when the compiler allows for it
verbose : like basic + definition of the DEBUG_VERBOSE CPP option
enhanced : disable optimizations and debug verbosely
paranoid : enhanced debugging with additional warnings
naughty : paranoid debugging with array bound check
In your *.ac file you can try to add the debug flags of your choice to the variable
Code: Select all
fcflags_opt_98_main="-g -O0 -check all -traceback"
That should only modify the makefile in the directory src/98_main and then recompile only the excutable, where your code is I guess.
BUT note that if the abinit package is not compiled with -g and the bug is inside the abinit src, then you won't be able to debug/have information to solve your issue. So this option will help you only the bug is inside ONLY inside your code. That's why I would recommand to rebuild the full abinit package with the same options (Remark : the compilation is usually faster(2x) with those flags than with juste -O2 since the compiler do not try to optimize the code)
Good luck
Jordan
Re: debug issues
Posted: Wed Sep 17, 2014 6:47 pm
by abokhanc
The only *.ac file that i have is configure.ac, and when i put those flags in it doesn't do anything for me. How come --enable-debug doesn't do anything for me when i put that as an argument in my configuration:
../configure --prefix=/home/stud2/bin --disable-mpi --enable-debug FC=ifort CC=icc CXX=icc
Re: debug issues [SOLVED]
Posted: Wed Sep 17, 2014 9:36 pm
by Jordan
Sorry I was not explicity enough.
First, don't modify the configure.ac file.
The *.ac file I was talking about is the one with the name of your compute in place of the *. This file is read by the buildsystem and avoid to avec a configure line too long when using a lot of configure options.
--enable-debug activates only the very basics of debug level so it might not be enough in your case, however you can use a debugger to find the line that causes this segfault.
You can pass the options I suggested on your command line
Code: Select all
../configure --prefix=/home/stud2/bin --disable-mpi --enable-debug FC=ifort CC=icc CXX=icc fcflags_opt_98_main="-g -O0 -check all -traceback"
or maybe better
Code: Select all
../configure --prefix=/home/stud2/bin --disable-mpi --enable-debug FC=ifort CC=icc CXX=icc FCFLAGS_EXTRA="-g -O0 -check all -traceback"
Jordan