0

As an example lets say I have a linked list implemented in C. Can I use the GDB python API to implement a custom array access operator so that I can get a value from the list like myList[0] while debugging?

Have tried reading through the docs but could find nothing on it

YupDeDup
  • 41
  • 1
  • 3
  • With the [XMethod API](https://sourceware.org/gdb/onlinedocs/gdb/Xmethod-API.html) this should be possible, but I don't actually know if this would work for C as well (since you can't define `operator[]` in C). – ssbssa Feb 20 '23 at 05:36
  • Thank you! That half works it seems. I can define xmethods, but they don't seem to run for C (I need to set the language to c++ and then they run) – YupDeDup Feb 20 '23 at 09:37
  • @YupDeDup Indeed. The XMethod API is designed to provide C++ operators - often these operators are inlined in compiled code and so not available for GDB to call while debugging. As C has no operator overload feature the XMethods are not applied when debugging C code. – Andrew Feb 20 '23 at 10:51

0 Answers0