Solved

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

Posted on 2004-08-06
4
1,159 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

763 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now