Hi All!
I started using the stm8 some years ago, tried some code on IAR and now I went ahead and tried to do the same but with sdcc just because I don't like IAR :)
My code uses multiple .c source files, and I'm using the stm8 binutils (all of these are provided on PlatformIO, but that's just because I'm trying to use their vscode extension instead of creating my own Makefiles).
If I try to build it and upload it with my stlink, it works. If I try to debug it with stm8-gdb; it "works", but I can't move thru the high level sources. The debugger clearly states that the elf file doesn't have debug symbols.
So I went ahead and tried to reproduce the issue outside of the environment, which I could do easily. Consider two source files, a.c and b.c. On the first one I have the main() function, which calls another function declared on b.c. This function changes a register value, so it doesn't get optimized. I ran the following commands:
However, the resulting file.elf doesn't contain ANY debug symbols. The manual is not clear enough about the usage of --debug outside of sdcdb; and the format of the .cdb files. However, it's kind of a nice-to-see feature if you can generate elf files with debug symbols when running the sdcc with a single source and it runs thru linkage without using .rel files; but it doesn't work when using multiple .rel files.
Is this documented somewhere? If so, is it even possible?
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think you are creating debug info in CDB format on compilation, then link as ELF.
gdb expects debug info in DWARF format. AFAIK, SDCC generates CDB on --debug without --out-fmt-elf, DWARF on --debug --out-fmt-elf, so you'll need to add --out-fmt-elf to the compilation command line.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Oh, I couldn't figure out that you have to specify --out-fmt-elf to generate DWARF debug symbols when generating object code!
I've tried it and it works perfectly! If it's possible, can this be explained in the manual? Maybe with some examples of invocation.
Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Since the SDCC 4.1.0 release is very close, it is too late for that. But I've just documented it in the manual in the sdcc-next branch, which will be merged after the release.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi All!
I started using the stm8 some years ago, tried some code on IAR and now I went ahead and tried to do the same but with sdcc just because I don't like IAR :)
My code uses multiple .c source files, and I'm using the stm8 binutils (all of these are provided on PlatformIO, but that's just because I'm trying to use their vscode extension instead of creating my own Makefiles).
If I try to build it and upload it with my stlink, it works. If I try to debug it with stm8-gdb; it "works", but I can't move thru the high level sources. The debugger clearly states that the elf file doesn't have debug symbols.
So I went ahead and tried to reproduce the issue outside of the environment, which I could do easily. Consider two source files, a.c and b.c. On the first one I have the main() function, which calls another function declared on b.c. This function changes a register value, so it doesn't get optimized. I ran the following commands:
However, the resulting file.elf doesn't contain ANY debug symbols. The manual is not clear enough about the usage of --debug outside of sdcdb; and the format of the .cdb files. However, it's kind of a nice-to-see feature if you can generate elf files with debug symbols when running the sdcc with a single source and it runs thru linkage without using .rel files; but it doesn't work when using multiple .rel files.
Is this documented somewhere? If so, is it even possible?
Thanks.
I think you are creating debug info in CDB format on compilation, then link as ELF.
gdb expects debug info in DWARF format. AFAIK, SDCC generates CDB on --debug without --out-fmt-elf, DWARF on --debug --out-fmt-elf, so you'll need to add --out-fmt-elf to the compilation command line.
Oh, I couldn't figure out that you have to specify --out-fmt-elf to generate DWARF debug symbols when generating object code!
I've tried it and it works perfectly! If it's possible, can this be explained in the manual? Maybe with some examples of invocation.
Thanks!
Since the SDCC 4.1.0 release is very close, it is too late for that. But I've just documented it in the manual in the sdcc-next branch, which will be merged after the release.
Is the generated file.elf even a real ELF file or is it actually an intel HEX file?
It's a real ELF file: