Dear TI team,
I'm trying to use the CCS core trace feature to analyze some hard-to-catch crashes / bugs. I'm currently on CCS 12.0, but I've seen this issue in previous versions (e.g. CCS 10.x, 11.x that were required for earlier MCU+ SDK versions).
I believe that in the past (AM65x, PDK, TI-RTOS, GCC) this was okay-ish. The function/file/lineno information wasn't always 100% correct, but it was mostly good enough.
I'm pretty sure that since we switched to AM64x (MCU+ SDK, FreeRTOS, ti-cgt-armllvm) the decoded trace information mostly lacks the function/file/lineno information and displays n/a instead.
What's a lot worse though is that it apparently doesn't even correctly decode the executed instructions.
In this case for example the core trace tells me that it executed instruction past the "bx lr" at the end of a function:
313981,0x700A0300,0x0000E7FF,n/a,,n/a,n/a,313980, 313982,0x700A0302,0x00009803,n/a,,n/a,n/a,313981, 313983,0x700A0304,0xF6447168,n/a,,n/a,n/a,313982, 313984,0x700A0308,0xF2C7010A,n/a,,n/a,n/a,313983, 313985,0x700A030C,0x00006809,n/a,,n/a,n/a,313984, 313986,0x700A030E,0x00003118,n/a,,n/a,n/a,313985, 313987,0x700A0310,0xF7FFFBFE,n/a,,n/a,n/a,313986, 313988,0x7009FB10,0x0000B084,n/a,,n/a,n/a,313987, 313989,0x7009FB12,0x00009003,n/a,,n/a,n/a,313988, 313990,0x7009FB14,0x00009102,n/a,,n/a,n/a,313989, 313991,0x7009FB16,0x00009802,n/a,,n/a,n/a,313990, 313992,0x7009FB18,0x00006800,n/a,,n/a,n/a,313991, 313993,0x7009FB1A,0x00009000,n/a,,n/a,n/a,313992, 313994,0x7009FB1C,0x00009800,n/a,,n/a,n/a,313993, 313995,0x7009FB1E,0x00003001,n/a,,n/a,n/a,313994, 313996,0x7009FB20,0x0000B920,n/a,,n/a,n/a,313995, 313997,0x7009FB22,0x0000E7FF,n/a,,n/a,n/a,313996, 313998,0x7009FB24,0x00009803,n/a,,n/a,n/a,313997, 313999,0x7009FB26,0x00006900,n/a,,n/a,n/a,313998, 314000,0x7009FB28,0x00009001,n/a,,n/a,n/a,313999, 314001,0x7009FB2A,0x0000E010,n/a,,n/a,n/a,314000, 314002,0x7009FB4E,0x00009801,n/a,,n/a,n/a,314001, 314003,0x7009FB50,0x00006840,n/a,,n/a,n/a,314002, 314004,0x7009FB52,0x00009902,n/a,,n/a,n/a,314003, 314005,0x7009FB54,0x00006048,n/a,,n/a,n/a,314004, 314006,0x7009FB56,0x00009802,n/a,,n/a,n/a,314005, 314007,0x7009FB58,0x00006841,n/a,,n/a,n/a,314006, 314008,0x7009FB5A,0x00006088,n/a,,n/a,n/a,314007, 314009,0x7009FB5C,0x00009801,n/a,,n/a,n/a,314008, 314010,0x7009FB5E,0x00009902,n/a,,n/a,n/a,314009, 314011,0x7009FB60,0x00006088,n/a,,n/a,n/a,314010, 314012,0x7009FB62,0x00009802,n/a,,n/a,n/a,314011, 314013,0x7009FB64,0x00009901,n/a,,n/a,n/a,314012, 314014,0x7009FB66,0x00006048,n/a,,n/a,n/a,314013, 314015,0x7009FB68,0x00009803,n/a,,n/a,n/a,314014, 314016,0x7009FB6A,0x00009902,n/a,,n/a,n/a,314015, 314017,0x7009FB6C,0x00006108,n/a,,n/a,n/a,314016, 314018,0x7009FB6E,0x00009903,n/a,,n/a,n/a,314017, 314019,0x7009FB70,0x00006808,n/a,,n/a,n/a,314018, 314020,0x7009FB72,0x00003001,n/a,,n/a,n/a,314019, 314021,0x7009FB74,0x00006008,n/a,,n/a,n/a,314020, 314022,0x7009FB76,0x0000B004,n/a,,n/a,n/a,314021, 314023,0x7009FB78,0x00004770,n/a,,n/a,n/a,314022, 314024,0x7009FB7A,0x00000000,n/a,,n/a,n/a,314023, 314025,0x7009FB7C,0x00000000,n/a,,n/a,n/a,314024, 314026,0x7009FB7E,0x00000000,n/a,,n/a,n/a,314025,
This is a part of the disassembly (return somewhere in vTaskPlaceOnEventList from a previous branch-and-link, a call to vListInsert and that function's execution):
700a02d0 <vTaskPlaceOnEventList>: ... 700a0300: ff e7 b 0x700a0302 <vTaskPlaceOnEventList+0x32> @ imm = #-2 700a0302: 03 98 ldr r0, [sp, #12] 700a0304: 44 f6 68 71 movw r1, #20328 700a0308: c7 f2 0a 01 movt r1, #28682 700a030c: 09 68 ldr r1, [r1] 700a030e: 18 31 adds r1, #24 700a0310: ff f7 fe fb bl 0x7009fb10 <vListInsert> @ imm = #-2052 7009fb10 <vListInsert>: 7009fb10: 84 b0 sub sp, #16 7009fb12: 03 90 str r0, [sp, #12] 7009fb14: 02 91 str r1, [sp, #8] 7009fb16: 02 98 ldr r0, [sp, #8] 7009fb18: 00 68 ldr r0, [r0] 7009fb1a: 00 90 str r0, [sp] 7009fb1c: 00 98 ldr r0, [sp] 7009fb1e: 01 30 adds r0, #1 7009fb20: 20 b9 cbnz r0, 0x7009fb2c <vListInsert+0x1c> @ imm = #8 7009fb22: ff e7 b 0x7009fb24 <vListInsert+0x14> @ imm = #-2 7009fb24: 03 98 ldr r0, [sp, #12] 7009fb26: 00 69 ldr r0, [r0, #16] 7009fb28: 01 90 str r0, [sp, #4] 7009fb2a: 10 e0 b 0x7009fb4e <vListInsert+0x3e> @ imm = #32 7009fb2c: 03 98 ldr r0, [sp, #12] 7009fb2e: 08 30 adds r0, #8 7009fb30: 01 90 str r0, [sp, #4] 7009fb32: ff e7 b 0x7009fb34 <vListInsert+0x24> @ imm = #-2 7009fb34: 01 98 ldr r0, [sp, #4] 7009fb36: 40 68 ldr r0, [r0, #4] 7009fb38: 00 68 ldr r0, [r0] 7009fb3a: 00 99 ldr r1, [sp] 7009fb3c: 88 42 cmp r0, r1 7009fb3e: 05 d8 bhi 0x7009fb4c <vListInsert+0x3c> @ imm = #10 7009fb40: ff e7 b 0x7009fb42 <vListInsert+0x32> @ imm = #-2 7009fb42: ff e7 b 0x7009fb44 <vListInsert+0x34> @ imm = #-2 7009fb44: 01 98 ldr r0, [sp, #4] 7009fb46: 40 68 ldr r0, [r0, #4] 7009fb48: 01 90 str r0, [sp, #4] 7009fb4a: f3 e7 b 0x7009fb34 <vListInsert+0x24> @ imm = #-26 7009fb4c: ff e7 b 0x7009fb4e <vListInsert+0x3e> @ imm = #-2 7009fb4e: 01 98 ldr r0, [sp, #4] 7009fb50: 40 68 ldr r0, [r0, #4] 7009fb52: 02 99 ldr r1, [sp, #8] 7009fb54: 48 60 str r0, [r1, #4] 7009fb56: 02 98 ldr r0, [sp, #8] 7009fb58: 41 68 ldr r1, [r0, #4] 7009fb5a: 88 60 str r0, [r1, #8] 7009fb5c: 01 98 ldr r0, [sp, #4] 7009fb5e: 02 99 ldr r1, [sp, #8] 7009fb60: 88 60 str r0, [r1, #8] 7009fb62: 02 98 ldr r0, [sp, #8] 7009fb64: 01 99 ldr r1, [sp, #4] 7009fb66: 48 60 str r0, [r1, #4] 7009fb68: 03 98 ldr r0, [sp, #12] 7009fb6a: 02 99 ldr r1, [sp, #8] 7009fb6c: 08 61 str r0, [r1, #16] 7009fb6e: 03 99 ldr r1, [sp, #12] 7009fb70: 08 68 ldr r0, [r1] 7009fb72: 01 30 adds r0, #1 7009fb74: 08 60 str r0, [r1] 7009fb76: 04 b0 add sp, #16 7009fb78: 70 47 bx lr 7009fb7a: 00 00 movs r0, r0 7009fb7c: 00 00 movs r0, r0 7009fb7e: 00 00 movs r0, r0
I believe (one of) the reason(s) trace decoding fails more often now than in the past is that a lot of MCU+ SDK code is now compiled as Thumb code, whereas before it was mostly/all ARM code.
I've dumped the ETB content and decoded it using OpenCSD:
Idx:65211; ID:10; OCSD_GEN_TRC_ELEM_ADDR_NACC( 0x700a0300 ) Idx:65211; ID:10; OCSD_GEN_TRC_ELEM_ADDR_UNKNOWN() Idx:65212; ID:10; [0xbc ]; P_HDR : Atom P-header.; EEEEEEEEEEEEEEE Idx:65213; ID:10; [0xbc ]; P_HDR : Atom P-header.; EEEEEEEEEEEEEEE Idx:65214; ID:10; [0x90 ]; P_HDR : Atom P-header.; EEEE Idx:65216; ID:10; [0x15 ]; BRANCH_ADDRESS : Branch address.; Addr=0x700A0314 ~[0x14]; Idx:65217; ID:10; [0xbc ]; P_HDR : Atom P-header.; EEEEEEEEEEEEEEE Idx:65217; ID:10; OCSD_GEN_TRC_ELEM_ADDR_NACC( 0x700a0314 )
Starting at address 0x700a0300 the code executed 49 instructions until it returned to address 0x700a0314, with no instructions "not executed" (which would be denoted as a 'N' instead of an 'E', e.g. "Atom P-header.; EEEN")::
- 7 instructions within vTaskPlaceOnEventList until the branch to vListInsert
- 9 instructions from 0x7009fb10 to 0x7009fb20, at which point a conditional branch is taken
- the core trace pretends that execution continued after that with instruction 7009fb24, which I believe is wrong
- 10 instructions from 0x7009fb2c to 0x7009fb3e, at which point a conditional branch is taken
- 23 instructions from 0x7009fb4c to 0x7009fb78, at which point the function returns via "bx lr"
- the core trace pretends that after the "bx lr" execution continued execution at address 0x7009fb7a to 0x7009fb84
The core trace also decodes 49 instructions starting at 0x700a0300 until it resumes at 0x700a0314, but it apparently ignores all the conditional branches and "takes" only the unconditional branches.
- I'm pretty sure that core trace fails to decode the conditional thumb mode branches.
- I'm only guessing that the inability to decode function/file/line started with the switch to cgt-arm-llvm.
- Are these known issues? Are there fixes for this otherwise very helpful feature planned?
Best Regards,
Dominic