在Mac 10.9上的gdb失败,并且“不是可执行格式:文件格式未被识别”为32 + 64拱 [英] gdb on mac 10.9 fails with "not in executable format: File format not recognized" for 32+64 arch

查看:245
本文介绍了在Mac 10.9上的gdb失败,并且“不是可执行格式:文件格式未被识别”为32 + 64拱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $文件应用程序
应用程序:具有2种架构的Mach-O通用二进制文件
应用程序(用于架构i386):Mach-O可执行文件i386
应用程序(适用于架构x86_64):Mach-O 64位可执行文件x86_64

$ gdb应用程序
GNU gdb(GDB)7.6
版权所有(C)2013 Free Software Foundation,Inc.
许可证GPLv3 +:GNU GPL版本3或更高版本< http://gnu.org/licenses/gpl.html>
这是免费软件:您可以自由更改和重新分配它。
在法律允许的范围内,不存在任何担保。有关详细信息,请键入显示复制
和显示保修。
此GDB被配置为x86_64-apple-darwin13.0.0。
有关错误报告的说明,请参阅:
< http://www.gnu.org/software/gdb/bugs/> ...
app:不在可执行文件中格式:文件格式不被识别


$文件测试
测试:Mach-O 64位可执行文件x86_64

$ gdb测试
GNU gdb(GDB)7.6
版权所有(C)2013自由软件基金会,Inc.
许可证GPLv3 +:GNU GPL版本3或更高版本< http://gnu.org/licenses/gpl.html>
这是免费软件:您可以自由更改和重新分配它。
在法律允许的范围内,不存在任何担保。有关详细信息,请键入显示复制
和显示保修。
此GDB被配置为x86_64-apple-darwin13.0.0。
有关错误报告的说明,请参阅:
< http://www.gnu.org/software/gdb/bugs/> ...
从/ Users / dmulder中读取符号/test...读取/Users/dmulder/test.dSYM/Contents/Resources/DWARF/test...done中的符号。
完成。

为什么64位二进制成功,但64 + 32二进制失败?

解决方案

不幸的是,非Apple版本的GNU gdb目前无法调试通用(或胖)二进制文件(包含32位和/或64位可执行文件)。

一个选项是使用 lipo 来提取单个体系结构并运行gdb那:

  lipo -thin x86_64 -output app-x86_64 ./app 

  lipo -thin i386 -output app- i386 ./app 

如果您想要调试组合可执行文件,可以尝试使用 LLDB 苹果版的gdb


$ file app
app: Mach-O universal binary with 2 architectures
app (for architecture i386):    Mach-O executable i386
app (for architecture x86_64):  Mach-O 64-bit executable x86_64

$ gdb app
GNU gdb (GDB) 7.6
Copyright (C) 2013 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-apple-darwin13.0.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
"app": not in executable format: File format not recognized


$ file test
test: Mach-O 64-bit executable x86_64

$ gdb test
GNU gdb (GDB) 7.6
Copyright (C) 2013 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-apple-darwin13.0.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /Users/dmulder/test...Reading symbols from /Users/dmulder/test.dSYM/Contents/Resources/DWARF/test...done.
done.

Why would the 64bit binary succeed, but the 64+32 binary fail?

解决方案

Unfortunately, the non-Apple version of GNU gdb is currently unable to debug universal (or 'fat') binaries (ones that contain both 32-bit and 64-bit executables).

One option is to use lipo to extract a single architecture and run gdb on that:

lipo -thin x86_64 -output app-x86_64 ./app

or

lipo -thin i386 -output app-i386 ./app

If you'd prefer to debug the combined executable, you could try using LLDB, or an Apple version of gdb.

这篇关于在Mac 10.9上的gdb失败,并且“不是可执行格式:文件格式未被识别”为32 + 64拱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆