O'Reilly logo

Windows Debugging Notebook: Essential User Space WinDbg Commands by Dmitry Vostokov, Roberto Alexis Farah

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

wt

According to WinDbg documentation this command runs through the whole function and then displays statistics when we execute it at the beginning of a function call. Thus, this command can be used only when doing live debugging, not a postmortem debugging (memory dump analysis). Its mnemonic is easy to remember: watch and trace.

To demonstrate this command let's use this simple Visual C++ application that recursively calculates a Fibonacci number:

#include "stdafx.h"

using namespace std;

// Recursive function.
unsigned FiboRecursive(unsigned n, int nNum = 0)
{
    if(n <= 1)
    {
        return n;
    }

    return FiboRecursive(n - 1, 1) + FiboRecursive(n - 2, 2);
}

int _tmain(int argc, _TCHAR* argv[])
{
    cout << FiboRecursive(5) << endl;
    return 0;
}

(AA) .cls     Clears ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required