Cristian Ion Preda
Cristian Ion Preda

Reputation: 51

How do I use gdbserver on Raspberry Pi?

I try to remotly debug using gdb. On the target computer (Raspberry Pi with Ubuntu Mate 15.10), I run gdbserver :4444 main. And on my laptop, I run ./arm-linux-gnueabihf-gdb ~/workspace/piCCompileProj/Debug/main. At the gdb prompt (on my laptop), I type:

target remote <target>:4444
run

But gdb reports this error message:

The "remote" target does not support "run". Try "help target" or "continue".

How I can use gdb remote? When I use gdb directly on the Raspberry Pi, it runs as expected.

Upvotes: 3

Views: 10209

Answers (2)

SH&#39;
SH&#39;

Reputation: 316

This is what helped me out(If any beginner is out here and searching for the solution)

Assumptions: Ubuntu(17.04)-> Host & Raspberry Pi (Model-3b) -> Target, My executable (.o) file-> dowhile

Step 1: Make executable file (.o) file for your target from your host machine. Please find follow command:

arm-linux-gnueabihf-gcc -g dowhile.c -o dowhile

Please download respective libraries to run this command successfully.

Step 2: Copy the generated executable file (dowhile.o) to the target machine like stated below:

scp dowhile [email protected]:/xxxx/yyyy/

(Please fill x and y details according to your target and source)

Also, check the copied executable is working fine:

./dowhile

Step 3: Run gdbserver on your target machine:

gdbserver localhost:2000 dowhile

(Keep 2000 or any number for your port, it will work anyway)

Step 4: Run gdb on your host machine:

gdb-multiarch dowhile

Step 5: Set architecture as arm

(gdb) set architecture armv5te

Step 6: Connect your target remotely

(gdb) target remote 10.x.y.z:2000

And you are done :)

Happy debugging!!!

Upvotes: 0

Cristian Ion Preda
Cristian Ion Preda

Reputation: 51

I find the solution for my problem.

If I run gdbserver :4444 main on my PI the main program will start and is not needed for run comand in gdb. To have full control on gdb I use in PI gdbserver --multi :4444 an in may local PC I use the command:./arm-linux-gnueabihf-gdb -x /path/init where the content of the /path/init file is:

symbol-file /home/username/workspace/piCCompileProj/Debug/main
target extended-remote 192.168.0.100:4444
set remote exec-file /home/username/cppSandbox/main

Upvotes: 1

Related Questions