eclipse的断点调试的几种方法
来源:互联网 发布:淘宝卖家二手开店流程 编辑:程序博客网 时间:2024/06/04 18:44
eclipse的断点调试的几种方法
linebreakpoint
我们可以在断点处设置某种条件,当达到该条件的时候才会停在断点处:
private int x; public void setX(int x) { this.x = x;//断点处 }
在断点处设置属性:
只有在x是偶数的时候,才会进入断点处。
watchpoint
watchpoint描述(http://en.wikipedia.org/wiki/Breakpoint):
Other kinds of conditions can also be used, such as the reading, writing, or modification of a specific location in an area of memory. This is often referred to as a conditional breakpoint, a data breakpoint, or a watchpoint.
当设置了一个watchpoint,就告诉IDE你希望监视一块内存。当被监视的内存的内容发生变化时(reading,writing,or modification),watchpoint就被触发了,此时程序暂停运行,等待我们查看,由于我们监控的是一块内存区域那么我们实际上是监控所在的内存空间
public class BreakPoint { private int value = 0;//这里有一个watchpoint private Random random = new Random(); public void setValue(int count) { for (int i = 0; i < count; i++) { value = random.nextInt(10); System.out.println(value); } }}
默认情况下watchpoint的property在读写的时候均进入变量查看:
也就是说以下两行代码在运行的时候均会停下
value = random.nextInt(10);System.out.println(value);
取消access(访问)的特性,那么下面代码就会跳过(访问value值)
System.out.println(value);
同理,取消modify(修改)的特性,那么下面代码会跳过监视(修改value值)
value = random.nextInt(10);
ExceptionBreakPoint
添加某个Exception(如IllegalArgumentException),那么在当程序执行到异常代码的时候会触发断点。例子:
public void setValue(int count) { for (int i = 0; i < count; i++) { value = 4; } } void printValue(int count) { setValue(count); if (value % 4 == 0) { throw new IllegalArgumentException("这个value值是不合法的"); } System.out.println(value); }
当程序运行到异常的时候,会触发断点。我们可以跟踪异常附近的变量值。
MethodBreakPoint
修改方法断点的属性,勾选Exit的选项
public void setValue(int count) {//该行设个断点 for (int i = 0; i < count; i++) { value = random.nextInt(10); } }
那么在进入方法和离开方法的手都会暂停。
注意debug的环境配置要和build的环境配置一致,否者如果build的版本较高:
debug的版本较低:
会出现如下的类版本错误的信息:
Exception in thread "main" java.lang.UnsupportedClassVersionError: test/ConcurrentHashMapTest : Unsupported major.minor version 52.0
- Eclipse调试断点的几种方法
- eclipse的断点调试的几种方法
- MTK断点调试的几种方法
- php断点调试的几种方法
- php断点调试的几种方法
- php断点调试的几种方法
- MTK断点调试的几种方法
- MTK快速调试定位的几种方法(断点设置)
- php断点调试的几种方法讨论
- php断点调试的几种方法讨论
- Eclipse 的断点调试
- eclipse 断点调试方法
- eclipse断点调试方法
- eclipse 断点调试方法
- eclipse-断点调试-设置断点选中行的背景颜色
- eclipse上ofbiz项目的断点调试
- eclipse上ofbiz项目的断点调试
- eclipse下的ndk断点调试
- Hibernate 工作原理详解
- 树莓派的配置文件config.txt
- 在Android中显示GIF动画
- Verilog基础知识3(门控时钟及FPGA时钟使能处理)
- CodeForces 474DFlowers
- eclipse的断点调试的几种方法
- python学习(1)——爬虫的结构
- 100小时学会SAP常见问题 转
- Oracle 存储过程实例集锦
- EventBus使用详解(一)——初步使用EventBus
- 1042. 字符统计(20)
- MySQL定时任务(每天凌晨3点钟执行)
- PHP Template Engine:Twig 语法汇总
- c/c++ 变量名前面加井号#