Solved

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

Posted on 2004-08-06
4
1,162 Views
Last Modified: 2013-12-14
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?


0
Comment
Question by:__Sarge
  • 2
  • 2
4 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 11737813
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()");
 
    //...
}
0
 

Author Comment

by:__Sarge
ID: 11742125
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?

0
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 11747792
You could 'customize' the way the profiler works by using '_penter()' on your own. See http://johnpanzer.com/aci_cuj/ ("Automatic Code Instrumentation") on that issue.
0
 

Author Comment

by:__Sarge
ID: 11786129
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.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question