Reading symbols from ./build/main.elf...(no debugging symbols found)...done.
(gdb) target extended-remote :3333
Remote debugging using :3333
0x00008055 in ?? ()
(gdb) monitor reset halt
target halted due to debug-request, pc: 0x00008055
(gdb) load
Loading section SSEG, size 0x1 lma 0x1
Loading section HOME, size 0x7 lma 0x8000
Loading section GSINIT, size 0x1a lma 0x8007
Loading section GSFINAL, size 0x3 lma 0x8021
Loading section CONST, size 0xc lma 0x8024
Loading section CODE, size 0x5d5 lma 0x8030
Start address 0x8007, load size 1542
Transfer rate: 7 KB/sec, 257 bytes/write.
(gdb) set $pc=0x8000
(gdb) break main
Function "main" not defined.
Make breakpoint pending on future shared library load? (y or [n])
I had the same error. I’m writing code for STM8 and using OpenOCD together with GDB for debugging.
Even if I use this command:
$(FLASHER) -c stlinkv2 -p $(MCU) -s flash -w $(OUTPUT_DIR)/main.hex
or even when I use main.ihx I still get the same error.
But when I use the .elf file, debugging through GDB works successfully.
$(FLASHER) -c stlinkv2 -p $(MCU) -w $(OUTPUT_DIR)/main.elf
Below are the commands I run in GDB.
first flash it
$(FLASHER) -c stlinkv2 -p $(MCU) -w $(OUTPUT_DIR)/main.elf
run opencd
openocd -f interface/stlink.cfg -f target/stm8s.cfg
stm8-gdb ./build/main.elf
(gdb) target extended-remote :3333
(gdb) monitor reset halt
(gdb) load
(gdb) set $pc=0x8000
(gdb) continue
(gdb) info locals
(gdb) next