Link to home
Start Free TrialLog in
Avatar of __Sarge
__Sarge

asked on

How to trace all function calls (including private functions) made in ATL COM DLL?

I have source code for an existing ATL COM DLL compiled in VC++ 6.0. I have made a test application in VB 6.0 that invokes one of the exposed function of the DLL. I need to generate a trace log of all the function calls made by the DLL to complete its operation. The DLL also has a number of private classes that are used during the execution of the invoked function.

e.g. The test client invokes f1().

f1()--> CTest1.f2()-->CTest1.f3()
     --> CTest2.f3()
     --> CTest3.f4()-->CTest1.f5()
     --> return

In short, i would like to save my entire call stack, so that i can determine the exact flow of execution inside the DLL.

Can anybody give any ideas on how to achieve this?


Avatar of jkr
jkr
Flag of Germany image

The easienst way - get yourself the latest version of one of the most powerful tools from www.dependencywalker.exe and use it's tracing feature. Alternatively, you could use the VC6 profiler (http://msdn.microsoft.com/library/en-us/vccore98/html/_core_profiling_from_the_development_environment.asp). Or, use a trace helper class

class trace {
public:
    trace ( char* pszName) : m_pszName ( pszName) { cout << "BEGIN: " << m_pszName << endl;}
    ~trace () { cout << "END: " << m_pszName << endl;}
protected:
    char* m_pszName;
};

and use it in each function like

void CTest::f1() {

    trace t ( "CTest::f1()");
 
    //...
}
Avatar of __Sarge
__Sarge

ASKER

Thanks for your comments.

I am only interested in getting a the sequence of execution of user defined functions. DependencyWalker does not give me this information.

I had contemplated using trace macro/helper class but the number of functions present in the private classes of the existing DLL is too large. It would be very time consuming to insert a trace call inside each function.

VC++6 profiler comes quite close to fulfill my requirement. It provides hit count, func time etc for each executed function but i could not find any option of PLIST to sort this in order of execution. Sorting this output by func time or alphabetically is possible but does not help me. The option /AT for PREP is not generating the complete output. Either the profiler crashes or just does not dump the complete results.

Am i missing some switch for PREP or PLIST that can give the desired output?

Is there any other profiler that can help me get the execution flow of the user defined functions of private classes inside the DLL?

ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of __Sarge

ASKER

Thanks, jkr.

I also came across that particular link, but compiling the code with /Gh option, makes me trace all function calls (including standard library functions.) This takes a lot of time to generate the log for completion of one sequence. I am still looking for more efficient and cleaner way.

I appreciate all your help.