NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

C/C++ Debugging with Attach to Application

Anyone have experience using the C/C++ Attach to Application debug feature in Eclipse? I get "Error while Launching command: gdb --version".  Before I spend hours figuring out what I've done wrong, I thought I would ask if it is possible.

Thanks,

Kevin

0 Kudos
Message 1 of 7
(6,469 Views)

Hello kwkengineer,

Are you attempting to run a stand-alone binary from boot (or started in some other fashion) and attach to this from Eclipse? Or do you want to debug an application that will be pushded to the target and launched from Eclipse itself? Basically, what is it that you want to do from a higher-level view?

More generally, the issue you've reported is likely due to the gdb tool setup in the project: note that you should be using the arm-...gnueabi-gdb that is included with the toolchain. There are some good guides out there for configuring Eclipse to work with an external toolchain.

0 Kudos
Message 2 of 7
(5,223 Views)

you got it....I missed the fact I needed to browse to the included gdb after creating the new Debug Configuration.

My desire is to debug a stand-alone binary that is launched from Labview application. 

I've tried using a shell script to launch the binary and redirect the stdout to a file.  No luck yet.

The attach to application is working, but two problems. 

1) I'm not getting the Remote Shell with the stdout in Eclipse.  This is strange because I do see the Remote Shell if I Debug Remote Application (Eclipse pushes and launches the binary).

2)  I could only get the Attach to work if I run the binary using gdbserver on the target.  That causes the the application to wait until the Eclipse debugger connects.  That might cause timing issues for my application.

I feel I'm left with no choice but to write more C code to throw log messages out a UDP socket.

0 Kudos
Message 3 of 7
(5,223 Views)

kwkengineer wrote:

you got it....I missed the fact I needed to browse to the included gdb after creating the new Debug Configuration.

I'm glad to hear you got that working. Eclipse settings can be tricky.

I've tried using a shell script to launch the binary and redirect the stdout to a file.  No luck yet.

Hmm, I was afraid that may not do the trick (basically inherriting the managed std(in|out|err) file descriptors. 

The attach to application is working, but two problems. 

1) I'm not getting the Remote Shell with the stdout in Eclipse.  This is strange because I do see the Remote Shell if I Debug Remote Application (Eclipse pushes and launches the binary).

This is the same class of problem that you've already been fighting: the ownership of the terminal that is connected to the std(in|out|err) of a running process is different than the one you're using right now. There are hacks to steal that away from a controlling terminal, but there are usually some undesireable effects when you go this route. It's also stinkin' complicated.

2)  I could only get the Attach to work if I run the binary using gdbserver on the target.  That causes the the application to wait until the Eclipse debugger connects.  That might cause timing issues for my application.

This is the very nature of the remote connection debugging: you *must* run the other side of the debugging (gdbserver) on the target prior to debugging. I vaguely recall that there is a way to define pre-debugging steps but I don't really have a setup handy for checking the UIs and testing things out.

I feel I'm left with no choice but to write more C code to throw log messages out a UDP socket.

0 Kudos
Message 4 of 7
(5,223 Views)

I feel I'm left with no choice but to write more C code to throw log messages out a UDP socket.

If you are just trying to do logging, may I suggest a different option: use the syslog() function. That way you can log through the system logger and you get the additional benefits of log maintanaince, remote logging if desired etc (and you don't have to mess with the stdout redirection).

0 Kudos
Message 5 of 7
(5,223 Views)

+1. Thanks gratian

0 Kudos
Message 6 of 7
(5,223 Views)

agreed. syslog is a good option as well.

The reason I've been focused on redirection and/or seeing the console is because the large majority of the C code is a third-party middleware interface and all of their logs are sent out to stdout and stderr.

0 Kudos
Message 7 of 7
(5,223 Views)