RedHawk IDE has supports debugging with gdb integrated into the IDE but the manual only discusses doing this with the sandbox. Gdb inself, of course, is able to attach to an already running process and even attach to a process running on a remote machine. Is it possible to use gdb as integrated in RedHawk/Eclipse to debug one of the components in a running waveform launched in a domain on the local machine or a remote target or must I just use gdb outside RedHawk with the integration?
-
You might be able to attach to an already running process: http://stackoverflow.com/questions/655853/is-it-possible-to-attach-a-debugging-session-to-a-running-program-in-eclipse-cdt – Erik Englund Jan 28 '15 at 20:24
-
How? I have not found a way to start the debugger in RedHawk specifying a pid or without it starting some component as a local component and with no console where I might issue a new attach. – Terry L Anderson Jan 29 '15 at 20:31
-
I looked at the Eclipse documentation on starting the debugger but none of the menus or steps they describe appear to be available in RedHawk. I see nothing about Debug Configurations or even a Debug dialog box in Redhawk. – Terry L Anderson Jan 29 '15 at 20:49
-
BTW I get the same error with log levels in devices as with components. – Terry L Anderson Dec 03 '18 at 21:37
-
I'm sorry this comment was added to the wrong question – Terry L Anderson Dec 03 '18 at 21:38
2 Answers
Debugging in a live domain requires several steps to get your component to run in a debugger. It's not the most straight-forward, but it's doable, and sometimes the only way to debug a behavior if you need it in a production environment and not the sandbox. I've used these steps with the REDHAWK 1.10 series.
First you'll need to reconfigure the component to launch via a script. This is based on the code generator template for Java components, if you're looking for an example. You'll want to add a new file to your project's implementation folder ('cpp' in my example) named debug.sh. Add the following contents:
#!/bin/sh
mydir=`dirname $0`
chmod +x ${mydir}/your_component_executable
exec gdbserver host:2345 ${mydir}/your_component_executable "$@"
Replace your_component_executable with the name of your component. Now, you'll need to make sure that a 'make install' installs this script. Add the following to your Makefile.am:
bin_SCRIPTS = debug.sh
Next, edit your .spd.xml file. Modify the localfile and entrypoint elements. The localfile element tells REDHAWK what the ExecutableDevice (i.e. your GPP) should copy over to its file system to be able to run the component. The entrypoint is what actually gets exec'd to start the process. After modifying, it might look something like this:
<code type="Executable">
<localfile name="cpp"/>
<entrypoint>cpp/debug.sh</entrypoint>
</code>
Notice the localfile now points at the implementation directory (not the executable file), and entrypoint points at the debug.sh.
Now, make sure that gdbserver is installed on the machine that will end up running the component (the machine with the GPP). For example, on CentOS 6:
sudo yum install gdb-gdbserver
For the next part, you'll actually want two IDEs open. With #1, we'll debug the component. With #2, we'll perform domain-functions. I'll assume you have your component as a project in your workspace in IDE #1.
In IDE #1, install your component to the target SDRROOT. Next, select your project in the Project Explorer, right-click, and select "Debug As" -> "Debug Configurations...". Double-click "C/C++ Remote Application". A configuration will be created and populated with your component project's details. Switch to the "Debugger" tab, and select the "Connection" tab under "Debugger Options". Change the host name to match the GPP where the component will run (if not on your localhost), and change the port to match the debug.sh script file (2345 in my example). Leave this dialog open.
Switch to IDE #2. If you need to, start your domain and a device manager with a GPP (right-click "Target SDR", select "Launch..."). Launch the waveform containing your component (right-click the domain, then "Launch Waveform..."). You'll notice that the launch dialog will pause waiting for the waveform to launch. This is because your component has paused in the main() method waiting for the debugger to connect, and it hasn't registered with the domain.
Switch to IDE #1. Click the "Debug" button on the dialog. You should be connected to the process, and the IDE will prompt you to switch to the debug perspective and you will see you're in your component's main() method. The component needs to regsiter within 60 seconds or the framework will assume it failed to launch and timeout. I normally click the run button to allow the component to complete its initialization. You'll see the launch complete in IDE #2, and a diagram for your waveform pop open.
At this point, it's easy to set breakpoints in your code (especially the service function, property change notifications, etc) and debug. If you have items you need to debug during the initialization phase of your component, you may need a custom installation of the framework which is modified to not timeout waiting for components to register.

- 539
- 3
- 10
-
I've been traveling away from my RedHawk host and so just now trying this. As you said, this technique is NOT straight forward but doable. I guess when you are through debugging you have to SPD to not start the component through the script. Byt my bigger problem is starting two IDEs. I've never wanted to do that before but tried it. When I attempt to start another IDE in the same workspace it tells me that the workspace is busy. How do I start a second instance? Or is just a second IDE window in the same session enough? – Terry L Anderson Feb 17 '15 at 18:17
-
No, another window in the same RedHawk instance is not enough. When I "leave this dialog open" in IDE#1 and switch to the other IDE window, it is locked waiting for me to exit the dialog in the first window. So I guess I must someway run another instance of RedHawk as IDE#2, but that seems not allowed using the same workspace????? – Terry L Anderson Feb 17 '15 at 18:45
-
Eclipse-based IDEs require unique workspaces - they get locked when the IDE starts. Since all you'd be doing with the second IDE is just using it to interact with a domain, it doesn't need to have anything in the workspace. You can just use a different directory. – Daniel Wille Feb 20 '15 at 15:53
-
If you prefer, rather than use a second IDE, you could also just start the domain/device managers via nodeBooter at the command-line, and use the Python API to launch a waveform in the domain. – Daniel Wille Feb 20 '15 at 15:54
I adapted the script to examine the properties passed to the component when exec'ed and decide whether to exec it under gdb or directly. This allows the script and the change to spd.xml to remain in place and debugging turned on or off by adding or removing a property in the component's property page. My property when present also specifies the port gdbserver should use and also allows specifying which instance to debug if the component has more than one instance in the waveform. I use a property gdbn to debug the n'th instance. This makes debugging components running in a domain much more practical.

- 263
- 1
- 11