Mendapatkan hasil kompilasi dengan debug symbols di Atom+PlatformIO

PlatformIO pada text editor Atom dapat dipergunakan untuk menghasilkan kode program yang bisa di-debug. Tetapi tanpa pengaturan yang tepat akan muncul kesalahan sebagaimana yang terlihat di Gambar 1 (no debugging symbols found).

xpiodbg003Gambar 1.

Untuk mengatasi masalah ini solusinya adalah dengan memberikan keterangan tambahan pada file platformio.ini .

xpiodbg001Gambar 2.

Untuk lebih mempermudah bisa disalin dari bagian berikut ini:

#
# PlatformIO Project Configuration File
#
# Please make sure to read documentation with examples first
# http://docs.platformio.org/en/stable/projectconf.html
#
[env:nucleo_f103rb]
platform = ststm32
framework = mbed
#build_flags = -g
board = nucleo_f103rb
upload_protocol = stlink

Keterangan lengkap mengenai penggunaan building options  di PlatformIO bisa dibaca di link ini. Untuk opsi debugging dengan compiler GCC bisa dibaca di sini.

-g

Produce debugging information in the operating system’s native format (stabs, COFF, XCOFF, or DWARF). GDB can work with this debugging information.

On most systems that use stabs format, -g enables use of extra debugging information that only GDB can use; this extra information makes debugging work better in GDB but probably makes other debuggers crash or refuse to read the program. If you want to control for certain whether to generate the extra information, use -gstabs+, -gstabs, -gxcoff+, -gxcoff, or -gvms (see below).

 

xpiodbg002Gambar 3. Hasil kompilasi yang berhasil di-debug  dengan DDD dan gdb.

 

 Command  Explanation
bp <address> [<asid>]<length> [‘hw’|’hw_ctx’]

list or set hardware or software breakpoint

exit exit telnet session
halt [milliseconds]

request target to halt, then wait up to the specifiednumber of milliseconds (default 5000) for it to complete

init Initializes configured targets and servers. Changes command mode from CONFIG to EXEC.  Unless ‘noinit’ is called, this command is called automatically at the end of startup. (command valid any time)
load_image filename address [ ‘bin’ | ‘ihex’ | ‘elf’ | ‘s19’ ] [min_address] [max_length]
reg [(register_number|register_name) [(value|’force’)]]

display (reread from target with “force”) or set a register; with no arguments, displays all registers and their values

reset [ run | halt | init ]

Reset all targets into the specified mode.Default reset mode is run, if not given.

resume [address]

resume target execution from current PC or address

step  [address]

step one instruction from current PC or address

Cmd
  • openocd -f ~/openocd-0.9.0/tcl/interface/stlink-v2.cfg -f ~/openocd-0.9.0/tcl/target/stm32f1x.cfg
  • telnet localhost 4444
    • help
    • halt
  • arm-none-eabi-gdb ––eval-command=”target remote localhost:3333″ firmware.elf
  • ddd ––eval-command=”target remote localhost:3333″ ––debugger arm-none-eabi-gdb firmware.elf