Introduction
Ok, so you're stuck with VC++ 6.0 (can't upgrade to .NET) but you need that nifty __FUNCTION__
macro for your debug sessions or, as in my case for debug session logging, and you Googled for it all over the world (including China) to get such ambiguous answers as "I'm a 100% sure that VC++ 6.0 implements it" and "get .NET you @$$#ole!". So you're outdated, sour and two steps shy of self-suicide (what an oxymoron).
Enter The Code Project (where you should have looked in the first place) to find that there's a whole world of portable executable image help APIs and symbols and processes and threads you really never cared about before, and... oh well.
There's also a whole debug section on CodeProject I didn't know about. Now get to Zoltan Csizmadia's article in which he implements the Extended Trace functions. My version is a downsized one from that of Csizmadia's, in which I only retrieve function names (to the point of omitting class names and arguments) to produce the kind of output shown in the figure. Granted, the code looks like overkill to achieve what .NET (VC++ 7.0 to my understanding) does intrinsically, but it works for me, and I bet you something not too worthy that intrinsically means going through a similar image-symbol-scanning process. In any case, I learned a lot about PEs, the Image Help API, debugging and a lot of stuff I wasn't really looking for, and ultimately, I got away with what I wanted to do.
To learn about all that stuff, get to the debug section of The Code Project, for I will not go into it in this article. The code is almost self-explanatory and fairly commented; just add the two files (header and CPP) to your project, add the #include
directives at the proper places, and call InitSymInfo()
upon start, and KillSymInfo()
before exiting; use the __FUNCTION__
macro anywhere in your code; it returns a (temp) LPCTSTR
you can use as you like.
Zoltan's version does retrieve the full function prototype, its arguments and their values; if you need all that or just want to check it out, click here.
Thank Zoltan and enjoy!