Rate This Document
Findability
Accuracy
Completeness
Readability

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

Table 1 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:
  • 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.

-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

-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.

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

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.