3

I am calling fortran 90 code from a c code. There is a main() (in c) that calls a wrapper function in the same file, that calls a fortran subroutine (actually in a liblibrary.a). I am working on linux. Now, I'm using gdb to debug the executable, but it cannot find the main.c file. I added the working directory using

directory /my/working/directory

but still it says there is no file named main.c
If I type list inside gdb it shows me a piece of fortran code. If I type show language, it says The current source language is auto; currently c.
If I run the executable and then I interrupt it and look to the stack it will show me the c-functions I am calling, but it will not state the source file, that instead will state for the fortran subroutine and function.
I am trying to investigate if I am passing the variables correctly from c to fortran and backwards, I suspect I am not.

The same thing happens in idb, more or less. when I try to put a break in main.c, it says not found. I compiled the fortran code with these flags:

-g -O0 -check bounds -warn all -traceback -align all -align rec8byte

and the c-code with:

-g -O0  -Wall

All suggestions are welcome.

favo
  • 5,426
  • 9
  • 42
  • 61
simona
  • 2,009
  • 6
  • 29
  • 41
  • What do you get if you type "b 1" (break at the very first line of code). You would normally get 'Breakpoint 1 at 0xXXXXXXXX: file main.c, line 1." Do you? – Tim Gee Jan 14 '12 at 22:44
  • I get "Breakpoint 1 at 0x404f7f: file eos2_wrapper.f90, line 1." that is the filename of the subroutine wrapper of the fortran function - so we are already in the library liblibrary.a – simona Jan 14 '12 at 23:06
  • directory /my/working/directory specifies an absolute path, is this the absolute path or relative path of the source directory? – Tim Gee Jan 14 '12 at 23:10
  • when I type 'show directories' I get 'Source directories searched: $cdir:$cwd'. Then I use 'directory /my/absolute/path' to set the absolute path. Now 'show directories' says '/my/absolute/path/:$cdir:$cwd'. I want to add that the liblibrary.a is in another path than my c-source. – simona Jan 14 '12 at 23:16

1 Answers1

2

Hello you need additional flag to put debug info into your executable. Here is manual for intel compiler: http://cache-www.intel.com/cd/00/00/34/75/347599_347599.pdf Please try -debug full as on page 35 written.

Eugen
  • 122
  • 5
  • Thank you! This solves my problem. At page 123 of the same manual they say the option for generating full debugging information is -g. Isn't it a little ambiguous? – simona Jan 14 '12 at 23:24
  • Maybe this option takes place because -g is more widely used. For example there is the same -g option for gcc which is standard compiler for linux: http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#Debugging-Options then -debug is option with better control of debugging info. – Eugen Jan 14 '12 at 23:34
  • I'd like to point out that compiling with the debug option sometimes isn't enough for me, in which case I can get `gdb` to find the file by deleting the program's `.o` file(s) first, then compiling with the debug option. – Nike Dec 11 '22 at 01:56