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

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

devkit advisor dr-check [-h | --help] {-f ELF_FILE | --elf-file ELF_FILE} [-i INPUT_PATH | --input INPUT_PATH] [-ec {true,false} | --enable-collect {true,false}] [--start-collect PID] [--stop-collect PID] [-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

Table 1 Parameter description

Parameter

Option

Description

-h/--help

-

Obtains help information.

-f/--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).

The ELF file is the binary file generated after compiling the C/C++ program.

-i/--input

-

Path to the source code folder corresponding to the ELF file. This parameter is optional.

-ec/--enable-collect

true/false

Indicates whether to enable data race check. The default value is true. This parameter is optional.

  • true: enables data race check.
  • false: disables data race check.

--start-collect

-

Sends the signal of enabling data race check to a specified process, where the specified process number corresponds to a process is included in data race check. This parameter is optional.

NOTE:

The --start-collect option takes effect only when -ec is set to false.

--stop-collect

-

Sends the signal of disabling data race check to a specified process, where the specified process number corresponds to a process is included in data race check. This parameter is optional.

NOTE:

The --stop-collect option takes effect only when -ec is set to true.

-s/--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

-

Input parameters required for executing the ELF file. This parameter is optional.

-o/--output

-

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

-

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

-

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

-

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:
  • Historical report files are stored in the directory where the DevKit command-line affinity analyzer tool (advisor) is located. A report name is in the format of ELF-file-name_Timestamp.memtracer_report.
  • The ELF file corresponding to a historical report file specified by the -d option must match the ELF file specified by the -f option.

-sr/--summary-report

true/false

Indicates whether to generate a simplified report. The default value is false. This parameter is optional.

  • true: generates a simplified report in JSON format.
  • false: generates a full report specified by the -r option.
NOTE:
  • A simplified JSON report contains only address, location, type, file, line, function, source_code, core_code, and backtrace.
  • If both the -sr and -r options are specified and -sr is set to true, -r is invalid.

-eb/--enable-backtrace

true/false

Indicates whether to enable call stack recording. The default value is false. This parameter is optional.

  • true: enables call stack recording.
  • false: disables call stack recording.

-r/--report-type

all/json/html/csv

Scan report format, which defaults to all. This parameter is optional.
  • 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.

-l/--log-level

0/1/2/3

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

--set-timeout

-

Timeout interval of a task, in minutes. If the execution duration exceeds the timeout interval, the task exits. This parameter is optional. 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
19
Executing data race check task, please wait...
The pid of the memtracer process is 3517879
Scanned time: 2025/05/14 08:54:50
 
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_20250514085450_0541.json
    /home/DevKit_Software/dr-check_20250514085450_0541.html
    /home/DevKit_Software/dr-check_20250514085450_0541.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.