我今天遇到了一个非常奇怪的错误.我在表单上有一个按钮,单击它会导致我的表单上的网格填充数据.如果单击该按钮两次,则会在"对象引用未设置为对象实例"的情况下崩溃.
我最终在Sub的开头放置一个断点来处理该网格的数量,我发现......它不再崩溃了.我点击按钮,在Visual Studio中按"F5",它不会崩溃.我做了这个,至少10次,它是固定的.
然后,我删除了断点,F5'ed,单击按钮,它崩溃了.重新添加断点,允许它工作.
有人能解释一下这里发生了什么吗?我正在使用的网格是第三方控件(Infragistics),该应用程序是一个WinForms应用程序.我没有做任何线程 - 我唯一的想法是它是某种'竞争条件'?但即使这样对我来说也没有意义.
编辑:这是一个VB.Net应用程序/ Visual Studio 2008
我的switch语句有大约十个结果,但是其中一些需要1/2循环来检查,所以我不能在case(条件)中写它们,所以我尝试使用多个默认情况,这可能吗?
<?php
switch(true) {
case 1:
break;
case 2:
break;
default:
echo "this text is never printed ??";
while(true) {
while(true) { // case 3
break 3;
}
break;
}
while(true) {
// case 4
break 2;
}
case 5:
break;
default:
while(true) {
// case 6
break 2;
}
case 7:
break;
}
?>
Run Code Online (Sandbox Code Playgroud)
这种事情是否可能,因为我的第一个默认值似乎根本没有执行?!
谢谢
所以我有这个简单的代码片段:
CString str;
..................
if ( str.IsEmpty() )
str = spRelease->GetID();
Run Code Online (Sandbox Code Playgroud)
我想在最后一行放置一个条件断点来测试str是否为空.我先试了一下:
str == ""
Run Code Online (Sandbox Code Playgroud)
但我明白了:
Error overloaded operator not found
Run Code Online (Sandbox Code Playgroud)
然后这个:
str.isEmpty() == 0
Run Code Online (Sandbox Code Playgroud)
得到这个:
Symbol isEMpty() not found
Run Code Online (Sandbox Code Playgroud)
有什么想法可以做到这一点?任何解决方法?
谢谢.
我现在已经研究过这个问题了一段时间,我觉得普通断点的位置会大大影响程序的运行时行为.
我在这里讲的是条件断点,例如当设置断点条件时,var == null这种情况永远不会发生但是当我删除断点var == null时经常发生的情况.
可能是吗?
附录:
我的代码是多线程的,因此很难发布代码以重现错误.基本上我有两个线程.一个是将队列中的项目排队,另一个是从队列中永久地取消项目.在下面的代码中,我遇到的情况是第一个线程永远不会将空项排队,但由于某种原因,它们正在进入队列.这让我插入if语句以防止NullReferenceException.虽然作为一个临时的解决方法,我的程序确实从那时开始运行.然后我感兴趣的是null项从队列中出队的频率,并且我在if语句的行中放置了一个条件断点inv == null.现在的效果是,当存在断点时,inv似乎永远不会为null,并且当没有断点时,inv似乎通常为null.
public void _dequeue () {
while (!Signals.TerminateSignal.WaitOne(0, false)) {
if (Signals.DequeueSignal.WaitOne()) {
lock (Queue) {
IInvocation inv;
Queue.TryDequeue(out inv);
// Conditional Breakpoint
if (inv != null)
inv.Invoke();
_poolHooks[PoolIndex].DecrementWaiting();
_poolHooks[PoolIndex].IncrementPending();
if (Queue.Count == 0) Signals.DequeueSignal.Reset();
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题再次开始,当队列中的一些项目开始是空项目,虽然我从来没有添加空项目.即使是因为这个原因,我已经放置了一行,当有空的东西时抛出异常.永远不会抛出异常,但我的队列中仍然有空项目,我不知道为什么.
public static void EnqueueInvocation (int poolIndex, IInvocation inv ) {
if (inv == null) throw new Exception("Red Alert");
lock (_deqThreads[poolIndex].Queue) {
_poolHooks[poolIndex].IncrementWaiting(); …Run Code Online (Sandbox Code Playgroud) 因此,我在调试Netbeans Java应用程序时注意到在断言函数中使用函数调用时,您无法在该函数中触发断点或进入该函数.
起初我认为它必须与使用重写函数和我被覆盖的函数没有被调用有关,但我确认这不是正在发生的事情.它仍然被调用,但无法进入.
这是我尝试过的片段:
public class Example
{
public static boolean blah()
{
System.out.println("Executing"); //**Breakpoint here
return true;
}
public static void main(String[] args)
{
assert(blah()); //Cannot step into or hit breakpoint on this line.
blah(); //Can here.
}
}
Run Code Online (Sandbox Code Playgroud)
任何人都有任何想法为什么这不起作用?
这是过去的试卷中的一个问题.代码在问题中给出,我需要获得值和断点的次数.我试过在eclipse中运行代码但无济于事.(如果代码执行,我可以在调试模式下找到值)
此问题还指出:该方法fact在类的实例上调用,其中n值为6.不确定我做错了什么,因为代码与问题中给出的完全相同.
public class FactLoop {
private int n;// assumed to be greater than or equal to 0
/**
* Calculate factorial of n
*
* @return n!
*/
public int fact() {
int i = 0;
int f = 1;
/**
* loop invariant 0<=i<=n and f=i!
*/
while (i < n) {// loop test (breakpoint on this line)
i = i++;
f = f * i;
}
return f;
}
// this main method …Run Code Online (Sandbox Code Playgroud) 期待TideSDK 1.3的发布.我已经扩展了提供的示例应用程序,但我无法弄清楚如何断开我的代码并逐步调试它以进行调试.当然,当在浏览器中运行时,我可以使用chrome调试工具,但在Tide沙箱中我该如何实现?
我有以下代码生成随机数,以在条形图上绘制.但是,只有在特定行上设置了断点时,它才能正常工作,否则,所有10个新数据点都会以完全相同的数字出现.
case 3:
//Add ten data sets to go through all default colors
DatasetPairing<BarPresentation, BarGraphDataset<GraphableDouble>> datasetPairing;
foreach (HorizontalBarPlotter<GraphableDouble, GraphableDouble> graphPlotter in this.Data.GraphPlots)
{
for (int i = 1; i <= 11; i++)
{
datasetPairing = new DatasetPairing<BarPresentation, BarGraphDataset<GraphableDouble>>();
datasetPairing.DatasetPresentation = new BarPresentation();
datasetPairing.GraphableDataset = GetOneDataset(0, false);
graphPlotter.DatasetMap.Add(datasetPairing); //breakpoint set here
}
List<IAxis> xAxes;
xAxes = new List<IAxis>();
xAxes.Add(graphPlotter.DetermineXAxis());
this.Data.BottomAxes = xAxes;
this.Data.TopAxes = xAxes;
}
NextStep = "Return to a single dataset and add comment to values for tooltips";
break; …Run Code Online (Sandbox Code Playgroud) 谁能知道是否有任何一种自动的方法可以同时在XCode中添加多个断点。就我而言,我想通过不使用快捷键的几下单击来在全部-viewDidLoad或-tableView:didSelecRowAtIndexPath:方法中添加断点,并全部cmd+shift+F设置(数十次甚至数百次)。
我正在使用VSCode调试python应用程序。
我从启动调试器的地方有一个主要的python文件。我可以在此文件中放置断点,但是如果要将断点放置在主文件调用的其他文件中,则将其作为“未验证的断点”获取,调试器将忽略它们。
如何更改我的位置,launch.json以便能够在项目中的所有文件上设置断点?
这是我目前的情况launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}"
},
{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}",
"port": 3000,
"secret": "my_secret",
"host": "localhost"
},
{
"name": "Python: Terminal (integrated)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}, …Run Code Online (Sandbox Code Playgroud)python breakpoints visual-studio-code vscode-settings vscode-debugger