gdb-tools icon indicating copy to clipboard operation
gdb-tools copied to clipboard

unable to call functions

Open marksilverman opened this issue 4 years ago • 2 comments

I'm very excited about duel (I remember using the non-python version back in the 90's). I wonder if it's possible to call functions the same way that the print command does. Currently: (gdb) dl head-->next->getKey() Value is not callable (not TYPE_CODE_FUNC). (gdb) p head->next->getKey() $68 = "foobar" At my company we often have containers filled with pointers to a base classes. I'd like to call a virtual function to get more info about the object. I could do it in two steps (get the address in duel and call the function manually) but that won't work in a loop. Thanks!

marksilverman avatar May 13 '20 23:05 marksilverman

I know. This is one of gdb python API limitations. It can store the "value" (e.g. head->next->getKey a pointer to a member method) in a python variable, but it doesn't allow to call it. Same for internal gdb functions like $_streq. It's reported as https://sourceware.org/bugzilla/show_bug.cgi?id=13326

There's a workaround, to use eval and I believe I'll implement it before gdb is fixed. In our C++ codebase I also often need to traverse a list and call some method

vuvova avatar May 14 '20 11:05 vuvova

Ok, interesting. I hope the workaround doesn't run very slowly.

Another thing I noticed is that the results from duel don't go into gdb's value history (i.e., the special variable '$' or '$1' or '$2', etc). I won't be surprised if that's not possible or easy to fix, but it would be a nice little feature.

Thanks for writing this library, it's really amazing. Some of the advanced constructions are hard to understand, but I'm getting pretty good at it.

marksilverman avatar May 14 '20 22:05 marksilverman