代码之家  ›  专栏  ›  技术社区  ›  Aaron

使用windbg的变量值

  •  7
  • Aaron  · 技术社区  · 17 年前

    问题:

    如何显示 价值 A的 C++ 迭代器 使用windbg,图示 以下:

    for (vector<string>::iterator i = args.begin(); i != args.end(); i++)
    //omitted
    //for instance:
    } else if (*i == "-i") {//attempting to display the value of *i
            ++i;
            if (!::PathFileExistsA(i->c_str()))
            {
    

    注:

    使用 ?? 评估C++表达式命令,显示以下内容:

    0:000> ?? i
    
    class std::_Vector_iterator<std::basic_string<char,
    std::char_traits<char>,
    std::allocator<char> >,
    std::allocator<std::basic_string<char,
    std::char_traits<char>,
    std::allocator<char> > > >
    
       +0x000 _Mycont          : 0x0012ff40 std::_Container_base_secure
       +0x004 _Mynextiter      : (null) 
       +0x008 _Myptr           : 0x009c6198 
    
    std::basic_string<char,std::char_traits<char>,std::allocator<char> >
    
    • 可以另一个命令吗 显示/打印 价值 *i -如果我错了请纠正我
    2 回复  |  直到 17 年前
        1
  •  9
  •   i_am_jorf    17 年前

    尝试:

    dt -r i
    

    它将递归地转储迭代器。其中一个成员应该是您所寻求的信息。冗长,但有效。

        2
  •  1
  •   Salman A    17 年前

    困难在于 *i 调用函数调用 operator* 在迭代器上。您想要的字符串可能被指向 _Myptr 0x009c6198 .