Understand: Static code analysis artifact

For a long time, I think Source Insight's code analysis is already the strongest and most professional in the industry. I tried the Understand of Scitools today. After importing the code, graphical analysis results can be generated directly, including inter-module calls, function call processes, etc., which is really shocking.

1. Settings

1. Set the font and color style
Modify the default font: Preference → Editor → Default style

“SourceCodePro Nerd Font Mono” 13

Modify color: Preference → Editor → Styles

Predefined is selected as "onyx"

Preference → General → Application Font

“SourceCodePro Nerd Font Mono” 12

Preference → User Interface → Command Window Font

“SourceCodePro Nerd Font Mono” 10

2. Import the project

new → project, enter the project name (linux-latest), understand the project database (previous directory)
Insert picture description here

1. Language selection
Assembly, C/C++, Python, Web

Note: The Strict mode includes Object-C and Object-C++, as well as Web comments
Insert picture description here

2. Import files and settings, choose the first one here
Insert picture description here

3. Add directories and files, add directories here
Insert picture description here
Insert picture description here
4. Code analysis
There are two options, one is to analyze the code immediately, and the other is to select the configuration. For us, we only need to default, and then click the OK button, and the software will begin to analyze the code.
Insert picture description here

3. Main functions

3.1. Code knowledge

Understanding provides you with relevant information about your code. Quickly view all information about functions, classes, variables, etc., how to use, call, modify and interact. Easily view the call tree, indicators, reference information and any other information you want to know about the code.
Insert picture description here

3.2. Indicators and reports

Understanding is very effective in collecting metrics about the code and provides you with different viewing methods. When we do not fully meet your needs, we can quickly obtain a large number of standard indicators and the option of writing your own custom indicators.
Insert picture description here

3.3. Drawing

Learn about providing diagrams so that you can view the code connections (dependencies), how the process is (control flowchart), which functions are used to call other functions (call diagrams), and so on. There are many customization options that make it easy for you to display only the content you are interested in, so this graph is best suited to your needs.
Insert picture description here

3.4. Standard Test

Understanding provides a way to check code using published coding standards or your own custom standards. These checks can be used to verify naming guidelines, metric requirements, published best practices, or any other rules or conventions that are important to your team.
Insert picture description here

3.5. Dependency analysis

Look at all the dependencies in the code and how they are connected. Use Understanding interactive graphics or use a text dependency browser to view these dependencies. Both allow you to quickly and easily view all dependencies, or drill down into details.
Insert picture description here

3.6. Edit

Insert picture description here

3.7. Search

There are multiple options for searching in "Understanding". To get instant results, please use our "Instant Search" feature, which provides results before typing. Learn about search options that also provide more custom and complex searches, such as regular expressions and wildcard searches.
Insert picture description here

3.8. Language

Understand that it supports more than a dozen languages, and can handle code libraries written in multiple languages. This allows you to view the calls and dependencies between languages ​​so that you can get information about the complete system.
Insert picture description here

4. Search function

1. Search for files: In this search, you can quickly search for the file you want to view.
1. Shortcut key, mouse click on the project structure window on the left side, and then press command + F keys to display the search box as shown in the figure below. Enter the class you want in the box
Insert picture description here
and press Enter 2. Search in the open file: Position the mouse in the code on the right, click command + F, a search box will pop up, enter the method and press Enter:
Insert picture description here

3. Global search: Shortcut key F5 or go to the search bar in the menu bar above to find
Insert picture description here
4. Entity search: Find entity in the menu bar, search according to structure, method, etc.
Insert picture description here

5. Project View

The project view contains many functions, which can automatically generate various flowchart structure diagrams to help you quickly clarify the code logic, structure, etc., so as to quickly understand the project process and develop quickly.

There are two ways to view the view,

One is to click on the class or method you want to view, then right-click to pop up the menu, move the mouse to Graphical Views, and then pop up the secondary menu, as shown in the following figure: The
Insert picture description here
other way is to click on the class or method you want to view, Then find the following icon in the menu bar above the code:
Insert picture description here
then click the drop-down arrow in the lower right corner of the icon, the following menu will pop up, and you can choose to view related views:

5.1. Hierarchical view classification

1.Butterfly: If there is a relationship between two entities, it will show the calling and being called relationship between the two entities; the
following figure is the relationship diagram of a method in Activity:
Insert picture description here
2.Calls: The display starts with the method you choose The entire call chain;
3.Called By: shows which code this entity is called by, the structure diagram is viewed from the bottom up or from right to left;
Insert picture description here
4.Calls Relationship/Calledby Relationship: shows the relationship between two entities The relationship between calling and called, operation method: First, right-click the first entity you want to select, and then click another entity you want to select. If the selection is wrong, you can click the other correct one again, and then click ok;
Insert picture description here
Insert picture description here
5.Contains: Show the hierarchy diagram in an entity, or it can be a file, a connecting line is read as "x includes y";
Insert picture description here
6.Extended By: Show this class is inherited by which class,
Insert picture description here
7.Extends: Show this class inherits from which class :
Insert picture description here

5.2. Structural relationship view classification

1.Graph Architecture: Show the structural relationship of a frame node;

2.Declaration: show the structural relationship of an entity, for example: show the parameters, the return type and the called function, for the class, show the private member variables (who inherits this class, who is based on this class)

3. Parent Declaration: show the structural relationship where this entity is declared;

4. Declaration File: Display all defined entities (such as functions, types, variables, constants, etc.) in the selected file;

5. Declaration Type: display the composition type;

6.Class Declaration: display the member variables of the defined class and the parent class;

7. Data Members: display the composition of the class or method, or the type it contains;

8. Control Flow: display an entity's control flow chart or similar entity type;
Insert picture description here

9.Cluster Control Flow: Show a flow chart of an entity or similar entity type, this one is more interactive than the previous one;

10. UML Class Diagram: Show the class defined in this project or in a file and the classes associated with this class
Insert picture description here
11. UML Sequence Diagram: Show the sequence diagram between two entities;
Insert picture description here

12.Package: Show all entities declared in a given package name

13.Task: Display the parameters, calls, and entities in a task

14.Rename Declaration: Display all entities that have been renamed in the entity

Since there are many views, I will paste the code one by one, mainly you need to debug it yourself, check the display structure and function of each functional view, which makes perfect, and it will be done in a few more operations, so I will not do too much explanation. . In the end, I hope this software can help you develop quickly and quickly read other people's or your own code.

6. Terminology

6.1. Architecture level:

An architecture is a hierarchical aggregation of source code units (entities). An architecture can be user created or automatically generated. Architectures need not be complete (that is, an architecture’s flattened expansion need not reference every source entity in the database), nor unique (that is, an architecture’s flattened expansion need not maintain the set property).

The level represents the hierarchical structure composed of code units (or entities), which can be manually created by the user or automatically generated by the software. A level may be incomplete (for example, a level of flattened extension may not be associated with all code entities in the database), or it may not be unique (the level of flattened extension may not handle its default attributes).

6.2. Database

The database is where the results of the source code analysis, as well as project settings, are stored. By default, this is a project’s “.udb” file.

The intermediate results generated after the code is analyzed, and the project settings are saved in the database, and its default extension is ".udb".

6.3. Entity

An Understand “entity” is anything it has information about. In practice this means anything declared or used in your source code and the files that contain the project. Subroutines, variables, and source files are all examples of entities.

The "entity" described by Understand means anything that contains information. Specifically, the identifiers declared or used in the code, the files containing the project, the subroutines, the variables, and the source files can all be called entities.

6.4. Project

The set of source code you have analyzed and the settings and parameters chosen. A “project file” contains the list of source files and the project settings.

Represents a collection of source codes and related configurations and parameters. The project file contains a list of source files and project settings.

6.5. Relationship

A particular way that entities relate to one another. The names of relationships come from the syntax and semantics of a programming language. For instance, subroutine entities can have “Call” relationships and “CalledBy” relationships.

The relationship between interacting entities. The name of the association comes from the syntax and semantics of the programming language. For example, procedural entities have associated objects of "calling" and "called".

6.6. Script

Generally a Perl script. These can be run from within Understand's GUI, or externally via the “uperl” command. The Understand Perl API provides easy and direct access to all information stored in an Understand database. 2.5 graphical user interface or external script command execution. The Understand Perl API provides a quick and easy access to all the information in the Understand database.

6.7. parts

The following figure shows some commonly used components in the Understand graphical user interface (GUI):

Insert picture description here

7. Common vocabulary

Insert picture description here

8. Right-click menu

The right-click menu of the code editing window provides many shortcuts for browsing and editing operations, as well as specific information about related entities.

The following describes the typical browsing operations included in the right-click menu (related to clicking the object):

View Information (see information browser)

Graphic Views (see)

Edit Source/Definition code editing (see)

User Tools (see)

Explore browse (see hierarchy view)

Find In… Find (see multi-file search)

Add Favorite Add to favorites (see favorites)

Metrics Chart (see)

The following introduces the typical editing operations contained in the right-click menu (related to the clicked object):

Undo/Redo

Cut/Copy/Past Cut/Copy/Past (see text selection and copy)

Select All (see text selection and copy)

Jump to Marching Brace

Select Block

Hide/Show Inactive Lines

Fold All Fold all branches

Soft Wrap

Comment Selection/Uncomment Selection

Change Case

Revert

Add Bookmark Add bookmark activity

9. Project Configuration

Use the menu bar Project>Configure Project and select C++ to open the following window.
Insert picture description here
The C++>Option configuration page includes the following areas:

Compiler:

Select the compiler or platform used by the current project, and the macro definitions related to the compiler are automatically set according to the selection. It should be noted that some features of the compiler may not be well supported.

Compiler Include Paths:

Enter the path of the header file used by the compiler, such as %include%.

Allow nested comments: >>By default, this option is forbidden. In the open state, Understand allows C language comment characters (/**/) to be nested (this style is prohibited by ANSI, but some compilers support it).

Prepend the names of externally linkable entities with:

Use an arbitrary string as the prefix of entities defined in codes written in other languages ​​in the project.

Append the names of externally linkable entities with:

Use an arbitrary string as the suffix for entities defined in codes written in other languages ​​in the project.

Create implicit special member functions:

When the source code does not have related statements for classes and structural entities, Understand Database automatically creates default constructors, destructors and implicit declaration references, so as to provide relevant reference entities for analysis. This option is disabled by default.

Create references in inactive code:

If you want to exclude the inactive code controlled by conditional compilation, you need to cancel this option, which is selected by default.

Create references to local objects:

By default, the Understand database contains all local objects. If you want to exclude the variables declared in the function, you need to cancel this option. The main window of Understand 2.5 can choose whether to include partial objects in the HTML report.

Create references to macros during macro expansion:

When selected, the database saves the reference relationship during macro parsing. Sometimes, the choice is useful. Note that the selection of this option causes the database to increase a lot of reference relationships, which will become very slow. Off by default.

Create references to parameters:

Turn off this option to cancel the reference relationship of parameters, and it is enabled by default.

Save comments associated with entities:

This option controls the association between the annotations before and after the code entity and the entity.

Save duplicate references:

By default, only one copy of the reference relationship is saved in the database. If this option is selected, repeated reference relationships will be recorded.

Save macro expansion text:

With this option selected, you can select Expanded Macro Text under the right-click menu of the selected macro to view the macro definition value.

Use Include cache:

Since header files are usually used by multiple source files, by default, the header files in the analysis phase are cached, which can speed up the analysis process, but requires more memory. If the analysis process encounters memory problems, you can turn this option off . At the same time, it should be noted that the use of cache will affect the analysis results.

10. Entity Filter window

Insert picture description here

Root filter

Root Calls:

Only display entities that are called but not called, such as upper code (mains), hardware called code (interrupt handling function), and dumb (not used) code.

Root CallBys:

Only display entities that are only called without calling other entities, that is, the lowest-level functions.

Root IncludeBys:

Only the files contained in other files are displayed, that is, the basic header files.

Root Classes:

Only show classes that do not depend on other classes, including underlying classes and library classes.

Root Decls:

Only the top-level declaration process (Ada) is displayed.

Root Withs:

Only display program units (including packages, tasks, subroutines, etc.) that are used by other units without using other units (Ada).

11. Information Browser

Insert picture description here

Information browser synchronization

Uncheck Sync to open multiple information browser windows. When Sync is checked, selecting an entity or selecting View Information will update the current information browser.

Checking File Sync can ensure that the content of the information browser is always synchronized with the active code editor.
Insert picture description here

12. Reference View

The "References" area of ​​the information browser displays all relevant information about the selected entity:

Insert picture description here

13. Project Browser

Insert picture description here

14. Context Information Sidebar

Insert picture description here

Displays the structure and information of the currently active editing window. The tab page contains the following information:

15. Structure Browser

Provides an extended range list of the current file, listing the names of functions, header file inclusions, macro definitions, classes, and various other structures in the file. The icon next to the name indicates the entity type. Move the mouse to an item, and an active text box showing the entity type and name will pop up. Use Ctrl+F to search within the tab page range.

File Information

Provides an information browser for the current file.

Scope Information

Display the relevant information of the selected entity in the Structure Browser.

Context Browser

The position of the current entity in the hierarchy is displayed on the left, and other entities contained in the current entity are displayed on the right. The icon in the upper right corner of the file information tab (or use Ctrl+,) can replace the files in the editing window and CIS with files with the same name but with different extensions in the same directory. For example, using this method can quickly switch between .p/.cpp and .h files.

The right-click menu also provides a variety of quick operation options.

16. Case modification

Understand 2.5 code editor supports quick case modification of selected text, the method is as follows:

  • 1. Select one or more words in the code.
  • 2. Via the menu bar Edit>Change Case, or select Change Case from the right-click menu.
  • 3. Choose the capitalization modification method you want to use, the options include:
    Insert picture description here

17. Hierarchical structure browser

Insert picture description here
Insert picture description here

The right-click menu of hierarchical structure nodes (such as the file system directory node and the quarterly modification node) contains additional options that are not provided by the right-click menus of the following other objects:

Graphical Views>Dependency Graphs: Display the dependencies of each node in the hierarchy, see.

Metrics Summary: Provides the metric data of each entity of the selected node. These metric data are based on the entities under the current node, excluding the entities in the child nodes, see.

Metrics Export: Export the metric summary to a CSV file, see.

XML Export: Export the entities contained in the selected node and sub-nodes in the hierarchical structure in XML format, see.

Edit Architecutre: Open a hierarchical structure builder for the hierarchical structure created by the user. The hierarchical structure automatically constructed by Understand cannot be modified, see.

Rename Architecture: Opens a hierarchical structure renaming window for the user to modify the name of the hierarchical structure or node created by the user. The hierarchical structure automatically constructed by Understand 2.5 cannot be renamed, see.

Duplicate Architecture: Open the hierarchy duplication window to name the duplicate of the selected hierarchy, see.

Manage Architecture: Open the hierarchical structure management window, see.

Guess you like

Origin blog.csdn.net/qq_40513792/article/details/111991978