How to: Generate Dependency graphs for C and C + + code

Source: Internet
Author: User
Tags visual studio 2010


Visual Studio1 out of 1 rated this helpful - Rate This topic

with this Visual Studio 2010 Feature Pack, you can visualize the organization and relationships in C and C + + code by generating dependency graphs in Visual Studio 2010 Ultimate Edition. Use these diagrams to help you browse, understand, and manage dependencies between source code, binaries, and source files and header files. For example, you can visualize dependencies between binary files, namespaces, and classes. diagrams represent code elements and their relationships as a set of nodes that are connected by links or edges. For more information, see Visual Studio Feature Pack .

Important issues

You must have the Visual Studio 2010 Feature Pack installed to use this feature.

To perform this task with Visual C or Visual C + + projects, you must install Visual C # with Visual Studio.

When you generate diagrams for C and C + + code, be aware of the following items:

  • When you open a solution that contains C and C + + projects, you may need to take the time to update the IntelliSense browsing database. During this time, the commands used to generate dependency graphs for source files and header files will not be available.

    Attention

    wait until the IntelliSense database finishes updating before you generate dependency graphs for these files. You can monitor the progress of these updates in the Visual Studio status bar. For more information about the messages that are caused by disabling some IntelliSense settings, see Troubleshooting.

  • The term "assembly" means "binary" in the user interface. For example, to view the dependencies between all binaries in the solution, on the Architecture menu, point to build dependencygraph, and then click by Assembly.

    Attention

    for binary files, the diagram shows only binary-level dependencies. For example, dependencies within the same binary, such as method calls and reference types, will not be displayed.

  • The default name of the generated graph document for C and C + + code is "Assemblydependenciesn. Dgml", wheren is the version number of the document. You can rename this document at any time.

  • Dependency graphs can be generated for the entire Visual Studio solution or for a specific item.

    Attention

    If your solution is very large, generating dependency graphs may take some time to parse all the files, or you will cause an out-of-memory exception. If this happens, either reduce the scope of the solution or use Architecture Explorer to select specific elements and relationships before you build the diagram.

  • use the same steps to generate dependency graphs for C and C + + code, as you would for. NET code to generate dependency graphs. For more information, see How to: Generate Dependency graphs for. NET code .

For information about issues that may occur when you generate dependency graphs for C or C + + code, see Troubleshooting.

to view dependencies between source files and header files

you can visualize dependencies between C and C + + source files and header files. You can select the following scopes for the dependencies to visualize:

Dependency graphs for Include files in C + + projects

    • All source files and header files in the solution

    • The currently open file and all first level source files and header files

View the dependencies between the following

Follow these steps

all source files and header files in the solution

On the architecture menu, point to , and then click "file by included" [by Included File] .

note When you run this command for the first time, Visual Studio must parse the C or C + + project files. This may take some time. .

The currently open file and all first level source files and header files

Tips To see other levels of dependencies, use the neighbor Browsing mode on the Diagram toolbar to select the level of dependency you want to view. For more information, see How to: Browse and navigate in a graph document .
  1. Open the source file or header file.

    The file opens in the Code Editor window.

  2. Right-click anywhere in the file, then "generate diagram for included files" [Generate graph for Included files].

Dependency graphs with header files with first level source and header files

Troubleshooting

When you generate dependency graphs for C or C + + code, the following issues may occur:

Problem

Possible causes

Workaround

When you try to generate a dependency graph from The Architecture menu, Visual Studio does not respond.

The program database (. pdb) file may be corrupted.

The. pdb file stores debugging information, such as type, method, and source file information.

For more information, see Program database files (c + +).

Rebuild the solution, and then try again.

Disable some settings for the IntelliSense browser database.

Some IntelliSense settings may have been disabled in the Options dialog box in Visual Studio.

Open the settings to enable them.

For more information, see " Advanced", "C + +", text Editor, Options dialog box.

The message "Unknown method" appears on the method node.

This issue occurs because the name of the method cannot be resolved.

The binary file may not have a base relocation table.

Open the /fixed:no option in the linker.

For more information, see /fixed (Fixed base address).

Only binary files that run on x86 architectures are supported.

The program database (. pdb) file could not be generated.

The. pdb file stores debugging information, such as type, method, and source file information.

For more information, see Program database files (c + +).

Open the /debug option in the linker.

For more information, see /debug (Generate debugging information).

Unable to open or locate the. pdb file at the expected location.

Make sure that the. pdb file is in the expected location.

Debugging information has been removed from the. pdb file.

If the /pdbstriped option is already used in the linker, the full. pdb file is included instead.

For more information, see /pdbstripped (Removing private symbols).

The caller is not a function, it is a form conversion (thunk) in a binary file or a pointer in a data section.

When the caller is a form conversion (thunk), try using _declspec (dllimport) to avoid the form conversion (thunk).

For more information, see:

  • General Rules and Limitations

  • Using __declspec (dllimport) to import function calls

  • dllexport, DllImport

Please seeConceptShow Existing codeOther resourcesHow to: Navigate and navigate in a graph documentHow to: Explore code using dependency graphshow to: Edit and customize a diagram document

How to: Generate Dependency graphs for C and C + + code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.