How to list all related functions

Hi, guys,

Do you have any ideas to list al related functions when I run some software

I got the source code and was told that there are no documents about it.

I was asked to do reverse engineering to figure out the logic diagram, to write down full documents for the source code: the design idea, the logic, the executive order and so on.

I used magicdraw to get the class diagram. But there is still a long distance to the final goal.

BTW, the source code can be compiled and built in Visual studio C++ 6.

It runs well.

Thanks for your consideration.

Damon




Answer this question

How to list all related functions

  • Hendro Wijaya

    I'm not sure what you mean by all related functions. However, there are several things you can do to get a good picture of what's going on.

    First off and easiest is to run the software in the debugger. From there you can either single step through the whole program and see what happens, or, you can hit break at any given point during execution and take a look at the call stack. The call stack is a listing of all the functions called to get to the current point in your code. It sounds like this might be quite useful to you. There are all sorts of great things you can do in the debugger to get a good idea of what's going on, like watch the value of variables in the program, break at certain lines or events, all sorts of good stuff.

    Once you've done that, another interesting exercise would be to run it through the profiler. Visual Studio 2005's F1 Profiler is really excellent and work either by sampling your app (checking the call stack periodically to get an idea of how much time it is spending where), or by instrumenting the code so that every call to a function updates the profiler with what it is leaving and where it is going. The instrumentation is slightly more invasive and gives you less accurate time numbers, at least if you have a lot of small functions, while sampling only really works if execution takes enough time. In either case, this will give you a good idea of where the app is spending its time.

    Finally, if you have any call coverage tools, they may be able to give you call graphs of what functions call which other functions.

    Good luck, and don't worry, it will get easier and you will pick up more speed in understanding as you go along gaining context.

    -Ben



  • Renuka

     Ben Anderson MSFT wrote:

    I'm not sure what you mean by all related functions.  However, there are several things you can do to get a good picture of what's going on.

     

    First off and easiest is to run the software in the debugger.  From there you can either single step through the whole program and see what happens, or, you can hit break at any given point during execution and take a look at the call stack.  The call stack is a listing of all the functions called to get to the current point in your code.  It sounds like this might be quite useful to you.  There are all sorts of great things you can do in the debugger to get a good idea of what's going on, like watch the value of variables in the program, break at certain lines or events, all sorts of good stuff.

     

    Once you've done that, another interesting exercise would be to run it through the profiler.  Visual Studio 2005's F1 Profiler is really excellent and work either by sampling your app (checking the call stack periodically to get an idea of how much time it is spending where), or by instrumenting the code so that every call to a function updates the profiler with what it is leaving and where it is going.  The instrumentation is slightly more invasive and gives you less accurate time numbers, at least if you have a lot of small functions, while sampling only really works if execution takes enough time.  In either case, this will give you a good idea of where the app is spending its time. 

     

    Finally, if you have any call coverage tools, they may be able to give you call graphs of what functions call which other functions. 

     

     

    Good luck, and don't worry, it will get easier and you will pick up more speed in understanding as you go along gaining context.

     

    -Ben

    Thank you so much, Ben.

    I will try to use the profile to track all invoked functions.

    May I ask you how to use Visual Studio 2005's F1 Profiler

    I installed Visual Studio 2005 Express Edition and did not find it.

    By the way,  there are some problems about my current project: first, it is built in VC6 and DirectX 8.1. I can only compile and build it in this environment; When I try to use Visual studio 2005 express, there are always some compiling or linking problems.

    Anyway, thanks again

    Damon



  • 105

    Unfortunately Visual Studio Express will likely not contain what you need. It is not intended for professional use, but rather is provided for students and hobbyists. As such it does not include many of the fine tuning tools such as a profiler. I believe that the profiler is only included in VS Team System, one of the higher end skus. If it is important to your employer to ship modern, professional level, first class applications I recommend having them purchase it for your use. Otherwise, there are other options for profiling. If you have VS 6.0 Professional or Enterprise, you can use the included profiler from 6.0. For help using it, search 6.0 MSDN (the help included with 6.0) index for "profiler, enabling".

    As for building your application with 2005 - you are likely running into problems due to the fact that VS Express is designed to be a very small download. As such it does not include the Windows SDK or DirectX, both of which are available as separate (and free) downloads. Once you have them installed, it is simply a matter of pointing VS Express's path, include and lib paths to the appropriate locations. However, if your app depends on other VC owned libraries such as ATL or MFC, which are only included with the various pay editions of Visual Studio, you will likely have to purchase one of the pay skus to port your app. There are a number of advantages to using 2005 over 6.0, including better security, better code-browsing and productivity enhancements in the IDE, better performance and a number of other enhancements, so depending on the state of your application (maintenance only, or improvement) it may or may not be worth making the move.

    From what I can tell, it may not be worth it in your situation, and if the VS6.0 profiler works for you, then all the better. However, I believe VS6.0 is out of support, so be aware.

    Thanks,

    Ben



  • How to list all related functions