Data Race Check Functions
The data race check function checks for any dynamic memory inconsistency problem when C/C++ source code is running on the Kunpeng platform (powered by Kunpeng 920 series processors), 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] [-d REPORT_FILE | --decode REPORT_FILE] [-sr {true,false} | --summary-report {true,false}] [-eb {true,false} | --enable-backtrace {true,false}] [-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
Parameter |
Option |
Description |
|---|---|---|
-h/--help |
- |
Obtains help information. This parameter is optional. |
-i/--input |
input_path |
Path to the source code folder corresponding to the ELF file. This parameter is optional. The ELF file is the binary file generated after compiling the C/C++ program. |
-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. This parameter is optional. 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. This parameter is optional. |
-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. This parameter is optional. |
-sf/--shield-file |
shield_file |
CFG configuration file. This parameter is optional. It specifies the files and dynamic libraries that are excluded from dynamic data race check. |
-cf/--config-file |
config_file |
JSON configuration file. This parameter is optional. It is a custom lock not included in data race check during dynamic memory consistency checks. |
-d/--decode |
report_file |
Historical report files. This parameter is optional. It specifies the historical report files saved during the tool running. A maximum of five historical reports can be saved. If this parameter is set, reports are parsed separately. NOTE:
|
-sr/--summary-report |
true/false |
Indicates whether to generate a simplified report. The default value is false. This parameter is optional.
NOTE:
|
-eb/--enable-backtrace |
true/false |
Indicates whether to enable call stack recording. The default value is false. This parameter is optional.
|
-l/--log-level |
0/1/2/3 |
Log level, which defaults to 1. This parameter is optional.
|
-r/--report-type |
all/json/html/csv |
Scan report format, which defaults to all. This parameter is optional.
|
--set-timeout |
time |
Timeout interval of a task, in minutes. This parameter is optional. 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
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. |