Visual Studio 2008调试器错误指令执行位置(Qt4,XML) [英] Visual Studio 2008 debugger wrong instruction executed position (Qt4, XML)

查看:195
本文介绍了Visual Studio 2008调试器错误指令执行位置(Qt4,XML)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码,调试器,在进入时,开始停止在{大括号突然跳回一个空白行,显然是做一些事情(变量更改),但位置是不同的有一些奇怪的偏移,跳过空白行),显然我看不到任何变量的内容。



一些事实: / p>


  • 我在DEBUG上编译

  • 失败的代码位于更多的代码中, 。

  • 代码无法正常工作,但我已经双重选中,它应该。

  • 调试器在那里保持疯狂,然后在调用函数中退出函数,并且

  • 此代码使用 Qt 4.7 QDomDocument 功能,但在其他部分代码。我将它添加到预编译头。 (QXML)



我尝试过这些错误:




  • 用手或视觉清洁溶液

  • 清洁所有相关的Qt文件(moc)。删除它们,重新编译,再次添加。

  • 已将此函数更改为类的其他部分。

  • 已将此代码更改为其他部分

  • 已删除的文件,从文件夹中删除,编译,再次添加并包含MOC。



注释代码使其工作完美。



以下是诅咒代码:

 (...载入档案,检查是否有效)

//将文件分配给dom文档
QDomDocument doc(XML);
if(!doc.setContent(file)){
file-> close();
return;
}

//根元素(对象)
QDomElement root = doc.documentElement();

QDomElement elt;
QDomElement elt2;
QDomElement elt3;

// NAME
elt = root.firstChildElement(name); // - 工作和调试ok
if(!elt.isNull())
obj-> setNameInfo(elt.text());

// TYPE
elt = root.firstChildElement(type); // - 工作和调试ok
if(!elt.isNull())
obj-> setTypeInfo(elt.text());

// REF NUMBER
elt = root.firstChildElement(ref); // - 工作和调试ok
if(!elt.isNull())
obj-> setRefNumberInfo(elt.text());

// COLLECTION< collection>< english>文字< / english> ...

elt = root.firstChildElement(collection); // - 工作和调试ok
if(!elt.isNull())
{
elt2 = elt.firstChildElement(english);
if(!elt2.isNull())
obj-> setCollectionInfo(elt2.text());
}

// BRAND< mainBrand>< id> id< / id>< web> url< / web>< / brand>

elt = root.firstChildElement(mainBrand); // - 工作和调试ok
if(!elt.isNull())
{
elt2 = elt.firstChildElement(id);
if(!elt2.isNull())
obj-> setMainBrandIdInfo(elt2.text());

elt2 = elt.firstChildElement(web);
if(!elt2.isNull())
obj-> setMainBrandUrlInfo(elt2.text());
}


// BRAND LIST< brands>< brand>< id> 2< / id>< url> google< / url> brand> ...< / brands>

elt = root.firstChildElement(trademarks);
{
QDomNodeList brands = elt.childNodes(); //此后,开始行动
if(!brands.isEmpty())
{
elt2 = brands.at(0).toElement();
for(;!elt2.isNull(); elt2 = elt2.nextSiblingElement())
{
QString id =;
elt3 = elt2.firstChildElement(id);
if(!elt3.isNull())
id = elt3.text();

QString url =;
elt3 = elt2.firstChildElement(url);
if(!elt3.isNull())
url = elt3.text();

obj-> addBrandInfo(id,url);
}
}
}

//描述//这是完全执行,但调试程序仍然停留在
elt = root.firstChildElement(description );
if(!elt.isNull())
{
elt2 = elt.firstChildElement(english);
if(!elt2.isNull())
obj-> setDescriptionInfo(elt2.text());
}

...更多在这里。


解决方案

p>我在长时间的试用后发现了答案:



读取代码的分解,我们检测到Comment行生成的代码,行不在正确的地方,等等。



问题出在换行符的编码。文件的编码不是WINDOWS编码。我们有这样设置,因为我们使用MAC配置,我们有一些关于换行符样式的错误消息。我们选择一个编码,从那以后没有失败,但现在这个错误出现了。



解决方案是保存为...文件,选择其他选项为保存,并选择更改编码到Windows或您要使用的任何编码。


I have some part of code with which the debugger , when entering , starts stopping in lines with { braces.. suddenly jumps back to a blank line, and apparently is doing something (variables change), but the positions are different (there is some kind of weird offset back, skipping blank lines) and obviously i cannot see the contents of any variable.

Some facts:

  • I'm compiling on DEBUG
  • The code that fails falls inside more code which executes perfectly before.
  • The code does not work properly, but i double checked and it should. They are just 10 lines of code, exactly the same lines that the ones before, just changing variables names.
  • The debugguer stays crazy there, then out of the function in the caller function, and then returns to a normal state in the third parent function.
  • This code uses Qt 4.7 and QDomDocument functionality but works perfectly on other parts of the code. I added it to precompiled headers. (QXML)

I tried these with same errors:

  • Cleaning solution by hand or by visual
  • Cleaning all related Qt files (moc). Removed them, recompile, add again.
  • Changed the function to other part of the class.
  • Changed that piece of code to other part of the function.
  • Deleted file, removed from folder, compile, add it again and include the MOC.
  • Checked other threads. It is on the good thread.

Commenting the code makes it work perfect.

Here's the cursed code:

(...loaded file, check if worked)

// Assign file to dom document
  QDomDocument doc("XML");
  if (!doc.setContent(file))  {
    file->close();
    return;
  }

  // Root element (object)
  QDomElement root = doc.documentElement();

  QDomElement elt;
  QDomElement elt2;
  QDomElement elt3;

  // NAME
  elt = root.firstChildElement("name");  //-- works and debugs ok
  if (!elt.isNull())
    obj->setNameInfo(elt.text());

  // TYPE
  elt = root.firstChildElement("type"); //-- works and debugs ok
  if (!elt.isNull())
    obj->setTypeInfo(elt.text());

  // REF NUMBER
  elt = root.firstChildElement("ref"); //-- works and debugs ok
  if (!elt.isNull())
    obj->setRefNumberInfo( elt.text() );

  // COLLECTION <collection><english>Text</english>...

  elt = root.firstChildElement("collection"); //-- works and debugs ok
  if (!elt.isNull())
  {
    elt2 = elt.firstChildElement("english");
    if (!elt2.isNull())
      obj->setCollectionInfo( elt2.text() );
  }

  // BRAND <mainBrand><id>id</id><web>url</web></brand>

  elt = root.firstChildElement("mainBrand"); //-- works and debugs ok
  if (!elt.isNull())
  {
    elt2 = elt.firstChildElement("id");
    if (!elt2.isNull())
      obj->setMainBrandIdInfo(elt2.text());

    elt2 = elt.firstChildElement("web");
    if (!elt2.isNull())
      obj->setMainBrandUrlInfo(elt2.text());
  }


  // BRAND LIST   <brands><brand><id>2</id><url>google</url></brand>...</brands>

  elt = root.firstChildElement("brands");  
  {
    QDomNodeList brands = elt.childNodes();  // AFTER THIS LINE, STARTS GOING WEIRD
    if ( ! brands.isEmpty() )                
    {
      elt2 = brands.at(0).toElement();
      for ( ; !elt2.isNull(); elt2 = elt2.nextSiblingElement() ) 
      {
        QString id= "";
        elt3 = elt2.firstChildElement("id");
        if (!elt3.isNull()) 
          id = elt3.text();

        QString url= "";
        elt3 = elt2.firstChildElement("url");
        if (!elt3.isNull()) 
          url = elt3.text();

        obj->addBrandInfo(id, url);
      }
    }
  }

  // DESCRIPTION   // THIS IS EXECUTED PERFECTLY BUT DEBUGGER IS STILL JUMPING AROUND
  elt = root.firstChildElement("description"); 
  if (!elt.isNull())
  {
    elt2 = elt.firstChildElement("english");
    if (!elt2.isNull())
      obj->setDescriptionInfo( elt2.text() );
  }

  ... MORE CODE HERE. UNTIL THE END THE DEBUGGER WORKS WITH SOME WEIRD OFSET... 

解决方案

I discovered the answer after long hours of trials:

Reading the dissasembling of the code, we detected that Comment lines generated code, lines were not in the correct place, etcetera.

The problem comes with the encoding of the line breaks. The encoding of the file was not WINDOWS encoding. We had this set like this because we worked with MAC configurations, and we had some error messages concerning line breaks style. We choose one encoding that didn't fail since then, but now this error appeared.

The solution is to Save As... the file, selecting other options for the saving, and choose change encoding to Windows or whatever encoding you want to use.

这篇关于Visual Studio 2008调试器错误指令执行位置(Qt4,XML)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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