2012-03-02 4 views
0

静的なstd :: forward_listでは、デバッガは1番目の要素のみを表示します。VS2010デバッガは静的なstd :: forward_listで失敗します。

静的ではないstd :: forward_listまたは静的なstd :: listは正常に動作します。

デバッガで使用できる回避策はありますか?

#include "stdafx.h" 
#include <forward_list> 
#include <list> 

int _tmain(int argc, _TCHAR* argv[]) 
{ 
    static std::forward_list<int> sfl; 
    sfl.push_front(1); 
    sfl.push_front(2); 

    std::forward_list<int> fl; 
    fl.push_front(1); 
    fl.push_front(2); 

    static std::list<int> sl; 
    sl.push_front(1); 
    sl.push_front(2); 

    //Break here. 
    //In a debugger watch window: 
    // 'sfl' only shows the '2' element 
    // 'fl' & 'sl' shows all elements. 
    return 0; 
} 

答えて

0

これはVisual Studioのデバッガビジュアライザのバグだと思う。私が作ってみた回避策に最も近いものはautoexp.datforward_listエントリを変更することである(通常は%VSINSTALLDIR%\Common7\Packages\Debugger\で見つかった)

ファイルには、次のセクションを持っている必要があります。

;------------------------------------------------------------------------------ 
; std::forward_list from <forward_list> 
;------------------------------------------------------------------------------ 
std::forward_list<*>{ 
    preview (
     #(
      "(", 
      #list(
       head: $e._Myhead, 
       next: _Next 
      ) : $e._Myval, 
      ")" 
     ) 
    ) 

    children (
     #list(
      head: $e._Myhead, 
      next: _Next 
     ) : $e._Myval 
    ) 
} 


置き換え:

;------------------------------------------------------------------------------ 
; std::forward_list from <forward_list> 
;------------------------------------------------------------------------------ 
std::forward_list<*>{ 
    preview (
     #(
      "(", 
      #(
       $e._Myhead->_Myval, 
       ",", 
       #list(
        head: $e._Myhead->_Next, 
        next: _Next 
       ) : $e._Myval, 
      ), 
      ")" 
     ) 
    ) 

    children (
     #(
      [actual 0]: $e._Myhead->_Myval, 
      #list(
       head: $e._Myhead->_Next, 
       next: _Next 
      ) : $e._Myval 
     ) 
    ) 
} 


これは素晴らしいソリューションではありません。子は[0], [1], [2], ...ではなく[actual 0], [0], [1], ...と表示されます。つまり、要素xには[x-1]というラベルが付けられています。

Visual Studioを終了することなくautoexp.datを変更することはできますが、デバッガを再起動するだけで済みます。ですから、特定の問題をデバッグして元のautoexp.datに戻す必要がある場合に限り、このハックを使用することをおすすめします。

関連する問題