Eclipse CDT-如何快速评估代码中未包含的表达式? [英] Eclipse CDT - how to quickly evaluate an expression which is not in the code?

查看:43
本文介绍了Eclipse CDT-如何快速评估代码中未包含的表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我离开Eclipse CDT已有一段时间了,并为JetBrains出色的IDE所宠爱(公司不会让我

  1. 在弹出窗口中输入表达式:

  1. 表达式视图将打开和/或移至顶部.

控制台

控制台视图允许您在标准

  1. 控制台视图现在将显示GDB的界面:

  1. 键入命令到GDB,例如 print i + j pi-j ( p print 的缩写):

使用控制台时的其他提示

  • 您可以固定"控制台,以便使用工具栏上的此按钮将其保持在所选控制台的顶部:

  • 您可以通过以下下拉菜单切换控制台:

  • 您可以打开第二个控制台,例如一个用于GDB交互,另一个用于使用以下按钮输出程序:

I have been away from Eclipse CDT for a while and have become spoiled by JetBrains' excellent IDEs (and the company won't let me have Clion). Admittedly these are mostly for interpreted, rather than compiled languages, so evaluation is simpler.

When I am breakpointed in Eclipse CDT, (how) can I quickly evaluate expressions involving variables known to the debugger, but in ways in which they are not used in the code?

For instance, if I have two integers, i and j, (how) can I quickly evaluate i + j?

Is it possible, given char *s, to evaluate stlen(s)? Or the result of a local function call?

解决方案

Off the top of my head I would suggest either the Expression view or the Console view, depending on what your flow is, etc.

Expressions

The Expressions view allows you to add any arbitrary expressions to be evaluated by the selected frame every time the debugger hits a breakpoint or completes a single step.

The Expressions view is not open by default. You can open it from the Window -> Show View -> Expressions.

You can then press the Add new expression button and enter an expression to evaluate. (You can enter pretty much any expression:i+j, strlen(s), or anything else you like)

Alternatively, you can:

  1. from the context menu, select *Add watch expression...":

  1. enter the expression in the pop-up:

  1. the Expressions view will open and/or come to the top.

Console

The console view allows you to enter GDB commands in standard GDB syntax.

To use the Console:

  1. Select the gdb item in the Debug View

  1. The Console view will now display the interface to GDB:

  1. Type commands to GDB, e.g. print i + j or p i - j (p is short for print):

Other Hints when using the Console

  • You can "pin" the console so that it stays the selected console top with this button on the toolbar:

  • You can switch console with this drop-down:

  • You can open a second console, e.g. one for GDB interaction and one for output of your program with this button:

这篇关于Eclipse CDT-如何快速评估代码中未包含的表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆