I have a Fortran program compiled with gfortran
with the -fcheck=bounds
compiler option. This causes the code to report "array out of bounds" errors and subsequently exit.
I would like to debug my program using gdb
to find the cause of the error. Unfortunately in gdb
the code will still just exit on an out of bounds error.
Is there a way to tell gdb
to stop execution when an out of bounds error occurs?
Compile with -g
to get debugging information. Then, first, I placed a break point on exit
, this works fine, once the program stops you'll be able to backtrace from exit
to the point of the error.
The backtrace also passes through a function called _gfortran_runtime_error_at
, so you might have more luck placing the breakpoint there, this worked for me, and obviously will only trigger when you get a run time error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With