Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Can I debug with idb in Xcode?

Li_Dong
Beginner
1,428 Views
Hi everyone,

Recently, I switched to develop Fortran program in Xcode with Intel Fortran compiler 11.1.084. When I debug, Xcode uses gdb. But I can't viewthe constant variables or public variables of a module from gdb. So how can I debug Fortran with idb in Xcode? I have done some search on the internet, but still can't figure it out.
And it seems that I can't see the array in user defined type with idb, too. It doesn't support "::" operator. How to see it?
Cheers,
DONG Li
0 Kudos
7 Replies
Ron_Green
Moderator
1,428 Views
IDB does not work under Xcode.

What is the entire command and syntax you use in IDB to view the array component? type%array ?

ron
0 Kudos
Li_Dong
Beginner
1,428 Views
Hi ron,

What a pity that IDB doesn't work with Xcode!
I define a type "tracer_type", and declare a 1D array "tracers" in that type. When I am in IDB, I input "p tracers(1)", it says
(idb) p tracers(1)
No symbol "tracers" in current context.
Evaluating 'tracers' failed!
Could not evaluate array expression tracers(1).
cannot evaluate tracers(1)
Cheers,
DONG Li
0 Kudos
Ron_Green
Moderator
1,428 Views
I don't seem to be able to reproduce what you are seeing. Here is my output:

fordprefect:731088 rwgreen$ ifort -o deb -save-temps -g -O0 deb.f90
fordprefect:731088 rwgreen$ idb deb
Intel Debugger for applications running on Intel 64, Version 11.1, Build [1.2097.2.319]
------------------
object file name: deb
Reading symbols from /Users/rwgreen/quads/forums/731088/deb...done.
(idb) list
5 real :: tracers(10)
6 end type tracer_type
7
8 type (tracer_type) :: my_struct
9
10 my_struct%tracers = 42.0
11
12 print*, "Tracer(1)", my_struct%tracers(1)
13
14 end program deb
(idb) break 12
Breakpoint 1 at 0x100000a06: file /Users/rwgreen/quads/forums/731088/deb.f90, line 12.
(idb) run
Starting program: /Users/rwgreen/quads/forums/731088/deb

Breakpoint 1, deb () at /Users/rwgreen/quads/forums/731088/deb.f90:12
12 print*, "Tracer(1)", my_struct%tracers(1)
(idb) p my_struct%tracers(1)
$1 = 42
(idb) p my_struct%tracers
$2 = {42, 42, 42, 42, 42, 42, 42, 42, 42, 42}
(idb) quit
The program is running. Exit anyway? (y or n) y
fordprefect:731088 rwgreen$ cat deb.f90

program deb
implicit none

type tracer_type
real :: tracers(10)
end type tracer_type

type (tracer_type) :: my_struct

my_struct%tracers = 42.0

print*, "Tracer(1)", my_struct%tracers(1)

end program deb

0 Kudos
Li_Dong
Beginner
1,428 Views
Hi, the simplified version of my code is

type tracer_type
... ! some variables
end type tracer_type
type(tracer_type) tracers(10) ! an array in type of tracer_type
So I got an array in type of "tracer_type", not an array in the type structure of it.
Cheers
PS:
How do I input formal code with color in forum? : P
0 Kudos
Ron_Green
Moderator
1,428 Views
You will have to show me your screen capture because I still can see the structure, as far as I understand:

ifort -o deb -save-temps -g -O0 deb.f90
fordprefect:731088 rwgreen$ !idb
idb ./deb
Intel Debugger for applications running on Intel 64, Version 11.1, Build [1.2097.2.319]
------------------
object file name: ./deb
Reading symbols from /Users/rwgreen/quads/forums/731088/deb...done.
(idb) list
6 integer :: bar
7 end type tracer_type
8
9 type (tracer_type) :: my_struct(10)
10
11 my_struct(1:10)%foo = 42.0
12 my_struct(1:10)%bar = 43
13
14 print*, "done"
15
(idb) break 14
Breakpoint 1 at 0x100000a39: file /Users/rwgreen/quads/forums/731088/deb.f90, line 14.
(idb) run
Starting program: /Users/rwgreen/quads/forums/731088/deb

Breakpoint 1, deb () at /Users/rwgreen/quads/forums/731088/deb.f90:14
14 print*, "done"
(idb) p my_struct(1)
$1 = {foo = 42, bar = 43}
(idb) p my_struct
$2 = {{foo = 42, bar = 43}, {foo = 42, bar = 43}, {foo = 42, bar = 43}, {foo = 42, bar = 43}, {foo = 42, bar = 43}, {foo = 42, bar = 43}, {foo = 42, bar = 43}, {foo = 42, bar = 43}, {foo = 42, bar = 43}, {foo = 42, bar = 43}}
(idb) quit
The program is running. Exit anyway? (y or n) y
fordprefect:731088 rwgreen$
fordprefect:731088 rwgreen$
fordprefect:731088 rwgreen$ cat deb.f90
program deb
implicit none

type tracer_type
real :: foo
integer :: bar
end type tracer_type

type (tracer_type) :: my_struct(10)

my_struct(1:10)%foo = 42.0
my_struct(1:10)%bar = 43

print*, "done"

end program deb


To insert text, there is an icon above the edit window, 2nd row, 4th icon. Looks like a pencil or erase - no, I think it is supposed to be a highlight pen. Try that.

ron
0 Kudos
Li_Dong
Beginner
1,428 Views
Hi ron,

I find out what is the problem. My main program (main.f90) uses a module (tracer.f90) which defines a type (tracer_type) and an array in that type (tracers). Then I can display the content of "tracers" in that module, but I can't see them in main program.
So the main program is not in the scope of "tracers".
I also tried "p tracer::tracers(1)", but it doesn't work. How to see it without in its module?
Thanks for help!
DONG Li
0 Kudos
Ron_Green
Moderator
1,428 Views
CAn you show a code sample?
0 Kudos
Reply