问题
I am trying to breakpoint a fortran program with lldb
on a Mac OS 10.12.5 system. I have
program badcall
integer a,b
a=2
b=3
write(*,*) a, b
end
I (have to) compile with the intel compilers.
ifort -g badcall.f90 -o badcall
then I run with lldb
and do
breakpoint set -f badcall.f90 -l 5
programs stops normally
Process 59474 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100000f35 prova`MAIN__ at badcall.f90:6
3 a=2
4 b=3
5
However if I then try to print the variable b
I get nothing
(lldb) p b
(lldb) print b
(lldb) q
So am I missing something? Is lldb
really usable to debug fortran code?
回答1:
It seems that lldb doesn't support Fortran, yet :( You will have to go with gdb:
curl "http://ftp.gnu.org/gnu/gdb/gdb-8.0.tar.gz" -o gdb-8.0.tar.gz
tar zxf gdb-8.0.tar.gz
cd gdb-8.0
./configure
make
Make sure to Code Sign the gdb! Follow instructions here:
https://gcc.gnu.org/onlinedocs/gcc-4.8.1/gnat_ugn_unw/Codesigning-the-Debugger.html
and you should be good to go
gfortran -g -o fort_sample ./fort_sample.f90
gdb ./fort_sample
(gdb) list
1 program badcall
2 integer a,b
3 a=2
4 b=3
5
6 write(*,*) a, b
7 end
(gdb) break 6
Breakpoint 1 at 0x100000e0e: file ./fort_sample.f90, line 6.
(gdb) run
...
...
badcall () at ./fort_sample.f90:6
6 write(*,*) a, b
(gdb) print a
$1 = 2
(gdb) print b
$2 = 3
(gdb)
来源:https://stackoverflow.com/questions/44988718/is-lldb-working-with-fortran