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.
Remote debug of shared objects (controller.so) from Eclipse?
-
- Posts: 5
- Joined: Thu Jul 17, 2014 5:46 pm
-
- Posts: 1441
- Joined: Sat Jun 07, 2014 12:49 pm
- Location: Königswinter
Re: Remote debug of shared objects (controller.so) from Ecli
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/ .
Then create a textfile "gdbinit" in the folder and put this into it:
eclipse Debug Configuration
In eclipse, create a new Debug Configuration for your project.
On your Red Pitaya, start gdbserver with the following command:
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.
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
Code: Select all
set breakpoint pending on
set sysroot /home/<user>/rpdbg/
In eclipse, create a new Debug Configuration for your project.
- Click the down-arrow to the right of the "Debug" button and select "Debug Configurations ..."
- Right-click on "C/C++ Remote Application" and select "New"
- On the "Main" tab, give it a name and select the project. Set the "C/C++ Application" to /home/<user>/rpdbg/sbin/nginx
- 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.
- On the "Debugging" tab, uncheck "Stop on startup at: ..."
- 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 .
- Add the path to your build directory (ie where the controller.so is generated) to "Directories:" under "Shared Libraries".
- Under "Connection", select TCP and put the IP address of your Red Pitaya as address. Set port to 2345.
- Apply the changes and leave the dialog.
On your Red Pitaya, start gdbserver with the following command:
Code: Select all
redpitaya> gdbserver --attach :2345 `pidof "nginx: worker process"`
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.
-
- Posts: 47
- Joined: Fri Apr 17, 2015 7:38 pm
- Location: Richmond, VA, USA
Re: Remote debug of shared objects (controller.so) from Ecli
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
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
-
- Posts: 1441
- Joined: Sat Jun 07, 2014 12:49 pm
- Location: Königswinter
Re: Remote debug of shared objects (controller.so) from Ecli
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.
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.
-
- Posts: 47
- Joined: Fri Apr 17, 2015 7:38 pm
- Location: Richmond, VA, USA
Re: Remote debug of shared objects (controller.so) from Ecli
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...
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...
-
- Posts: 1441
- Joined: Sat Jun 07, 2014 12:49 pm
- Location: Königswinter
Re: Remote debug of shared objects (controller.so) from Ecli
I amended the description with your info concerning the linaro debugger, thank you.
Maybe something goes seriously wrong in your rpinit() function ? 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 wrote:Unfortunately stepping over rpinit() caused the debugger to terminate...
-
- Posts: 47
- Joined: Fri Apr 17, 2015 7:38 pm
- Location: Richmond, VA, USA
Re: Remote debug of shared objects (controller.so) from Ecli
It looks like rp_init() just resets the whole thing; trashing the connection to the debugger/web app....
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: No registered users and 5 guests