0

I have an application which runs on the Raspberry Pi and I would like to debug it from my host computer.

Cross compiling works fine and I am able to start the gdb server to debug. enter image description here

gdbConfigurationScript.sh

empty!

copyToRemote.sh

#!/bin/bash
USER=pi
HOST_IP=192.168.178.20
REMOTE_IP=multikopter
TARGET_PATH=/home/pi/Documents/Multikopter
PROGRAM=Multikopter
PORT=12345
PATH_TO_PROGRAM_HOST="/home/martin/GITProjekte/Build00_Multikopter"
PW=****

if [ -f "$PATH_TO_PROGRAM_HOST/$PROGRAM" ]
then
    echo "Copy file '$PATH_TO_PROGRAM_HOST/$PROGRAM' to target"
    sshpass -p $PW ssh -t $USER@$REMOTE_IP "echo PGREPGDBSERVER: $(pgrep gdbserver);sudo kill -2 $(pgrep gdbserver)"
    sshpass -p $PW scp "$PATH_TO_PROGRAM_HOST/$PROGRAM" $USER@$REMOTE_IP:$TARGET_PATH
    sshpass -p $PW ssh -t $USER@$REMOTE_IP "sudo gdbserver $HOST_IP:$PORT $TARGET_PATH/$PROGRAM"
else
    echo "file '$PATH_TO_PROGRAM_HOST/$PROGRAM'not exist"
fi

connectToRemoteGDB.sh

file Multikopter
target remote multikopter:12345
b main
continue

The problem is, I'm not able to stop the program again and the gdbserver is still running. To debug again, I have to kill the gdbserver on the raspberrypi manually first.

Is there another way to debug remote with KDevelop or is there an easy way to stop the program?

Murmi
  • 91
  • 10
  • `sudo pkill -9 gdbserver` instead of `kill -2`? Also, why is your program running as root? – Botje Apr 27 '20 at 12:16
  • Unrelated: consider using SSH public keys so you don't have to futz around with `sshpass`. – Botje Apr 27 '20 at 12:16
  • For more details see kill(1). Usage: kill [options] [...] Options: [...] send signal to every listed -, -s, --signal specify the to be sent -l, --list=[] list all signal names, or convert one to a name -L, --table list all signal names in a nice table -h, --help display this help and exit -V, --version output version information and exit – Murmi Apr 27 '20 at 12:47
  • 1
    `sudo pkill -9 gdbserver`. Note the "p" there. – Botje Apr 27 '20 at 13:04
  • Thank you for the proposal with the public keys. When I am trying sudo pkill -9 gdbserver it does not work. gdbserver is not killed, and I am not able to restart. – Murmi Apr 28 '20 at 09:13
  • Sorry I copied the wrong: Copy file '/Build00_Multikopter/Multikopter' to target Connection to multikopter closed. Process /Multikopter created; pid = 1775 Listening on port 12345 But I am not able to press the continue button in KDevelop to start the program. – Murmi Apr 28 '20 at 09:18
  • But the problem is also that gdbserver is closed when I debug newly. When I stop with KDevelop, The motors of the copter are still running, because gdb is not ended. – Murmi Apr 28 '20 at 09:20
  • That is correct. `gdbserver` remains running because you might attach to it later. If you want it to stop you need to convince KDevelop to give a `monitor exit` command somehow. Might be in the settings? – Botje Apr 28 '20 at 09:58
  • But KDevelop should do that when I press the stop button. Or this different? – Murmi Apr 29 '20 at 17:01

0 Answers0