如果调试行为与正常执行不同,该怎么办? [英] What to do, if debug behaviour differs from normal execution?

查看:202
本文介绍了如果调试行为与正常执行不同,该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个调试会话的问题。我的程序在调试会话中执行得很好,但如果我开始正常运行,它的行为完全不同。

问题是,我不能说,为什么它的行为不同。



一个可能的原因是执行时间较慢,因为你一直都要按 F6 等等。

我试图插入 Thread.sleep(1000); 但是我没有得到导致不同行为的指令。



那么:什么是提示,最佳做法了解为什么它在调试会话中如此不同?

解决方案

两种解决方案:



a)使用穷人的调试器(打印到控制台)或使用日志框架。发生错误后,分析输出。



b)编写一个试图重现问题的测试用例。即使你找不到这样的方式,这样做会清理您的代码,有时也会解决问题。


I have a problem with debugging sessions. My program executes very well in a debug session but if I start a normal run, it behaves completely different.
The problem is, that I cannot say, why it acts different.

One possible reason is the slower execution time because you alway have to press F6 or so.
I tried to insert Thread.sleep(1000); but I don't get the instruction causing the different behaviour.

So: What are hints, best practices to get to know why it acts so different in debug sessions?

解决方案

Two solutions:

a) Use poor man's debugger (print to the console) or use a logging framework. After the error happens, analyze the output.

b) Write a test case that tries to reproduce the problem. Even if you can't find it that way, this will clean your code and sometimes solve the issue.

这篇关于如果调试行为与正常执行不同,该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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