当我没有 Xcode 项目时,如何在 Mac OS 上获得可视化调试器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2900271/
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-09-14 19:23:11  来源:igfitidea点击:

How do I get a visual debugger on Mac OS when I have no Xcode project?

c++xcodedebugginggdb

提问by Michael Labbé

I am porting a project over to OS X. I am finding GDB debugging in the console to be woefully insufficient and really need a visual debugger. My project is built using Scons and as such, it sidesteps Xcode's IDE entirely. This is acceptable until I need to fire up a visual debugger and step through my code.

我正在将一个项目移植到 OS X。我发现控制台中的 GDB 调试严重不足,确实需要一个可视化调试器。我的项目是使用 Scons 构建的,因此它完全避开了 Xcode 的 IDE。这是可以接受的,直到我需要启动可视化调试器并逐步执行我的代码。

Aside from generating and maintaining an Xcode project (to supplement all of the other platforms I have to support already), what can I do to get a visual debugger up and running on OS X?

除了生成和维护 Xcode 项目(以补充我已经支持的所有其他平台),我还能做些什么来在 OS X 上启动和运行可视化调试器?

This is for a C++ project.

这是针对 C++ 项目的。

回答by tomdemuyt

Simple:

简单的:

  1. Start XCode
  2. Click 'Run' in top menu
  3. Choose attach to process, choose the process you want to debug
  1. 启动 XCode
  2. 单击顶部菜单中的“运行”
  3. 选择附加到进程,选择要调试的进程

Make sure to compile with full debug of course ... which means using option -ggdb

确保使用完整的调试进行编译......这意味着使用选项 -ggdb

回答by Paul R

Xcode supports makefile projects - you can just drag all your source into a new legacy project template, set up the makefile command line, tell it where the executable lives, and you're in business.

Xcode 支持 makefile 项目——您只需将所有源代码拖到一个新的遗留项目模板中,设置 makefile 命令行,告诉它可执行文件的位置,然后您就可以开展业务了。

回答by davidh

If you are Emacs friendly then: M-x gdbwill put you into "gud" mode. This turns Emacs into a visual debugger. This can be made to work with the new lldb too.

如果您对 Emacs 友好,那么:M-x gdb将使您进入“gud”模式。这将 Emacs 变成了可视化调试器。这也可以与新的 lldb 一起使用。

回答by karlvirgil

You can try ddd

你可以试试ddd

sudo port install ddd

ddd acts as a front end to gdb and has a nice GUI. In my experience, ddd has been quite stable and useful on OS X. I've mainly used it for debugging OpenFOAM C++ code.

ddd 充当 gdb 的前端,并具有很好的 GUI。根据我的经验,ddd 在 OS X 上非常稳定和有用。我主要用它来调试 OpenFOAM C++ 代码。