在 Eclipse 中设置内存断点
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13310693/
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
Setting Memory Breakpoints in Eclipse
提问by Jim Fell
How do you set memory breakpoints in Eclipse? That is, I would like to set a conditional breakpoint that triggers when the data at a given memory location changes.
你如何在 Eclipse 中设置内存断点?也就是说,我想设置一个条件断点,当给定内存位置的数据发生变化时触发。
This question has been asked before, but the only provided answerdoesn't addressthe question and is essentially the same information that can be found in the Eclipse Online help.
这个问题以前曾被问过,但唯一提供的答案并没有解决这个问题,并且本质上与Eclipse 在线帮助中可以找到的信息相同。
What I am looking for is more detailed information (or an example would be good) for setting a conditional breakpoint in Eclipse that will trigger when the data at a specific memory address changes.
我正在寻找的是用于在 Eclipse 中设置条件断点的更详细信息(或示例会更好),该断点将在特定内存地址处的数据发生更改时触发。
采纳答案by Mike Kwan
You need to use a watchpoint. From the page:
您需要使用观察点。从页面:
- Highlight the variable in the editor, or select it in the Outline view.
- Click Run > Toggle Watchpoint.
- Do any of the following:
- To stop execution when the watch expression is read, select the Readcheck box.
- To stop execution when the watch expression is written to, select the Writecheck box.
- The watchpoint appears in the Breakpointsview list.
- 在编辑器中突出显示变量,或在大纲视图中选择它。
- 单击运行 > 切换观察点。
- 执行以下任一操作:
- 要在读取监视表达式时停止执行,请选中读取复选框。
- 要在写入监视表达式时停止执行,请选中写入复选框。
- 观察点出现在断点视图列表中。
回答by MaximeD
Solution that works:
有效的解决方案:
1/ Select the variable representing the pointer you want to break on in a given context in the "Variables" tab
2/ Right click, then select "Add Watchpoint (C/C++)
3/ In the field "Expression to watch", just replace the name of the variable by the memory address to break on.
回答by Technophile
Using a Watchpoint in Eclipse Oxygen:
在 Eclipse Oxygen 中使用观察点:
- In the Expressions view (Window > Show View > Expressions), add an Expression such as:
*(uint8_t*)0x231cc528
. The cast tells Eclipse the memory location size. - Right-click the added expression and select "Add Watchpoint".
- The resulting Watchpoint may be edited and controlled in the "Breakpoints" view.
- It may be important to edit the Watchpoint. If you want to e.g. detect changes done by other threads: right-click the Watchpoint in the "Breakpoints" view, select Breakpoint Properties... > Filter, UN-check "Restrict to Selected Processes and Threads"
- 在表达式视图(窗口 > 显示视图 > 表达式)中,添加一个表达式,例如:
*(uint8_t*)0x231cc528
。演员表告诉 Eclipse 内存位置大小。 - 右键单击添加的表达式并选择“添加观察点”。
- 可以在“断点”视图中编辑和控制生成的观察点。
- 编辑观察点可能很重要。例如,如果您想检测其他线程所做的更改:右键单击“断点”视图中的观察点,选择“断点属性...”>“过滤器”,取消选中“限制到选定的进程和线程”