views:

457

answers:

8

Hello,

I am going through the process of trying to figure out how a library of code works. I would like some sort of tool that would analyze the program that I run off of the library and tells me what functions are called in what order by each thread. Does such a tool exist? What google terms would I use to find such a program?

Note: Using VS2008/Win7/C++

+1  A: 

What you are looking for is a profiler. On a Linux system I would say 'gprof', but I can't really name the tool of choice for MSVC.

DevSolar
+6  A: 

A profiler or code coverage tool will tell you this.

codeelegance
Funny how your answer beats mine by a significant number of upvotes. I start to think it's a bad thing to state what you *don't* know. ;-)
DevSolar
Hard to say. You posted only a few seconds before me but my answer mentioned more than one solution to the question.
codeelegance
+6  A: 

I think a call graph may help you. Most profilers can generate a call graph after profiling. Profiling can also help you identified what code is being used most often.

Another possibility is using a tool to generate sequence diagrams. This won't show you specifically what happened during runtime, but it will give a clear idea what the code is doing.

Regards Dirk

dirk
A call graph is what I was looking for. Conclusion information in an answer below.
VSC
+4  A: 

You are searching for a profiler. This StackOverflow thread will help you to find one.

Patrice Bernassola
+1. Absolutely the best answer.
DevSolar
+1  A: 

WinAPIOverride32 tool, it may be useful for your need.

lsalamon
A: 

You can check out this this thread and this link

da_m_n
+2  A: 

In linux, I would suggest ltrace which does exactly what you describe. I googled "ltrace for windows" and found dumbug. This promises to be "ltrace for windows".

stefaanv
A: 

The solution I ended up using is John Panzer's Call Moniter class. This code runs with my program and outputs the functions with their full names(including class), when there are called, and when they are finished, using indentation to show how deep the function is embedded in other functions. It took a little modification to get rid of excess data, but it works beautifully. I will probably modify it to output to excel instead of outputting to the console as called.

Thanks all for your answers. Looking at all the results, none of them quite did the job, but it helped give me an idea of what was going on.

Some of the suggested answers might have worked, but they were all over my head or I could not get them operational or I could not find the functionality I was looking for.

EDIT: The Call Moniter class ended up being another false trail. It showed functions names as they were called, in the order they were called, and nested them to show which functions called which, and that was great. I had to filter out some noise, which was fine. But at the end, when I looked at the results, this class missed a full half of all the functions that were called! Oh, and I dont know if it would work with threads properly, as the functions that called threads were some of those that were skipped over.

From what I understand, what I wanted was a call graph.

VSC
@VSC - Clean up your answer a bit then mark it as answered. By clean up I mean make textual reference to the page, not just a link. Links can go stale, but with enough info the next user can still search for it or something similar. E.g [John Panzer. "Automatic Code Instrumentation" C/C++ Users Journal, January 1999]. Mark questions as answered, even when you answer them yourself, that way people looking to help others don't go trawling through answered questions, and people looking for answers know where to look too.
Andre Artus
Thanks Andre for your help.
VSC