LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-18-2007, 03:56 AM   #1
Sulman Shah
Member
 
Registered: Oct 2006
Posts: 38

Rep: Reputation: 15
Identifying the flow of an application??


If I have an open source application which consists of about hundreds of files(.c,.cpp,.hpp,and .h) and about ten Makefiles(a Makefile 4 a module) and the application have some submodules and all of are integrated and run in collaboration with each others. My question is can I identify the flow of the projec? can we run the project line by line or file by file. Can we debug it? Can anyone tell me any generalized method which can make this thing easy? Can we identify the flow of project in hand?
 
Old 01-18-2007, 04:27 AM   #2
shivaligupta
Member
 
Registered: Oct 2004
Posts: 45

Rep: Reputation: 15
use some tool like cscope, ctags etc and start browsing the code start from one point
 
Old 01-18-2007, 06:47 AM   #3
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
Quote:
Originally Posted by Sulman Shah
can we run the project line by line or file by file. Can we debug it?
File by file: no, because once you link everything together there's no notion of individual source files anymore. Compile with the -g option to GCC and then use GDB to debug / step through it "line-by-line" (sequentially).
 
Old 01-19-2007, 12:30 AM   #4
Sulman Shah
Member
 
Registered: Oct 2006
Posts: 38

Original Poster
Rep: Reputation: 15
You have written that "Compile with the -g option to GCC and then use GDB to debug / step through it "line-by-line" (sequentially)" Can you please elaborate it more?
which file should I compile first. There are some many files in the project. When i run Makefile all are compiled but i dont know how to do it manually. Plz tell me.
 
Old 01-19-2007, 12:37 AM   #5
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Debugging and tracing code is very painful if you don't know where the program is going - especially when you've got a lot of event-triggered callbacks and so on.

Approaching the problem from multiple levels is useful. Become a domain expert - find out what the program achieves, and the logic behind the problem and solution... this can give insight into how the author solved the problem. Add that to trying to follow the code and you might start to understand it. Medium level design documents might be useful, if any exist.

Ultimately, the only documentation that matters is the code... you've just got to roll up your sleeves and get into it.

If you can get hold of the author, try to get hold of them and sit over some coffee and talk about it.
 
Old 01-19-2007, 01:13 AM   #6
Sulman Shah
Member
 
Registered: Oct 2006
Posts: 38

Original Poster
Rep: Reputation: 15
I don't have any design document, I wish I could have one cuz it would have made my problem easier. The author is responding to any of my query i dont know whats the reason. The following is the project I want to know about.

http://www.globule.org/download/1.3....e-1.3.2.tar.gz

Can I extract something about the flow of the project from the makefile? Or no other way? I have to dig in more I?
 
Old 01-19-2007, 06:31 AM   #7
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 735

Rep: Reputation: 76
Hi.

When I receive a large project, I like to use static analysis tools. Most run by looking at the source code and then produce call trees and other interesting tables and lists -- who calls whom, who is called by whom, etc.

Looking for "static analysis tools" with Google yields about 1.5 M hits.

One of the first, http://www.spinroot.com/static/ , has a list of tools with links to commercial and academic tools.

Depending on your expertise, you could also use the tools in *nix, such as nm (namelist), along with some glue-programs (in awk, perl, etc) to extract symbols from object modules to produce cross-reference lists, call trees, etc. The advantage of that is the compilers do all the work, and the tools are general because they don't need to look at the source so they can process any language. You can see this approach by compiling a small c program, then run nm on the .o file. Briefly, you'd get a transfer address, say "main", so you know where to start, then perhaps an undefined, such as "printf", so you know that main calls printf:
Code:
% nm main.o
00000000 T main
         U printf
or, with posix output:
Code:
main.o: main T 00000000 0000001e
main.o: printf U
That's essentially the call tree, and a program that processes the nm output could produce a list that shows the line / reference number and level:
Code:
  1 (  0)  main
  2 (  1)    printf
Best wishes ... cheers, makyo

( edit 1: typo, add example output )

Last edited by makyo; 01-19-2007 at 05:28 PM.
 
Old 01-20-2007, 03:58 AM   #8
Sulman Shah
Member
 
Registered: Oct 2006
Posts: 38

Original Poster
Rep: Reputation: 15
Thanks to all of you, You people are very kind and co-operative. I am gonna use the tools you have mentioned. thanks once again.
 
Old 01-23-2007, 12:08 AM   #9
Sulman Shah
Member
 
Registered: Oct 2006
Posts: 38

Original Poster
Rep: Reputation: 15
In my case only one library file or binary file "mymodule.so" is made from all the files of the application. So, my question is; Do i need to run this file with the help of the applications you have mentioned? Will this one ".so" file consist of references to all the source files from which i have compile it?

Last edited by Sulman Shah; 01-23-2007 at 12:11 AM.
 
Old 01-23-2007, 06:51 AM   #10
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
Quote:
Originally Posted by Sulman Shah
Will this one ".so" file consist of references to all the source files from which i have compile it?
The shared object file consists of all the program text necessary to carry out all the functions that it exports for external use. It also contains all the required internal functions and references to exported functions from other shared libraries where appropriate and necessary. Shared object files don't really have a "flow" because they're not interactive to any external service other than the actual applications that use them. But if you're tracing calls from a program through shared libraries, you'll have to dip inside them at some point.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
About Packet Flow qs_tahmeed Linux - Networking 3 10-20-2005 05:50 PM
Identifying Traffic azcoder2 Linux - Networking 2 10-17-2005 02:36 PM
identifying component's etc bigjohn Linux - General 4 09-23-2004 10:32 PM
flow chart sw allelopath Linux - General 1 04-06-2004 06:02 AM
Identifying Processes Transition Linux - General 4 02-18-2004 03:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration