Search code examples
c++visual-studio-2010debuggingbreakpoints

Break when value encountered


Okay, I'm going out on a limb here, because I'm not sure this functionality exists, but if it doesn't, it probably should. Here's what I know:

Somewhere in the code, a chunk of data is read in. I'm trying to find that part of the code. (And we're talking a HUGE code-base here - tens of thousands of files in almost 300 projects. Couldn't even begin to guess at lines of code - 2000-3000 per file is not uncommon, so this is real needle/haystack territory.) I know that this data contains a specific identifiable string. I'd like to be able to set a breakpoint for when any chunk of memory is set to that string.

What I don't know:

I have no idea where or even if this string is being stored anywhere, so I can't set a breakpoint on a memory address or a variable. All I know is that for at least a brief period of time (perhaps no more than the scope of one function, or even just one iteration of a for loop), this value exists somewhere. It's possible the string itself is ignored by the code and only the accompanying data is stored, but the string must exist in memory at some point.

I obviously can't set a regular breakpoint, because if I knew where to put that breakpoint, I'd already have what I need and there'd be no need to resort to such measures. I don't even know what project this code occurs in, let alone what file or what function within that file - that's what I'm trying to figure out.

Is this just wishful thinking? Or is there some easy way to do this kind of thing?


Solution

  • Use Process Monitor from Microsoft (was SysInternals) to monitor file I/O. If you have symbols configured correctly (yours and Microsoft's) then Process Monitor will display the stack traces associated with each file I/O operation.