Gold mine of Visual C++ tricks!
Watch heap objects eventhough the symbol went out of scope.
![]()
While debugging we want to watch some objects through out. An object can be watched only with its symbol and it should be valid in the current stack frame. For instance,
CJobManager* CJobManager::GetJobManager
{
return m_pJobManager;
}
For watching the JobManager instance, we need the symbol m_JobManager in this stack frame. When the function leaves, we can’t see the JobManager instance anymore. So how can i watch these heap objects without the symbol in stack frame?
![]()
1) Get the address of your heap object. Just add to watch window and get the location. For instance assume its 0×00034de0.
2) Now add a new entry to the watch window like this – (CJobManager*)(0×00034de0)
3) Now eventhough your function returns and you loss the symbol, still you can see your heap object.
Really helpful isn’t it? i was fed up with the global objects in my project and atlast find this method to watch them premenently.
| Print article | This entry was posted by Jijo Raj on March 25, 2008 at 4:21 am, and is filed under Codeproject, Debugging Tips. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 10 months ago
But if the type information went out of scope (in fact if it’ has been overwritten by a forward declaration like “class myclass;” ) it won’t work. Still looking for the solution to that.