Commit 141816b3 authored by norvell's avatar norvell
Browse files

Merge branch 'Ericsson/memory_analysis' into 'main'

Debugging feature: Memory analysis and plotting script

See merge request !280
parents ad1818dc 78bdd79a
Loading
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1484,6 +1484,11 @@ static ivas_error decodeG192(
        }
#ifdef WMOPS
        update_wmops();
#endif
#ifdef DEBUGGING
#ifdef RAM_ANALYSIS
        mem_analyze();
#endif
#endif
    }

@@ -1840,6 +1845,11 @@ static ivas_error decodeVoIP(

#ifdef WMOPS
        update_wmops();
#endif
#ifdef DEBUGGING
#ifdef RAM_ANALYSIS
        mem_analyze();
#endif
#endif
    }

+5 −0
Original line number Diff line number Diff line
@@ -765,6 +765,11 @@ int main(

#ifdef WMOPS
        update_wmops();
#endif
#ifdef DEBUGGING
#ifdef RAM_ANALYSIS
        mem_analyze();
#endif
#endif
    }

+1 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@
/*#define WMOPS_PER_FRAME*/                     /* Output complexity in WMOPS per frame to the file "res/wmops" (one float value per frame) */
/*#define WMOPS_DETAIL*/                        /* Activate complexity detail printout for every function. Increases runtime overhead */
/*#define WMOPS_WC_FRAME_ANALYSIS*/             /* Output WMOPS analysis for worst case frame */
/*#define RAM_ANALYSIS*/                        /* Output memory allocated with count_malloc each frame. Can be parsed and plotted with scripts/mem_analysis.m */

#ifdef DEBUGGING

+24 −0
Original line number Diff line number Diff line
@@ -49,6 +49,10 @@ typedef INT64 int64_t;
#define FALSE 0
#endif

#ifdef RAM_ANALYSIS
#include "debug.h"
#endif

/* How to use the tool notes
   =========================

@@ -906,4 +910,24 @@ size_t mem_count_summary( Counting_Size cnt_size )
    return size;
}

#ifdef DEBUGGING
#ifdef RAM_ANALYSIS
void mem_analyze( void )
{
    unsigned int i;
    char buffer[1024];

    for ( i = 0; i < Num_Records_Cur_RAM; i++ )
    {
        sprintf( buffer, "%s:%d,%ld;", Current_Allocations[i].name, Current_Allocations[i].lineno, Current_Allocations[i].block_size );
        dbgwrite( buffer, sizeof( char ), strlen( buffer ), 1, "mem_analysis.csv" );
    }
    sprintf( buffer, "\n" );
    dbgwrite( buffer, sizeof( char ), strlen( buffer ), 1, "mem_analysis.csv" );

    return;
}
#endif
#endif

#endif
+6 −0
Original line number Diff line number Diff line
@@ -95,6 +95,12 @@ extern "C"
    extern void *mem_alloc( const char *func_name, int func_lineno, size_t size, char *alloc_str );
    extern void mem_free( const char *func_name, int func_lineno, void *ptr );

#ifdef DEBUGGING
#ifdef RAM_ANALYSIS
    extern void mem_analyze( void );
#endif
#endif

#ifdef __cplusplus
}
#endif
Loading