hello,
I am using cmake+nijia to create ELF files instead of S32DS IDE. The target development board is S32K344, and the compiler is GHS.
I have successfully generated ELF files so far, but when using PE for ELF file debugging, it does not work as expected, such as the Step over and Step return functions.
Here is the CMake project configuration I am using
***********************************CompileCfg.cmake**************************************
How to use IDE debugging correctly,
Kind Regards.
已解决! 转到解答。
Hi,
This issue is probably related to a known issue listed in the S32DS release notes:
Step out work incorrect with dbg_derived_types source: The GHS toolchain does not
generate DWARF Call Frame information that is suitable for unwinding the call stack. For
third-party debuggers incapable of unwinding the call stack through an alternate means
(disassembling code), this may nullify the ability to walk the call stack or view variables saved
in previous frames. As a workaround S32DS removes the debug frames info to force GDB client
to recreate the frames. In some cases this method may not work and lead to incorrect behaviour
for Step out command.
Workaround: Set a breakpoint at function end and run to breakpoint
Similar issue was pressent in S32DS for arm/power:
Problems could be experienced while debugging of elf file generated by GHS compiler like
missing call stack information, incorrect info on step into function, etc.
Workaround: On occasion GHS generates GDB incompatible debug information preventing the
debugger from displaying the call stack. In some cases, without such information gdb can still
debug your program. The program build needs to be augmented with a post-build step, select the
project in the project explorer view and File->Properties to display the project properties, under
C/C++ Build -> Settings select the build steps tab and enter the command gstrip –
r=.debug_frame executable. Switch to Instruction Stepping Mode to be able to step through
function. If this workaround does not help – please report issue to GreenHills support.
Hope it helps.
Stan
@Bruce_Ye hello, may I ask you a question?
how to import the source code into the S32DS ide?
when I import the elf which is generated by ghs into S32DS, but when I download the elf into MCU, I can not see the source code , only see the assembly code?
thanks
The following is the engineering log of IDE using the GHS compiler:
******************************************************************************
Finished building: ../src/main.c
Building file: ../Projectcode/Mcal_config/src/Clock_Ip_Cfg.c
Invoking: GHS C Compiler for ARM Standalone
ccarm -preprocess_assembly_files -c99 --gnu_asm -g -dwarf2 -Onone -DSTART_FROM_FLASH -DS32K3XX -DENABLE_FPU -DLTC_ISOFT_CUSTOM -DINIT_STDBY_RAM -DARMCM7_SP -D__ITCM_INIT -D__DTCM_INIT -D__ghs__ -DGEELY_SPECIFICATION_USED=1 -DDISABLE_MCAL_INTERMODULE_ASR_CHECK -DBTB_ENABLE -DUSING_OS_AUTOSAROS -DS32K344 -DGHS -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Extend" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\CommonInclude" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Kernel" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Platform" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\BSW_Config" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Base_TS_T40D34M10I0R0" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Base_TS_T40D34M10I0R0\header" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Base_TS_T40D34M10I0R0\include" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Base_TS_T40D34M10I0R0\src" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Det_TS_T40D34M10I0R0" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Det_TS_T40D34M10I0R0\include" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Det_TS_T40D34M10I0R0\src" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Mcu_TS_T40D34M10I0R0" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Mcu_TS_T40D34M10I0R0\include" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Mcu_TS_T40D34M10I0R0\src" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Platform_TS_T40D34M10I0R0" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Platform_TS_T40D34M10I0R0\build_files" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Platform_TS_T40D34M10I0R0\build_files\ghs" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Platform_TS_T40D34M10I0R0\include" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Platform_TS_T40D34M10I0R0\src" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Platform_TS_T40D34M10I0R0\startup" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Platform_TS_T40D34M10I0R0\startup\include" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Platform_TS_T40D34M10I0R0\startup\src" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Platform_TS_T40D34M10I0R0\startup\src\m7" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Platform_TS_T40D34M10I0R0\startup\src\m7\ghs" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Rte_TS_T40D34M10I0R0" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Rte_TS_T40D34M10I0R0\include" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal\Rte_TS_T40D34M10I0R0\src" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal_config" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal_config\include" -I"D:\D\workpalce\S32k344\S32K344_DEMO_20\Projectcode\Mcal_config\src" -cpu=cortexm7 -fsingle -thumb -MD -c -o "Projectcode/Mcal_config/src/Clock_Ip_Cfg.o" "../Projectcode/Mcal_config/src/Clock_Ip_Cfg.c"
"D:\D\workpalce\S32k344\S32K344_DEMO_20\Platform\Arch_Define.h", line 66: warning #1-D:
last line of file ends without a newline
/*=======[E N D O F F I L E]==============================================*/
^
Finished building: ../Projectcode/Mcal_config/src/Clock_Ip_Cfg.c
************************************************************************************************
Building target: S32K344_DEMO_20.elf
Invoking: GHS C Linker for ARM Standalone
ccarm --gnu_asm -g -dwarf2 -T "D:/D/workpalce/S32k344/S32K344_DEMO_20/Projectcode/Mcal/Platform_TS_T40D34M10I0R0/build_files/ghs/linker_flash_s32k344.ld" -e Reset_Handler -nostartfiles -cpu=cortexm7 -thumb -o "S32K344_DEMO_20.elf" ./src/main.o ./Projectcode/Mcal_config/src/Clock_Ip_Cfg.o ./Projectcode/Mcal_config/src/Clock_Ip_PBcfg.o ./Projectcode/Mcal_config/src/IntCtrl_Ip_Cfg.o ./Projectcode/Mcal_config/src/Mcu_Cfg.o ./Projectcode/Mcal_config/src/Mcu_PBcfg.o ./Projectcode/Mcal_config/src/OsIf_Cfg.o ./Projectcode/Mcal_config/src/Platform_Cfg.o ./Projectcode/Mcal_config/src/Platform_Ipw_Cfg.o ./Projectcode/Mcal_config/src/Power_Ip_Cfg.o ./Projectcode/Mcal_config/src/Power_Ip_PBcfg.o ./Projectcode/Mcal_config/src/Ram_Ip_Cfg.o ./Projectcode/Mcal_config/src/Ram_Ip_PBcfg.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Adc.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Can.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Crc.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Crypto.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Dio.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Eth.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_EthSwt_43_SJA11XX.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_EthTrcv_43_PHY.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Fee.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Fls.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Gpt.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_I2c.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_I3c.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Icu.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Iseled.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Lin.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Mcl.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Mcu.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Ocu.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Port.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Pwm.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Rm.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Sai.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Sbc_fs26.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Sbc_fs86.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Sent.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Spi.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Uart.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Wdg.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Wdg_43_fs26.o ./Projectcode/Mcal/Rte_TS_T40D34M10I0R0/src/SchM_Wdg_43_fs86.o ./Projectcode/Mcal/Platform_TS_T40D34M10I0R0/startup/src/m7/ghs/Vector_Table.o ./Projectcode/Mcal/Platform_TS_T40D34M10I0R0/startup/src/m7/ghs/startup_cm7.o ./Projectcode/Mcal/Platform_TS_T40D34M10I0R0/startup/src/m7/exceptions.o ./Projectcode/Mcal/Platform_TS_T40D34M10I0R0/startup/src/m7/startup.o ./Projectcode/Mcal/Platform_TS_T40D34M10I0R0/startup/src/nvic.o ./Projectcode/Mcal/Platform_TS_T40D34M10I0R0/startup/src/sys_init.o ./Projectcode/Mcal/Platform_TS_T40D34M10I0R0/startup/src/system.o ./Projectcode/Mcal/Platform_TS_T40D34M10I0R0/src/IntCtrl_Ip.o ./Projectcode/Mcal/Platform_TS_T40D34M10I0R0/src/Platform.o ./Projectcode/Mcal/Platform_TS_T40D34M10I0R0/src/Platform_Ipw.o ./Projectcode/Mcal/Platform_TS_T40D34M10I0R0/src/System_Ip.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Clock_Ip.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Clock_Ip_Data.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Clock_Ip_Divider.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Clock_Ip_DividerTrigger.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Clock_Ip_ExtOsc.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Clock_Ip_FracDiv.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Clock_Ip_Frequency.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Clock_Ip_Gate.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Clock_Ip_IntOsc.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Clock_Ip_Irq.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Clock_Ip_Monitor.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Clock_Ip_Pll.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Clock_Ip_ProgFreqSwitch.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Clock_Ip_Selector.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Clock_Ip_Specific.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Mcu.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Mcu_Dem_Wrapper.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Mcu_Ipw.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Power_Ip.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Power_Ip_CortexM7.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Power_Ip_FLASH.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Power_Ip_MC_ME.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Power_Ip_MC_RGM.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Power_Ip_MC_RGM_Irq.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Power_Ip_PMC.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Power_Ip_PMC_Irq.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Power_Ip_Private.o ./Projectcode/Mcal/Mcu_TS_T40D34M10I0R0/src/Ram_Ip.o ./Projectcode/Mcal/Det_TS_T40D34M10I0R0/src/Det.o ./Projectcode/Mcal/Det_TS_T40D34M10I0R0/src/Det_stub.o ./Projectcode/Mcal/Base_TS_T40D34M10I0R0/src/OsIf_Timer.o ./Projectcode/Mcal/Base_TS_T40D34M10I0R0/src/OsIf_Timer_System.o ./Projectcode/Mcal/Base_TS_T40D34M10I0R0/src/OsIf_Timer_System_Internal_Systick.o ./Projectcode/BSW_Config/Os_Cfg.o ./Projectcode/BSW_Config/Os_Intvet.o ./Projectcode/BSW_Config/Os_Kdata.o ./Projectcode/BSW_Config/Os_UserInf.o ./Platform/Arch_Extend.o ./Platform/Arch_Irq.o ./Platform/Arch_Mpu.o ./Platform/Arch_PendSV.o ./Platform/Arch_Processor.o ./Platform/Arch_Timer.o ./Platform/Arch_Trap.o ./Kernel/Os_Alarm.o ./Kernel/Os_Appl.o ./Kernel/Os_Core.o ./Kernel/Os_Counter.o ./Kernel/Os_Event.o ./Kernel/Os_Hook.o ./Kernel/Os_Interrupt.o ./Kernel/Os_Ioc.o ./Kernel/Os_Kernel.o ./Kernel/Os_Mprot.o ./Kernel/Os_Panic.o ./Kernel/Os_Peripheral.o ./Kernel/Os_Resource.o ./Kernel/Os_Rpc.o ./Kernel/Os_ScheduleTable.o ./Kernel/Os_Spinlock.o ./Kernel/Os_Sprot.o ./Kernel/Os_StackMonitor.o ./Kernel/Os_Task.o ./Kernel/Os_Tprot.o ./Extend/Os_Extend.o
Finished building target: S32K344_DEMO_20.elf
**********************************************************************************************
**********************************************************************************************
Hi,
This issue is probably related to a known issue listed in the S32DS release notes:
Step out work incorrect with dbg_derived_types source: The GHS toolchain does not
generate DWARF Call Frame information that is suitable for unwinding the call stack. For
third-party debuggers incapable of unwinding the call stack through an alternate means
(disassembling code), this may nullify the ability to walk the call stack or view variables saved
in previous frames. As a workaround S32DS removes the debug frames info to force GDB client
to recreate the frames. In some cases this method may not work and lead to incorrect behaviour
for Step out command.
Workaround: Set a breakpoint at function end and run to breakpoint
Similar issue was pressent in S32DS for arm/power:
Problems could be experienced while debugging of elf file generated by GHS compiler like
missing call stack information, incorrect info on step into function, etc.
Workaround: On occasion GHS generates GDB incompatible debug information preventing the
debugger from displaying the call stack. In some cases, without such information gdb can still
debug your program. The program build needs to be augmented with a post-build step, select the
project in the project explorer view and File->Properties to display the project properties, under
C/C++ Build -> Settings select the build steps tab and enter the command gstrip –
r=.debug_frame executable. Switch to Instruction Stepping Mode to be able to step through
function. If this workaround does not help – please report issue to GreenHills support.
Hope it helps.
Stan
Thank you for your help.
"Problems could be experienced while debugging of elf file generated by GHS compiler like
missing call stack information, incorrect info on step into function, etc.". It is indeed here that caused the problem. I encountered the same issue during debugging when deleting gstrip - r=. debug_frame ${ProjName}. elf in the S32DS compiled project.
Next, I need to add relevant commands to my CMakeLists.txt. I hope everything goes smoothly.