| Skip Navigation Links | |
| Exit Print View | |
|
Oracle Solaris Studio 12.3: Debugging a Program With dbx Oracle Solaris Studio 12.3 Information Library |
4. Viewing and Navigating To Code
5. Controlling Program Execution
6. Setting Breakpoints and Traces
8. Evaluating and Displaying Data
11. Debugging Multithreaded Applications
16. Debugging Fortran Using dbx
Running the Sample dbx Session
Viewing Fortran 95 Derived Types
17. Debugging a Java Application With dbx
18. Debugging at the Machine-Instruction Level
19. Using dbx With the Korn Shell
You can show structures, Fortran 95 derived types, and pointers with dbx.
demo% f95 -o debstr -g DebStruc.f95
demo% dbx debstr
(dbx) stop in main
(2) stop in main
(dbx) list 1,99
1 PROGRAM DebStruPtr! Debug structures & pointers
Declare a derived type.
2 TYPE product
3 INTEGER id
4 CHARACTER*16 name
5 CHARACTER*8 model
6 REAL cost
7 REAL price
8 END TYPE product
9
Declare prod1 and prod2 targets.
10 TYPE(product), TARGET :: prod1, prod2
Declare curr and prior pointers.
11 TYPE(product), POINTER :: curr, prior
12
Make curr point to prod2.
13 curr => prod2
Make prior point to prod1.
14 prior => prod1
Initialize prior.
15 prior%id = 82
16 prior%name = "Coffee Cup"
17 prior%model = "XL"
18 prior%cost = 24.0
19 prior%price = 104.0
Set curr to prior.
20 curr = prior
Print name from curr and prior.
21 WRITE ( *, * ) curr%name, " ", prior%name
22 END PROGRAM DebStruPtr
(dbx) stop at 21
(1) stop at "DebStruc.f95":21
(dbx) run
Running: debstr
(process id 10972)
stopped in main at line 21 in file "DebStruc.f95"
21 WRITE ( *, * ) curr%name, " ", prior%name
(dbx) print prod1
prod1 = (
id = 82
name = "Coffee Cup"
model = "XL"
cost = 24.0
price = 104.0
)
Above, dbx displays all fields of the derived type, including field names.
You can use structures and inquire about an item of an Fortran 95 derived type.
Ask about the variable
(dbx) whatis prod1
product prod1
Ask about the type (-t)
(dbx) whatis -t product
type product
integer*4 id
character*16 name
character*8 model
real cost
real price
end type product
dbx displays the contents of a pointer, which is an address. This address can be different with every run.
(dbx) print prior
prior = (
id = 82
name = ’Coffee Cup’
model = ’XL’
cost = 24.0
price = 104.0
)