Commit 9036bf0d authored by malenov's avatar malenov
Browse files

support for .csv output of per-frame memory consumption

parent 6fb74bfb
Loading
Loading
Loading
Loading
+39 −3
Original line number Diff line number Diff line
@@ -1238,13 +1238,14 @@ static void subst(char* s, char from, char to)
    return;
}


/*-------------------------------------------------------------------*
 * mem_count_summary()
 *
 * Print detailed (per-item) information about heap memory usage
 *--------------------------------------------------------------------*/

static void mem_count_summary(void)
static void mem_count_summary()
{
    int i, j, flag_intra_frame_memory;
    size_t length;
@@ -1341,6 +1342,42 @@ static void mem_count_summary(void)

    return;
}

/*-------------------------------------------------------------------*
 * export_mem()
 *
 * Export detailed (per-item) information about heap memory usage to a .csv file
 *--------------------------------------------------------------------*/

void export_mem( const char *csv_filename )
{
    int i;
    FILE *fid;
    allocator_record *record_ptr;

    /* Export individual heap memory records to a .csv file */
    if ( csv_filename != NULL && strcmp( csv_filename, "" ) != 0 )
    {
        fid = fopen( csv_filename, "wb" );

        if ( fid == NULL )
        {
            fprintf( stderr, "\nCannot open %s!\n\n", csv_filename );
            exit( -1 );
        }

        for ( i = 0; i < Num_Records; i++ )
        {
            record_ptr = &( allocation_list[i] );
            fprintf( fid, "%s:%d,%ld;\n", record_ptr->name, record_ptr->lineno, record_ptr->block_size );
        }
        fprintf( fid, "\n" );

        fclose( fid );
    }

    return;
}
#endif

/*-------------------------------------------------------------------*
@@ -1424,7 +1461,6 @@ void print_mem(ROM_Size_Lookup_Table Const_Data_PROM_Table[])
#endif
    }


    if (Stat_Cnt_Size > 0)
    {
        fprintf(stdout, "\nNote: 1 word = %d bits\n", 8 << Stat_Cnt_Size);
+3 −0
Original line number Diff line number Diff line
@@ -487,6 +487,9 @@ void mem_free(const char* func_name, int func_lineno, void* ptr);

void reset_mem(Counting_Size cnt_size);
void print_mem(ROM_Size_Lookup_Table Const_Data_PROM_Table[]);
#ifdef MEM_COUNT_DETAILS
void export_mem( const char *csv_filename );
#endif

int push_stack(const char* filename, const char* fctname);
int pop_stack(const char* filename, const char* fctname);