Files
Gen4_R-Car_Trace32/2_Trunk/demo/practice/etc/print_backtrace.cmm
2025-10-14 09:52:32 +09:00

74 lines
2.4 KiB
Plaintext

; --------------------------------------------------------------------------------
; @Title: Show PRACTICE backtrace in AREA
; @Description:
; Prints a PRACTICE backtrace into the AREA window.
; Further handling of the error e.g. abort PRACTICE execution, user messages,
; aso. need's to be done in the calling script.
; This script must be invoked from an ON ERROR GOSUB block as shown below.
; Usage:
; Example 1: show Backtrace in AREA, abort PRACTICE execution
; ON ERROR GOSUB
; (
; ON ERROR DEFault
; DO ~~/demo/practice/etc/print_backtrace.cmm
; ; <implementation dependent action e.g. further messages for user>
; AREA
; END
; )
; ; <section to guard>
; ON ERROR inherit
;
; Example 2: show Backtrace in AREA, stop PRACTICE, show debug view
; ON ERROR GOSUB
; (
; ON ERROR DEFault
; DO ~~/demo/practice/etc/print_backtrace.cmm
; ; <implementation dependent action e.g. further messages for user>
; AREA
; PLIST
; STOP
; RETURN
; )
; ; <section to guard>
; ON ERROR inherit
; @Author: AME
; @Copyright: (C) 1989-2020 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: print_backtrace.cmm 16991 2021-01-14 09:21:03Z mobermeir $
ON ERROR DEFault
IF VERSION.BUILD()<85424.
(
PRINT "Sorry, your version of TRACE32 is too old for script " OS.PPF()
ENDDO
)
IF PRACTICE.CALLER.FILE(1.)==""
ENDDO
IF PRACTICE.CALLER.FILE(2.)==""
ENDDO
(
PRIVATE &sStackCallerFile &sCallerString
&sStackCallerFile=PRACTICE.CALLER.FILE(2.)
SPRINTF &sCallerString "(line %d., %s)" PRACTICE.CALLER.LINE(2.) OS.FILE.NAME(&sStackCallerFile)
PRINT %COLOR.NORMAL "PRACTICE error: '" %ERROR ERROR.MESSAGE() "/" ERROR.ID() %COLOR.NORMAL "' when executing '" %ATTR 0x24 ERROR.CMDLINE() %ATTR 0 %COLOR.NORMAL "' &sCallerString"
)
(
// print stackdump
PRIVATE &nStackLevel &sStackCallerFile &nStackCallerFileLength
&nStackLevel=1.
RePeaT
(
&sStackCallerFile=PRACTICE.CALLER.FILE(&nStackLevel+1.)
IF ("&sStackCallerFile"!="")
PRINTF " #%02u in %-32s line %4d., path %s" &nStackLevel OS.FILE.NAME("&sStackCallerFile")+"," PRACTICE.CALLER.LINE(&nStackLevel) "&sStackCallerFile"
&nStackLevel=&nStackLevel+1.
)
WHILE ((&nStackLevel<100.)&&("&sStackCallerFile"!=""))
)
ENDDO