Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Get variable type based on RTTI with gdb HEAD and Eclipse bug #376901

Hi,

On HEAD gdb has a nice feature that might be useful for C++ developers. It can provide a variable type based on RTTI via MI interface (gdb can do it via CLI for many years, but this information ). This feature is turned on with a "set print object on" CLI command (it could be added to .gdbinit). Consider the following example:

    struct SuperInterface {
        virtual ~SuperInterface() {}  // enable RTTI for SuperInterface
    };
   
    struct TheImplementation : public SuperInterface {
        TheImplementation(int _v1, float _v2)
            : someField(_v1), anotherField(_v2) {}
   
        int someField;
        float anotherField;
    };
   
   
    int main() {
        SuperInterface* i = new TheImplementation(42, 4.2);
        return 0;     // [Run until here]
    }

Here is the screenshot how it looks in Eclipse (upper - how it looks with gdb7.4 and will look with gdb7.5 with "set print object off"; lower - with "set print object on" on gdb HEAD):



I am writing this because I think it is a nice feature and because there is a small bug in Eclipse with variables type update. I have filed it (https://bugs.eclipse.org/bugs/show_bug.cgi?id=376901) and I have provided a patch. Now I am asking the committers about the review.


P.S. I didn't want to be annoying. Sorry if this information was not useful for you.

Thanks,
Anton.


Back to the top