Program Database Toolkit (PDT) ********************************************************************** Program Database (PDB) Format Items ID attribute prefix prefix HEADER FILES so s ROUTINES ro r GROUPS gr g TYPES (non-groups) ty y TEMPLATES te t NAMESPACES na n MACROS ma m PRAGMAS pr p Prototype format for each item: * Each item is decribed by a block of lines * First line is always where consists of prefix as described aboved followed by '#' followed by an unsigned (>=0) and unique number (unique inside the item category). The numbering has no other constraints (especially contiguous allocation or start with 0) * Each other line is of the form: attribute value value... * Attributes and values are separated by exactly one space (" ") * Item description blocks are terminated by an empty line * Values which are references to other items are done using IDs * Values are never enclosed in "" * Attributes with boolean value are only listed if true (value == T) i.e. absence means false * String "[...]" after attribute means "0 or more" instances of this attribute line possible ********************************************************************** HEADER Item # magic string including # version (X = 1|2|3) lang < c|c++|c_or_c++|fortran # [optional] |java|multi> # parser language ********************************************************************** SOURCE FILE Item so#[fileID] ssys # is system include? (c/c++) sinc [...] # IDs of included files scom [...] comID = co# where i = 0 .. n start_loc = | NULL 0 0 end_loc = | NULL 0 0 # comment descriptor # one for each comment # in the file [optional] ********************************************************************** ROUTINE Item ro#[routineID] rloc # location [ rgroup # parent group racs # access OR rnspace # parent namespace (c++) OR rroutine # parent routine (f90) racs # access (f90) OR racs # access for interfaces (f90) ] ralias # alias (via interface) (f90) rsig # signature rlink # linkage rkind # (f90) rimpl [...] # for "rkind falias" (f90) rstatic # is static function? (c/c++) rskind # special kind rvirt # virtuality (c++) rcrvo # is covariant return # virtual override? (c++) rinline # is inline? (c/c++) rcgen # is compiler generated? (c++) rexpl # is explicit ctor? (c++) rtempl # ID if template instance; (c++) rspecl # is specialized? (c++) rarginfo # explicit interface defined? (f90) rrec # is declared recursive? (f90) riselem # is elemental? (f90) rstart # location of first # executable statement (c/f90) rcall [...] # callees rret [...] # location of return (f90) rstop [...] # location of stop (f90) rpos <"{"> <"}"> rstmt [...] [] where id = st# kind = start_loc = | NULL 0 0 end_loc = | NULL 0 0 next_st = st# | NA down = st# | NA extra = for_init = st# | NA (associated with for) else_stmt = st# | NA (associated with if) catch_stmt = st# | NA (associated with try) target_stmt = st# | NA (associated with goto, break, continue) break_stmt = st# | NA (associated with case) rbody [...] where statement_block = st# # entry point ********************************************************************** GROUP Item gr#[groupID] gloc # location [ ggroup # parent group gacs # access OR gnspace # parent namespace (c++) ] gkind # (f90) gtempl # template ID (c++) gspecl # is specialized? (c++) gsparam [...] # specialization (c++) OR # template arguments OR gbase [...] # direct base groups (c++) gfrgroup [...] # friend groups (c++) gfrfunc [...] # friend functions (c++) gfunc [...] # member functions gmem [...] # other members gmloc # location gmgroup # parent group (f90) gmacs # access gmkind # kind: type or group, # static or non-static # variable, template [ if (gmkind == type): gmtype # type of member if (gmkind == statvar): gmtype # type of member gmtempl # ID if template static (c++) # data member gmspecl # is specialized? (c++) gmconst # was initializer # specified at its # declaration within the # group definition? (c++) if (gmkind == var): gmtype # type of member gmisbit # is bit field? gmmut # is mutable? (c++) gmconst # is constant? (f90) if (gmkind == templ): gmtempl # template ID (c++) ] gpos <"{"> <"};"> ********************************************************************** TYPE Item ty#[typeID] yloc # location [ ygroup # parent group yacs # access OR ynspace # parent namespace (c++) OR yacs # access (f90) ] ykind ysigned # is explicitly signed? if (ykind == enum): yenum [...] # name-value pairs if (ykind == fchar): # (f90) yclen # *: unspecified # else constant if (ykind == float|ffloat|fcmplx): yfkind # float kind if (ykind == ptr|fptr): yptr # type pointed to if (ykind == ref): yref # type referred to if (ykind == func|ffunc): yrett # return type yargt [...] <-|name> * where src = NA 0 0 | so# where the position represents the beginning of type # argument type # argument name # has default value? # intent in? (f90) # intent out? (f90) # is optional? (f90) yellip # has ellipsis? yqual # qualifier yexcep [...] # absence of attribute # indicates any exception # may be thrown; # NULL indicates no excep- # tions will be thrown if (ykind == array): yelem # type of array element ystat # (C99) is static? i.e., # is array tagged with C99 # keyword "static"? ynelem # -2: template dependent size array; # -1: variable length array; # 0: [] incomplete-type case; # else number of elements if (ykind == farray): # (f90) yelem # type of array element yshape yrank # number of dimensions ydim [...] # bounds of dimensions # *: if upper bound for asmdsize; # NA: if not constant; # else constant value if (ykind == tref): ytref # typedef type yqual * # qualifiers if (ykind == ptrmem): ympgroup # type of group to which # member pointed to belongs ymptype # type of member pointed to ] ********************************************************************** TEMPLATE Item (c++ only) te#[templateID] tloc # location [ tgroup # parent group tacs # access OR tnspace # parent namespace ] tdecl # declaration of template, # if not current template tdef # definition of template, # if not current template tkind tparam [...] OR <-|name> OR # template parameters tsparam [...] # partial specialization OR # template parameters OR if (ykind == func|memfunc): tproto # prototype instantiation if (ykind == class|memclass): tproto # prototype instantiation if (ykind == statmem): ttype # variable type ttext # text of template tpos <">"> <"}"> ********************************************************************** NAMESPACE Item (c++ only) na#[namespaceID] nloc # location nnspace # parent namespace nmem [...] nalias # alias of namespace npos <"{"> <"}"> ********************************************************************** MACRO Item ma#[macroID] mloc # location mkind # kind mtext # text of macro ********************************************************************** PRAGMA Item pr#[pragmaID] ploc # location pkind # kind [optional] ppos ptext # text of pragma ********************************************************************** NOTES AND CAVEATS: To eliminate unneeded (C++) entities, add the EDG option "--remove_unneeded_entities" to the cxxparse command line. ROUTINE rpos, GROUP gpos, TEMPLATE tpos, NAMESPACE npos: * Positions have form * Position 1 corresponds to the first 3 values, position 2 to the next 3 values, etc. * Location of the header is given by the first 2 positions, location of the body by the last 2 positions. * A value of "NULL 0 0" indicates an unknown position. * Tab characters are counted as a single column. ROUTINE rcall: * The values for rcall will be NULL 0 0, if the routine calling (e.g. some constructors) or being called (e.g. implicit conversions) is compiler generated. * Some positions are not ideal (but the best that can be done): ctor/dtor calls associated with "new"/"delete", dtor calls within dtors for derived classes, new/ctor calls associated with return statements, positions associated with macros. * Destructor calls are often reported with the corresponding constructor calls; this is for exception handling. ROUTINE rpos: * For unused member functions of instantiated template classes, the header positions are known, but not the body positions. * For unused constructors of instantiated template classes, position 2 will not reflect the constructor initializers. * Fortran 90: only first position is available in IL. ROUTINE: Fortran 90 ENTRY statement is not handled. GROUP gpos: * C++: If position 2 is null, then the class is a typedef having the form: typedef struct { . . . }; * C++: Position 3 cannot be determined for non-template classes and speciali- zations; it is not given in the IL. * C++: In cases where positions 3 and 4 are null -- i.e. the class corresponds to a template declaration rather than a definition -- position 2 will not reflect base classes, if there are any. This is the best that can be done given the structure of the IL. * Fortran 90: No positions are available in IL. TEMPLATE tspecl: * For a specialized class template, it would be nice to know the class template that it is a specialization of, i.e. a "tspecl te#xx" attribute would be nice. (The IL does not provide needed information.) TEMPLATE tpos: * Position 2 is unknown in IL. * For tkind ttparam, only position 1 is known. * For tkind memfunc and statmem, only positions 3 and 4 are known for definitions, whereas no positions are known for declarations. NAMESPACE npos: * The positions for a namespace pertain to the first encountered segment of a namespace. * Position 1 is unknown in IL. * Position 2 is known in IL only for named namespaces. * Position 3 is known in IL only for unnamed namespaces. * Position 4 is unknown in IL for namespace aliases. IL Analyzer (bin/taucpdisp): * Routine calls using pointers to functions are not currently reported. The function signature can be determined without difficulty; what else can be determined is not known at this time. See emails on "C++ function calls" from Kathie and Bernd, and ptrToFunc.c example. (1/20/00) DUCTAPE application bin/pdbmerge: * Namespace definitions spread over several files are not merged correctly. DUCTAPE application bin/pdbtree: * Class hierarchy is a DAG, not a tree, and therefore display is bad. Possible enhancements: * Full symbol information * type * location where defined * locations where used ********************************************************************** CHANGE LOG: ************************************ Change date: September 21, 2000, klindlan ALL: group[ID] (renamed from "class[ID]") ROUTINE: rgroup (renamed from "rclass") (rroutine + racs) OR racs (added for f90) ralias (added for f90) rlink ("fint", "f90" values added for f90) rkind (renamed from "rstore", values added for f90) rimpl (added for f90) rskind (renamed from "rkind") rstart (added for f90) rreturn (added for f90) rstop (added for f90) rpos (only first position is available in IL for f90) GROUP (previously known as CLASS): all attributes ('cl' -> 'gr', 'c' -> 'g') ggroup (renamed from "cclass") gkind ("fderived", "fmodule" values added for f90) gfrgroup (renamed from "cfrclass") under gmem: gmgroup (added for f90; needed to handle "USE" within module) if (gmkind == var): gmconst (added for f90) gpos (no positions are available in IL for f90) TYPE: ygroup (renamed from "yclass") yacs (occurrence without "ygroup" added for f90) ykind (values added for f90) if (ykind == fint|flogic|fchar): yikind ("wchar" value added for f90) if (ykind == fchar): yclen (added for f90) if (ykind == ffloat|fcmplx): (added for f90) if (ykind == fptr): (added for f90) if (ykind == func|ffunc): ("ffunc" added for f90) yarginfo, yrec, yiselem (added for f90) yargt ("name" value added; "in," "out," "opt" values added for f90; boolean converted to "def") if (ykind == farray): yelem, yshape, yrank, ydim (added for f90) if (ykind == ptrmem): ympgroup (renamed from "ympclass") TEMPLATE: tgroup (renamed from "tclass") NOTES AND CAVEATS: ROUTINE rpos, GROUP gpos (added comments for f90) Fortran 90 ENTRY statement is not handled CHANGE LOG: Old entries deleted ************************************ Change date: March 13, 2001, klindlan OTHER: Updated C++ IL Analyzer to reflect changes for CLASS->GROUP Deleted various out-of-date comments SOURCE FILE: ssys (added for C++) ROUTINE: rimpl (added "[...]") rtempl (values include templateID and boolean) rtarg (added for C++) rarginfo, rrec, riselem (added for f90) rret (name changed from "rreturn", added for C++) GROUP: gtempl (values include templateID and boolean) gtarg (added for C++) gsarg (added for C++) gfunc (corrected so that location is displayed) gmem gmkind (added "templ" value) if (gmkind == templ): gmtempl (added for C++) TYPE: if (ykind == enum): yenum (changed format to hex without leading 0s) if (ykind == func|ffunc): yargt (added "-" in case an argument name is not given) yarginfo, yrec, yiselem (deleted for f90) if (ykind == array); ynelem (value is "-2" for template dependent size array) TEMPLATE: tkind (added value "ttparam" for template template parameters) tparam, tproto, ttype (added for C++) ************************************ Change date: March 23, 2001, klindlan ROUTINE: rkind (added tproto for C++) rtempl (deleted boolean) rtarg (deleted) GROUP: gkind (added tproto for C++) gtempl (deleted boolean) gtarg (deleted) gsparam (renamed from gsarg) TEMPLATE: tparam (defaults are now optional IDs or values) ************************************ Change date: May 16, 2001, klindlan Integrated PDT with EDG v. 2.45 ROUTINE: rcatch (added) rpos (accommodates EDG changes in handling of templates/instantiations and exceptions) GROUP: gtempl (reports definition template, if possible) gsparam (modified ntype value) gpos (reports location of definition template, when appropriate) TYPE: if (ykind == array): ystat (added for C99) TEMPLATE: tdecl (added) tdef (added) tsparam (added) tpos (not complete) ************************************ Change date: June 6, 2001, klindlan TEMPLATE: tloc (modified) tpos (completed implementation, added notes) ************************************ Change date: July 6, 2001, klindlan ROUTINE: rcatch (deleted) GROUP: gmem (extraneous template entries are no longer reported) TYPE: yqual (fixed so that qualifiers are reported for functions) ************************************ Change date: September 25, 2001, klindlan Deleted out-of-date notes, caveats, issues. ************************************ Issues List: * CHECK attribute names -- for F90-related changes (class -> group, etc.) * "use" hierarchy is not reported explicitly. * With modules, routines can be represented by two PDB entries, one for an internal routine, the other for a module procedure. The only connection between the two is "rloc" entries having the same location. * Items from a module accessed via "USE" are not listed under the corresponding group entry. The IL does not list members of such a module. * (Kathie, 2/16/01) Could not find use of "tpck_template_ref" with test cases pdtoolkit-IRIX64/test/template/t*.cc. Will have to check for these when testing with POOMA, etc. (Look for "a_template_arg" in il_def.h.) * (KL, 3/21/01) Check output for yenum on all architectures. INTEGER_VALUE_REPR_IS_A_HOST_INTEGER is 1 on all architectures (?) LINUX at least does not work properly: it reports "Internal error: check_target_config: an_integer_value is too small" If value is set to 0, then output for yenum is, e.g., "0x0x00000000000a." * (KL, 4/19/01) Added another filter to disp_class_type_scope() so that template instantiations are not reported as class members. if ((type_ptr->kind == tk_array || type_ptr->kind == tk_class || type_ptr->kind == tk_union) && type_ptr->variant.class_struct_union.is_template_class) continue; Make sure this is right. ************************************************************ (Bernd, 1/29/01 and 1/30/01) For the following: subroutine bar() print *, "bar" end subroutine bar program xx interface foo subroutine bar() end subroutine bar end interface call foo() end program xx As I understand it rimpl/ralias comes as a pair. If ro#1 has ralias#2 then ro#2 has rimpl#1. It actually works for your intv*.f90 test cases. But in my xx.f90 test case I sent you, only "rimpl" shows up, but not "ralias". One difference I noted is that in the intv.f90 test case the interfaces are within a module, in my test case it is not. kal -- I investigated -- and couldn't see the connection in the IL -- except at a routine call. Looks like something is wrong with the IL. ************* Change date: July 3, 2003, Bernd, Sameer * Added new "pragma" item describing C/C++ pragmas and Fortran directives * Added new "scom" attributes which describes comments in files * Added "rstmt" which describes statements (only C/C++ for now) If "rstmt" is available, "rret", "rstop", "rstart" should not be specified. Open Issues: - end location of declaration statement point not to ';' but end of last token in declaration - declarations inside the "if" and "while" control expression are not shown * added location information to function parameters (yargt)