[Vala] Can't debug instance members easily



Suppose I have the following class that I want to debug with gdb:

class Example {
    private int foo;
    private int bar;

    const string[] colors = {"red", "green", "blue"};

    public Example() {
        foo = 9;
        bar = 18;
    }

    public int add_myself() {
        int result = 0;

        result = foo + bar;
        return result;
    }
}

void main (string[] args) {
    var thing = new Example();
    thing.add_myself();
}

I compile with vala -g test.vala.

While debugging, I set a breakpoint at the line "return result" in public int 
add_myself(). Now, if I run "print foo" in
gdb, gdb says "No symbol foo in current context". Remembering that vala produces 
C sources, I type
"print self->priv->foo", and I get "9"; the right value prints. However, this 
isn't really what I expect, compared
to similar experiences debugging C++ source, where I can actually print my data 
members without jumping
through an extra hoop.

Similarly, I can't run "print colors" in gdb, and I haven't actually figured out 
a way to do so. I figure
because its name is mangled during compilation.

Is this something that is planned to be addressed? Will I be able to debug vala 
code using "predictable" names
or is the intent to always have to reference the C code when debugging? If the 
latter is the case, then what
is the purpose of having the gdb line annotations for vala source? Since I'd 
need to see the C code anyway,
I might as well set breakpoints in the produced source.

I think walking though a vala debugging session (printing variables, getting the 
ptype for members variables and
member functions) would be a useful addition to the vala documentation on 
gnome.org.


      



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]