Project : Bookshelf Program : fbgen ( fact base generator ) Date Updated: November 5, 1997 Author: Gerry Kovan, University of Toronto Purpose of Program: ------------------- This program takes as input a ?.cfx.mr file that is produced by CFX (C Fact Extractor) and converts the data into TA format where the tuples produced are of the type defined in the section 'Relations and Attributes Defined'. Syntax of Program: ------------------ fbgen [options] Description of arguments to program: ------------------------------------ - this is the file produced by CFX - it contains the input data to the program - the file contains a file table ( all the source code files used in building the program ) and the import export relations for each of the files in the file table - this file contains the output data of the program - the format of the file is TA - see section 'Relations and Attributes Defined' for a description of the tuples created [options] "-l" output long file names to fact base file "-x" debug mode (creates a file called fbgen.debug) Relations and Attributes Defined (Scheme): ------------------------------------------- // relation tuples extracted from cfx data funcdef file function // function is defined in file funcdcl file function // function declared in file funcdcl file libraryfunction // libraryfunction declared in file vardef file variable // var defined in file vardcl file variable // var declared in file macrodef file macro // macro defined in file typedef file type // type defined in file structdef file struct // struct defined in file uniondef file union // union defined in file enumdef file enum // enum defined in file include file file // file 1 includes file 2 sourcecall function function // function 1 calls function 2 // ( function 2 definition is // in same compilation unit // OR // is included in same compilation // unit as function 1 ) sourceref function variable // function references variable // ( variable definition is // in same compilation unit // OR // is included in same compilation // unit as variable ) linkcall function function // function 1 calls function 2 // ( function 2's definition // must be linked to ) linkref function variable // function references variable // ( variable definition must // be linked to ) usemacro file macro // file uses macro usetype file type // file uses type usestruct file struct // file uses struct useunion file union // file uses union useenum file enum // file uses enum librarycall function libraryfunction // function calls libraryfunction // ( a libraryfunction is a fcn // whose definition does not // exist in the analysed code ) // Attribute tuples extracted from cfx defloc function file:lineNum // fcn definition location dclloc function file:lineNum // fcn declaration location vardefloc variable file:lineNum // var definition location vardclloc variable file:lineNum // var declaration location macrodefloc macro file:lineNum // macro definition location typedefloc type file:lineNum // type definition location enumdefloc enum file:lineNum // enum definition location structdefloc struct file:lineNum // struct definition location uniondefloc union file:lineNum // union definition location deflocend function file:lineNum // fcn definition end location enumdeflocend enum file:lineNum // enum definition end location structdeflocend struct file:lineNum // struct definition end location uniondeflocend union file:lineNum // union definition end location Schema Diagram : ---------------- The scheme for the relations emitted by fbgen can be drawn as follows: Arrows represent relations and boxes represent entities. include ----------- | | v | +=========+ | | file |-------- linkcall, sourcecall +=========+ ------------------ | | | | v | | funcdcl, funcdef +========+ | +-------------------------->|function|--------------- | +========+ | | | | | | | librarycall | | | | | | | | |funcdcl+=================+ | | sourceref, +------>| libraryfunction | <-+ | linkref | +=================+ | | | | | | v | vardcl, vardef +========+ +-------------------------->|variable| | +========+ | | | macrodef, usemacro +========+ +-------------------------->| macro | | +========+ | | typedef, usetype +========+ +-------------------------->| type | | +========+ | | structdef, usestruct +========+ +-------------------------->| struct | | +========+ | | uniondef, useunion +========+ +-------------------------->| union | | +========+ | | enumdef, useenum +========+ +-------------------------->| enum | +========+ Conversion of CFX import/export relation to the RSF relations: ------------------------------------------------------------------ The fbgen program emits relations based on CFX relations, in the following manner. rsf relation CFX relation ------------ ----------------------- funcdef EXPORT_PUBLIC_FCN_DEF EXPORT_STATIC_FCN_DEF funcdcl EXPORT_PUBLIC_FCN_DECL EXPORT_STATIC_FCN_DECL vardef EXPORT_PUBLIC_VAR_DEF EXPORT_STATIC_VAR_DEF vardcl EXPORT_PUBLIC_VAR_DECL macrodef EXPORT_MACRO typedef EXPORT_TYPE enumdef EXPORT_ENUM_TAG structdef EXPORT_STRUCT uniondef EXPORT_UNION include INCLUDE_FILE sourcecall IMPORT_PUBLIC_FCN_DEF IMPORT_STATIC_FCN_DEF sourceref IMPORT_PUBLIC_VAR_DEF IMPORT_STATIC_VAR_DEF linkcall IMPORT_LINK_FCN linkref IMPORT_LINK_VAR librarycall IMPORT_EXTERN_FCN usemacro IMPORT_MACRO usetype IMPORT_TYPE useenum IMPORT_ENUM_TAG usestruct IMPORT_STRUCT useunion IMPORT_UNION