VC++ debugger, mouse-over variable inspection question
-
When stopped in the debugger (Visual C++ 2005, native Win32/MFC code), you can mouse over variables and the debugger shows a nice tooltip. For some classes it also shows the member variables and values in that tooltip. For our MFC CObject-derived classes, all we get is the class name; it refuses to show the variables. We can use the + button to expand it and see the variables, but it would be nice to get them right in the tooltip. Any idea what controls this? === For example:
class BaseClass
{
protected:
double i;
double j;
double k;
public:
BaseClass() { i = j = k = 0.57722; }
virtual ~BaseClass() {}
};class MyClass : public BaseClass
{
protected:
double x;
double y;
double z;
public:
MyClass() { x = y = z = 3.14159; }
virtual ~MyClass() {}
};void SomeFunction()
{
MyClass someVar;int x = 0; // set breakpoint here and stop in the debugger and mouse-over someVar
}For the above example, when you're stopped in the debugger and you mouse-over someVar, you can see the below in the tool-tip.
someVar = {x=3.1415899999999999 y=3.1415899999999999 z=3.1415899999999999 }
Now, if you modify the code slightly by deriving from CObject, it seems to break this. If you change it to the below:
class MyClass : public CObject
{
protected:
double x;
double y;
double z;
public:
MyClass() { x = y = z = 3.14159; }
virtual ~MyClass() {}
};void SomeFunction()
{
MyClass someVar;int x = 0; // set breakpoint here and stop in the debugger and mouse-over someVar
}Now when you stop in the debugger and mouse-over someVar, you instead see the below.
someVar = {MyClass}
So for some reason, when deriving from CObject, we've now lost the mouse-over tooltip info! Does anyone know what's going on? How can we get that back?
-
When stopped in the debugger (Visual C++ 2005, native Win32/MFC code), you can mouse over variables and the debugger shows a nice tooltip. For some classes it also shows the member variables and values in that tooltip. For our MFC CObject-derived classes, all we get is the class name; it refuses to show the variables. We can use the + button to expand it and see the variables, but it would be nice to get them right in the tooltip. Any idea what controls this? === For example:
class BaseClass
{
protected:
double i;
double j;
double k;
public:
BaseClass() { i = j = k = 0.57722; }
virtual ~BaseClass() {}
};class MyClass : public BaseClass
{
protected:
double x;
double y;
double z;
public:
MyClass() { x = y = z = 3.14159; }
virtual ~MyClass() {}
};void SomeFunction()
{
MyClass someVar;int x = 0; // set breakpoint here and stop in the debugger and mouse-over someVar
}For the above example, when you're stopped in the debugger and you mouse-over someVar, you can see the below in the tool-tip.
someVar = {x=3.1415899999999999 y=3.1415899999999999 z=3.1415899999999999 }
Now, if you modify the code slightly by deriving from CObject, it seems to break this. If you change it to the below:
class MyClass : public CObject
{
protected:
double x;
double y;
double z;
public:
MyClass() { x = y = z = 3.14159; }
virtual ~MyClass() {}
};void SomeFunction()
{
MyClass someVar;int x = 0; // set breakpoint here and stop in the debugger and mouse-over someVar
}Now when you stop in the debugger and mouse-over someVar, you instead see the below.
someVar = {MyClass}
So for some reason, when deriving from CObject, we've now lost the mouse-over tooltip info! Does anyone know what's going on? How can we get that back?
I found a solution to this. I discovered the name of the feature described is the DataTip. Once I had this a modified google search yielded the below article. http://www.zanshu.com/ebook/149\_debugging\_applications/html/ch05d.htm The summary is that there's a config file in the VC++ install directory which controls the auto-expansion in the DataTip. For Visual C++ 2005, the file is at the below path. C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\Packages\Debugger\autoexp.dat The comments in the file explain how to add your own types. For the above example, I added the below line and it then worked. MyClass =x= y= z= So its a matter of customizing this file with your types and then keeping track of the customizations for new machines or re-installs of VS. I'm still not sure why it does it automatically when you don't derive from CObject but fails when you derive from CObject. One guess is that the base class adds in too many variables? The problem with that guess is that in my example I included a base class with variables (i,j,k) and those didn't show up in the tip, so I don't understand why the base class matters.
-
I found a solution to this. I discovered the name of the feature described is the DataTip. Once I had this a modified google search yielded the below article. http://www.zanshu.com/ebook/149\_debugging\_applications/html/ch05d.htm The summary is that there's a config file in the VC++ install directory which controls the auto-expansion in the DataTip. For Visual C++ 2005, the file is at the below path. C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\Packages\Debugger\autoexp.dat The comments in the file explain how to add your own types. For the above example, I added the below line and it then worked. MyClass =x= y= z= So its a matter of customizing this file with your types and then keeping track of the customizations for new machines or re-installs of VS. I'm still not sure why it does it automatically when you don't derive from CObject but fails when you derive from CObject. One guess is that the base class adds in too many variables? The problem with that guess is that in my example I included a base class with variables (i,j,k) and those didn't show up in the tip, so I don't understand why the base class matters.
Got a good tip from the MSDN forums on this. Just comment out the below line in that file (insert a ; at the beginning of the line, or just delete the line). CObject =<,t> If you do this, it immediately shows the vars for your CObject-derived classes.
-
Got a good tip from the MSDN forums on this. Just comment out the below line in that file (insert a ; at the beginning of the line, or just delete the line). CObject =<,t> If you do this, it immediately shows the vars for your CObject-derived classes.
Thanks for sharing your solution with us. :thumbsup:
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <