No source available in Eclipse - eclipse

I'm using GDB 7.3 in Eclipse. It's connecting to a GDBServer.
When I launch the debugger in Eclipse I get:
No source available for "main() at 0x101250"
I'm compiling with the optimizer turned off and the debug flag set to max:
-O0 -g3
I see the debug symbols when I run:
./powerpc-unknown-eabi-objdump.exe -g | grep debug
GDB 8.1 is able to find the sources. However, I can't use it due to incompatibilities with the GDBServer I'm connecting to :(
Edit:
I have added the source in the "Source" tab in the "Debug Configuration." I've even added the source manually in the GDB terminal aka "Debugger Console" using the following:
directory /path/to/src/
Source directories searched: /path/to/src/:$cdir:$cwd

For those who have this issue in the future.
The problem comes from using a new version of GCC (GCC 8.1) and an older version of GDB (GDB 7.3)
GCC is putting out a new version of debug symbols that the old version GDB does not know how to deal with. I added flags to GCC to produce older dwarf symbols:
-ggdb -gdwarf-3
Here is the documentation for those flags

Related

How to choose a specific MinGW installation for eclipse CDT

I am using 32-bit eclipse CDT Kelper to manage a piece of code, which I could compile on command line but not with eclipse if I use any up-to-date c++11 feature. CDT tells me that "-std=c++11" is unrecognized.
After turning on the verbose option in project properties\settings\tool settings, I found that eclipse CDT somehow chooses an older version of MinGW that comes with Haskell platform 2013.2:
Configured with: ../gcc-4.5.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --disable-werror --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.5.2 (GCC)
COLLECT_GCC_OPTIONS='-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-v' '-o' 'src\vaomp_bnb.o' '-shared-libgcc' '-mtune=i386' '-march=i386'
c:/haskell platform/2013.2.0.0/mingw/bin/../libexec/gcc/mingw32/4.5.2/cc1plus.exe -quiet -v -iprefix c:\haskell platform\2013.2.0.0\mingw\bin\../lib/gcc/mingw32/4.5.2/ -dD ..\src\vaomp_bnb.cpp -quiet -dumpbase vaomp_bnb.cpp -mtune=i386 -march=i386 -auxbase-strip src\vaomp_bnb.o -g3 -O0 -Wall -version -fmessage-length=0 -o C:\DOCUME~1\ting\LOCALS~1\Temp\ccWNoh7I.s
GNU C++ (GCC) version 4.5.2 (mingw32)
I searched SO, and there is a similar question a half year ago here. But the answer there was about setting environment variables and didn't solve the problem.
In my case, CDT can find a MinGW GCC, but found the wrong one. I have installed tdm-gcc 64 bit with gcc-4.8.1, and Haskell platform. The tdm-gcc has priority and
gcc --version
on both DOS and MSYS shows
gcc.exe (tdm64-2) 4.8.1
I don't know what heuristic does CDT use to find toolchains. My question is, how can I tell CDT to use the gcc in a specific location, e.g. c:/MinGW?
Note, I can't uninstall the Haskell platform version of gcc as I will need HP.
Thanks,
I figured it out. It seems that Eclipse CDT does not take tdm-gcc MinGW 64-bit because eclipse itself is 32-bit. So it picked up the only 32-bit MinGW it can find, which is the old version from HP.
To verify this, I installed java 1.7 64-bit, and downloaded 64-bit version of Eclipse CDT (Kelper). Now, CDT automatically selects the TDM-GCC 64 version of MinGW gcc.
For those in a similar situation, one additional issue is that the 64-bit CDT - MinGW64 combination combination does not build projects. No binary/executable files are generated even for a newly created HelloWorld c++ project (even though compilation is OK). In my case, I changed the build tool in the project properties..\tool chain. from CDT internal builder to either of the other two options (one is Gnu's and another is a long name), and then the project can be successfully made to generate exe files.

Eclipse not finding gcc?

I did a fresh install of my computer, I installed a new Eclipse and imported a program into my workspace. The program was working fine before but now I get this message when I try to compile
Program "gcc -std=gnu99" not found in PATH
I checked if gcc is on my PATH variable and it is
user#computer:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/cuda-5.5/bin
and
user#computer:~$ which gcc
/usr/bin/gcc
Any idea what the problem is?
It appears to be looking for an executable named "gcc -std=gnu99", which of course doesn't exist.
I don't know Eclipse very well, but presumably you have to specify the command name gcc and the argument(s) -std=gnu99 separately.
This question discusses setting gcc options in Eclipse.
From that and my own brief experiments, compiler options are set for each project. After selecting a project, follow this sequence of menus:
Project --> Properties -->C/C++ Build --> Settings --> GCC C compiler
In my installation, I have:
Command: gcc
All options: -O0 -g3 -Wall -c -fmessage-length=0
If you have "-std=gnu99" in the "Command" setting, delete it and add it to the "All options" setting.
This is for Eclipse 3.5.2 running on Debian; the menu hierarchy might be different on yours.
If that's not it, you might also want to check your environment variables:
$ env | grep gnu99

not able to run c/cpp execs in eclipse cdt

I installed eclipse and then cdt on an ubuntu system recently and was trying to make the first runnable c/c++ proj..
I installed g++ also, and then created the first executable cpp 'Hello World' project
some files are created... then some issues...
even though Build Automatically is selected, I have to goto the
project n do a Build Project to build it manually, and this i have
to do every time I make a change
After Building manually, there are some new folders created with Binaries and Debug files and I can see g++ commands in the console being executed. The project binary is output both to debug n binaries folder. But i am not able to run these through the Green Play Button or any other way in eclipse. Even Run configuration is not showing any option for C/C++ project..
Though I can goto terminal and run the binary myself through ./
But I want to be able to run n debug this through eclipse.
please help in fixing me this problem as I really love eclipse n have some c/cpp assignments coming soon..
Console info on doing a manual project build -
Build of configuration Debug for project qwe **
make all
Building file: ../src/qwe.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/qwe.d" -MT"src/qwe.d" -o "src/qwe.o" "../src/qwe.cpp"
Finished building: ../src/qwe.cpp
Building target: qwe
Invoking: GCC C++ Linker
g++ -o "qwe" ./src/qwe.o
Finished building target: qwe
Build Finished **
I had an identical problem and solved it by installing two additional "C/C++ Development Tools" that didn't show up when I originally filtered for "cdt" in Eclipse software update. Filter for C++ instead and you'll spot them, after install and reboot everything works.

Eclipse CDT debug attaching to process - not in executable format: File format not recognized

I'm trying to use Eclipse with CDT to debug a 64 bit binary. The binary is built outside of Eclipse, and runs fine. I start up the binary outside of eclipse, and then attempt to attach to the process using the 'C/C++ Attach to Application' debug configuration type.
I can choose the process from the list that pops up when you run the debug configuration, however, I get the following error message:
Error in final launch sequence
Failed to execute MI command:
attach 22014
Error message from debugger back end:
"program.x64": not in executable format: File format not recognized
Everything works fine if I build for an i386 target.
I'm not quite sure where to go with this, I've read that it might have something to do with the binary parsers in Eclipse:
This link mentions parsers, and this link describes a bug with the PE parser that is fixed.
I am running Eclipse Indigo with Eclipse CDT 8.0.0 on Linux x64. I have tried the 'Elf Parser' and 'GNU Elf Parser' under project_properties/c++_build/settings with no luck.
File information:
hostmachinea:file program.x64
programs.x64: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped
GDB and gdbinit files are the Eclipse defaults
It sounds as if the GDB that Eclipse is using was built for i386, and thus can't debug 64-bit binaries. You likely need to install 64-bit capable GDB.
Here what the error message from current GDB looks like:
$ ./gdb --version
GNU gdb (GDB) 7.3.50.20110809-cvs
Copyright (C) 2011 Free Software Foundation, Inc.
...
This GDB was configured as "i686-linux".
...
$ ./gdb -q /bin/date
"/bin/date": not in executable format: File format not recognized
GDB and gdbinit files are the Eclipse defaults
Did you install 32-bit or 64-bit version of CDT?
In the shell, GDB I believe is 64 bit:
~:gdb --version
GNU gdb (GDB) 7.0.1
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
Loading date:
~:gdb -q /bin/date
Reading symbols from /bin/date...(no debugging symbols found)...done.
Typing which gdb, and after putting that path explicitly into the debug configuraiton in Eclipse, I no longer get the error message.
As a bit of a side note, how can you find out which GDB Eclipse uses by default?
I downloaded 64-bit version Eclipse Indigo, which came pacakged with CDT.

The program can't start because cygwin1.dll is missing... in Eclipse CDT

I've had Eclipse for Java on my computer for a few years, and decided to install the CDT and learn C. I installed both MinGW and Cygwin and the CDT detects and tries to use them when I make a new project.
I choose File > New C++ Project and choose Hello World C++ Project and the CygwinGCC toolchain. I name the project "asdf" and hit "Build Debug" in the toolbar. The compiler completes without error. I hit Run and nothing happens.
Browsing to the project directory manually and running asdf.exe gives me an error saying:
"The program can't start because cygwin1.dll is missing from your computer. Try reinstalling the program to fix this problem."
The same thing happens using MinGW, only a different dll is missing.
What do I need to do to have a usable .exe?
(I'm running Windows 7 x64 and the newest version of Eclipse and the CDT.)
EDIT:
The compiler output is as follows:
**** Build of configuration Debug for project asdf ****
make all
Building file: ../src/asdf.cpp
Invoking: Cygwin C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/asdf.d" -MT"src/asdf.d" -o"src/asdf.o" "../src/asdf.cpp"
cygwin warning:
MS-DOS style path detected: C:\Users\Shawn\Dropbox\eclipse\asdf\Debug
Preferred POSIX equivalent is: /cygdrive/c/Users/Shawn/Dropbox/eclipse/asdf/Debug
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
Finished building: ../src/asdf.cpp
Building target: asdf.exe
Invoking: Cygwin C++ Linker
g++ -o"asdf.exe" ./src/asdf.o
Finished building target: asdf.exe
This error message means that Windows isn't able to find "cygwin1.dll". The Programs that the Cygwin gcc create depend on this DLL. The file is part of cygwin , so most likely it's located in C:\cygwin\bin. To fix the problem all you have to do is add C:\cygwin\bin (or the location where cygwin1.dll can be found) to your system path. Alternatively you can copy cygwin1.dll into your Windows directory.
There is a nice tool called DependencyWalker that you can download from http://www.dependencywalker.com . You can use it to check dependencies of executables, so if you inspect your generated program it tells you which dependencies are missing and which are resolved.
You can compile with either Cygwin's g++ or MinGW (via stand-alone or using Cygwin package). However, in order to run it, you need to add the Cygwin1.dll (and others) PATH to the system Windows PATH, before any cygwin style paths.
Thus add: ;C:\cygwin64\bin to the end of your Windows system PATH variable.
Also, to compile for use in CMD or PowerShell, you may need to use:
x86_64-w64-mingw32-g++.exe -static -std=c++11 prog_name.cc -o prog_name.exe
(This invokes the cross-compiler, if installed.)
To add to this and save someone another google, just do this in cmd:
set PATH=%PATH%;C:\cygwin64\bin