; --------------------------------------------------------------------------------
; @Title: Accumulate trace statistics in stack mode
; @Description: Accumulated trace statistics in stack mode
; @Keywords: accumulate, statistic, trace
; @Author: REI
; @Copyright: (C) 1989-2014 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: trace_stat_accumulate_stack.cmm 7545 2014-08-20 12:50:15Z mobermeir $


; close all windows
  WinPAGE.RESet

;load copy application to debugger memory
  Data.LOAD.Elf *.elf /VM

;trace configuration
  Trace.METHOD Analyzer
  Trace.Init
  Trace.AutoInit ON
  Trace.AutoArm OFF
  Trace.Mode Stack
  Trace.ACCESS VM:   ;use application copy in VM for analysis

;open some windows
  WinCLEAR
  WinPOS 0% 0%
  Trace.state
 
  WinPOS 50% 0%
  Trace.STATistic.Func /Accumulate
 
  WinPOS 0% 50%
  AREA.view

;if application is stopped, run now
  IF !STATE.RUN()
    Go.direct
 
  &repeatcount=10.
  &count=0.
  WHILE &count<&repeatcount
  (
    &count=&count+1
    PRINT "start recording &count..."

    ;enable trace recording
    Trace.Init
    Trace.Arm

    ;wait until trace turned off
    WAIT A.STATE()==0

    PRINT "analyzing recording &count..."

    ;wait until Trace.STATistic.Func window finished
    ;program execution continues while performing the statitic analysis without recording
    SCREEN.WAIT
  )

  PRINT "finished."

ENDDO
