×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Nokia Developer Expert
    Join Date
    Oct 2008
    Posts
    12

    How to find the runtime type for a variable

    I want to know how to find the runtime type of a variable in the Variables view. There is an "Actual Type" column in this view, which looks like it should give the right information, but it is always empty. The C++ runtime has the runtime type info available, so carbide should be able to work this out too.

    For example, I am trying to debug the following line deep in the heart of the Symbian active scheduler: TRAP(aError, active->RunL());
    active is derived from CActive and its RunL() has thrown a non-Symbian exception. I need to find the actual type of active so that I can know which active object is doing this.

    For reference, I am working with a recent Nokia internal carbide build, debugging on the winscw emulator.

  2. #2
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: How to find the runtime type for a variable

    Hi,
    can't you find it out via the adress or the contents of the variable?
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  3. #3
    Nokia Developer Expert
    Join Date
    Oct 2008
    Posts
    12

    Re: How to find the runtime type for a variable

    Quote Originally Posted by tamhanna View Post
    Hi,
    can't you find it out via the adress or the contents of the variable?
    The contents of the variable only show those of the declared type, not the derived type.

    The address of the variable does give me some help, eg I could conditionally breakpoint all constructors of the base type (takes a lot of time), or try to extract the vptr from the object (couldn't figure out how to convert that to any symbolic name), or try to force the debugger to call a virtual function in it (I set up all the relevant registers I could see, but couldn't make this work).

    A working implementation of "actual type" would be so much easier.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

    Re: How to find the runtime type for a variable

    You can check if the approach in http://discussion.forum.nokia.com/fo...d.php?t=170712 helps you or not. However an exception will not necessarily have a virtual method table.

  5. #5
    Nokia Developer Expert
    Join Date
    Oct 2008
    Posts
    12

    Re: How to find the runtime type for a variable

    I finally found a method to identify the runtime type for the active object I was trying to debug:

    1) Note the address of the object.
    2) Find a line of code containing a call to a virtual function in that object (RunL in my case).
    3) Tell the debugger to move to that line.
    4) Switch to the disassembly view and locate the exact instruction for the virtual call.
    5) Reverse engineer the previous assembly statements to figure out how the object address is used and converted into a vtable lookup and call.
    6) Click on the first of of those assembly lines, right click and select "move to line" (a mov ecx,edx statement in my case).
    7) Switch to the registers view and modify the appropriate registers to the appropriate values to set up the virtual funciton call (I had to set EDX to my active object's address).
    8) Click on the call line, right click and select "run to line".
    9) Click the "step into function" button, and you should find yourself in a function associated with the active object (in my case, I found myself in another base class, but was able to step further to find the ultimate derived type and identify the bug).

    ta da! Easy as something very hard indeed.

    Note: you will have to figure out what assembly language means.
    Note: your program state is probably invalid now, and will crash very hard very soon.
    Note: I've raised a request to have "actual type" properly supported in the future.

Similar Threads

  1. How to check the type of member variable from a cpp file by pointing the cursor on it
    By julppoupou in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-06-08, 15:35
  2. Error: could not find Java 2 Runtime Environment
    By lindomar in forum Mobile Java General
    Replies: 1
    Last Post: 2005-03-18, 17:59
  3. list box example
    By murmur20 in forum Symbian User Interface
    Replies: 1
    Last Post: 2004-11-09, 04:42
  4. Find ALL files of type X
    By gavin_tranter in forum Symbian
    Replies: 3
    Last Post: 2004-10-21, 09:16
  5. D211 : Compiling the user interface for Linux...?
    By franz_meyer in forum Multimodecards
    Replies: 1
    Last Post: 2002-12-09, 11:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×