Aaron
Aaron

Reputation: 2863

Value of a variable using WinDbg

Question:

How to display the value of a C++ iterator using WinDbg, illustrated below:

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()))
        {

Note:

Using ?? evaluate C++ expression command, which displays the following:

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> >

Upvotes: 7

Views: 11032

Answers (2)

Eclipse
Eclipse

Reputation: 45493

The difficulty is that *i invokes a function call to operator* on the iterator. The string you want is likely being pointed to by _Myptr at 0x009c6198.

Upvotes: 1

i_am_jorf
i_am_jorf

Reputation: 54600

Try:

dt -r i

Which will recursively dump the iterator. One of the members should be the info you seek. Verbose, but effective.

Upvotes: 9

Related Questions