can't do remote-debugging with j-link in Clion IDE - remote-debugging

I am trying to remote-debug a project in Clion but I can't seem to get a working debugging session. I think I've correctly launched my gdb server/client because my gdb client connects to the JLinkGDBServerCL.exe process
and they communicate.However, in clion, I can't break in the source code. The only thing that I get from clion is a disassembly of my program with no symbol at all which is odd because there is a symbol table in the .elf
that I am trying to debug. And one last detail, I can't "step in" the assembly code neither (but I can run commands in the gdb client in Clion).
Here is a picture of my debug configuration : debug config
And here is what I'm talking about when I say I can't get a proper debugging session : "debugging session"
Does anybody know what the problem is ?
System info:
OS: Windows 10
IDE: Clion 2018.1.6
GDB Server: JLinkGDBServerCL.exe
Target: TM4C129 (cortex M4) (no OS, just a firmware)
Program: USBMicroloader.elf (debug mode)

I'm having the same issue. I found that if I add the path to the elf file from the build directory into the "Symbol file" (in the run configuration where you set up the remote gdb connection), it fixes your issue. This seems a bit kludgey, but I haven't been able to find a better solution.
However, the next issue I run into is that I can only run that configuration a single time. When I stop debugging I get a message in the console that reads Remote doesn't know how to detach. Debugger disconnected. The clean and build menu options are greyed out until I restart CLion.

Related

Eclipse "Error in final launch sequence: Command '-file-exec-and-symbols myprog.exe' is timed out

I am using
Eclipse IDE for C/C++ Developers
Version: 2018-09 (4.9.0)
Build id: 20180917-1800
under Win 10 with Portable Msys2, and gcc 8.3.0.
When launching a debug configuration in CDT, I am getting message
Error in final launch sequence: Command '-file-exec-and-symbols myprog.exe' is timed out
Session is terminated
Reason: Commnd '-gdb-exit' is timed out
Note: I only get this error while trying to debug one project.
All my other debug configurations for other projects run with no problem.
I have copied one of these working debug configurations and changed only the project name and executable into the problematic one, and I still get the error.
One possible solution I found is (here and here) downgrading component
C/C++ GDB Hardware Debugging (Help -> About Eclipse IDE -> Installation Details -> C/C++ GDB Hardware Debugging)
from 9.4.0.201712051550 to 9.3.2.201709131603.
I have
Version 9.5.3.201809121146 org.eclipse.cdt.debug.gdbjtag.feature.group Eclipse CDT.
Perhaps in my case downgarding to that old version would work too.
Prior to messing up with the downgrading, I meant to try another option (here and here):
In the debug configuration of the project, in the debugger tab, uncheck
“Reset and Delay (seconds)” and
“Halt”.
(more details here)
But I couldn't find these settings in the Debugger tab, and I do not have the Startup tab under either the Debug configuration for my project or GDB Hardware Debugging, as shown here or here.
See image.
Where can I find these settings?
Are there any other alternatives to try solving the issue, other than these two? (lest reinstalling, e.g.)
I am looking for something that allows me to debug my project, so far I cannot.
References I found for similar topics (although not exactly the same) are:
Error in Final Launch Sequence - Eclipse System Workbench Debugging for STM32L476
http://www.openstm32.org/forumthread6323

CLion run program in separate system terminal

I have an ncurses program that I'd like to interactively debug using CLion. The problem is that when I run the program in CLion to debug it, the inbuilt console where the program is run doesn't display the output of the ncurses program properly.
I'd like to have the program run in my systems terminal so I can see the output properly whilst debugging the program with CLions debugger.
Is there any way to do this?
The best way to accomplish this is to use GDB now it can be really frustrating to get started so Ill show you how I accomplished it in linux
open a terminal and go to your project debug file and type gdbserver localhost:1234 ./myFile
open clion to myFile project and in the upper right corner you should see a build all (or your projects name) click it and go to "edit configurations"
in the upper left corner you should see a plus sign, click it and press "GDB remote debug"
then in "target remote" type tcp:127.0.0.1:1234
Next in "path mappings" press the plus and type /location/to/file/myFile (same file as in 1.) in both Remote and Location
Press OK and in the upper right corner select the name of the configuration that you just made and press debug
you might need to try to restart the gdbserver one more time for this to work but if you did all the steps above you should see a debug prompt come up and on the terminal you should see your project running.
There are some limitations with this for example you always have to run gdbserver localhost:1234 ./myFile command on your terminal for it to work.
Some Video/documentation that helped me:
Debugging with GDB at 33:35 (Video by JetBrain)
GDB documentation on Jetbrain
I hope this helped :)
In other debuggers, you would do this by running the ncurses application in a terminal, and attaching the debugger to the process using ncurses.
Doing that avoids interference between ncurses (which changes the terminal I/O modes) and the debugger's command-line.
The attach feature is a recently released feature of the CLions debugger:
Further reading:
More power to debug: Attach to local process (January 20, 2016)
CLion 1.2 roadmap (August 31, 2015)
Debugging in CLion (May 8, 2015 )
CLion answers frequently asked questions (September 16, 2014)
Debugging ncurses application with gdb
Using GNU's GDB Debugger:
Debugging Ncurses Programs

Eclipse debug: "Error in final sequence - Failed to execute MI command"

I'm running Eclipse on win7. I want to make console applications that can run on either windows or linux. I followed the guide here on how to setup the compiler
I'm trying to compile and run a simple hello world program. It compiles fine, but when I try to debug I get the following error:
'launching test' has encountered a problem.
Error in final launch sequence.
Clicking details reveals the following information.
Error in final launch sequence
Failed to execute MI command:
-exec-run
Error message from debugger back end:
Don't know how to run. Try "help target".
Don't know how to run. Try "help target".
My gdb debugger path is C:\codesourcery\bin\arm-none-eabi-gdb.exe
I'm not exactly sure how to proceed.
If you're creating a windows console then I would think you would need gdb found in c:\minGW or wherever you have your Windows 7 gcc toolchain.
To change your debugger on Eclipse Kepler go to:
Run->Debug Configurations. Select Debugger tab and in the "GDB debugger:" field, enter the path of your Windows gdb.exe file (c:\MinGW\bin\gdb.exe if you're using minGW)
I realize this is an old question, but hoping it will help someone. In my case, there was a breakpoint set with only a memory address (no file name associated with it). Not sure how I got into this situation... Once I removed the breakpoint, I was able to launch my program with debugger. Note, I am using Eclipse Luna CDT (SR2)

Remote GDB debugging

I've just spent a whole day trying to find a way to enable GDB debugging from Qt Creator or Eclipse. I learned that there are basically two approaches to launch the target application:
Using ssh (ssh host gdb)
Using gdbserver
I was able to use both approaches to launch gdb remotely and start the application. However, GDB never responds to any breakpoints set in the IDE. Also I can't pause the application to inspect the program state. In Qt Creator I just get an obscure stack trace (I might have been looking at the traces of ssh or gdb actually...).
Can anyone help me to get started?
Progress!
I found that with Qt Creator 2.0 there is an feature called "Attach and debug remote application." It's based on gdbserver. The good thing is that it stops on the IDE's breakpoints. However, there are two issues:
When it hits a breakpoint it only shows assembly code, not the source code.
GDB often quits because of 'signal received'
I should probably mention that the remote executable is compiled with an older version of GCC than the one installed on my local PC. Perhaps some of the problems are related to this.
Update
I should mention that I switched to running cgdb on the remote machine via SSH.
The remote Qt Creator-based solution wasn't stable. GDB tends to quit because of mysterious 'signal received' messages.
So that GDB on your host (the machine you develop and compile on, so where you have Qt Creator) you have to give it access to the "symbol file".
I usually don't use Qt Creator, but GDB and gdbserver directly for cross-compiled programs remote-debugging. You could maybe give this a try to be sure that this works for you and maybe then find the missing option in Qt Creator (or maybe this will help you find what is missing).
On the target machine run:
gdbserver :5000 yourprogram
On the host machine, run gdb and then load the symbol file:
(gdb) symbol-file yourprogram
On GDB on the host machine, you then have to connect to connect GDB to the remote gdbserver:
(gdb) target remote target_ip_address:5000
From then you can use GDB on the host controlling the program on the target.
I hope this helps!
Due to peculiarities in our makefile build system the file references contained in the debugging symbols look like this:
../src/main.cpp
../../src/utils/logger.cpp
This is no problem for GDB, but Qt Creator was unable to map these paths to the actual files. I was able to fix this by adding 'dir' statements in the GDB init file:
dir src
dir src/utils
...
Now it works.

How to do remote debugging with Eclipse CDT without gdbserver?

We're using the Eclipse CDT 5 C++ IDE on Windows to develop a C++ application on a remote AIX host.
Eclipse CDT has the ability to perform remote debugging using gdbserver. Unfortunately, gdbserver is not supported on AIX.
Is anyone familiar with a way to debug remotely using Eclipse CDT without gdbserver? Perhaps using an SSH shell connection to gdb?
finally I got gdb run remotly anyhow now. At the Bug-symbol on the taskbar I took Debug Configurations - GDB Hardware Debugging.
In Main C/C++ Applications I set the full path on the Samba share of the executable (X:\abin\vlmi9506). I also set a linked folder on X:\abin in the project. Then I modified my batch-script in GDB Setup. It's not directly calling gdb in the plink-session but a unix-shell-script, which opens gdb. By this I have the possibility to set some unix environment-variables for the program before doing debug. The call in my batch:
plink.exe prevoax1 -l suttera -pw XXXXX -i /proj/user/dev/suttera/vl/9506/test/vlmi9506ddd.run 20155 dev o m
In the unix script I started gdb with the command line params from eclipse, that I found in my former tryals. The call in the shell command looks like this:
gdb -nw -i mi -cd=$LVarPathExec $LVarPathExec/vlmi9506
Then IBM just gives gdb 6.0 for AIX. I found version 6.8 in the net at http://www.perzl.org/aix/index.php?n=Main.Gdb. Our Admin installed it.
I can now step through the program and watch variables. I even can write gdb-commands directly in the console-view. yabadabadooooooo
Hope that helps to others as well. Can not tell, what was really the winner-action.
But each answer gives more new questions. Now I got 3 of them.
When I start the debug config I have to click restart in the toolbar to come really in the main procedure. Is it possible to come directly in main without restarting?
On AIX our programs are first preprocessed for embedded sql. The preprocessed c-source is put in another directory. When I duble-click the line to set a breakpoint, I get the warning "unresolved breakpoint" and in the gdb-console I see, that the break is set to the preprocessed source which is wrong. Is it possible to set the breakpoints on the right source?
We are using CICS on AIX. With the xldb-Debugger and the CDCN-command of CICS we manage that debugging is started, when we come in our programs. Is it possible to get that remotely (in plink) with gdb-eclipse as well?
I wouldn't normally take a shot in the dark on a question I can't really test the answer to, but since this one has sat around for a day, I'll give it a shot. It seems from looking at:
http://wiki.eclipse.org/TM_and_RSE_FAQ#How_can_I_do_Remote_Debugging_with_CDT.3F
...that even if the CDT has changed since that wiki page was made, you should still be able to change the debug command to:
ssh remotehost gdb
instead of using TM which uses gdbserver. This will probably be slightly slower than the TM remote debugging since that actually uses a local gdb, but on the other hand this way you won't have to NFS or SMB mount your source code to make it available to the local debugger (and if you're on a LAN it probably won't matter anyhow).
There's also a reference TCF implementation for linux, which you may or may not have any luck recompiling for AIX, but it allows for remote debugging if gdbserver is otherwise not available:
http://wiki.eclipse.org/DSDP/TM/TCF_FAQ
tried also to remotly debug an aix-appl with windows eclipse-cdt-gdb.
Got blocked at the end with unix/windows path-problems. Maybe my result can help u a little further - maybe you already got it work. I'm interested in your comment. asked on eclipse news portal- following the answer of martin oberhuber (thanks again) tried dsp dd (also blocked with path problem) and set an request in eclipse bugzilla.
here the link to news:
http://www.eclipse.org/newsportal/article.php?id=406&group=eclipse.dsdp.tm
Here my bugzilla:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=252758
At the moment we still debug localy with xldb but I am trying ddd-gdb at the moment. At least locally gdb is running.