|
From: Julian S. <js...@ac...> - 2006-06-06 21:47:54
|
One grotty hack which has been used on more than one occasion is to find the return address, change it to point at some magic piece of code under your control, wait till you get there, do whatever, restore the real address, and continue. It's nasty. Not least because it's platform dependent. Much easier, cleaner and platform independent in the 3.2.0 line is to use function wrapping - just write a wrapper for main and put it in your tool's preload.so file. See wrap[1-8].c for examples; function wrapping is also pretty well documented. Uh .. why do you want to know when main has returned? Point is the returning of main does not mean the program has finished, especially not in a multithreaded environment. J On Tuesday 06 June 2006 20:48, Bryan Meredith wrote: > Dear Valgrinders, > > Is there a simple (read cheap) way to detect when the program has > returned from main()? > > On Suse 10.1 (x86_64) I am having a few issues crop up with omega that I > can easily fix, given a boolean or some such to show when function main > is finished with. I suppose the most useful indication of all would be a > bool that is set only whilst the program is somewhere within main or a > function called from main. > > Failing that, a suggestion of where to add in an appropriate hook would > also be helpful. > > I looked in m_stacktrace.c for clues but string comparison seems a > little expensive for what would be quite a common check. Maybe > integrating the indication with the stack retrieval in some fashion > would do it (first stack request outside of main() sets the flag)? > > Thanks in advance, > Bryan "Brain Murders" Meredith > > > _______________________________________________ > Valgrind-developers mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-developers |