debugDDe (1158408), страница 3
Текст из файла (страница 3)
Figure 2. The variable-table representation
The following structure is used to store elements of table of variables:
| typedef struct tag_VarInfo | ||||
| { | ||||
| byte | Busy; | |||
| void * | VarAddr; | |||
| long | PrevNo; | |||
| int | EnvirIndex; | |||
| byte | Type; | |||
| SysHandle * | Handle; | |||
| void * | Info; | |||
| int | Tag; | |||
| byte | IsInit; | |||
| PFN_VARTABLE_ELEMDESTRUCTOR | pfnDestructor; | |||
| } | VarInfo; | |||
| Busy | – | flag is equal 1 if this element contains valid variable information and 0 if variable is removed from the table of variables. This flag is used for work optimization and preventing frequent memory copying. | ||
| VarAddr | – | variable address; | ||
| PrevNo | – | the number of table of variables element that describes the same variable on a previous level | ||
| EnvirIndex | – | number of the variable level | ||
| Type | – | the class of variable using | ||
| Handle | – | handle of a distributed array. It is not equal to zero if this element describes a distributed array | ||
| Info | – | pointer to an additional variable information structure. It is depended on a variable type. | ||
| Tag | – | flag to store various variable attributes according to type of variable usage | ||
| IsInit | – | flag of variable initialization. Is used for scalar variables. | ||
| pfnDestructor | – | pointer to variable description destructor. This function is called when variable is removed from the table of variables. It can be equal NULL | ||
The following structure describes a variable table:
| typedef struct tag_VAR_TABLE | ||||
| { | ||||
| HASH_TABLE | hIndex; | |||
| TABLE | vTable; | |||
| } | VAR_TABLE; | |||
| hIndex | – | hash-table. It is used for searching variable information by its address. | ||
| vTable | – | table used to keep variable information | ||
The following functions are intended for work with table of variables:
| void vartable_Init( VAR_TABLE *VT, int vTableSize, int hIndexSize, int hTableSize, PFN_CALC_HASH_FUNC Func ) | ||
| VT | – | pointer to table of variables structure to be initialized |
| vTableSize | – | size of vTable expanding; |
| hIndexSize | – | size of hash-index array of hIndex; |
| hTableSize | – | size of hash-table hIndex expanding; |
| Func | – | pointer to a function that calculates hash-value by variable address. |
The function initializes the table of variables.
| void vartable_Done( VAR_TABLE *VT ); | ||
| VT | – | pointer to table of variables structure |
The function destructs table of variables.
| VarInfo *vartable_GetVarInfo( VAR_TABLE *VT, long NoVar ) | ||
| VT | – | pointer to table of variables structure |
| NoVar | – | number of variable in the table of variables |
The function returns the variable information from the table of variables by variable number. The NoVar should point to a valid table of variables element.
| VarInfo *vartable_FindVar( VAR_TABLE *VT, void * Addr ) | ||
| VT | – | pointer to table of variables structure |
| Addr | – | variable address. |
The function returns the variable information from the table of variables by variable address. The function returns NULL if a variable with such address is not registered.
| long vartable_FindNoVar( VAR_TABLE *VT, void * Addr ) | ||
| VT | – | pointer to table of variables structure |
| Addr | – | variable address. |
The function returns the variable number by variable address. The function returns –1 if a variable with such address is not registered.
| long vartable_PutVariable(VAR_TABLE* VT, void* Addr, int Env, byte Type, SysHandle* Handle, int Tag, void* Info, PFN_VARTABLE_ELEMDESTRUCTOR pfnDestructor) | ||
| VT | – | pointer to table of variables structure |
| Addr | – | variable address. |
| Env | – | variable level |
| Type | – | class of variable usage |
| Handle | – | distributed array handle if distributed array is registered |
| Tag | – | variable attributes; |
| Info | – | pointer to additional variable information; |
| pfnDestructor | – | pointer to variable information destructor. It can be NULL |
The function registers of a new variable in the table of variables and returns a number of the registered variable.
| void vartable_VariableDone( VarInfo* Var ) | ||
| Var | – | pointer to variable information structure |
The function uninitializes variable information structure. The function sets the Busy flag to 0 and calls corresponding variable information destructor if available.
| void vartable_RemoveVariable( VAR_TABLE *VT, void * Addr ) | ||
| VT | – | pointer to table of variables structure. |
| Addr | – | variable address. |
The function removes variable information from the table of variables.
| void vartable_RemoveAll( VAR_TABLE *VT ); | ||
| VT | – | pointer to table of variables structure. |
The function removes all variables from the table of variables.
| void vartable_RemoveVarOnLevel( VAR_TABLE *VT, int Level ) | ||
| VT | – | pointer to table of variables structure. |
| Level | – | executed level |
The function removes all variables with the specified variable level.
| void vartable_Iterator( VAR_TABLE *VT, PFN_VARTABLEITERATION Func ) | ||
| VT | – | pointer to table of variables structure. |
| Func | – | iteration function with the following prototype: void (*PFN_VARTABLEITERATION)( VarInfo * ). All the pointers to variable information structures from the variable table are passed to the function. |
The function applies the same operation for all the elements of the table of variables.
| void vartable_LevelIterator(VAR_TABLE* VT, int Level, PFN_VARTABLEITERATION Func) | ||
| VT | – | pointer to table of variables structure. |
| Level | – | variable level |
| Func | – | iteration function with the following prototype: void (*PFN_VARTABLEITERATION)( VarInfo * ). All the variable information structures of the table of variables with specified variable level are passed to the function |
The function applies the same operation for all the elements of the table of variables with specified variable level.
4.4Diagnostics output module
The module of diagnostics output has special requirements. The special requirements are demanded to the module of diagnostics. In the first, the detailed context of detected error should be reported. In the second, it is necessary to prevent output of many errors of the same type and in the same execution context that is possible when examining a program with the large loops.
At last, it is necessary to allow the user to output diagnostics both on a screen, and in a file for the consequent analysis.
The diagnostics module consists of two modules. The sub-module of context processing monitors current execution context of the program and allows to get a detailed current context description for diagnostics. The sub-module of diagnostics output prints detected errors and filters errors of the same type.
4.4.1Processing diagnostics context
The program execution context represents description of all current executed loops and current values of all their iteration variables. The current context varies each time, when entering or leaving the parallel or sequential loop or when new iteration execution begins.















