Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do a remote debug using GDB from Qt Creator?

I'm working on a Embedded Linux application and I would like to use GDB to debug it. The problem is that, although the Kit configuration seems fine (the Debugger option is correctly pointed to the GDB correspondent to the device's GCC - device is a Linux ARM), when I ask Qt Creator to run in debug mode it returns an error in the "Application Output":

sh: gdbserver: not found

This seems strange since, as I sad, the configuration is fine and no error about that is reported by Qt Creator in any moment before starting debug mode.

I did some research on the web to find which was the exact steps to use GDB to debug an Embedded Linux application from within Qt Creator (to use breakpoints, etc.) and the closest thing to an answer I got was this commentary by Tobias Hunger:

You will need to have ssh and gdbserver installed on your board for this to work. Then you need to set up your board [qt-project.org] in Creator. Afterwards you need to set up a kit [qt-project.org] using this device.

Those steps, thought, are not clear to me.

  • First, why would I need to have a GDB inside the device if the Kit should point to my local GDB?
  • Or it shouldn't?
  • Where would I put the GDB anyway?
  • How do I know if I have this ssh on my device?
  • If I don't, how do I install it?
  • All the other mentioned steps are already done, but related to the GDB located on my Desktop Ubuntu. Should I change something if I do the above steps?

And of course, is this manual my Tobias complete or do I need to do something else for this to work?

like image 609
Momergil Avatar asked Sep 04 '14 20:09

Momergil


People also ask

How will you do remote debugging using GDB?

To start remote debugging, run GDB on the host machine, and specify as an executable file the program that is running in the remote machine. This tells GDB how to find your program's symbols and the contents of its pure text. Note that the colon is still required here.

What is GDB remote?

It's where you run GDB on one machine and the program being debugged on another. To do this you need something to allow GDB to control the program being debugged, and that something is called the remote stub. GDB ships with a remote stub called gdbserver, but other remote stubs exist.


1 Answers

You need gdb and ssh on your Ubuntu and gdbserver and sshd on your device: actually when you deploy a project on a remote device using QtCreator, it makes use of ssh for copying the files to target, then it launches gdbserver on the device (attached to the executable that you want to debug) and then launches gdb on your Ubuntu connecting to the running gdbserver on the device.

So you need all of them to make things working.

ssh and gdb can be installed on your Ubuntu simply via apt-get. Instead the installation of sshd and gdbserver on your board is platform-specific: it can be that some boards already have them in their standard system image, or maybe in some cases it is up to you to install them... if your Linux distribution on the board has some package manager then you might try to use it... in the worst case you will have to compile them on your own for your board and install them manually.

like image 53
Morix Dev Avatar answered Sep 29 '22 22:09

Morix Dev