A P P E N D I X B |
C++ and Fortran 90 Support |
This appendix identifies the particular features of C++ and F90 programs that the Prism environment is able to debug and those it does not support. This discussion is organized into the following sections:
The Prism environment provides limited support for debugging C++ programs.
This section describes the C++ program features that, with few exceptions, are supported by the Prism environment.
You can simply type print member to print a data member when in a class method.
You can set breakpoints using the stop in command with functions having either C or C++ linkage (mangled) names.
You can use the Prism environment stop in, func, and list commands with methods of a class.
(prism all) stop in class_name::method_name (prism all) func class_name::method_name (prism all) list class_name::method_name |
The Prism environment supports assignment to class member variables.
You can use the whatis and print commands with variables of class type and template classes.
The Prism environment recognizes the this identifier in C++ methods. Its value also appears in stack backtraces.
The Prism environment allows you to set breakpoints in overloaded method names. A list pops up from which you can select the correct method.
The Prism environment allows you to set breakpoints in template functions. A list pops up from which you can select the correct function.
The Prism environment's identifier syntax recognizes the C++ scope operator, ::. For example:
(prism all) whereis dummy variable: `symbol.x`symbol.cc`Symbol::print:71`dummy |
This section describes the C++ program features that, with significant limitations, are supported by the Prism environment.
The Prism environment recognizes casting a class pointer to the class of a base type only for single-inheritance relationships. For example, the Prism environment recognizes the following cast syntax when printing variable P:
(prism all) print (struct class_name *) P (prism all) print (class class_name *) P (prism all) print (class_name *) P |
You can print static class members when the current scope is a class method. You cannot print static class members when not in class scope. For example, the following command will fail if you issue it outside of the scope of class_name:
(prism all) print class_name::var_name
You cannot use a method name that has some forms of non-C identifier syntax to set a breakpoint. For example, this fails with a syntax error:
(prism all) stop in class_name::operator+
You must instead use stop at line syntax. These method names are correctly identified in a stack trace, however.
This section identifies the C++ programming features that are not supported by the Prism environment.
Using the Prism environment, you cannot set a breakpoint in an inlined method that is used in multiple source files. Only one of the several debuggable copies of the inlined function gets the breakpoint.
The Prism environment does not support calling C++ methods, using any syntax.
The Prism environment does not support printing variables of type reference, such as int &xref. Also, variables of type reference appear as (unknown type) in stack traces.
The Prism environment provides limited support for debugging F90 programs. This support is described in three sections, as follows:
This section describes the F90 program features that, with few exceptions, are supported by the Prism environment.
With the exception of constructors, the Prism environment supports derived types in Fortran 90. For example, given these declarations:
type point3 integer x,y,z; end type point3 type(point3) :: var,var2; |
you can use Prism commands with these Fortran 90 variables:
(prism all) print var (prism all) whatis var (prism all) whatis point3 (prism all) assign var=var2 (prism all) print var%x (prism all) assign var%x = 70 |
The Prism environment fully supports generic functions in Fortran 90. For example, given the generic function fadd, declared as follows:
interface fadd integer function intadd(i, j) integer*4, intent(in) :: i, j end function intadd real function realadd(x, y) real, intent(in) :: x, y end function realadd end interface |
you can use Prism commands with these Fortran 90 generic functions:
(prism all) p fadd(1,2) (prism all) whatis fadd (prism all) stop in fadd |
In each case, the Prism environment asks you which instance of fadd your command refers to. For example:
In addition to the standard assignment operator (=), the Prism environment supports the new Fortran 90 pointer assignment operator =>. For example:
program pnode type node integer x,y type(node), pointer :: next end type node type(node), target :: n1,n2,n3 type(node), pointer :: pn1, pn2 ... pn1 => n1 pn2 => n2 i = 0 end |
The following examples assume that a breakpoint has been set at the last statement, i = 0, and show how the Prism environment supports Fortran 90 pointers:
If pn1 does not point to any value, an attempt to access it will result in an error message:
(prism all) p pn1 Fortran variable is not allocated/associated. |
You can find the state of a pointer using the whatis command. Assume pn1 has not been associated:
(prism all) whatis pn1 node pn1 ! unallocated f90 pointer |
Assume pn1 has been associated with a value:
(prism all) whatis pn1 node pn1 ! f90 pointer |
The Prism environment supports pointers to arrays in the same way that it supports simple pointers. The Fortran 90 language constraints apply. For example, Fortran 90 allows pointer assignment between pointers to arrays. Assignment to arrays having different ranks is not allowed.
For example, given these declarations:
real, dimension(10), target :: r_arr1real, dimension(20), target :: r_arr2real, dimension(:), pointer :: p_arr1,p_arr2
you can use Prism commands with these Fortran 90 pointers to arrays:
(prism all) print p_arr1 (prism all) whatis p_arr2 (prism all) assign p_arr1 => r_arr1 (prism all) assign p_arr1(1:2) = 7 |
The Prism environment does not handle Fortran 90 pointers to array sections correctly. For example,
array_ptr => some_array(1:10:3)
The Prism environment will print some elements of the array, although it will not print the correct elements or the correct number of elements.
The Prism environment supports allocatable arrays in the same way that it supports pointers to arrays. Fortran 90 support includes the Prism commands print and whatis. The Prism environment also supports slicing and striding Fortran 90 allocatable arrays. For example, to print a section of allocatable array alloc_array, type:
(prism all) print alloc_array(1:30:2)
Fortran 90 language constraints apply. For example, Fortran 90 allows allocating or deallocating memory for an allocatable array but does not allow an allocatable array to point to another object. Therefore, the Prism environment does not recognize pointer assignment, =>, to allocatable arrays.
The Prism environment supports Fortran 90 operations on arrays or array sections, and assignment to continuous sections of arrays.
(prism all) assign a=b+c (prism all) assign a(3:7)=b(2:10:2)+c(8:8) |
The Prism environment supports Fortran 90 masked print statements:
(prism all) where (arr>0) print arr
The Prism whatis command shows variable attributes. These attributes include allocated and associated attributes for pointers, or the (function variable) attribute displayed for a RESULT variable in Fortran 90.
Consider, for example, this declaration:
function inc(i) result(j) integer i; integer k; integer j; k = i+1 j = k end function inc |
In this situation, the whatis command displays the function variable attribute of j:
(prism all) whatis j (function variable) integer*4 j |
This section describes the Fortran 90 program features that, with significant limitations, are supported by the Prism environment.
The Prism environment views user-defined operators as functions. If a new operator .my_op. appears in a Fortran 90 program, then the Prism environment cannot deal with the operator .my_op. as an operator, but it can deal with the function my_op, viewed as a generic function. You cannot use operators named * (or +, or any other keyword operator), but you can stop in functions that are used to define such operators. For example:
In this example, the Prism environment does not support debugging the user-defined function .add_op:
(prism all) print 1 .add_op. 2
However, the Prism environment supports the function add_op:
(prism all) print add_op(1,2)
A list pops up, allowing you to choose which add_op to apply.
The following commands can take internal procedure names as arguments:
If there are several procedures with the same name, a list pops up from which to select the desired procedure.
The Prism environment supports the same intrinsics in Fortran 90 that it supports in Fortran 77. See Using Fortran Intrinsic Functions in Expressions.
This section identifies the F90 programming features that are not supported by the Prism environment.
The Prism environment does not support constructors for derived types.
type point3 integer x,y,z;end type point3 type(point3) :: var,var2; |
The Prism environment does support assignment to derived types, however. For example:
(prism all) assign var = var2
Although Fortran 90 allows the use of constructors, the Prism environment does not support them. The following example is not supported:
(prism all) assign var = point3(1,2,3)
Assume the generic function is defined in the current module as in this example:
interface fadd integer function intadd(i, j) integer*4, intent(in) :: i, j end function intadd real function realadd(x, y) real, intent(in) :: x, y end function realadd end interface |
In this situation, only references to the fadd are supported, but references to specific functions that define fadd are not. For example:
(prism all) whatis intadd prism: "intadd" is not defined in the scope `f90_user_op_generic.exe`f90_user_op_generic.f90`main` |
The error checking involved by the semantics of the => operator is not fully supported. If your program causes an illegal pointer assignment, the Prism environment might not issue any error, and the behavior of the program will be undefined.
The Prism environment does not print the result of an array-valued function.
Copyright © 2002, Sun Microsystems, Inc. All rights reserved.