我要评分
获取效率
正确性
完整性
易理解

Data Race Check Commands

The data race check function checks for any dynamic memory inconsistency problem when C/C++ source code is running on the Kunpeng platform (specifically Kunpeng 920), and provides the check result and also suggestions on inserting memory barriers.

Data race check can be performed only for single-process applications, and the GCC version must be later than 9.4.0.

Command Function

Dynamically checks for data race in source code.

Syntax

1
devkit advisor dr-check [-h | --help] {-f ELF_FILE | --elf-file ELF_FILE} [-i INPUT_PATH | --input INPUT_PATH] [-s SAFE_FILE | --safe-file SAFE_FILE] [-p ELF_PARAMS | --elf-params ELF_PARAMS] [-o OUTPUT_PATH | --output OUTPUT_PATH] [-sf SHIELD_FILE | --shield-file SHIELD_FILE] [-cf CONFIG_FILE | --config-file CONFIG_FILE] [-r {all,json,html,csv} | --report-type {all,json,html,csv}] [-l {0,1,2,3} | --log-level {0,1,2,3}] [--set-timeout TIMEOUT] 

Parameter Description

Table 1 Parameter description

Parameter

Option

Description

-h/--help

-

Obtains help information.

-i/--input

input_path

Path to the source code folder corresponding to the ELF file.

-f/--elf-file

elf_file

ELF file path. This parameter is mandatory. The ELF file to be tested must contain debugging information (add the -g option during compilation).

-s/--safe-file

safe_file

CFG configuration file. It specifies the safe functions that are skipped in dynamic data race check. The name of a C++ function must be the name after the C++ function is reloaded.

-p/--elf-params

elf_parameter

Input parameters required for executing the ELF file.

-o/--output

output_path

Path for storing scan reports. By default, scan reports are stored in the current execution path. A report name is the format of Module name_Timestamp.

-sf/--shield-file

shield_file

CFG configuration file. It specifies the files and dynamic libraries that are excluded from dynamic data race check.

-cf/--config-file

config_file

JSON configuration file. It is a custom lock not included in data race check during dynamic memory consistency checks.

-l/--log-level

0/1/2/3

Log level, which defaults to 1.
  • 0: DEBUG
  • 1: INFO
  • 2: WARNING
  • 3: ERROR

-r/--report-type

all/json/html/csv

Scan report format, which defaults to all.
  • all: generates reports in JSON, HTML, and CSV formats.
  • json: generates a report only in JSON format.
  • html: generates a report only in HTML format.
  • csv: generates a report only in CSV format.

--set-timeout

time

Timeout interval of a task, in minutes. If the execution duration exceeds the timeout interval, the task exits. By default, there is no timeout interval. The task will be executed until it is complete.

Example

In this example, the source file in the /home/testcase/project directory is scanned. Replace the example directory with the actual one.

1
devkit advisor dr-check -i /home/testcase/project -f /home/advisor/test

The following information is displayed and a report is generated:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
Executing data race check task, please wait...
Scanned time: 2024/07/16 14:01:30
 
Configuration:
    Elf file path: /home/advisor/test
    Scan source code path: /home/testcase/project
    Generate report path: /home/ DevKit_Software
    Generate report type: all
    Task Timeout Interval: The timeout period is not set.
    Log level: info
 
Summary:
There are 2 recommendable code lines to modify.
 
For the details information, please check:
    /home/ DevKit_Software /dr-check_20240716140130_6480.json
    /home/ DevKit_Software /dr-check_20240716140130_6480.html
    /home/ DevKit_Software /dr-check_20240716140130_6480.csv

Output Report

Table 2 Output report parameters

Parameter

Description

Configuration

Displays the paths to the software source file and executable file.

Source File to Be Modified

Displays information such as the path to the source file that needs to be modified.