Remote debug of shared objects (controller.so) from Eclipse?

Applications, development tools, FPGA, C, WEB
Post Reply
BrandonKinman
Posts: 5
Joined: Thu Jul 17, 2014 5:46 pm

Remote debug of shared objects (controller.so) from Eclipse?

Post by BrandonKinman » Sat Feb 14, 2015 3:52 am

Heya folks!
Don't suppose anybody here has any experience setting up remote debugging of bazaar applications?

I've been able to do remote debugging of command line applications (such as acquire, generate, and other apps I've written)... But it's not readily apparent to me how I would go about debugging the nginx shared objects through Eclipse.

I fear that in order to make this happen, I may need to fool around with .gdbinit, and perhaps write a couple of shell scripts to be executed upon launch of a debug configuration.

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: Remote debug of shared objects (controller.so) from Ecli

Post by Nils Roos » Mon Feb 16, 2015 1:56 am

Heya Brandon,

As you suggested, it is not readily apparent, and you need to jump through some hoops to do it.
I did the following on the Xilinx SDK under linux, but it should work in every eclipse + CDT that has an ARM cross-toolchain configured. The machine where your eclipse runs is called the "host" in the description (substitute <user> and <host> as appropriate).
The description is based on linux, so if your host runs a different OS, you'll need to do some things a little differently.

Preparation
First, copy the Red Pitaya system environment (/usr /lib /bin /sbin) to a folder on your host. The debugger will only know symbols from libraries and executables that are available on the host's filesystem. I put them in the folder /home/<user>/rpdbg/ .

Code: Select all

redpitaya> tar -cf /tmp/rpdbg.tar /usr /lib /bin /sbin
redpitaya> scp /tmp/rpdbg.tar <user>@<host>:/home/<user>/rpdbg.tar

<user>@<host> ~$ mkdir rpdbg
<user>@<host> ~$ cd rpdbg
<user>@<host> ~/rpdbg$ tar -xf ../rpdbg.tar
Then create a textfile "gdbinit" in the folder and put this into it:

Code: Select all

set breakpoint pending on
set sysroot /home/<user>/rpdbg/
eclipse Debug Configuration
In eclipse, create a new Debug Configuration for your project.
  1. Click the down-arrow to the right of the "Debug" button and select "Debug Configurations ..."
  2. Right-click on "C/C++ Remote Application" and select "New"
  3. On the "Main" tab, give it a name and select the project. Set the "C/C++ Application" to /home/<user>/rpdbg/sbin/nginx
  4. Set the launcher to "GDB (DSF) Manual Remote Debugging Launcher". The active launcher and an option to "Select other ..." is at the bottom of the "Main" tab. You'll need to check "Use configuration specific settings" checkbox in the following dialog to enable the selection.
  5. On the "Debugging" tab, uncheck "Stop on startup at: ..."
  6. In the "Debugger Options", set the "GDB Debugger:" under "Main" to arm-xilinx-linux-gnueabi-gdb (as jmadsenee pointed out, if you are using the linaro cross-toolchain, you will need to enter the full path to its debugger here, and the debugger executable has a different name: arm-linux-gnueabi-gdb). Point the "GDB command file:" to /home/<user>/rpdbg/gdbinit .
  7. Add the path to your build directory (ie where the controller.so is generated) to "Directories:" under "Shared Libraries".
  8. Under "Connection", select TCP and put the IP address of your Red Pitaya as address. Set port to 2345.
  9. Apply the changes and leave the dialog.
Start debugging
On your Red Pitaya, start gdbserver with the following command:

Code: Select all

redpitaya> gdbserver --attach :2345 `pidof "nginx: worker process"`
This will serve exactly one connection attempt, so you'll need to do this anew each time you disconnect from the debugging session.
In eclipse, start debugging with the newly created configuration.
Note: If you did not start your web-app yet, its controller.so is not yet loaded. Setting breakpoints in the library code will work, but the debugger will emit warnings about it. The breakpoints will still be activated once your code is loaded (so you can set a breakpoint in the rp_app_init() function and debug your startup code).

The controller.so is not uploaded to the Red Pitaya automatically. If you build a new shared object with changes, you will need to copy it manually to its /opt/www/apps/<app_name>/ directory.

jmadsenee
Posts: 47
Joined: Fri Apr 17, 2015 7:38 pm
Location: Richmond, VA, USA

Re: Remote debug of shared objects (controller.so) from Ecli

Post by jmadsenee » Fri May 01, 2015 9:08 pm

Hi Nils,

I am trying to debug from Eclipse as described. I configured it as shown. I get an error when trying to run the debugger: "Cannot run program "arm-xilinx-linux-gnueabi-gdb": Unknown reason." Does this mean that I need to install the Xilinx PetaLinux SDK? Or, am I doing something else wrong?

Thanks!

John Madsen

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: Remote debug of shared objects (controller.so) from Ecli

Post by Nils Roos » Sat May 02, 2015 1:32 am

Hi John,

What is your environment like - OS ? Xilinx SDK or "native" eclipse + CDT + cross-toolchain (linaro ?) or other ?
Can you build the controller.so successfully and run it on the RP ?

I find developing with the Xilinx SDK usefull because it handles the Red Pitaya project with minimal configuration / secondary installations. It may not have the latest compiler versions, but after a few tweaks it is push-of-a-button for most things I need.

jmadsenee
Posts: 47
Joined: Fri Apr 17, 2015 7:38 pm
Location: Richmond, VA, USA

Re: Remote debug of shared objects (controller.so) from Ecli

Post by jmadsenee » Mon May 04, 2015 3:44 pm

Hi Nils,

I am running Eclipse on Ubuntu using VirtualBox on a Windows 7 computer. I installed Eclipse and the linero tool chain as described in the "Eclipse for Linux" wiki. I also figured out my problem - when using Eclipse/linero you need to set the GDB debugger to <path> arm-linux-gnueabi-gdb instead of arm-xilinx-linux-gnueabi-gdb . All the rest of your directions were spot on. I was able to get into the debugger and set a breakpoint right before my rpinit() instruction. Unfortunately stepping over rpinit() caused the debugger to terminate...

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: Remote debug of shared objects (controller.so) from Ecli

Post by Nils Roos » Mon May 04, 2015 8:30 pm

I amended the description with your info concerning the linaro debugger, thank you.
jmadsenee wrote:Unfortunately stepping over rpinit() caused the debugger to terminate...
Maybe something goes seriously wrong in your rpinit() function ? :shock: I confess I haven't done much debugging on web-apps, and have not even installed linaro, since the XSDK works well for me. So I have not much more to offer than a general 'it should work,' based on analogy.

jmadsenee
Posts: 47
Joined: Fri Apr 17, 2015 7:38 pm
Location: Richmond, VA, USA

Re: Remote debug of shared objects (controller.so) from Ecli

Post by jmadsenee » Tue May 05, 2015 4:36 pm

It looks like rp_init() just resets the whole thing; trashing the connection to the debugger/web app....

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: tknopp and 95 guests