xcode GDB 与 LLDB 调试器

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

GDB Vs LLDB debuggers

xcodedebuggingcocoa-touchgdblldb

提问by Abhinav

What is the difference between GDB & LLDB debuggers? I recently upgraded my Xcode version from 4.2 to 4.3 & started getting warning to upgrade my debugger from GDB to LLDB.

GDB 和 LLDB 调试器之间有什么区别?我最近将我的 Xcode 版本从 4.2 升级到 4.3 并开始收到警告,将我的调试器从 GDB 升级到 LLDB。

采纳答案by infinitetape

LLDB is part of the LLVM suite of tools that Apple is moving to, including Clang. There are tons of improved features, including improved performance. There's a quick intro for GDB users here: http://lldb.llvm.org/tutorial.html

LLDB 是 Apple 正在迁移到的 LLVM 工具套件的一部分,包括 Clang。有大量改进的功能,包括改进的性能。这里有 GDB 用户的快速介绍:http: //lldb.llvm.org/tutorial.html

However...

然而...

You might want to take a trip over to the forums at developer.apple.com. There's a fair bit of rumbling about issues with LLDB at the moment (in XCode 4.3.1). One nasty issue, which people from Apple have confirmed, is that viewing ivars while stepping may show you the wrong values.

您可能想访问 developer.apple.com 上的论坛。目前(在 XCode 4.3.1 中)有很多关于 LLDB 的问题。Apple 人员已经确认的一个令人讨厌的问题是,在步进时查看 ivars 可能会向您显示错误的值。

回答by boraseoksoon

1. By Difference of Definition

1. 定义不同

First, What is GDB?

一、什么是GDB?

"GDB is the standard debugger for the GNU software system"
The GNU Debugger, usually called just GDB and named gdb as an executable file, is the standard debugger for the GNU operating system. However, its use is not strictly limited to the GNU operating system; it is a portable debugger that runs on many Unix-like systems and works for many programming languages, including Ada, C, C++, Objective-C, Free Pascal, Fortran, Java1and partially others.2

(quotation from wikipedia)

“GDB 是 GNU 软件系统的标准调试器”
GNU 调试器,通常简称为 GDB,将 gdb 命名为可执行文件,是 GNU 操作系统的标准调试器。但是,它的使用并不严格限于 GNU 操作系统;它是一个便携式调试器,可在许多类 Unix 系统上运行,并适用于多种编程语言,包括 Ada、C、C++、Objective-C、Free Pascal、Fortran、Java 1和部分其他语言。2

(引自维基百科)

Second, What is LLDB?

二、什么是LLDB?

"LLDB is a debugger built as a set of reusable components which highly leverage existing libraries in the larger LLVM Project, such as the Clang expression parser and LLVM disassembler.
LLDB is Apple's “from the ground up” replacement for GDB, developed in close coordination with the LLVM compilers to bring you state-of-the-art debugging with extensive capabilities in flow control and data inspection. Starting with Xcode 5, all new and preexisting development projects are automatically reconfigured to use LLDB. The standard LLDB installation provides you with an extensive set of commands designed to be compatible with familiar GDB commands. In addition to using the standard configuration, you can easily customize LLDB to suit your needs.

(quotation from Apple official site)
/* I tried to find actual / practical datas to prove the statement : LLDB is already much faster than GDB when debugging large programs.) However, I could not find it. if there is someone having this related data, please edit this article. */

“LLDB 是作为一组可重用组件构建的调试器,它高度利用了更大的 LLVM 项目中的现有库,例如 Clang 表达式解析器和 LLVM 反汇编器
。LLDB 是 Apple 对 GDB 的“从头开始”替代品,在密切协调下开发使用 LLVM 编译器为您带来最先进的调试以及流控制和数据检查方面的广泛功能。从 Xcode 5 开始,所有新的和预先存在的开发项目都会自动重新配置为使用 LLDB。标准的 LLDB 安装为您提供一套广泛的命令,旨在兼容熟悉的GDB命令。除了使用标准配置外,您还可以轻松自定义LLDB以满足您的需求。

(引自苹果官网)
/* 我试图找到实际/实用的数据来证明这个说法:在调试大型程序时,LLDB 已经比 GDB 快得多。)但是,我找不到它。如果有人有这个相关数据,请编辑这篇文章。*/

Both GDB and LLDB are of course excellent debuggers without doubt.
GDB is debugger part of the GNU project created to work along the GNU compiler.
LLDB is debugger part of the LLVM project created to work along LLVM compiler.

毫无疑问,GDB 和 LLDB 都是优秀的调试器。
GDB 是为与 GNU 编译器一起工作而创建的 GNU 项目的调试器部分。
LLDB 是为与 LLVM 编译器一起工作而创建的 LLVM 项目的调试器部分。

2. By Difference of Debugger Command usage

2. Debugger Command 用法的不同

The majority of the commands are the same.
However, lldb and gdb, two different debuggers are developed by different set of developers and thus have a little bit different commands.

大多数命令是相同的。
但是,lldb 和 gdb 这两个不同的调试器是由不同的开发人员开发的,因此命令略有不同。

This is good link below for comparing difference of these two debugger commands.
let me link the detail below : https://developer.apple.com/library/content/documentation/IDEs/Conceptual/gdb_to_lldb_transition_guide/document/lldb-command-examples.html

这是下面比较这两个调试器命令差异的好链接。
让我链接以下详细信息:https: //developer.apple.com/library/content/documentation/IDEs/Conceptual/gdb_to_lldb_transition_guide/document/lldb-command-examples.html

http://lldb.llvm.org/lldb-gdb.html

http://lldb.llvm.org/lldb-gdb.html

This clearly indicates and organizes the difference of commands.

这清楚地指示和组织命令的差异。

In case the site is not accessible anymore, I summary the major difference of commands below from the linked site.

如果该站点不再可访问,我总结了以下链接站点命令的主要区别。

Execution command difference between GDB and LLDBBreak-Point command difference between GDB and LLDBExamining variable command difference between GDB and LLDBExamining thread state command difference between GDB and LLDB

3. By Personal Opinion

LLDB has been fully integrated from Xcode IDE 5 by default as primary debugger.
From that time, there has been some complaint report about LLDB stability, performance issues and bugs.
However, LLVM with LLDB project has been being incredibly improved and upgraded so far as the one of the core open-source project in the world.
So, I think, at least, LLDB should be used for Apple development environment since LLDB stole the position of GDB and is already primary default debugger at least in Apple world.
(In late September, 2016, Xcode 8 integrating LLVM and LLDB was officially released, meaning quite a lot of time has been passed since LLVM/LLDB is default tool-chain for Xcode.)
But, We all already know GDB has been historically and strongly verified and battle-proven debugger over 30 years, which is awesome.

GDB和LLDB的执行命令区别GDB 和 LLDB 的 Break-Point 命令区别检查 GDB 和 LLDB 之间的变量命令差异检查 GDB 和 LLDB 之间的线程状态命令差异

3. 根据个人意见,

LLDB 已默认从 Xcode IDE 5 完全集成为主要调试器。
从那时起,有一些关于 LLDB 稳定性、性能问题和错误的投诉报告。
然而,LLVM with LLDB 项目一直在得到令人难以置信的改进和升级,成为世界上核心的开源项目之一。
因此,我认为,至少 LLDB 应该用于 Apple 开发环境,因为 LLDB 抢走了 GDB 的位置,并且至少在 Apple 世界中已经是主要的默认调试器。
(2016 年 9 月下旬,集成 LLVM 和 LLDB 的 Xcode 8 正式发布,这意味着自从 LLVM/LLDB 成为 Xcode 的默认工具链以来,已经过去了很多时间。)
但是,我们都知道 GDB 已经过 30 多年的历史和强有力的验证和实战证明的调试器,这太棒了。

So, I would say…
I would like to use lldb while using clang, use gdb while using gcc compiler as the good combination or pair because lldb is based on llvm, whereas gdb is a GNU debugger.

所以,我会说……
我想在使用 clang 时使用 lldb,在使用 gcc 编译器时使用 gdb 作为很好的组合或配对,因为 lldb 基于 llvm,而 gdb 是 GNU 调试器。

I wish it could be helpful for you.

我希望它对你有帮助。

Thanks.

谢谢。