www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ide - VisualD - how to view runtime type of class in debbuger?

reply "Michal Minich" <michal.minich gmail.com> writes:
Please consider code

class C { int c = 1; }
class D : C { int d = 2; }

int main() {
   C c = new D();
   return c.d;
}

when paused in debugger on the return statement the locals 
windows shows variable c as of type C. Only way to be able to 
view data of D instance was when I used Mango engine and used 
locals "cast(main.D)c"

This has following issues:
  - only supported in Mango
  - one must know the runtime type of variable, it is not 
displayed by debugger
  - it must be manually written into watches window

Is there a way
  - to achieve the same (or better) effect using Visual Studio 
debugger
  - possibility to display runtime type (without putting manually 
some string variable with type name into every class)

Thank you.
Jun 04 2015
parent Rainer Schuetze <r.sagitario gmx.de> writes:
On 04.06.2015 14:36, Michal Minich wrote:
 Please consider code

 class C { int c = 1; }
 class D : C { int d = 2; }

 int main() {
    C c = new D();
    return c.d;
 }

 when paused in debugger on the return statement the locals windows shows
 variable c as of type C. Only way to be able to view data of D instance
 was when I used Mango engine and used locals "cast(main.D)c"

 This has following issues:
   - only supported in Mango
   - one must know the runtime type of variable, it is not displayed by
 debugger
   - it must be manually written into watches window

 Is there a way
   - to achieve the same (or better) effect using Visual Studio debugger
   - possibility to display runtime type (without putting manually some
 string variable with type name into every class)

 Thank you.
The D debug engine is called mago BTW. If you use VS2010 (or earlier) or enable the same debug engine in VS2012 or later (by enabling "*native* Edit and Continue" in the global debuggerr options), the visualizer support for the Visual Studio debug engine shows the actual runtime class in the preview. You can also view it as a C++ watch "(main D*)c" similar to mago. Inspecting the runtime class members as part of the "c" instance similar to C++ is something I also like to have, but it will only be possible to implement in mago.
Jun 04 2015