在使用Eclipse CDT进行调试时,如何在gdb提示符下输入命令?

时间:2023-01-24 19:03:54

I'm using Eclipse (Helios SR1) CDT for my C++ development. Eclipse interfaces with GDB for debugging, but I can't figure out how to manually enter commands to GDB while debugging through the Eclipse interface. For example, it would be nice to be able to enter p myVar instead of having to click and scroll through the local variables window.

我正在使用Eclipse(Helios SR1)CDT进行C ++开发。 Eclipse与GDB接口进行调试,但我无法弄清楚如何在通过Eclipse接口进行调试时手动输入命令到GDB。例如,能够输入p myVar而不必单击并滚动局部变量窗口会很好。

Note: The only reason I'd like to use the Eclipse interface for debugging is because I like how it shows the code that is being stepped through. So if anyone has an alternative to suggest that would allow me to view the code that's being stepped through, please suggest! (I've used DDD, but I don't especially like it.)

注意:我想使用Eclipse接口进行调试的唯一原因是因为我喜欢它如何显示正在逐步执行的代码。因此,如果有人可以选择建议允许我查看正在执行的代码,请建议! (我使用过DDD,但我不是特别喜欢它。)

2 个解决方案

#1


22  

It is actually very simple.

它实际上非常简单。

Start debugging (eclipse will switch to Debug Perspective). Then make sure Console View is shown. If it's not show it (Window->Show view...). In that view you will find "Display selected console" icon. Select down arrow next to it an select console named "gdb" (not gdb traces!).

开始调试(eclipse将切换到Debug Perspective)。然后确保显示Console View。如果没有显示它(Window-> Show view ...)。在该视图中,您将找到“显示所选控制台”图标。选择旁边的向下箭头,选择一个名为“gdb”的控制台(不是gdb trace!)。

What you enter in this console is forwarded directly to gdb (you can use all gdb commands).

您在此控制台中输入的内容将直接转发到gdb(您可以使用所有gdb命令)。

#2


2  

If you are not debugging under Windows, you could try the gdb TUI. It's a little awkward to get used to, and is sometimes buggy, but in general it works fairly well. You can see the code being stepped through in one window while still being able to enter commands.

如果您没有在Windows下调试,可以尝试gdb TUI。习惯这有点尴尬,有时候有些笨拙,但总的来说它运作得相当好。您可以在一个窗口中查看代码,同时仍然可以输入命令。

Assuming your version of gdb was built with the --enable-tui configure option, simply fire up gdb and press C-x C-a to enter the TUI. Then, to make sure you can see the code and command windows, press C-x 2 (for two-window layout) It's been a while since I've had to use the TUI, but it should work for your requirements.

假设您的gdb版本是使用--enable-tui configure选项构建的,只需启动gdb并按C-x C-a即可进入TUI。然后,为了确保你能看到代码和命令窗口,按C-x 2(用于双窗口布局)已经有一段时间了,因为我必须使用TUI,但它应该适合你的要求。

#1


22  

It is actually very simple.

它实际上非常简单。

Start debugging (eclipse will switch to Debug Perspective). Then make sure Console View is shown. If it's not show it (Window->Show view...). In that view you will find "Display selected console" icon. Select down arrow next to it an select console named "gdb" (not gdb traces!).

开始调试(eclipse将切换到Debug Perspective)。然后确保显示Console View。如果没有显示它(Window-> Show view ...)。在该视图中,您将找到“显示所选控制台”图标。选择旁边的向下箭头,选择一个名为“gdb”的控制台(不是gdb trace!)。

What you enter in this console is forwarded directly to gdb (you can use all gdb commands).

您在此控制台中输入的内容将直接转发到gdb(您可以使用所有gdb命令)。

#2


2  

If you are not debugging under Windows, you could try the gdb TUI. It's a little awkward to get used to, and is sometimes buggy, but in general it works fairly well. You can see the code being stepped through in one window while still being able to enter commands.

如果您没有在Windows下调试,可以尝试gdb TUI。习惯这有点尴尬,有时候有些笨拙,但总的来说它运作得相当好。您可以在一个窗口中查看代码,同时仍然可以输入命令。

Assuming your version of gdb was built with the --enable-tui configure option, simply fire up gdb and press C-x C-a to enter the TUI. Then, to make sure you can see the code and command windows, press C-x 2 (for two-window layout) It's been a while since I've had to use the TUI, but it should work for your requirements.

假设您的gdb版本是使用--enable-tui configure选项构建的,只需启动gdb并按C-x C-a即可进入TUI。然后,为了确保你能看到代码和命令窗口,按C-x 2(用于双窗口布局)已经有一段时间了,因为我必须使用TUI,但它应该适合你的要求。