如何使用gdb达到与使用可视化调试器相同的效率水平?

时间:2022-05-20 16:40:46

I know this is like heresy, but I simply can't see how using gdb can be more efficient, in daily debug use (not advanced dumping and logging debug), than a visual debugger.

我知道这就像异端邪说,但我无法看到在日常调试使用(不是高级转储和日志记录调试)中使用gdb比使用可视化调试器更高效。

I come from a background of .Net (Love the environment hate the mentality) and over the past coupld of years moved to PHP & C++. I am now developing a project in C++, using Eclipse, and hate how heavy the editor is, so I've moved to Textmate. But debugging is so uncomfortable. I'm using gdb, but miss visual debug, which is so much easier and efficient.

我来自.Net的背景(热爱环境讨厌心态),并且在过去的几年里转向了PHP和C ++。我现在正在用C ++开发一个使用Eclipse的项目,并且讨厌编辑器有多重,所以我已经转移到了Textmate。但是调试很不舒服。我正在使用gdb,但错过了可视化调试,这非常简单有效。

And yet, every one says - Learn to use gdb properly! So I'm asking- how do I use gdb properly & efficiently?

然而,每个人都说 - 学会正确使用gdb!所以我问 - 如何正确有效地使用gdb?

6 个解决方案

#1


1  

As for me, I always use gdb's TUI mode. From gdb manual:

至于我,我总是使用gdb的TUI模式。从gdb手册:

The gdb Text User Interface (TUI) is a terminal interface which uses the curses library to show the source file, the assembly output, the program registers and gdb commands in separate text windows. The TUI mode is supported only on platforms where a suitable version of the curses library is available.

gdb文本用户界面(TUI)是一个终端接口,它使用curses库在单独的文本窗口中显示源文件,程序集输出,程序寄存器和gdb命令。仅在具有合适版本的curses库的平台上支持TUI模式。

It brings some visual debugging to gdb and it's enough for me. I usually start gdb in regular command line mode, watch backtraces and set breakpoints in it. When I want to look at source code I swith to TUI mode with key binding C-x C-a and switch back to look backtraces for example. This is built-in ready to use feature of gdb. You need not any additional software like KDevelop or Emacs to use it.

它为gdb带来了一些可视调试,这对我来说已经足够了。我通常在常规命令行模式下启动gdb,观察回溯并在其中设置断点。当我想查看源代码时,我使用键绑定C-x C-a切换到TUI模式,然后切换回看例如回溯。这是gdb的内置即用型功能。您无需使用任何其他软件(如KDevelop或Emacs)来使用它。

#2


6  

You could use gdb with an IDE like KDevelop. It has an visual interface so that helps.
Or GDB with Emacs, It does nearly everything fancy graphical debuggers can do and with ease.

您可以将gdb与像KDevelop这样的IDE一起使用。它有一个可视界面,所以有帮助。或者使用Emacs的GDB,几乎所有花哨的图形化调试器都可以轻松完成。

Just to add, You can have a look at this article. It tells about some nice tricks.

只是补充一下,你可以看一下这篇文章。它讲述了一些不错的技巧。

#3


3  

You could try qt-creatror, which has also nice and easy GDB visual interface.

你可以尝试qt-creatror,它也有很好的GDB可视化界面。

#4


2  

What about DDD ?

DDD怎么样?

#5


0  

I use netbeans for C++. It integrates with gdb and gives you visual debugging. It's not as nice as Visual Studio but it's close. It's cleaner and lighter than Eclipse. It wasn't easy to get everything set up on Windows though. I can provide some pointers there if you need them

我使用netbeans for C ++。它与gdb集成,为您提供可视化调试。它不如Visual Studio好,但它很接近。它比Eclipse更清洁,更轻巧。虽然在Windows上设置所有内容并不容易。如果你需要它我可以提供一些指示

#6


0  

Perhaps gdb is even more efficient. It can make use of core dumps when debugging hard to reproduce bugs like peculiar dead locks. It can also debug running processes. Other features like conditional breakpoints, and more recently developed reverse execution also make gdb stand out.

也许gdb更有效率。它可以在调试时使用核心转储,以便重现诸如特殊死锁之类的错误。它还可以调试正在运行的进程。其他功能,如条件断点,以及最近开发的反向执行也使gdb脱颖而出。

Disclaimer: I don't use a visual debugger, and I am not very sure if they support the above.

免责声明:我不使用可视化调试器,我不确定他们是否支持上述内容。

#1


1  

As for me, I always use gdb's TUI mode. From gdb manual:

至于我,我总是使用gdb的TUI模式。从gdb手册:

The gdb Text User Interface (TUI) is a terminal interface which uses the curses library to show the source file, the assembly output, the program registers and gdb commands in separate text windows. The TUI mode is supported only on platforms where a suitable version of the curses library is available.

gdb文本用户界面(TUI)是一个终端接口,它使用curses库在单独的文本窗口中显示源文件,程序集输出,程序寄存器和gdb命令。仅在具有合适版本的curses库的平台上支持TUI模式。

It brings some visual debugging to gdb and it's enough for me. I usually start gdb in regular command line mode, watch backtraces and set breakpoints in it. When I want to look at source code I swith to TUI mode with key binding C-x C-a and switch back to look backtraces for example. This is built-in ready to use feature of gdb. You need not any additional software like KDevelop or Emacs to use it.

它为gdb带来了一些可视调试,这对我来说已经足够了。我通常在常规命令行模式下启动gdb,观察回溯并在其中设置断点。当我想查看源代码时,我使用键绑定C-x C-a切换到TUI模式,然后切换回看例如回溯。这是gdb的内置即用型功能。您无需使用任何其他软件(如KDevelop或Emacs)来使用它。

#2


6  

You could use gdb with an IDE like KDevelop. It has an visual interface so that helps.
Or GDB with Emacs, It does nearly everything fancy graphical debuggers can do and with ease.

您可以将gdb与像KDevelop这样的IDE一起使用。它有一个可视界面,所以有帮助。或者使用Emacs的GDB,几乎所有花哨的图形化调试器都可以轻松完成。

Just to add, You can have a look at this article. It tells about some nice tricks.

只是补充一下,你可以看一下这篇文章。它讲述了一些不错的技巧。

#3


3  

You could try qt-creatror, which has also nice and easy GDB visual interface.

你可以尝试qt-creatror,它也有很好的GDB可视化界面。

#4


2  

What about DDD ?

DDD怎么样?

#5


0  

I use netbeans for C++. It integrates with gdb and gives you visual debugging. It's not as nice as Visual Studio but it's close. It's cleaner and lighter than Eclipse. It wasn't easy to get everything set up on Windows though. I can provide some pointers there if you need them

我使用netbeans for C ++。它与gdb集成,为您提供可视化调试。它不如Visual Studio好,但它很接近。它比Eclipse更清洁,更轻巧。虽然在Windows上设置所有内容并不容易。如果你需要它我可以提供一些指示

#6


0  

Perhaps gdb is even more efficient. It can make use of core dumps when debugging hard to reproduce bugs like peculiar dead locks. It can also debug running processes. Other features like conditional breakpoints, and more recently developed reverse execution also make gdb stand out.

也许gdb更有效率。它可以在调试时使用核心转储,以便重现诸如特殊死锁之类的错误。它还可以调试正在运行的进程。其他功能,如条件断点,以及最近开发的反向执行也使gdb脱颖而出。

Disclaimer: I don't use a visual debugger, and I am not very sure if they support the above.

免责声明:我不使用可视化调试器,我不确定他们是否支持上述内容。