Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Value of a variable using WinDbg

Tags:

c++

winapi

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> >
  • Can another command display/print the value of *i - please correct me if I'm wrong
like image 330
Aaron Avatar asked Apr 16 '09 20:04

Aaron


People also ask

How do you use WinDbg?

Launch Notepad and attach WinDbg In the Open Executable dialog box, navigate to the folder that contains notepad.exe (typically, C:\Windows\System32). For File name, enter notepad.exe. Select Open. The symbol search path tells WinDbg where to look for symbol (PDB) files.

Is WinDbg debugging tool?

The Windows Debugger (WinDbg) can be used to debug kernel-mode and user-mode code, analyze crash dumps, and examine the CPU registers while the code executes. To get started with Windows debugging, see Getting Started with Windows Debugging.

How do you break in a WinDbg?

When you are performing remote debugging with WinDbg, you can press the Break key on the host computer's keyboard. If you want to issue a break from the target computer's keyboard, use CTRL+C on an x86-based computer.


1 Answers

Try:

dt -r i

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

like image 159
i_am_jorf Avatar answered Oct 02 '22 14:10

i_am_jorf