一千萬個為什麽

搜索

關於VS2010 C ++中斷點的問題


我正在使用VS2010 Ultimate。 有代碼:

//file IntSet.h
#include "stdafx.h"
#pragma once
/*Class representing set of integers*/
template
class IntSet
{
private:
 T** myData_;
 std::size_t mySize_;
 std::size_t myIndex_;
public:
#pragma region ctor/dtor
 explicit IntSet();
 virtual ~IntSet();
#pragma endregion
#pragma region publicInterface
 IntSet makeUnion(const IntSet&)const;
 IntSet makeIntersection(const IntSet&)const;
 IntSet makeSymmetricDifference(const IntSet&)const;
 void insert(const T&);

#pragma endregion
};

//file IntSet_impl.h
#include "StdAfx.h"
#include "IntSet.h"

#pragma region ctor/dtor
template
IntSet::IntSet():myData_(nullptr),
     mySize_(0),
     myIndex_(0)
{
}

template
IntSet::~IntSet()
{
}
#pragma endregion

#pragma region publicInterface
template
void IntSet::insert(const T& obj)
{//BREAKPOINT---------------------------<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
/*IF I SET A BREAKPOINT HERE AND AFTER THAT I CHANGE SOMETHING IN THE BODY 
    I'M GETTING MSG SAYING THAT THE BREAKPOINT WILL NOT CURRENTLY BE HIT, AFTER I REBUILD 
    THE BREAKPOINT IS VALID AGAIN*/

 /*Check if we are initialized*/
 if (mySize_ == 0)
 {
  mySize_ = 1;
  myData_ = new T*[mySize_];
 }
 /*Check if we have place to insert obj in.*/
 if (myIndex_ < mySize_)
 {
  myData_[myIndex_++] = new T(obj);
  return;
 }

 /*We didn't have enough place...*/
 T** tmp = new T*[mySize_];//for copying old to temporary basket
 std::copy(&myData_[0],&myData_[mySize_],&tmp[0]);
 delete myData_;
 auto oldSize = mySize_;
 mySize_ *= 2;
 myData_ = new T*[mySize_];
 std::copy(&tmp[0],&tmp[oldSize],&myData_[0]);
 myData_[myIndex_] = new T(obj);
 ++myIndex_;
}
#pragma endregion

請參閱標記為BREAKPOINT的linke。 謝謝。

最佳答案

如果在程序運行時更改代碼,則代碼不再與編譯的代碼匹配,因此調試器(通常)無法管理斷點,直到程序停止並使用新源重建。

在某些情況下,Visual Studio支持編輯並繼續調試,您可以在調試器在斷點處停止時編輯文件,然後在恢復時將重新編譯該代碼並使用修改後的代碼繼續。

轉載註明原文: 關於VS2010 C ++中斷點的問題

猜你喜歡