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:


C++ Support in the Prism Environment

The Prism environment provides limited support for debugging C++ programs.

Fully Supported C++ Features

This section describes the C++ program features that, with few exceptions, are supported by the Prism environment.

Data Members in Methods

You can simply type print member to print a data member when in a class method.

C++ Linkage Names

You can set breakpoints using the stop in command with functions having either C or C++ linkage (mangled) names.

Methods of a Class

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

Class Member Variables

The Prism environment supports assignment to class member variables.

Variables of Class Type and Template Classes

You can use the whatis and print commands with variables of class type and template classes.

this Identifier

The Prism environment recognizes the this identifier in C++ methods. Its value also appears in stack backtraces.

Overloaded Method Names

The Prism environment allows you to set breakpoints in overloaded method names. A list pops up from which you can select the correct method.

Template Functions

The Prism environment allows you to set breakpoints in template functions. A list pops up from which you can select the correct function.

Scope Operator in the Prism Environment's Identifier Syntax

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

Partially Supported C++ Features

This section describes the C++ program features that, with significant limitations, are supported by the Prism environment.

Casts

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

Static Class Members

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

Breakpoints in Methods

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.

Unsupported C++ Features

This section identifies the C++ programming features that are not supported by the Prism environment.

Inlined Methods Used in Multiple Source Files

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.

Calling C++ Methods

The Prism environment does not support calling C++ methods, using any syntax.

Variables of Type Reference

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.


Fortran 90 Support in the Prism Environment

The Prism environment provides limited support for debugging F90 programs. This support is described in three sections, as follows:

Fully Supported Fortran 90 Features

This section describes the F90 program features that, with few exceptions, are supported by the Prism environment.

Derived Types

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

Generic Functions

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:

(prism all) whatis fadd
More than one identifier `fadd'.
Select one of the following names:
0) Cancel
1) `f90_user_op_generic.exe`f90_user_op_generic.f90`fadd
! real*4 realadd
2) `f90_user_op_generic.exe`f90_user_op_generic.f90`fadd
! integer*4 intadd
> 1
real*4 function fadd (x, y)
(dummy argument) real*4 x
(dummy argument) real*4 y

Simple Pointers

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:

  • print pn1 - Prints the value pointed to by pn1, in this case n1.
  • print pn1%x - Prints the value of the member x in the object pointed to by pn1 (in this case n1%x).
  • assign pn1%x = 3 - Assigns n1%x = 3.
  • assign pn1=n3 - Assigns n3 to the value pointed to by pn1 (this has the same effect as assign n1=n3).
  • assign pn1=>n3 - Makes pn1 point to n3.
  • assign pn1=>pn2 - Makes pn1 point to the same object as pn2.

Interactive Examples of Support for 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

Pointers to Arrays

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

Pointers to Sections of an Array in Fortran 90

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.

Allocatable Arrays

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.

Array Sections and Operations on 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)

Masked Array Operations

The Prism environment supports Fortran 90 masked print statements:

(prism all) where (arr>0) print arr

Variable Attributes

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

Partially Supported Fortran 90 Features

This section describes the Fortran 90 program features that, with significant limitations, are supported by the Prism environment.

User-Defined Operators

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:

interface operator(.add_op.)
  integer function int_add(i, j)
  integer*4, intent(in) :: i, j
  end function int_add
  real function real_add(x, y) 
  real, intent(in) :: x, y 
  end function real_add
end interface

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.

Internal Procedures

The following commands can take internal procedure names as arguments:

  • stop in
  • whatis

If there are several procedures with the same name, a list pops up from which to select the desired procedure.

Supported Intrinsics

The Prism environment supports the same intrinsics in Fortran 90 that it supports in Fortran 77. See Using Fortran Intrinsic Functions in Expressions.

Unsupported Fortran 90 Features

This section identifies the F90 programming features that are not supported by the Prism environment.

Derived Type Constructors

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)

Generic Functions

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`

Pointer Assignment Error Checking

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.

Printing Array-Valued Functions

The Prism environment does not print the result of an array-valued function.