这种调试行为是否引起关注(如果是这样,需要注意什么) [英] Is this debugging behavior cause for concern (and if so, what to look for)

查看:70
本文介绍了这种调试行为是否引起关注(如果是这样,需要注意什么)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置了一些似乎工作得很好的C ++项目的代码,并且它爆炸了。所以我添加了一些断点。



我发现Visual Studio Express 2013直接跳到例程(不是构造函数)的中间,然后蜿蜒几个地方,包括许多空白行。所以谷歌搜索删除了SUO,我做了。此外,我在调试版本,这些似乎只是真正的解决方案。



在中间,我评论了导致错误。 Visual Studio STILL逐步完成了时髦的行(它们出现在我评论的行之前,因此我的评论不应该在这方面有所作为)。但程序不会崩溃。



我应该关注这种时髦的行为吗?我知道我以前见过VS'捕获'断点,通常是在构造函数中,而不是通过整个构造函数,在这些情况下它似乎不是问题。



如果引起关注,我该怎么办?



谢谢,

David

I set added some code to a C++ project that seemed to work fine, and it blew up. So I added some breakpoints.

I found that Visual Studio Express 2013 was jumping directly into the middle of a routine (not a constructor), then meandering about a few places, including many blank lines. So googling said to delete the SUO, which I did. Also, I'm in debug version, and those seem like only real solutions put forth.

In the middle of that, I commented out the lines that resulted in the bug. Visual Studio STILL steps through the funky lines (and they occurred before the lines I commented, so my comments shouldn't have made a difference in that aspect). But the program doesn't crash.

Should I be concerned about this funky behavior? I know I've seen VS 'catch' breakpoints before, usually in constructors, without going through the entire constructor, and it seemed to not be an issue in those cases.

If it is cause for concern, what should I be looking for?

Thanks,
David

推荐答案

这似乎是Visual Studio 2013本身的一个错误。很奇怪,如果有人可以在他们的安装上确认,但它归结为枚举的头内初始化导致调试器变得不稳定,表明可能产生错误的代码。要复制,这是最小的设置:



创建一个新的Visual C ++ General解决方案空项目。添加一个主单位,或任何你想要的单位。粘贴以下内容:

It seems to have been a bug in Visual Studio 2013 itself. Curious if anyone with it can confirm on their installations, but it boiled down to in-header initialization of enums causing the debugger to go wonky, indicating probable bad code generation. To replicate, here's the smallest setup:

Create a new Visual C++ General solution empty project. Add a 'main' unit to it, or whatever you want to call it. Paste the following:
#include "Object.h"
#include <iostream>

int main() {
   Junk * junk = NULL;
   Object o(junk);

   int dummy;
   std::cout << std::endl << "Press a key and 'Enter' to quit ";
   std::cin >> dummy; //Total junk way to do this, but good enough for testing
   return 0;
   }



添加'Object.cpp'文件:


Add an 'Object.cpp' file:

#include "Object.h"

Object::Object(Junk * junk) : junkC(junk) { //Breakpoint on this line.

   }


bool Object::doSomething() {
   return true;
   } //Debugger jumps to here!!!  Wonky!



和Object.h


And an "Object.h"

#pragma once

class Junk; //Forward declaration (but left incomplete for example)

class Object {
   private:
      Junk * junkC;

   public:
      enum Style { ThreeD, Flat, Shadow } containerStyleC = ThreeD;

      Object(Junk * junk);

      bool doSomething();
   };



在Object :: Object(垃圾*)上放置一个断点...当它被击中时,执行'step into'。下一个调试器进入的行是'doSomething'块的结束。



如果在cpp文件的类初始化列表中执行枚举初始化,调试器将按预期执行。我尝试通过VS中的报告错误选项报告这一点,但它还没有出现,尽管可能有一个步骤我没有完成。事实上,它显示我没有提交,我猜我错过了一步,但我会等一会儿,也许它会出现。


Put a breakpoint at Object::Object(Junk*)... When it is hit, do a 'step into.' The next line the debugger goes to is the end of the 'doSomething' block.

If the enum initialization is performed in the cpp file's class initialization list, the debugger steps as expected. I tried reporting this through the 'Report a bug' option in VS, but it hasn't appeared yet, although there may have been one step I didn't complete. By the fact it shows I have no submissions, I'm guessing I missed a step, but I'll wait a while and maybe it will appear.


这篇关于这种调试行为是否引起关注(如果是这样,需要注意什么)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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