macos Mac OS X v10.7 (Lion) 上的 Gdb

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8336433/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:39:37  来源:igfitidea点击:

Gdb on Mac OS X v10.7 (Lion)

macosgdb

提问by bsr

I am a new Mac user and wonder how to install the latest version of GDB (> 7.1). I prefer to use Homebrew, but I could not find GDB listed.

我是 Mac 新用户,想知道如何安装最新版本的 GDB (> 7.1)。我更喜欢使用Homebrew,但我找不到列出的 GDB。

brew install gdb
Error: No available formula for gdb

What is the best way to do it?

最好的方法是什么?

When installed Xcode, it may have installed an older version. Currently,

安装 Xcode 时,它​​可能安装了旧版本。目前,

$ which gdb
/usr/bin/gdb

$ gdb --version
GNU gdb 6.3.50-20050815 (Apple version gdb-1705) (Fri Jul  1 10:50:06 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.

But I need version > 7.1

但我需要版本 > 7.1

System version,

系统版本,

Model Name:     MacBook Air
System Version: Mac OS X 10.7.1 (11B2118)

回答by wkl

Homebrew does not provide gcc and the associated development tool formulas over concerns that custom/non-system compilers could break builds. Two possibilities for easiness:

Homebrew 不提供 gcc 和相关的开发工具公式,因为担心自定义/非系统编译器可能会破坏构建。两种方便的可能性:

This is probably the command for you:

这可能是你的命令:

brew install https://raw.github.com/Homebrew/homebrew-dupes/master/gdb.rb

回答by Cripto

Some new users may find themselves in the same situation given the Mac OS X v10.9 (Mavericks) upgrade.

考虑到 Mac OS X v10.9 (Mavericks) 升级,一些新用户可能会发现自己处于相同的情况。

Solution

解决方案

Install the development tools and Xcode

安装开发工具和 Xcode

Then install Homebrew

然后安装 Homebrew

Then do:

然后做:

 brew install homebrew/dupes/gdb

You will notice that some applications will not allow you to use the newly added GDB.

您会注意到某些应用程序不允许您使用新添加的 GDB。

This is because it is not signed by Apple any more.

这是因为它不再由 Apple 签署。

To side step this issue: Follow this; thanks to @andre

回避这个问题:按照这个; 感谢@andre

I've had some people hit me up on IRC for more detailed instructions for this. I made a post on my site. You can find it here.

我已经让一些人在 IRC 上找到我以获得更详细的说明。我在我的网站上发了一个帖子。你可以在这里找到它。

回答by John Clements

This does not directly answer the given question, but if you're like me, what you really want is a simple way to run (something very much like) gdb.

这并没有直接回答给定的问题,但如果你像我一样,你真正想要的是一种运行(非常像)gdb 的简单方法。

Apple now uses Clang as its compiler, and it turns out that the clang debugger, lldb, is installed along with the other command-line tools. It appears that lldb is designed with a user interface that mimics gdb very closely.

Apple 现在使用 Clang 作为其编译器,事实证明,clang 调试器 lldb 与其他命令行工具一起安装。看来 lldb 的设计用户界面非常接近 gdb。

So, the answer to your question may in fact be:

所以,你的问题的答案实际上可能是:

just use lldb!

只需使用 lldb!