On Sunday 02 March 2003 05:57 pm, Duane Clark wrote:
Just wondering if anyone has written a script or something that does indenting of relay traces. I don't know how other people handle these, but I find that I invariably spend a lot of time indenting the calls in relay trace files to make them easier to follow. It would seem like something that someone would already have an automated method of handling (or maybe I'm the only one that does this).
I've never seen such a thing but it would be really cool if it existed.
The hard, but really, really, really cool thing, I reckon, would be if we were able to "automagically" indent them (presumably this is what you are looking for anyhow). I imagine, if we took a "snapshot" of the stack on each debugmsg, and compared it against the stack the next time a debugmsg was issued, we could do it some, but not all of the time. API's that are just internal "workhorse" API's can just always indent their debugmsg's; I tried this for a while in the rpc code but found it was pretty difficult to maintain that way, and, when it broke, disproportionately confusing to fix.... so I reverted those in a subsequent patch. It is probably dangerous to go crawling around following stack pointers every time a debugmsg is issued, but maybe some careful exception handling code could handle the fallout.
Of course, the performance hit would be disgusting... And compiler inlining would break it... I guess it's probably more trouble than its worth... unless someone knows of a better way? Could API snooping be re-jiggered, somehow, to increment some static, thread-local integer on each call, and decerement it on each return, for example?