Jonathan Wakely <jwak...@redhat.com> writes: > One part of the patch I wasn't sure about was this, where 'mgr' is a > function pointer: > > func = gdb.block_for_pc(int(mgr.cast(gdb.lookup_type('intptr_t')))) > > Is there a better way to get a pc from the function pointer? > I tried simply int(mgr) but it didn't work.
Well, long() WFM; e.g. with Python 2 and gdb 7.8.50.20140706-cvs I can do: (gdb) python print(long(gdb.parse_and_eval("(void(*)())-1"))) 4294967295 The fact that int() does not work the same way may indicate a shortcoming in gdb.Value.__int__(); I'm told that in recent 2.x versions, int() is perfectly happy returning a long instead of an int. Of course, this still presumably won't work on architectures where function pointers don't point straight to the code, e.g. most PowerPC, where as I understand things it actually points at a "function descriptor", which in turn references the actual code. So it seems we're missing an API for this. -- Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!