dkulacz / gcc-v850-elf-toolchain

GCC-based toolchain for RH850
11 stars 8 forks source link

The generated ELF file cannot be debugged #19

Open mikisama opened 3 years ago

mikisama commented 3 years ago

Hi, @dkulacz

I compiled my own GCC by modifying build-gcc-v850-elf-toolchain.sh. I even used it to porting FreeRTOS for RH850. It seems work well after I burn the SRecod into the MCU through Renesas E1. I create an IAR debug only project, but IAR was crashed and it seems that the ELF file generated by the self-build GCC can not be recognized by IAR debugger. However, when I compile my project again with GCC download from gcc-renesas.com, the IAR debugger works well.

Would you mind sharing some suggestions?

dkulacz commented 3 years ago

Hi @mikisama, Glad to hear it works well with FreeRTOS on RH850. Personally I've not tested debugging with IAR. Only debugging using GreenHills MULTI IDE + Renesas E1 was tested. Startup & linker script used in your project is custom one or newlib's built-in ? When custom linker used, maybe it is something related with .debug* sections in ELF. I can look at gcc-renesas.com toolchain in spare time, to check what is under the hood. Alternatively, you can generate map files for your binary for both toolchains and compare what differs.

mikisama commented 3 years ago

Hi @dkulacz Sorry for the late reply. I have compiled GCC 4.9.4, 7.2.0, 8.2.0, 9.3.0 and 10.2.0. They all work well, but they cannot be debugged using IAR. I also tried to compile GCC 4.9.2 and 4.8.5 with GCC 9.3.0 on Ubuntu 20.04, but the compilation failed. For GCC 9.3.0, the source code of GCC 4.9.2 and 4.8.5 may be too old. Finally, I gave up using IAR for debugging. I found that Renesas e2 studio contains an RH850 gdb server and it works fine.

I compared the generated map files. gcc-renesas.com toolchain have less .debug* sections, this may be the reason why the IAR debugger cannot work.

gcc_rh850_map_file.zip

darklukee commented 3 years ago

Hi @mikisama, We have trouble using gcc-10. We get errors during linking: https://github.com/dkulacz/gcc-v850-elf-toolchain/runs/943995552?check_suite_focus=true

Did you change anything to make it work?

mikisama commented 3 years ago

Hi @mikisama, We have trouble using gcc-10. We get errors during linking: https://github.com/dkulacz/gcc-v850-elf-toolchain/runs/943995552?check_suite_focus=true

Did you change anything to make it work?

Hi @darklukee, I don't use C++, so I only use --enable-languages=c. It seems that gcc-10 works well, but g++-10 does not......

darklukee commented 3 years ago

Hi @mikisama, We have trouble using gcc-10. We get errors during linking: https://github.com/dkulacz/gcc-v850-elf-toolchain/runs/943995552?check_suite_focus=true Did you change anything to make it work?

Hi @darklukee, I don't use C++, so I only use --enable-languages=c. It seems that gcc-10 works well, but g++-10 does not......

Oh, ok. Thank you!

mikisama commented 3 years ago

Hi, @dkulacz I've figured out the cause of the problem. The IAR does not support dwarf-4 ELF debug file which is generated by default.

I solved this problem in the following two steps:

  1. Build newlib with make -w ${NUMJOBS} TARGET_CFLAGS="-gdwarf-2"
  2. Build the project source with -gdwarf-2

My build script is here https://github.com/mikisama/Auto_Build_GCC_RH850/blob/master/build_gcc_rh850.sh