Well thank you very much EvilSOB. I now sorta got the macro working.
Sorta, because after the first few wait calls, it always seems to be returning a certain function name - no longer the one which the wait is actually called in.
I suspect this has to do with the wrong behavior of gettaskinfo.
This entirely defeats the purpose of the whole thing, because what I need to do is find out where my text object is overwritten, so I log the name of the current function and the text object's value on every wait call. But if the function name isn't correct, I might as well just not do it.
The only Idea I've had so far is to set a string to a different value after every wait() call (and then log that string), but I'd have to do that manually. Which totally sucks.
Or I'll write a c++ script which does it for me... which might be less horrible, cause I probably have around a thousand functions.