void Trick::MemoryManager::clear_arrayed_class( char* address, ATTRIBUTES* A, int curr_dim, int offset) {

    int ii, extent;

    /** @par Design Details:
     This function is implemented using the following algorithm:
     */

    /** If we are looking at the pointer then clear it..*/
    if (A->index[curr_dim].size == 0) {
        clear_rvalue( address, A, curr_dim, offset);
    } else {
        extent = A->index[curr_dim].size;

        for (ii = 0; ii < extent; ii++) {

            if (curr_dim < A->num_index - 1) {
                clear_arrayed_class( address, A, curr_dim + 1, offset * extent + ii);
            } else {
                char* element_addr;
                element_addr = address + (offset * extent + ii) * A->size ;
                clear_class( element_addr, (ATTRIBUTES*)A->attr);
            }
        }

    }
}
// MEMBER FUNCTION
void Trick::MemoryManager::clear_var( void* address) {

    ATTRIBUTES* reference_attr;
    ALLOC_INFO* alloc_info;

    pthread_mutex_lock(&mm_mutex);
    alloc_info = get_alloc_info_at( address);
    if (alloc_info != NULL) {
        reference_attr = make_reference_attr( alloc_info);
        if (alloc_info->type == TRICK_STRUCTURED ) {
            if (alloc_info->num_index != 0) {
                clear_arrayed_class( (char*)(alloc_info->start), reference_attr, 0, 0) ;
            } else {
                clear_class( (char*)(alloc_info->start), alloc_info->attr) ;
            }
        } else {
            clear_rvalue( alloc_info->start, reference_attr, 0, 0 );
        }
        free_reference_attr( reference_attr);
    } else {
        std::stringstream message;
        message << "Cannot clear the variable at address " << address
                << "because memory manager knows nothing about it." ;
        emitError(message.str());
    }
    pthread_mutex_unlock(&mm_mutex);
}
void Trick::MemoryManager::clear_class( char *address, ATTRIBUTES * A) {

    int jj;
    char *element_addr;

    /** @par Design Details:
     This function is implemented using the following algorithm:
     */

    for (jj = 0; A[jj].name[0] != '\0'; jj++) {
        /*
         * For all the parameters in this data structure...
         */

        if (currentCheckPointAgent->input_perm_check(&A[jj])) {

            /**
             Determine the address of the structure/class element. If the element is a
             C++ static variable, then the element's ATTRIBUTES.offset contains the
             it's address.  Otherwise the element's address is the structure/class
             base address + the element's ATTRIBUTES.offset.
             */
            if (A[jj].mods & 2) {
                element_addr = (char *) A[jj].offset;
            } else {
                element_addr = address + A[jj].offset;
            }

            if (A[jj].type == TRICK_STRUCTURED) {
                if (A[jj].num_index != 0) {
                    clear_arrayed_class( element_addr, &A[jj], 0, 0);
                } else {
                    if ( A[jj].attr != NULL ) {
                        clear_class( element_addr, (ATTRIBUTES*)(A[jj].attr));
                    }
                }
            } else {
                clear_rvalue( element_addr, &(A[jj]), 0, 0);
            }

        }
    }
    return;
}
Beispiel #4
0
int add_class( void )
{
	int i;

	if( class_table[CLASSES-1].name != NULL
	&&  class_table[CLASSES-1].name[0] != '\0' )
	{
		extend_class_table();
	}

	/* CLASSES is now CLASSES + 10 */

	for( i = 0; i < CLASSES; i++ )
	{
		if( class_table[i].name == NULL 
		||  class_table[i].name[0] == '\0' )
		{
			clear_class(i);
			break;
		}
	}
	return i;
}