Problem Definition:
With exception enabled, we don’t see the stack pointer being properly returned from the exception handler.
The stack pointer returned from the exception handler is always 2 functions above the place where the exception has occurred.
This issue is seen with our real time setup.
Recreation of issue in EVM:
We were able to recreate this issue with EVM. The project is attached.
Explanation of the code used in the project:
There are 10 functions defined in the .c file (Example_CallTrace.cpp). The functions are named function_level1() to function_level10()
In function_level10(), there is an exception triggered forcefully(line 106).
I have printed SP in every function from 1 to 10. Always in the exception handler, we always see the SP of the function_level8() instead of function_level10().
If I add a breakpoint at *ptr = 0x10; (line 106) and continue until the end of the function (line 107) using step in debug, I get the proper stack pointer. I have added both the console prints (with free run and with adding breakpoint and stepping in)
I hope the problem is understood.
CCS details:
- I tried the experiment with compiler 7.3.19, bois 6_33_04_39 and following components:
**** Build of configuration Debug for project CallTrace ****
"E:\\ti\\ccsv5\\utils\\bin\\gmake" -k all
'Building file: ../CallTrace.cfg'
'Invoking: XDCtools'
"C:/ti/xdctools_3_23_03_53/xs" --xdcpath="C:/ti/dsplib_c66x_3_1_0_0/packages;C:/ti/edma3_lld_02_11_05_02/packages;C:/ti/imglib_c66x_3_1_0_1/packages;C:/ti/ipc_1_24_02_27/packages;C:/ti/mathlib_c66x_3_0_1_1/packages;C:/ti/mcsdk_2_00_09_21/demos;C:/ti/pdk_C6657_1_0_0_0/packages;C:/ti/pdk_C6670_1_0_0_21/packages;C:/ti/pdk_C6678_1_0_0_21/packages;C:/ti/bios_6_33_04_39/packages;C:/ti/uia_1_01_00_04/packages;E:/ti/xdais_7_21_01_07/packages;E:/ti/xdais_7_21_01_07/examples;" xdc.tools.configuro -o configPkg -t ti.targets.elf.C66 -p ti.platforms.evm6670 -r release -c "C:/ti/ccsv5/tools/compiler/c6000_7.3.19" "../CallTrace.cfg"
making package.mak (because of package.bld) ...
generating interfaces for package configPkg (because package/package.xdc.inc is older than package.xdc) ...
configuring CallTrace.xe66 from package/cfg/CallTrace_pe66.cfg ...
generating custom ti.sysbios library makefile ...
Starting build of library sources ...
making E:/Swaroop/Code/CallTrace/ExampleProjectTICallTrace/CallTrace/src/sysbios/sysbios.lib ...
Build of libraries done.
cle66 package/cfg/CallTrace_pe66.c ...
'Finished building: ../CallTrace.cfg'
' '
'Building file: ../Example_CallTrace.cpp'
'Invoking: C6000 Compiler'
"E:/ti/ccsv5/tools/compiler/c6000_7.4.4/bin/cl6x" -mv6600 -g --include_path="C:/ti/ccsv5/tools/compiler/c6000_7.3.19/include" --display_error_number --diag_warning=225 --abi=eabi --preproc_with_compile --preproc_dependency="Example_CallTrace.pp" --cmd_file="./configPkg/compiler.opt" "../Example_CallTrace.cpp"
- I also tried with compiler 7.4.4 and bios 6_37_05_35 and the following components:
**** Build of configuration Debug for project SPErrorProj ****
"E:\\ti\\ccsv5\\utils\\bin\\gmake" -k all
'Building file: ../CallTrace.cfg'
'Invoking: XDCtools'
"C:/ti/xdctools_3_25_06_96/xs" --xdcpath="C:/ti/dsplib_c66x_3_1_0_0/packages;C:/ti/edma3_lld_02_11_05_02/packages;C:/ti/imglib_c66x_3_1_0_1/packages;C:/ti/ipc_1_24_02_27/packages;C:/ti/mathlib_c66x_3_0_1_1/packages;C:/ti/mcsdk_2_00_09_21/demos;C:/ti/pdk_C6657_1_0_0_0/packages;C:/ti/pdk_C6670_1_0_0_21/packages;C:/ti/pdk_C6678_1_0_0_21/packages;C:/ti/bios_6_37_05_35/packages;E:/ti/uia_1_03_01_08/packages;E:/ti/xdais_7_21_01_07/packages;E:/ti/xdais_7_21_01_07/examples;E:/ti/ccsv5/ccs_base;" xdc.tools.configuro -o configPkg -t ti.targets.elf.C66 -p ti.platforms.evm6670 -r release -c "E:/ti/ccsv5/tools/compiler/c6000_7.4.4" "../CallTrace.cfg"
making package.mak (because of package.bld) ...
generating interfaces for package configPkg (because package/package.xdc.inc is older than package.xdc) ...
configuring CallTrace.xe66 from package/cfg/CallTrace_pe66.cfg ...
generating custom ti.sysbios library makefile ...
Starting build of library sources ...
making E:/Swaroop/Code/CallTrace/ExampleProjectTISPError/SPErrorProj/src/sysbios.ae66 ...
gmake[1]: Entering directory `E:/Swaroop/Code/CallTrace/ExampleProjectTISPError/SPErrorProj/src/sysbios'
cle66 C:/ti/bios_6_37_05_35/packages/ti/sysbios/BIOS.c ...
asme66 C:/ti/bios_6_37_05_35/packages/ti/sysbios/family/c64p/Hwi_disp_always.s64P ...
asme66 C:/ti/bios_6_37_05_35/packages/ti/sysbios/family/c64p/Hwi_asm.s62 ...
asme66 C:/ti/bios_6_37_05_35/packages/ti/sysbios/family/c64p/Hwi_asm_switch.s62 ...
asme66 C:/ti/bios_6_37_05_35/packages/ti/sysbios/family/c64p/Clobber_asm.s62 ...
asme66 C:/ti/bios_6_37_05_35/packages/ti/sysbios/family/c64p/Exception_asm.s64P ...
asme66 C:/ti/bios_6_37_05_35/packages/ti/sysbios/family/c64p/MemoryProtect_asm.s64P ...
asme66 C:/ti/bios_6_37_05_35/packages/ti/sysbios/family/c62/TaskSupport_asm.s62 ...
asme66 C:/ti/bios_6_37_05_35/packages/ti/sysbios/timers/timer64/Timer_asm.s64P ...
asme66 C:/ti/bios_6_37_05_35/packages/ti/sysbios/timers/dmtimer/Timer_asm.s64P ...
asme66 C:/ti/bios_6_37_05_35/packages/ti/sysbios/../sk/sk_cwrap.asm ...
are66 BIOS.obj c64p_Hwi_disp_always.obj c64p_Hwi_asm.obj c64p_Hwi_asm_switch.obj c64p_Clobber_asm.obj c64p_Exception_asm.obj c64p_MemoryProtect_asm.obj c62_TaskSupport_asm.obj timer64_Timer_asm.obj dmtimer_Timer_asm.obj sk_sk_cwrap.obj ...
gmake[1]: Leaving directory `E:/Swaroop/Code/CallTrace/ExampleProjectTISPError/SPErrorProj/src/sysbios'
Build of libraries done.
cle66 package/cfg/CallTrace_pe66.c ...
'Finished building: ../CallTrace.cfg'
' '
'Building file: ../Example_CallTrace.cpp'
'Invoking: C6000 Compiler'
"E:/ti/ccsv5/tools/compiler/c6000_7.4.4/bin/cl6x" -mv6600 --abi=eabi -g --include_path="E:/ti/ccsv5/tools/compiler/c6000_7.4.4/include" --display_error_number --diag_warning=225 --diag_wrap=off --preproc_with_compile --preproc_dependency="Example_CallTrace.pp" --cmd_file="./configPkg/compiler.opt" "../Example_CallTrace.cpp"
Console prints:
With FREE-RUN:
[C66xx_0] function_level0 : SP 0x00812818 : PC 0x00802ec8
function_level1 : SP 0x00812800 : PC 0x00802f54
function_level2 : SP 0x008127e8 : PC 0x00802f88
function_level3 : SP 0x008127d0 : PC 0x00802fc0
function_level4 : SP 0x008127b8 : PC 0x00802ff0
function_level5 : SP 0x008127a0 : PC 0x00803024
function_level6 : SP 0x00812788 : PC 0x00803054
function_level7 : SP 0x00812770 : PC 0x00803088
function_level8 : SP 0x00812758 : PC 0x008030c0
function_level9 : SP 0x00812740 : PC 0x008030f0
function_level10 : SP 0x00812718 : PC 0x0080312c
x20b04658
A16=0x8124e2 A17=0x30
A18=0x8124e0 A19=0x0
A20=0x6c A21=0x4c
A22=0x93272da9 A23=0x18002000
A24=0x0 A25=0x4
A26=0x0 A27=0x0
A28=0x80180088 A29=0x4000
A30=0x1 A31=0x58
B0=0x0 B1=0x0
B2=0x80fa69 B3=0x8030d8
B4=0x0 B5=0x10
B6=0x31 B7=0x813128
B8=0x812480 B9=0x3a
B10=0x812758 B11=0x8013
B12=0x0 B13=0xf8
B14=0x0 B15=0x812758
B16=0x30 B17=0x81270c
B18=0x80f30b B19=0x78
B20=0x69 B21=0x69
B22=0xffffffff B23=0x0
B24=0x14280800 B25=0x18000800
B26=0x84820 B27=0x40010100
B28=0xc1820841 B29=0x20000482
B30=0x70 B31=0xffffffff
NTSR=0x1000c
ITSR=0x0
IRP=0x0
SSR=0x0
AMR=0x0
RILC=0x0
ILC=0x0
Exception at 0x803112
EFR=0x40000000 NRP=0x803112
UMC Exception MPFAR=0x0 MPFSR=0x110
Supervisor Write violation, Fault ID=0x1
Inside Exception : SP 0x00812758 : PC 0x008030d8 : NRP 0x00803112
ti.sysbios.family.c64p.Exception: line 248: E_exceptionMin: pc = 0x00000000, sp = 0x00812758.
To see more exception detail, use ROV or set 'ti.sysbios.family.c64p.Exception.enablePrint = true;'
xdc.runtime.Error.raise: terminating execution
With adding Debug point and stepping in for lines 106 and 107:
[C66xx_0] function_level0 : SP 0x00812818 : PC 0x00802ec8
function_level1 : SP 0x00812800 : PC 0x00802f54
function_level2 : SP 0x008127e8 : PC 0x00802f88
function_level3 : SP 0x008127d0 : PC 0x00802fc0
function_level4 : SP 0x008127b8 : PC 0x00802ff0
function_level5 : SP 0x008127a0 : PC 0x00803024
function_level6 : SP 0x00812788 : PC 0x00803054
function_level7 : SP 0x00812770 : PC 0x00803088
function_level8 : SP 0x00812758 : PC 0x008030c0
function_level9 : SP 0x00812740 : PC 0x008030f0
function_level10 : SP 0x00812718 : PC 0x0080312c
x20b04658
A16=0x8124e2 A17=0x30
A18=0x8124e0 A19=0x0
A20=0x6c A21=0x4c
A22=0x93272da9 A23=0x18002000
A24=0x0 A25=0x4
A26=0x0 A27=0x0
A28=0x80180088 A29=0x4000
A30=0x1 A31=0x58
B0=0x0 B1=0x0
B2=0x80fa69 B3=0x803144
B4=0x0 B5=0x10
B6=0x31 B7=0x813128
B8=0x812480 B9=0x3a
B10=0x812758 B11=0x8013
B12=0x0 B13=0xf8
B14=0x0 B15=0x812718
B16=0x30 B17=0x81270c
B18=0x80f30b B19=0x78
B20=0x69 B21=0x69
B22=0xffffffff B23=0x0
B24=0x14280800 B25=0x18000800
B26=0x84820 B27=0x40010100
B28=0xc1820841 B29=0x20000482
B30=0x70 B31=0xffffffff
NTSR=0x1000c
ITSR=0x0
IRP=0x0
SSR=0x0
AMR=0x0
RILC=0x0
ILC=0x0
Exception at 0x80314c
EFR=0x40000000 NRP=0x80314c
UMC Exception MPFAR=0x0 MPFSR=0x110
Supervisor Write violation, Fault ID=0x1
Inside Exception : SP 0x00812718 : PC 0x00803144 : NRP 0x0080314c
ti.sysbios.family.c64p.Exception: line 248: E_exceptionMin: pc = 0x00000000, sp = 0x00812718.
To see more exception detail, use ROV or set 'ti.sysbios.family.c64p.Exception.enablePrint = true;'
xdc.runtime.Error.raise: terminating execution