When someone asks for a map of a program, what do they mean?

In summary, I was given a C++ program and asked to create a map of it. He added some more details (something about functions), and I left his office thinking I understood what he requested but now I realize I don't. I'll approach him and ask for more details but before I do that I'd like to see if physicsforums can help. In summary, a call graph and map file are two different things.
  • #1
dEdt
288
2
I was given a C++ program (a hefty one at that) and asked to create a map of it. He added some more details (something about functions), and I left his office thinking I understood what he requested but now I realize I don't.

I'll approach him and ask for more details but before I do that I'd like to see if physicsforums can help. (I rather look like an idiot to online strangers than to my prof).
 
Technology news on Phys.org
  • #3
Given that the "map" is supposed to be "something about functions", this sounds like a call graph. The nodes in the graph represent the functions in the program, and the directed edges between nodes represent one function calling another.
 
  • #4
Also there is ArgoUML which supports java, C++ and UML 1.4:

http://argouml.tigris.org/features.html

ideally look for one that can do reverse engineering from the source otherwise you'll need to study the code and develop the diagrams manually using the tool.

Fancier versions will generate code from your diagrams and allow you ro rearchitect your code but they usually cost money and don't always do the best job.

And I found this tool ASTAH which is free to students and has a plugin for C++ reversal:

http://astah.net/features/cpp-reverse-plugin

and of course there's the high-powered tools from IBM:

http://pic.dhe.ibm.com/infocenter/r...oc/topics/rhp_c_dm_preserve_cd_structure.html
 
Last edited:
  • #5
D H said:
Given that the "map" is supposed to be "something about functions", this sounds like a call graph. The nodes in the graph represent the functions in the program, and the directed edges between nodes represent one function calling another.

This sounds right. What's the easiest way of generating a call graph for a C++ program?
 
  • #6
Call graph tools (linux:)
compile to profile ( gcc option -pg); then run the code and view the result with gprof [name of compiled program]
This will produce a call graph. gcover also helps in this regard. These are free. I did not do windows because I do not know of opensource call graph apps for it. Does not mean there are none.

There are lots of good (read: expensive or not free) call graph generation tools but college is not the place to opt for that.
ex:
http://sourceinsight.com/index.html
 
  • Like
Likes 1 person
  • #7
A map file is a text file produced by a linker that documents where various parts of the program are in the executable file. For example, if there is function A in the program, the map file would list the address(es) where the machine code representing function A resides, among (many) other things.
 
  • #8
Thanks voko, I think this is what I need to do, not make a call graph.

First question: what do you mean by "the address(es) where the machine code representing function A resides"? I'm still new C++, so apologies if this seems like a stupid question.

Second question: what's the easiest way to make a map file? The code I'm working with is long and I don't want to have to go through it by hand.
 
  • #9
Or am I mistaken in thinking that a call graph and a map file are two different things?
 
  • #10
A map file and a call graph, to me, are completely different.

The compiler generates machine code from the C++ language. It writes that code into object files. Object files are not directly executable because they do not contain library code and the code from other compiled files. The linker then, well, links all the object files (including those of the libraries) into a single executable. It basically takes chunks of machine code from the object files and dumps them into the single executable file. At this stage every function in the program obtains a fixed address (offset from its beginning) in the file. This is a very simplified description, though.

As to how to obtain a map file, that depends on the tools that you use to compile and link your program. I am sure it documented somewhere. If not, let us know what you use and we may have an answer for you.
 
  • #11
Okay, I think I understand what an address is.

I'm using Code::Blocks as my IDE. Is there some way I can get it to generate a map file for me? Or do you mean something completely different when you said "the tools that you use to compile and link your program"?

Thanks again, you're being a great help.
 
  • #13
Once you get a link map from program, what would you do with it? Sometimes link maps are used with a type of profiler that generates interrupts (hopefully asynchronously with the program) to capture program counter values, and after a run, produces a histogram using the captured array of program counter values and the link map, then sorts (in descending order) the historgram to produce a list of where the program is spending most of its time.
 
  • #14
If you do call graph, just realize that it may never be the same for any two runs of the program. Differences in inputs can result in completely different call graphs.
 

Related to When someone asks for a map of a program, what do they mean?

1. What is a program map?

A program map is a visual representation of the different components and connections within a program. It provides an overall view of the program's structure and can help identify potential areas for improvement or optimization.

2. Why would someone ask for a map of a program?

Someone may ask for a program map to better understand the relationships between different parts of the program, to track its progress, or to communicate its structure to others.

3. How is a program map created?

A program map can be created using various techniques, such as flowcharts, diagrams, or mind maps. The specific method used will depend on the complexity of the program and the preferences of the individual or team creating the map.

4. What information should be included in a program map?

A program map should include the main components of the program, such as input/output, data flow, and decision-making processes. It should also show the relationships between these components and any dependencies or interactions.

5. How can a program map be used in the development process?

A program map can be used as a planning tool to identify potential issues or bottlenecks in the program's design. It can also be used to track progress and make adjustments as needed during the development process.

Similar threads

  • STEM Academic Advising
Replies
1
Views
705
  • Sticky
  • Programming and Computer Science
Replies
13
Views
4K
  • STEM Academic Advising
Replies
11
Views
628
  • Programming and Computer Science
Replies
13
Views
2K
  • Programming and Computer Science
Replies
29
Views
3K
  • Programming and Computer Science
Replies
2
Views
1K
Replies
1
Views
892
  • Linear and Abstract Algebra
Replies
1
Views
983
  • Programming and Computer Science
Replies
5
Views
3K
Replies
3
Views
1K
Back
Top