?
Solved

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

Posted on 2004-08-06
4
Medium Priority
?
1,166 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 750 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

719 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