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 Eclip开发者_开发技巧se 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.
精彩评论