Movatterモバイル変換


[0]ホーム

URL:


CN112395190A - Non-invasive coverage rate statistical method for various processor architectures - Google Patents

Non-invasive coverage rate statistical method for various processor architectures
Download PDF

Info

Publication number
CN112395190A
CN112395190ACN202011280982.6ACN202011280982ACN112395190ACN 112395190 ACN112395190 ACN 112395190ACN 202011280982 ACN202011280982 ACN 202011280982ACN 112395190 ACN112395190 ACN 112395190A
Authority
CN
China
Prior art keywords
information
file
current
instruction
address
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Withdrawn
Application number
CN202011280982.6A
Other languages
Chinese (zh)
Inventor
贾张涛
吴超
付修锋
安恒
李雅斯
沈兴龙
闫帅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Institute of Computer Technology and Applications
Original Assignee
Beijing Institute of Computer Technology and Applications
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Institute of Computer Technology and ApplicationsfiledCriticalBeijing Institute of Computer Technology and Applications
Priority to CN202011280982.6ApriorityCriticalpatent/CN112395190A/en
Publication of CN112395190ApublicationCriticalpatent/CN112395190A/en
Withdrawnlegal-statusCriticalCurrent

Links

Classifications

Landscapes

Abstract

The invention relates to a non-invasive coverage rate statistical method aiming at various processor architectures, which comprises the following steps: building an embedded software simulation running environment; analyzing various architecture target files and debugging information formats, acquiring debugging information formats corresponding to the processor, and acquiring embedded software source code target code corresponding relation information by analyzing the debugging information formats; analyzing the source code to obtain the branch information of the source code; acquiring coverage information, comprising: after the simulation execution starts, judging whether the current instruction is a branch instruction or not, if not, continuing to execute the instruction; if so, taking the current address as the end address of the basic block, and taking the start address and the end address of the basic block as indexes, and updating the coverage rate lookup table; and outputting the result of the statistical analysis of the coverage rate. The coverage rate statistical analysis method can make up the defects of the existing coverage rate statistical analysis tool and meet the requirements of the coverage rate statistical analysis under various scenes.

Description

Non-invasive coverage rate statistical method for various processor architectures
Technical Field
The invention relates to a testing technology of embedded software, in particular to a non-intrusive coverage rate statistical method aiming at various processor architectures.
Background
With the wide application of embedded software in different fields, the development technology of embedded software is more and more diversified. The security and reliability issues of embedded software are increasingly attracting attention of users and developers, especially in industries with high reliability and security requirements. The embedded software can only run under a specific hardware environment, but the testing environment and the development environment of the embedded software are different from the real running environment, which causes that the absolute safety of the embedded software under the real running environment cannot be ensured even if the target machine is fully tested.
In order to provide powerful support for testing of embedded software, a common virtual verification platform is a verification means based on a certain mode, cannot meet the requirement of the embedded software on virtualization verification, and lacks an effective coverage rate statistical analysis means.
The coverage statistics provided by the current popular test tools are all based on source codes, and the coverage information statistics tools based on target codes are few. In order to meet the emerging requirement of object code verification, some companies propose corresponding products, but all have defects, and the support for the object code verification technology of the embedded system with high security and high reliability is not enough. Most of the coverage statistical analysis tools based on the source codes are realized based on instrumentation algorithms, and there are two more typical coverage analysis methods, one is a coverage analysis tool depending on a certain specific compiler, and the other is a coverage analysis tool with a single function.
Disclosure of Invention
The invention aims to provide a non-invasive coverage rate statistical method for various processor architectures, which is used for solving the problem that coverage rate information cannot be acquired difficultly in the embedded software object code testing process.
The invention relates to a non-invasive coverage rate statistical method aiming at various processor architectures, which comprises the following steps: building an embedded software simulation running environment; analyzing various architecture target files and debugging information formats, acquiring debugging information formats corresponding to the processor, and acquiring embedded software source code target code corresponding relation information by analyzing the debugging information formats; analyzing the source code to obtain the branch information of the source code; acquiring coverage information, comprising: after the simulation execution starts, judging whether the current instruction is a branch instruction or not, if not, continuing to execute the instruction; if so, taking the current address as the end address of the basic block, and taking the start address and the end address of the basic block as indexes, and updating the coverage rate lookup table; and outputting the result of the statistical analysis of the coverage rate.
According to an embodiment of the present invention, a non-invasive coverage statistical method for multiple processor architectures is provided, wherein a debug information format middebug info is defined, and multiple debug information is converted into the debug information format middebug info after being analyzed, the debug information includes file information, function information, and source code and object code corresponding relationship information, wherein the file information includes a file name, a file path, an object code start address and an object code end address corresponding to a file, the function information includes a function name, a function start address, and a function end address, and the source code and object code corresponding relationship information includes a source code line number, and an object code start address and an object end address corresponding to the line source code.
According to an embodiment of the non-intrusive coverage statistical method for various processor architectures, the building of the embedded software simulation running environment comprises the following steps: simulating a target processor kernel instruction set, simulating an embedded system peripheral and controlling a simulation process; the simulation of the target processor kernel instruction set adopts a dynamic binary compilation method based on LLVM to realize the heterogeneous execution of a target instruction under a Windows/Intel host machine architecture, and the target code is separated from the original hardware execution environment; the embedded system peripheral simulation is used for realizing the simulation of target processor peripheral equipment, and comprises RS-422 and RS-485 serial port equipment simulation, switching value equipment simulation and storage system simulation; the simulation process control adopts a unified clock scheduling algorithm to realize the execution control and the cooperative operation of all components of the virtual environment.
In an embodiment of the present invention, a method for non-intrusive coverage statistics for multiple processor architectures, parsing multiple architecture target files and debug information formats comprises: establishing a three-level structure information table with file, function and line number information; (1) analyzing a target file of a plurality of processors, determining the type of debugging information according to the structure of the target file, and reading the debugging information; (2) analyzing the debugging information formats of Dwarf1, Dwarf2, Dwarf3, sta, COFF and OMF51, and converting the debugging information formats into a debugging information format MidDebugInfo; (3) reading debugging information in a debugging information format MidDebugInfo, and judging the type of a current debugging information node; (4) judging whether the current debugging information node is a file start type node or not, if so, creating a file information recording structure, writing a target code start address corresponding to the file into the current file information recording structure, executing the step (3), and if not, executing the step (5); (5) judging whether the current debugging information node is a function starting type node or not, if so, creating a function information recording structure, writing a target code starting address corresponding to a function into the current function information recording structure, inserting the current function information structure into a current file information recording mechanism, and executing the step (3), otherwise, executing the step (6); (6) judging whether the current debugging information node is a line number information type node, if so, creating a line number information recording structure, inserting the current line number information structure into a current function information recording mechanism, and executing the step (3), otherwise, executing the step (7); (7) judging whether the current debugging information node is a function end type node or not, if so, writing the target code end address corresponding to the function into the current function information recording structure, executing the step (3), and if not, executing the step (8); (8) judging whether the current debugging information node is a file end type node or not, if so, writing an end address of the target code corresponding to the file into the current file information recording structure, and executing the step (9); (9) and (4) judging whether the reading of the debugging information is finished, if not, executing the step (3), otherwise, starting to analyze the source code to obtain the branch information of the source code.
In an embodiment of the non-intrusive coverage statistics method for multiple processor architectures according to the present invention, parsing the source code branch information comprises: acquiring source code path information; and reading in the source files one by one according to the three-level query structure table, judging the branch information of the source code line corresponding to the line number information node, and acquiring the branch condition of the source code.
In an embodiment of the present invention, a non-invasive coverage statistics method for various processor architectures is provided, wherein the coverage information output format is: a basic block start address, a basic block end address, a number of executions, a branch instruction address, and branch information.
According to an embodiment of the non-intrusive coverage rate statistical method for various processor architectures, a file for recording coverage rate information is read according to a three-level structure information table of files, functions and line number information, and a coverage rate statistical analysis result is generated according to the corresponding relation between a source code and a target code and the branch information of a source file.
In one embodiment of the present invention, a non-intrusive coverage statistics method for multiple processor architectures is provided, wherein the coverage statistics output provides instruction fetching, decoding, disassembling, and performing information parsing to generate a coverage statistics analysis result.
According to an embodiment of the present invention, a basic block of object codes is used as a minimum statistical unit, the basic block includes a start address, an end address, a branch instruction address, execution times and branch information, and one basic block includes one or more lines of object codes corresponding to source codes.
In an embodiment of the non-intrusive coverage statistics method for various processor architectures according to the present invention, obtaining coverage information comprises: (a) running an embedded simulation environment and loading a target file into a simulation memory; (b) simulating the execution start, and taking the execution start address as the start address of the first basic block; (c) reading and translating the instruction, executing the current instruction and judging whether the current instruction is a branch instruction, if not, continuing to execute the step (c), and if so, executing the step (d); (d) the address corresponding to the branch instruction is a basic block end address, and the start address and the end address of the current basic block and the branch information of the branch instruction are recorded; (e) using the starting address and the ending address of the basic block as indexes, inquiring the position of the current basic block in a three-level coverage rate information table, determining a line number information structure corresponding to the basic block, and adding the execution times of the corresponding line number information structure together to update branch information; (f) judging whether the coverage rate is generated or not, if not, continuing to execute the step (c), and if so, executing the step (g); (g) and writing the information recorded in the coverage rate information lookup table into a file of a specified path in a specific format, and suspending simulation execution.
The invention aims to provide a non-invasive coverage rate statistical method for various processor architectures, which converts different types of debugging information formats into universal type debugging information by analyzing the types of target files and the types of the debugging information formats under different processor architectures, acquires coverage rate execution information according to a processor virtualization simulation system, and finally completes the coverage rate statistical analysis function, makes up the defects of the existing coverage rate statistical analysis tool, and meets the requirements of coverage rate statistical analysis under various scenes.
Drawings
Is free of
Detailed Description
In order to make the objects, contents, and advantages of the present invention clearer, the following detailed description of the embodiments of the present invention will be given in conjunction with examples.
The invention relates to a non-invasive coverage rate statistical method aiming at various processor architectures, which comprises the following steps:
the method for building the embedded software simulation running environment comprises the following steps:
the embedded software simulation running environment adopts the virtualization simulation technology to realize the high-precision and high-performance simulation of a target system, provides the virtualization running environment of the embedded software, and records the instruction execution process and the branch information, and mainly comprises the following steps: the method comprises the steps of target processor kernel instruction set simulation, embedded system peripheral simulation and simulation process control.
Analyzing various architecture target files and debugging information formats comprises:
the analysis of the multiple architecture target files and the debugging information formats mainly analyzes the file format and the debugging information format related to the mainstream embedded processor, acquires the debugging information format corresponding to the processor by analyzing the file format, and acquires the embedded software source code target code corresponding relation information by analyzing the debugging information format.
The mainstream embedded software relates to a plurality of debugging information formats, in order to facilitate the statistics and output of the coverage rate information of the embedded software, a new debugging information format (MidDebugInfo) is defined, and the plurality of debugging information are converted into the debugging information format after being analyzed. The debugging information mainly comprises file information, function information and source code and target code corresponding relation information, wherein the file information comprises a file name, a file path, a target code starting address and a target code ending address corresponding to the file, the function information comprises a function name, a function starting address and a function ending address, and the source code and target code corresponding relation information comprises a source code line number, a target code starting address and a target ending address corresponding to the source code line. In order to facilitate the recording and query of information, a three-level structure information table of files, functions and row number information is established, wherein the files can contain a plurality of functions, and the functions contain a three-level coverage rate information table of a plurality of row number information; when the coverage rate information needs to be updated, inquiring a file where a Basic Block (Basic Block) is located, then inquiring a function where the Basic Block is located, finally sequentially traversing the target code address contained in the Basic Block, and then updating the line number information of the target code interval.
The source code branch information parsing includes:
the source code branch information mainly provides a function of obtaining analysis information of the source code, the embedded processor assembly instruction set comprises various branch instructions, the branch information of the source code cannot be obtained through debugging information format analysis, and the branch information of the source code can be obtained through analyzing the source code.
The coverage information acquisition comprises:
in the process of program simulation execution, after instruction fetching and decoding, the instruction code of the executed instruction can be obtained. By judging the execution code, whether the instruction code is a jump instruction or not and the type of the jump instruction can be obtained. By debugging information format analysis and source code analysis information analysis, the source code corresponding to the instruction, the source code corresponding to the jump instruction and the type corresponding to the jump instruction can be obtained.
In the process of acquiring the coverage rate information, in order to reduce the influence of coverage rate statistics on simulation execution, a Basic Block (Basic Block) of target codes is taken as a minimum statistical unit, the Basic Block comprises a start address, an end address, a Branch Instruction (Branch Instruction) address, execution times and Branch information, and one Basic Block comprises one or more lines of target codes corresponding to source codes.
After the simulation execution starts, judging whether the current instruction is a branch instruction or not, and if not, continuing to execute; if the Current instruction is a branch instruction, the Current address (Current Program Count) is used as the end address of the basic block, and the start address and the end address of the basic block are used as indexes to update the coverage rate lookup table.
The output of the result of the coverage rate statistical analysis comprises the following steps:
and outputting a coverage statistical result, wherein the output of the coverage statistical result mainly provides instruction fetching, decoding, disassembling and information analysis execution, and finally generates a coverage statistical analysis result.
For an embodiment of the present invention, a non-invasive statistical coverage analysis method for various processor architectures includes the following specific steps:
the method for building the embedded software simulation running environment comprises the following steps:
the embedded software simulation operation environment adopts the virtualization simulation technology to realize the high-precision high-performance simulation of a target system, provides the virtualization operation environment of the embedded software, provides a monitoring means of the instruction execution process and state, is an execution platform of an abnormal processing test case of the embedded software, and mainly comprises: the method comprises the steps of target processor kernel instruction set simulation, embedded system peripheral simulation and simulation process control.
The target processor kernel instruction set simulation adopts a dynamic binary compilation method based on LLVM to realize heterogeneous execution of a target instruction under a Windows/Intel host machine architecture, and a target code is separated from an original hardware execution environment; the embedded system peripheral simulation is used for realizing the simulation of target processor peripheral equipment, comprises RS-422 and RS-485 serial port equipment simulation, switching value equipment simulation, storage system simulation and the like, and supports the injection and the acquisition of data excitation; the simulation process control adopts a unified clock scheduling algorithm to realize the execution control and the cooperative operation of all components of the virtual environment.
The analysis of the formats of the various architecture target files and debugging information comprises the following steps:
analyzing a file format and a debugging information format related to the mainstream embedded processor, acquiring the debugging information format corresponding to the processor by analyzing the file format, and acquiring the embedded software source code object code corresponding relation information by analyzing the debugging information format. And a three-level structure information table of file, function and row number information is established, so that the information is conveniently recorded and inquired.
(1) Analyzing a target file of a plurality of processors, determining the type of debugging information according to the structure of the target file, and reading the debugging information;
(2) analyzing the debugging information formats of Dwarf1, Dwarf2, Dwarf3, stab, COFF and OMF51, and converting the debugging information formats into MidDebugInfo;
(3) reading MidDebugInfo debugging information, and judging the node type of the current debugging information;
(4) judging whether the current debugging information node is a file start type node or not, if so, creating a file information recording structure, writing a target code start address corresponding to the file into the current file information recording structure, executing the step (3), and if not, executing the step (5);
(5) judging whether the current debugging information node is a function starting type node or not, if so, creating a function information recording structure, writing a target code starting address corresponding to a function into the current function information recording structure, inserting the current function information structure into a current file information recording mechanism, and executing the step (3), otherwise, executing the step (6);
(6) judging whether the current debugging information node is a line number information type node, if so, creating a line number information recording structure, inserting the current line number information structure into a current function information recording mechanism, and executing the step (3), otherwise, executing the step (7);
(7) judging whether the current debugging information node is a function end type node or not, if so, writing the target code end address corresponding to the function into the current function information recording structure, executing the step (3), and if not, executing the step (8);
(8) judging whether the current debugging information node is a file end type node or not, if so, writing an end address of the target code corresponding to the file into the current file information recording structure, and executing the step (9);
(9) judging whether the reading of the debugging information is finished or not, if not, executing the step (3), otherwise, executing the step (10);
the source code branch information parsing includes:
the source code branch information mainly provides a function of obtaining analysis information of the source code, the embedded processor assembly instruction set comprises various branch instructions, the branch information of the source code cannot be obtained through debugging information format analysis, and the branch information of the source code can be obtained through analyzing the source code.
(10) Acquiring source code path information;
(11) reading in source files one by one according to the three-level query structure table, judging the branch information of the source code row corresponding to the row number information node, and acquiring the branch condition of the source code;
the coverage information acquisition comprises:
in the process of program simulation execution, after instruction fetching and decoding, the instruction code of the executed instruction can be obtained. By judging the execution code, whether the instruction code is a jump instruction or not and the type of the jump instruction can be obtained. By debugging information format analysis and source code analysis information analysis, the source code corresponding to the instruction, the source code corresponding to the jump instruction and the type corresponding to the jump instruction can be obtained.
(12) The embedded software simulation running environment adopts a virtualization simulation technology to realize high-precision high-performance simulation of a target system, provides a virtualization running environment of embedded software, and constructs the embedded software simulation running environment through the environment;
(13) running an embedded simulation environment and loading a target file into a simulation memory;
(14) simulating the execution start, and taking the execution start address as the start address of the first basic block;
(15) reading an instruction, translating the instruction, executing the current instruction and judging whether the current instruction is a branch instruction or not, if not, continuing to execute the step (15), and if so, executing the step (16);
(16) the address corresponding to the current instruction is a basic block end address, and the start address and the end address of the current basic block and the branch information of the branch instruction are recorded;
(17) using the start address and the end address of the basic block as indexes, inquiring the position of the current basic block in a three-level coverage rate information table, determining a line number information structure corresponding to the basic block, and adding the execution times of the corresponding line number information structure together to update branch information;
(18) judging whether the coverage rate is generated or not, if not, continuing to execute the step (15), and if so, executing the step (19);
(19) and writing the information recorded in the coverage rate information lookup table into a file of a specified path in a specific format, and suspending simulation execution. The output format of the coverage rate information is as follows: the basic block starting address, the basic block ending address, the execution times, the branch instruction address and the branch information are divided by colons in the middle;
the output of the result of the coverage rate statistical analysis comprises the following steps:
and outputting a coverage statistical result, wherein the output of the coverage statistical result mainly provides instruction fetching, decoding, disassembling and information analysis execution, and finally generates a coverage statistical analysis result.
(20) And reading the file for recording the coverage rate information according to the three-level structure information table of the file, the function and the line number information, and generating a coverage rate statistical analysis result according to the corresponding relation between the source code and the target code and the branch information of the source file.
The invention realizes the debugging of the software by analyzing the debugging information of the software target file and realizes the statistics of the statement coverage rate and the branch coverage rate of the software by analyzing the DWARF information. The software performance evaluation is realized by abstracting fault types and simulating fault injection of the software and counting the execution times of statements of a tested program and the number of clocks in the simulation execution process. Only the information required by the virtual verification platform is processed in the lexical analysis process, so that the time consumed by the lexical analyzer is reduced. The parallel instruction serialization idea is adopted to solve the DSP instruction parallel problem. In the coverage rate information counting process, only jump instruction information is counted, and the execution efficiency of the simulator is improved.
The above description is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, several modifications and variations can be made without departing from the technical principle of the present invention, and these modifications and variations should also be regarded as the protection scope of the present invention.

Claims (10)

2. The method as claimed in claim 1, wherein the debug information format middebug info is defined, and the debug information format middebug info is converted into the debug information format middebug info after parsing, the debug information includes file information, function information, and source code and object code corresponding relationship information, wherein the file information includes a file name, a file path, an object code start address and an object code end address corresponding to the file, the function information includes a function name, a function start address and a function end address, and the source code and object code corresponding relationship information includes a source code line number, and an object code start address and an object end address corresponding to the line source code.
CN202011280982.6A2020-11-162020-11-16Non-invasive coverage rate statistical method for various processor architecturesWithdrawnCN112395190A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202011280982.6ACN112395190A (en)2020-11-162020-11-16Non-invasive coverage rate statistical method for various processor architectures

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202011280982.6ACN112395190A (en)2020-11-162020-11-16Non-invasive coverage rate statistical method for various processor architectures

Publications (1)

Publication NumberPublication Date
CN112395190Atrue CN112395190A (en)2021-02-23

Family

ID=74600479

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202011280982.6AWithdrawnCN112395190A (en)2020-11-162020-11-16Non-invasive coverage rate statistical method for various processor architectures

Country Status (1)

CountryLink
CN (1)CN112395190A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN114661588A (en)*2022-03-142022-06-24浙江迪捷软件科技有限公司Code execution coverage rate counting method and device and computing equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN114661588A (en)*2022-03-142022-06-24浙江迪捷软件科技有限公司Code execution coverage rate counting method and device and computing equipment

Similar Documents

PublicationPublication DateTitle
CN111813672B (en) A Non-Intrusive Coverage Statistics Method for Multiple Processor Architectures
US8776029B2 (en)System and method of software execution path identification
US8832125B2 (en)Extensible event-driven log analysis framework
US7937692B2 (en)Methods and systems for complete static analysis of software for building a system
US20130318504A1 (en)Execution Breakpoints in an Integrated Development Environment for Debugging Dataflow Progrrams
US20200143061A1 (en)Method and apparatus for tracking location of input data that causes binary vulnerability
US9626170B2 (en)Method and computer program product for disassembling a mixed machine code
US20070011664A1 (en)Device and method for generating an instruction set simulator
JP6342129B2 (en) Source code error position detection apparatus and method for mixed mode program
US20180032320A1 (en)Computer-implemented method for allowing modification of a region of original code
US8347278B2 (en)Instrumenting a compiled software routine for augmentation
CN116501378B (en)Implementation method and device for reverse engineering reduction source code and electronic equipment
CN113806231B (en)Code coverage rate analysis method, device, equipment and medium
CN111813670A (en) A Non-Intrusive MC/DC Coverage Statistical Analysis Method
CN102722438B (en)Kernel debugging method and equipment
JP6357814B2 (en) Analysis of incomplete software
Durfina et al.Detection and recovery of functions and their arguments in a retargetable decompiler
CN112395190A (en)Non-invasive coverage rate statistical method for various processor architectures
CN114968779B (en) A code-oriented application performance analysis method and system
US9710360B2 (en)Optimizing error parsing in an integrated development environment
CN112861138A (en)Software security analysis method and analysis device, electronic device, and storage medium
Pauley et al.Performant binary fuzzing without source code using static instrumentation
Andrzejak et al.Confguru-a system for fully automated debugging of configuration errors
CN114238098B (en)Method and system for dynamically analyzing use condition of embedded software stack based on data breakpoint
LókiCompiler Optimizations and Source Code Analysis

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
WW01Invention patent application withdrawn after publication

Application publication date:20210223

WW01Invention patent application withdrawn after publication

[8]ページ先頭

©2009-2025 Movatter.jp