Oct 19

The whole chain from entering source code in Geany, compiling using gcc-cris, transfering the application to the target using ssh and finally debugging it using gdbserver, gdb-cris and kdbg is now working using below makefile. In Geany the execute button executes the make execute command in the folder holding the source of the application and the makefile.

COMPILER = /usr/local/cris/bin/gcc-cris
CFLAGS = -g -fno-omit-frame-pointer -O0 -mlinux -o
SOURCES = main.c MyUnit.c
TARGET = Hello_World
USER = root@FOXBoard
DESTINATION = /mnt/flash/bin/HelloWorld

# top-level rule to create the program, executed by default if no params are provided
all: compile

# Called by pressing the Compile or Build button in Geanny
compile: $(SOURCES)
<TAB>$(COMPILER) $(CFLAGS) $(TARGET) $(SOURCES)

build: compile
<TAB>scp $(TARGET) $(USER):$(DESTINATION)

execute: build
<TAB>ssh $(USER) “gdbserver :1234 $(DESTINATION)/$(TARGET)” &
<TAB>sleep 5
<TAB>kdbg -r FOXBoard:1234 $(TARGET)
<TAB>ssh $(USER) “/mnt/flash/bin/StopRemote.sh $(TARGET)”

Everything works great except one thing: the printf command does not show anything in either the terminal available in Kdbg or in Geany. Although I can fully debug the application in theory I do not need printf to debug by application but using printf to display progress or status in my applications would be very nice.

When I start gdbserver on the FB using a ssh terminal than printf works when using Kdbg (or gdb-cris manually) although not in the terminal from Kdbg but in the terminal that was used to start gdbserver. When starting gdbserver using a ssh root@FOXBoard “gdbserver….” command than printf does not work until the moment that the application (and so gdbserver) is stopped.

My guess is that printf prints to the terminal that was used for starting the application. In case of using the ssh root@FOXBoard “gdbserver….” command a new shell is started in which the command passed to ssh is executed.

Thinking about this more, over the last days I find myself always having a ssh terminal running to the FOXBoard doing maintenance like organizing files and (previously) killing gdbserver from time to time. So it would not be a bad idea to not fully automate the process. Perhaps a better option is to have three programs open (Geany, a ssh terminal and Kdbg) in which case the order would be:

  • Change code in Geany, execute compilation and secure copy the application to the FB
  • In case of debugging, start gdbserver in the ssh terminal (arrow up and enter the second time)
  • In case of normal development, start the application in the ssh terminal
  • In case of debugging, in Kdbg select File |Recent Executables…, select the application and press F1 to reload the source before starting the debugging.

For now I will start working like this to see if this is an acceptable way of working. The only change needed in order to work like this is to change the command that will be executed when pressing the Compile button in Geany. In Build | Set Includes and arguments change the Compile command into make build. As a result, pressing the Compile button will compile and copy the application to the FB. Pressing the Execute button will also start gdbserver and Kdbg.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.