I've been setting up remote debugging for an embedded Linux target. I've tested that I have the correct combination of gdbserver running on the target and gdb client running on my workstation. I can start the server and on the workstation side run:
(gdb) target remote 10.28.22.226:2345
and I can list source and step just fine.
In Qt Creator I have configured a device. In that window I specify the GDB server executable: gdbserver (see pic).
I also configure the cross debugger in the 'Build & Run' Debuggers tab as shown below:
In this case, I have manually started the gdbserver with my executable on the target with port 2345. To start debugging with Qt Creator, I choose the Debug->Start Debugging->Attach to running Debug server pulldown menu. It gives me the prompt shown below, where I enter the server port (2345). I give it the appropriate kit and local executable (copy of the executable on the remote target).
After I hit OK, it seems to run the gdb client locally with a few commands, then times out trying to communicate with the gdbserver. I have debug logging turned on with the server, so I know the server never sees anything from the client run from Qt Creator. Additionally, I did Window->Views->Debugger Log to help me get a better idea of what was going on. The log shows the correct IP address and port for my device, but I don't see anything that looks like a 'target remote IP:port' call.
I'm looking for a hint or reference here. I seem to be a bit stuck at the moment. Thanks!
EDIT: additional information - I've verified that my gdb client has support for python compiled in. I see that Qt Creator requires python support. I also have further support that nothing ever goes out on the wire from Qt Creator. I did a wireshark capture and don't see anything going to port 2345 on the target.
Alternately, if anyone would share their Qt Creator debugger-log output with me so I can compare, that would be helpful.
Avoid Qt Creator 4.5-beta1. It seems 4.5RC1 doesn't have this problem. I was able to do remote debugging using the method described above just fine.
Even QtCreator 4.5.0 seems to have the same bug.
The only workaround I've found is to start the GDB server manually on the remote target: with "top" I get the pid of the remote process to debug then I run the following command: gdbserver --attach remote ip:remote port pid.
After the server is listening, I finally choose: "Attach to Running Debug" server".
Maybe you can write a server start script on target which include the above statement...
Related
Is it possible to run a remote debug session targeting Windows with CLion?
The docs say that I can do any system that has gdbserver:
Remote OS: any supporting gdbserver and SSH
However, when I try to run my remote app, I get an error:
10:53 PM Build finished in 3 sec, 44 ms
10:53 PM Error running 'remote'
1: 'env' is not recognized as an internal or external command,
operable program or batch file.
I can't find a place where I could see the whole command that CLion runs that causes this error.
Here is my configuration:
After some investigation, I have come to the conclusion that it is impossible to remote debug a Windows app with CLion 2021.3.1 (regardless of Host platform).
CLion does not support remote debugging when targeting Windows OS using GDB Server (hence targeting Windows is impossible) due to:
CLion does not handle cases when SSH Server is using a non-Unix shell like CMD.exe or PowerShell. Commands like exec, env, chmod can’t be handled. This can be circumvented by using a Unix shell:
a. Unfortunately, connection fails for MSYS2 Bash and Git Bash when Windows OpenSSH Server is configured to use one as a default shell.
b. Windows WSL SSH Server works. Connection is established, Unix commands are recognized. WSL must be installed. It is not easy to configure WSL when Windows itself is running on virtual machine.
c. MinGW64 SSH Server. Didn’t test it.
Uploading binaries via SFTP fails when OpenSSH Service is used. Can be circumvented with 1.b..
CLion doesn’t consider the binary’s file extension. It always assumes that the binary is built for Linux, hence the attempt to transfer fails, when a binary has an .exe extension (fails to find test, though test.exe was built). This is a major bug that prevents remote debugging targeting Windows. There are, however, ways to work around:
a. Manual renaming before running debug. Unacceptable.
b. Adding a conditional custom CMake command. May work but pollutes the CMakeLists.txt
CLion can’t connect to MinGW GDB Server it has started. Connection times out. However, if the Server was started from a terminal, CLion connects successfully and is able to run debug as intended. This can ONLY be worked around MANUALLY:
a. In Edit Configurations… one must put a stub command in GDB Server:, for example ‘sleep’. In GDB Server args: ‘5’. This will give a time to manually run the gdbserver.exe command via an SSH connection in Terminal.
These issues were reproduced for CLion versions for Windows 10 and Ubuntu 20.04.
3. and 4. are very serious and prevent from remote debugging targeting Windows as it was intended to be done.
This happens when CLion connects to the Server it has started:
This is a work around:
As can be seen from the screenshots, with this approach GDB’s console does not catch the output. You must switch to Terminal to see it.
I've already set up a remote run configurations in CLion.
The remote server check is available, and the code has been synced to remote server.
However when I debug in clion, it always show error:
com.jetbrains.cidr.execution.debugger.backend.gdb.GDBDriver$GDBCommandException: To open a remote debug connection, you need to specify what
serial device is attached to the remote system
(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.).
Debugger disconnected
How to specify the serial device?
No perfect, but working solution (for me)
Run->Edit Configurations->GDB: change from Bundled GDB to <path to gdb>
If you using Linux, it should be something like /usr/bin/gdb.
In Java
java -agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n <other arguments>
allows us to
Start an application and suspends it
opens up a socket (dt_socket) using Java Debug Wire Protocol - Allows to debug remotely
Hosted on 8000 port
We can run this on a remote Linux Server and yet debug it on our own Desktop (even Windows) environment using either Netbeans or IntelliJ or other feature rich IDEs.
Is something of the sorts possible in C++ with visual studio community/code ? If so how.
PS: I know of ddd (data display debugger) & gdb
Yes, you can (using gdb).
Follow the manual.
There may be some IDE using gdb as backend.
I followed the steps in this link
and I manage to debug a binary which resides in linux host from my windows machine from command prompt.
I have gdbserver in linux and I installed gdb with the help of mingw in windows. As I told I can prompt "target remote x.x.x.x:10000 test" to command in windows and debug my test application.
My problem is I can't do the same with eclipse gui, it seems to me it has tones of buttons, options but they make no sense to me.
I am choosing debug_configurations-->C/C++ Remote Application(the only one which allows me to input linux machine ip/port), in "Main" tab to connection I am inputting my linux ip. In same menu under Debugger tab I am inputting my window's gdb path and gdbserver port.
After doing all those I believe I gave enough info to eclipse for connect gdb server but it never enough for eclipse. I am checking gdbserver logs by starting gdbserver with --debug, gdbserver never gets triggered, it does not writes a single line of log. Eclipse even does not starts a connection. But instead it gives me a error like "Error during file upload." which makes no sense to me.
I am using "Eclipse Version: Juno Service Release 2" . Any help will be appreciated .
I believe that the "C/C++ Remote Application" option uses Eclipse's RDT (Remote Development Tools) and RSE (Remote System Explorer) to connect, upload, execute, and debug the application itself. It
If all you want to do is connect to a gdbserver, then create a "C/C++ Attach to Application" debug configuration, and under the Debugger tab, set Debugger to gdbserver.
I also encountered this error message for other reason on Eclipse version 2019-09 R (4.13.0).
I very recommend to read paragraph "How do I debug a remote application?" from this great guide.
It explains which of three remote debugging options you should be using - Automatic Remote Launcher, Manual Remote Launcher and Remote Attach Launcher and how to use each one.
I was using the wrong launcher and hence got the error, while on the remote side gdbserver was listening and waiting for a connection. Switching to Manual Remote Launcher solved it.
for example it says:
If you don't have RSE installed, you cannot use the "Automatic Remote
Launch"
RSE = Remote System Explorer End-User Runtime
Launcher setting is configured from the bottom of the Remote Debug Configuration window - "Using GDB (DSF) Automatic/Manual Remote Debugging Launcher".
OK, this seems pretty basic, but no luck. I'm using Eclipse Helios w/ CDT. Both host & target are linux boxes. I've been starting my application on the target machine with:
gdbserver :port my_app
and successfully attaching from eclipse using a "C/C++ Attach to Application" debug configuration. My application's stdout is displayed on the target system, but stdin doesn't go to my app. In eclipse, I have a console for gdb (commands) and gdb trace, but no application console like when debugging locally. The debug configuration "Allocate Console" check-box just controls whether or not I get a gdb command console.
I tried starting the application separately and attaching (using gdbserver --multi). This was worse: eclipse/gdb didn't see all running threads and stdin on the target tty resulted in
Child terminated with signal = 0x5 (SIGTRAP)
Trace/breakpoint trap
Any help would be appreciated.
Application std in/out will go to the terminal you used to start the gdbserver (and application) from. Eclipse cannot redirect those.