Solved

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

Posted on 2004-08-06
4
1,165 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
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…

631 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