I am trying to debug and profile (ideally line-by-line time spent) Fortran code on an M1 Mac. Most commands I tried don't seem to work for Fortran and/or M1.
gdb
seems outdated and won't runlldb
complains that it does not work on M1.- I tried Time Profiler within Instruments, but I cannot make any sense of the recorded output.
If someone could tell me which commands or flags are needed or show and example, that'd be greatly appreciated!
Context: I'm trying to find some bottlenecks for optimization of serial code and in addition, an OpenMP version of my subroutine just stops with "Illegal instruction: 4", so I'm trying to find out why this is happening (stack and OMP_STACKSIZE
is large).
EDIT - To give some more details:
I am compiling with gfortran
(Homebrew GCC 13.1.0). So wanted to compile with -p -pg
option and run gdb ./a.out
, but installing gdb
fails with
"gdb: The x86_64 architecture is required for this software."
also adding the -pg
option during compilation does not seem to work. It complains that "ld: library not found for -lgcrt1.o" but this file is nowhere to be found (neither in homebrew nor on the Xcode SDK packages) and brew install glibc
(of which gcrt1.o seems to be part of) also does not work ("glibc: Linux is required for this software.").
I managed to start lldb ./a.out
, but this seems useless to me. I can set a break point, but if I try to print out a variable (e.g. p (int) ix
, I get "error: Could not find type system for language fortran95: TypeSystem for language fortran95 doesn't exist".
So in summary just stepping through any simple little fortran program in a debugger does not work for me on an M1 Mac. If someone knows how to make this work or where to find those missing libraries, that would greatly be appreciated. Extra credit would be a line-by-line-time-spent output to help me find where the bottleneck is.