Yes, it is technically possible. There is not much joy, mind you have to tell the debugger to dereference the pointer to get the value of a local variable in another frame of the stack.
A simple example:
#include "stdafx.h" #include <iostream> void foo() { for (int ix = 0; ix < 5; ++ix) { std::cout << ix << " "; // <=== Conditional breakpoint here } } void bar() { for (int jx = 0; jx < 5; ++jx) { std::cout << jx << ": "; // <=== Start with a breakpoint here foo(); std::cout << std::endl; } } int _tmain(int argc, _TCHAR* argv[]) { bar(); return 0; }
First you need to get the address of the variable on which you want to set the condition. Set a breakpoint in the display line in line (). When it hits, evaluate &jx and copy the value.
Now set a conditional breakpoint using this value. I used:
*(int*)0x0073fbc8 == 2 && ix == 3
Where 0x0073fbc8 is the value of I obtained at the first breakpoint. Or you can make it relative from the base pointer register. Set an unconditional breakpoint, and when it hits, use the Debug + Windows + registers to view the EBP value. Subtract it from & jx. I used:
*(int*)(ebp+0xd8) == 2 && ix == 3
Both worked well. Note that you will want to disable ASLR for Debug builds to hope that these addresses will repeat from one run to another. Project + Properties, Linker, Advanced, Randomized Base Address = No.
source share