SSD code coverage rate statistical method and device and related medium
By creating a coverage statistics table in SSD and using interrupt statistics programs and coverage management programs, the problem of insufficient sustainability of SSD code coverage statistics is solved, and the function of restoring statistical information after power-off is realized, meeting the needs of frequent up and down scenarios in SSD tests is achieved, and the sustainability of SSD in coverage statistics is improved.
Patent Information
- Application Number
- CN202510101086.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-22
- Publication Date
- 2025-05-16
AI Technical Summary
In the prior art, the SSD code coverage statistics are insufficient and cannot support power-down statistics, resulting in the loss of statistical information in memory after power-down, which cannot meet the needs of frequent up and down scenarios in SSD tests.
By creating and initializing the coverage statistics table, the registered interrupt statistics program obtains the CPU execution address of the user program in the SSD in the set time period and updates it to the coverage statistics table. Based on the coverage management program in SSD, the periodic coverage statistics table is saved to the NAND memory. When the system powers off and powers on again, the coverage statistics table in the NAND memory is loaded into memory, and the coverage obtaining command is received from the host side, and the coverage statistics table is returned to the host side.
The sustainability of SSD code coverage statistics is achieved, the statistical information is lost after power-off is avoided, the demand for frequent up and down electric scenarios in SSD tests is met, and the sustainability of SSD in coverage statistics is improved.
Smart Images

Figure CN120010782A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a SSD code coverage statistics method, device and related media. Background Art
[0002] In the prior art, the statistics of SSD code coverage are usually calculated in the following two ways: one way is a real-time acquisition method based on hardware devices, which uses a dedicated hardware device (such as JTAG) to collect the instruction execution address of the CPU in real time, and transmits the collected data to the host, and the host side parses and counts the code coverage. This method requires expensive hardware devices and complex hardware wiring, which is not only costly, but also difficult to achieve large-scale deployment. In addition, due to the limitations of data transmission rate and host parsing ability, this method is difficult to achieve real-time coverage statistics when the CPU is running at full speed. Another way is a statistical method based on pile code, which records the execution of user code by inserting auxiliary pile code (Stub Code) in the target code, and stores the statistical information in the SSD memory, or reports it to the host through the serial port for analysis. However, this method can cause the code volume to expand significantly and cannot be loaded into the limited storage space of the SSD. At the same time, the execution of pile code can significantly reduce the program running efficiency and affect the overall performance.
[0003] The above two technologies have limitations in practical applications, that is, they cannot support power-off statistics, resulting in the loss of statistical information in the memory after power-off, and cannot meet the needs of frequent power-on and power-off scenarios in SSD testing. Therefore, the continuity of SSD coverage statistics in the existing technology is insufficient, and it is difficult to effectively ensure the verification integrity of the SSD code. Summary of the invention
[0004] The embodiments of the present invention provide a method, device and related medium for SSD code coverage statistics, aiming to solve the problem of insufficient persistence of SSD coverage statistics in the prior art.
[0005] In a first aspect, an embodiment of the present invention provides a method for calculating SSD code coverage, including:
[0006] Create and initialize the coverage statistics table;
[0007] Using the registered interrupt statistics program to obtain the CPU execution address of the user program in the SSD at a set time period, and updating it to the coverage statistics table;
[0008] Based on the coverage management program in the SSD, the coverage statistics table having periodicity is saved to the NAND memory;
[0009] When the system is powered on again after being powered off, the coverage management program is used to load the coverage statistics table in the NAND memory into the internal memory;
[0010] Receive a coverage acquisition command sent by the host end, and return the coverage statistics table in the memory to the host end according to the coverage acquisition command.
[0011] In a second aspect, an embodiment of the present invention provides an SSD code coverage statistics device, including:
[0012] A data creation unit, used to create and initialize a coverage statistics table;
[0013] A data updating unit, used to obtain the CPU execution address of the user program in the SSD in a set time period by using the registered interrupt statistics program, and update it into the coverage statistics table;
[0014] A data storage unit, configured to save the periodic coverage statistics table to a NAND memory based on a coverage management program in the SSD;
[0015] A data loading unit, used for loading the coverage statistics table in the NAND memory into the internal memory by using the coverage management program when the system is powered on again after being powered off;
[0016] The data returning unit is used to receive a coverage acquisition command sent by the host end, and return the coverage statistics table in the memory to the host end according to the coverage acquisition command.
[0017] In a third aspect, an embodiment of the present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the SSD code coverage statistics method of the first aspect when executing the computer program.
[0018] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the SSD code coverage statistics method of the first aspect is implemented.
[0019] The embodiment of the present invention provides a method for SSD code coverage statistics, including creating and initializing a coverage statistics table; using a registered interrupt statistics program to obtain the CPU execution address of the user program in the SSD at a set time period, and updating it to the coverage statistics table; based on the coverage management program in the SSD, saving the periodic coverage statistics table to the NAND memory; when the system is powered on again after powering off, using the coverage management program to load the coverage statistics table in the NAND memory to the memory; receiving a coverage acquisition command issued by the host side, and returning the coverage statistics table in the memory to the host side according to the coverage acquisition command. The present invention saves the periodic coverage statistics table to the NAND memory, and then loads it from the NAND memory to the memory. When it is necessary to obtain it, the coverage statistics table can be returned to the host side through the coverage acquisition command. In this way, the statistical information in the memory can be restored when it is powered on again after powering off, meeting the needs of frequent power-on and power-off scenarios in SSD testing, and improving the continuity of SSD in coverage statistics.
[0020] The embodiment of the present invention also provides an SSD code coverage statistics device, a computer device and a storage medium, which also have the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0022] Figure 1 A schematic diagram of a flow chart of a SSD code coverage statistics method provided by an embodiment of the present invention;
[0023] Figure 2 A schematic diagram of a framework of an SSD code coverage statistics method provided by an embodiment of the present invention;
[0024] Figure 3 Another schematic diagram of a flow chart of a SSD code coverage statistics method provided by an embodiment of the present invention;
[0025] Figure 4 A schematic block diagram of an SSD code coverage statistics device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0026] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0027] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0028] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0029] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0030] See below Figure 1 , Figure 1 A flowchart of a SSD code coverage statistics method provided by an embodiment of the present invention specifically includes: steps S101 to S105.
[0031] S101, create and initialize a coverage statistics table;
[0032] S102, using the registered interrupt statistics program to obtain the CPU execution address of the user program in the SSD at a set time period, and updating it to the coverage statistics table;
[0033] S103, based on the coverage management program in the SSD, saving the periodic coverage statistics table to the NAND memory;
[0034] S104, when the system is powered on again after being powered off, using the coverage management program to load the coverage statistics table in the NAND memory into the internal memory;
[0035] S105, receiving a coverage acquisition command sent by the host end, and returning the coverage statistics table in the memory to the host end according to the coverage acquisition command.
[0036] Combination Figure 2 As shown, the code part of the corresponding embedded code coverage statistical method in the present invention is divided into the following three parts:
[0037] Part 1: User program, the original traditional SSD internal program, used to access the service host;
[0038] The second part: interrupt statistics program is used to execute periodically according to the set time frequency. Each time it is executed, the CPU execution address of the current user program (cur_cpu_ptr) is obtained, and the corresponding table value of the coverage statistics table in the memory is incremented (cov_tbl_in_mem[cur_cpu_ptr]++);
[0039] Part 3: Coverage management program, used to save the coverage table in memory (cov_tbl_in_mem) to NAND (cov_tbl_in_nand), or load it from NAND memory to memory.
[0040] Furthermore, a coverage statistics table (cov_tbl_in_mem) is stored in the memory to update the frequency of user program access. Its index is the user program address, and its value is the number of times the corresponding program address is accessed. A coverage statistics table (cov_tbl_in_nand) is stored in the NAND memory to periodically save the coverage table in the memory so that it can be loaded into the memory to continue statistics after power failure. The host side can issue user-defined VU commands through the standard PCIe / NVMe driver to obtain the latest coverage information. The SSD can return the coverage statistics table in the memory to the host side.
[0041] Combination Figure 3 As shown, in step S101, in the mass production stage of the SSD, a coverage statistics table may be created through a coverage management program and the coverage statistics table may be initialized.
[0042] In step S102, the registered interrupt statistics program runs inside the SSD, and the interrupt is triggered according to the time period set by the user (for example, 1 millisecond). Each time the interrupt is triggered, the statistics program obtains the CPU execution address (cur_cpu_ptr) of the current user program and updates the coverage statistics table in the memory. By periodically collecting the code execution address, the real-time recording of the SSD user program execution path is achieved, and the impact on the SSD performance is very low.
[0043] In step S103, to ensure the persistence of statistical data, the coverage management program will periodically (or before the system is powered off) write the coverage statistics table (cov_tbl_in_mem) in the memory into the coverage statistics table (cov_tbl_in_nand) in the NAND memory in batches. This design can effectively avoid the problem of data loss during power off and achieve long-term preservation of coverage data.
[0044] In step S104, when the system is powered on again after being powered off, the coverage management program will reload the coverage statistics table (cov_tbl_in_nand) in the NAND memory into the coverage statistics table (cov_tbl_in_mem) in the memory. In this way, the statistics of the previous test phase can be accumulated in the new test cycle, thereby achieving the continuity of coverage statistics.
[0045] In step S105, the SSD supports the host to send a coverage acquisition command (ie, a VU command) through a standard PCIe / NVMe interface. After receiving the command, the coverage management program returns the coverage statistics table (cov_tbl_in_mem) in the memory to the host for statistical analysis and code coverage evaluation.
[0046] In one embodiment, the step S101 includes:
[0047] Creating the coverage statistics table, and corresponding each table entry of the coverage statistics table to each CPU execution address of the user program in sequence;
[0048] Setting all table items of the coverage statistics table to initial values;
[0049] The table entry address of the coverage rate statistics table is mapped to the memory, so that the coverage rate statistics table can be updated in real time.
[0050] In this embodiment, the coverage statistics table is divided into a coverage statistics table in memory (cov_tbl_in_mem) and a coverage statistics table in NAND memory (cov_tbl_in_nand). Each table entry is indexed by the CPU execution address of the user program, and its corresponding value records the access frequency of the address. In order to achieve real-time update, a one-to-one mapping relationship is established between the table address of the coverage statistics table and the physical address in the memory. In this way, during the operation of the user program, the access status of the CPU execution address can be directly reflected in the corresponding table entry of the coverage statistics table. In order to ensure the correctness and consistency of the coverage statistics, all table entries need to be initialized after the coverage statistics table is created, and the values of all table entries in the coverage statistics table are set to the initial value 0, indicating that no code address has been accessed at present. The initialized coverage statistics table is written to the coverage statistics table (cov_tbl_in_nand) in the NAND memory to ensure the basic data consistency of the coverage statistics table during the SSD mass production or deployment stage.
[0051] Furthermore, the coverage management program can map the coverage statistics table to the memory in the following way: establish a direct mapping relationship between each CPU execution address of the user program and the table entry address of the coverage statistics table in the memory. Whenever the interrupt statistics program obtains the CPU execution address (cur_cpu_ptr) of the current user program, it can directly locate the corresponding table entry in the coverage statistics table through the index. Through the mapping relationship, when the user program is running, the table entry value of the coverage statistics table can be dynamically incremented according to each access, reflecting the code execution path of the user program in real time.
[0052] In one embodiment, the step S102 includes:
[0053] Register the interrupt statistics program to the interrupt service list of the SSD, and set the time period as a trigger condition;
[0054] When the time period is triggered, the CPU execution address of the currently running user program is obtained;
[0055] Using the CPU execution address, searching the memory for an entry corresponding to the coverage statistics table;
[0056] The table entry corresponding to the CPU execution address in the coverage statistics table is incremented in value to record the number of accesses to the CPU execution address, and the coverage statistics table is updated at the same time.
[0057] In this embodiment, the coverage management program runs inside the SSD, registers the interrupt statistics program in the interrupt service list of the SSD, and sets a time period as the interrupt trigger condition. The time period is a fixed interval time that can be customized by the user, such as 1 millisecond (1ms). When the set time is reached, the interrupt service mechanism will automatically call the interrupt statistics program. Each time it is triggered, the interrupt statistics program obtains the CPU execution address of the current user program and updates the corresponding table entry in the coverage statistics table. When the interrupt is triggered, the interrupt statistics program starts running and collects the CPU instruction address of the currently executing user program. The interrupt statistics program obtains the CPU execution address (cur_cpu_ptr) of the currently running user program by accessing the CPU status register or program counter (PC, Program Counter). The interrupt statistics program only collects the address at the current moment in each time period, which can avoid affecting the overall performance of the SSD.
[0058] Furthermore, using the collected CPU execution address, the interrupt statistics program searches for the table entry corresponding to the address in the coverage statistics table (cov_tbl_in_mem) in the memory. The index of the coverage statistics table is the CPU execution address of the user program. Through the fast mapping relationship, the corresponding table entry in the memory can be directly located. Since the coverage statistics table is designed as an efficient memory structure, the search operation can be completed in a very short time, thereby ensuring the real-time performance of the statistics program.
[0059] Furthermore, after locating the corresponding table entry, the interrupt statistics program increments the table entry value to record the access frequency of the CPU execution address. The value of the current table entry is increased by 1, indicating that the CPU execution address has been accessed once (cov_tbl_in_mem[cur_cpu_ptr]++). After the increment operation is completed, the data in the coverage statistics table is immediately updated to reflect the execution path of the user program in real time.
[0060] In one embodiment, when the time period is triggered, obtaining the CPU execution address of the currently running user program includes:
[0061] The CPU status reading function is called through the interrupt statistics program to obtain the CPU execution address of the currently running user program;
[0062] Verify whether the current CPU execution address belongs to the valid address of the user program; if the CPU execution address is valid, use the CPU execution address as the key value; if the CPU execution address is invalid, skip and verify the CPU execution address of the next running user program.
[0063] In this embodiment, after the interrupt statistics program is triggered, the CPU status reading function inside the SSD is first called to obtain the CPU execution address of the currently running user program. By accessing the CPU status register or program counter (Program Counter, PC), the CPU execution address (cur_cpu_ptr) of the user program at the current moment is directly read. To ensure the accuracy of the coverage statistics, it is necessary to verify whether the obtained CPU execution address is a valid address of the user program. The effective address refers to the address within the range of the legal code segment of the user program. This range can be pre-defined by the SSD firmware when loading the user program, usually including the starting address and ending address of the user program. The interrupt statistics program makes the following judgment on the currently obtained cur_cpu_ptr:
[0064] If cur_cpu_ptr is within the user program address range, the address is considered valid and serves as the key value for subsequent statistical operations.
[0065] If cur_cpu_ptr exceeds the user program address range, the address is considered invalid. At this time, skip the address and wait for the next interrupt to be triggered to verify the CPU execution address for the next run.
[0066] Through address verification, we ensure that only the code execution of the user program is counted, and exclude the interference of other addresses (such as interrupt service routines or hardware driver codes) on the statistical data. After filtering invalid addresses, only the execution path of the user program is recorded in the coverage statistics table, thereby improving the accuracy of code coverage analysis. Through the fast verification mechanism, the resource waste caused by invalid addresses is reduced, and the statistical efficiency is further optimized.
[0067] In one embodiment, the step S103 includes:
[0068] Determine whether the coverage statistics table needs to be saved in the NAND memory, and if necessary, serialize the coverage statistics table according to a predefined data format to adapt to the storage structure of the NAND memory;
[0069] The data writing interface in the coverage management program is called to write the serialized coverage statistics table into the designated storage area of the NAND memory.
[0070] In this embodiment, the coverage management program first determines whether the coverage statistics table (cov_tbl_in_mem) in the memory needs to be saved to the NAND memory (cov_tbl_in_nand). If it is determined that the coverage statistics table needs to be saved, it is serialized to adapt to the storage structure of the NAND memory. Serialization is to convert the data of the coverage statistics table from the efficient access format in the memory to a linear data format suitable for storage. The coverage statistics table (cov_tbl_in_mem) in the memory includes the table entry index (code address) and the table entry value (number of accesses).
[0071] Furthermore, the coverage management program calls the data writing interface to write the serialized coverage statistics table into the specified storage area of the NAND memory. A storage area is pre-allocated in the NAND memory to store the coverage statistics table (cov_tbl_in_nand). The write operation is performed in blocks according to the size of the coverage statistics table to ensure the continuity of the data in the memory. The writing process is as follows: determine the storage start address; write the serialized data in blocks to the NAND memory according to the predefined block size; perform verification after each block is written to ensure that the data is correct; update the metadata of the storage area (such as the latest save time, data size, etc.) after the write is completed.
[0072] In one embodiment, the step S104 includes:
[0073] Locating, by means of the coverage management program, a target storage area in the NAND memory storing the coverage statistics table;
[0074] Extracting serialized data of the coverage statistics table from the target storage area;
[0075] The extracted serialized data is decoded to restore the original coverage statistics table structure, and the decoded coverage statistics table is loaded into the memory.
[0076] In this embodiment, the coverage management program needs to locate the storage location of the coverage statistics table in the NAND memory. The serialized data of the coverage statistics table is stored in a predefined storage area in the NAND memory, which is specified by the coverage management program during the system mass production stage and records the meta information of the coverage statistics table (such as the starting address, size, and verification information). The coverage management program reads the meta information record in the NAND memory. The starting address and storage length of the coverage statistics table are determined based on the meta information, thereby determining the target storage area.
[0077] Furthermore, after locating the target storage area, the coverage management program extracts the serialized data of the coverage statistics table from the NAND memory. According to the starting address and storage length of the target storage area, the serialized data of the coverage statistics table is read in blocks; after each reading, a data integrity check (such as CRC check) is performed to ensure that the data is not damaged; if the check passes, the read data is temporarily stored in the memory buffer for subsequent decoding operations. Through the data verification mechanism, data errors caused by NAND memory write failure or power off can be effectively avoided to ensure the correctness of the statistics table.
[0078] Furthermore, the extracted serialized data needs to be restored to the original coverage statistics table structure through decoding so that it can be loaded into the memory. Decoding is performed in reverse according to the serialization format of the coverage statistics table, parsing the linearized data stream into a table entry structure. Each table entry includes an index (CPU execution address) and a corresponding value (access frequency), which are restored one by one in the sorting order when stored. The decoding process is as follows: read the table entry information in the serialized data, parse out the index and value respectively according to the predefined format; check the integrity of each table entry to ensure that the data is consistent with that when stored; gradually rebuild the memory structure (cov_tbl_in_mem) of the coverage statistics table, including the mapping relationship between the table entry index and the memory address. After decoding is completed, the restored coverage statistics table is loaded into the memory to continue the code coverage statistics. The decoded table entries are written one by one into the pre-allocated coverage statistics table area (cov_tbl_in_mem) in the memory to ensure that the index (code address) of each table entry is correctly mapped to the memory address, so that the subsequent interrupt statistics program can directly update the table entry value. After loading is complete, the coverage statistics table can continue to accumulate based on previous statistical results, supporting continuous statistics after power off. The statistical data read by the host through commands will include the execution path information before and after power off, ensuring the integrity of the code coverage analysis.
[0079] In one embodiment, the step S105 includes:
[0080] Parsing the coverage acquisition command through the built-in command processing module of the SSD to obtain the coverage statistical range;
[0081] Retrieve and extract the coverage rate statistics table in the memory according to the coverage rate statistics range;
[0082] The extracted coverage statistics table is packaged according to a preset data transmission format and transmitted to the host end through the communication interface of the SSD.
[0083] In this embodiment, when the host sends a coverage acquisition command, the built-in command processing module of the SSD parses the command and extracts relevant information such as the coverage statistical range. The built-in command processing module of the SSD can process host instructions received through a standard interface (such as PCIe / NVMe). For the coverage acquisition command, the module parses the parameter field in the command to determine the coverage statistical range required by the host. The host can specify to obtain coverage statistical data of part of the user program (for example, specify a certain code address range), or request the entire coverage statistical table. The parsing results include the starting address and ending address of the statistical range, which are used for subsequent data retrieval operations.
[0084] Furthermore, according to the coverage statistics range obtained by the analysis, the SSD retrieves and extracts the corresponding data from the coverage statistics table (cov_tbl_in_mem) in the memory. That is, the coverage management program calculates the range of table items that need to be extracted based on the statistical range parameters. The index (code address) and value (access frequency) of the corresponding table item are read one by one from cov_tbl_in_mem. If the host requests full table data, the coverage statistics table in the entire memory is traversed directly. If a specified range of data is requested, only the table items within the range are extracted to reduce data transmission and processing overhead.
[0085] During the encapsulation process, checksum information (such as CRC checksum) is added to ensure data integrity and avoid data corruption during transmission. If the amount of statistical data is large, it is encapsulated in blocks according to the block size (such as 4KB or 8KB), and each block is attached with a block number and checksum so that the host can parse and verify it block by block. After encapsulation, the coverage statistics data is transmitted to the host through the communication interface of the SSD (such as PCIe / NVMe). The PCIe / NVMe interface supports high-speed data transmission and can quickly send the encapsulated coverage statistics data to the host. The host receives and parses the data through a custom driver. The transmission process is as follows: initialize the data transmission module and establish a communication channel between the SSD and the host; send data block by block in the order of the encapsulated blocks, and wait for the host to confirm after each block is sent; after the host confirms receipt, continue to send the next block of data until all data is sent; after the transmission is completed, clean up the temporary buffer and release the storage resources.
[0086] The present invention establishes a coverage statistics table inside the SSD, combines an interrupt statistics program and a coverage management program, and realizes real-time collection, persistent storage and continuous statistics of code coverage data. Compared with the prior art, the present invention does not need to rely on expensive hardware equipment or introduce redundant stub codes, avoiding the problems of high hardware cost, performance degradation and code expansion. At the same time, by periodically saving the coverage statistics table in the NAND memory and restoring it to the memory after power off, the present invention solves the problem of statistical continuity in the prior art that cannot support power-off scenarios. In addition, by combining the host-side coverage acquisition command with the SSD communication interface, the present invention supports the host to flexibly obtain statistical data to meet the diverse needs of code coverage analysis. In summary, the present invention improves the sustainability of code coverage statistics.
[0087] Combination Figure 4 As shown, Figure 4 A schematic block diagram of an SSD code coverage statistics device provided by an embodiment of the present invention, the SSD code coverage statistics device 400 includes:
[0088] A data creation unit 401 is used to create and initialize a coverage statistics table;
[0089] The data updating unit 402 is used to obtain the CPU execution address of the user program in the SSD in a set time period by using the registered interrupt statistics program, and update it into the coverage statistics table;
[0090] A data storage unit 403 is used to save the periodic coverage statistics table to a NAND memory based on a coverage management program in the SSD;
[0091] A data loading unit 404 is used to load the coverage statistics table in the NAND memory into the internal memory by using the coverage management program when the system is powered on again after being powered off;
[0092] The data returning unit 405 is used to receive a coverage acquisition command sent by the host end, and return the coverage statistics table in the memory to the host end according to the coverage acquisition command.
[0093] In this embodiment, the data creation unit 401 creates and initializes a coverage statistics table; the data update unit 402 uses a registered interrupt statistics program to obtain the CPU execution address of the user program in the SSD at a set time period, and updates it to the coverage statistics table; the data preservation unit 403 saves the periodic coverage statistics table to the NAND memory based on the coverage management program in the SSD; the data loading unit 404 uses the coverage management program to load the coverage statistics table in the NAND memory to the internal memory when the system is powered on again after being powered off; the data return unit 405 receives the coverage acquisition command issued by the host end, and returns the coverage statistics table in the internal memory to the host end according to the coverage acquisition command.
[0094] In one embodiment, the data creation unit 401 includes:
[0095] An address adjustment unit, used for creating the coverage statistics table, and corresponding each table entry of the coverage statistics table to each CPU execution address of the user program in sequence;
[0096] A value setting unit, used to set all items of the coverage statistics table to initial values;
[0097] The table entry mapping unit is used to map the table entry address of the coverage rate statistics table with the memory, so that the coverage rate statistics table can be updated in real time.
[0098] In one embodiment, the data updating unit 402 includes:
[0099] A condition setting unit, used for registering the interruption statistics program to the interruption service list of the SSD, and setting a time period as a trigger condition;
[0100] An address acquisition unit, used for acquiring a CPU execution address of a currently running user program when the time period is triggered;
[0101] A value search unit, used for searching the table entry corresponding to the coverage statistics table in the memory by using the CPU execution address;
[0102] The table updating unit is used to increment the value of the table entry corresponding to the CPU execution address in the coverage statistics table to record the number of times the CPU execution address is accessed, and to update the coverage statistics table at the same time.
[0103] In one embodiment, the address acquisition unit includes:
[0104] A function calling unit, used to call a CPU status reading function through the interrupt statistics program to obtain a CPU execution address of a currently running user program;
[0105] The address verification unit is used to verify whether the current CPU execution address belongs to the valid address of the user program; if the CPU execution address is valid, the CPU execution address is used as the key value; if the CPU execution address is invalid, the CPU execution address of the next running user program is skipped and verified.
[0106] In one embodiment, the data storage unit 403 includes:
[0107] a format adjustment unit, configured to determine whether the coverage statistics table needs to be saved in the NAND memory, and if necessary, serialize the coverage statistics table according to a predefined data format to adapt to the storage structure of the NAND memory;
[0108] The interface writing unit is used to call the data writing interface in the coverage management program to write the serialized coverage statistics table into the designated storage area of the NAND memory.
[0109] In one embodiment, the data loading unit 404 includes:
[0110] A numerical storage unit, used for locating a target storage area storing the coverage statistics table in the NAND memory through the coverage management program;
[0111] A value extraction unit, used for extracting serialized data of the coverage statistics table from the target storage area;
[0112] The numerical decoding unit is used to decode the extracted serialized data to restore the original coverage statistics table structure and load the decoded coverage statistics table into the memory.
[0113] In one embodiment, the data returning unit 405 includes:
[0114] A range acquisition unit, used for parsing the coverage acquisition command through a command processing module built into the SSD to obtain a coverage statistical range;
[0115] A range retrieval unit, used for retrieving and extracting the coverage rate statistics table in the memory according to the coverage rate statistics range;
[0116] The data encapsulation unit is used to encapsulate the extracted coverage statistics table according to a preset data transmission format, and transmit it to the host end through the communication interface of the SSD.
[0117] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.
[0118] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed, the steps provided in the above embodiment can be implemented. The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0119] The embodiment of the present invention also provides a computer device, which may include a memory and a processor, wherein a computer program is stored in the memory, and when the processor calls the computer program in the memory, the steps provided in the above embodiment may be implemented. Of course, the computer device may also include various network interfaces, power supplies and other components.
[0120] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of this application.
[0121] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises", "comprising" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. A SSD code coverage statistics method, characterized in that: include: Create and initialize the coverage statistics table; Using the registered interrupt statistics program to obtain the CPU execution address of the user program in the SSD at a set time period, and updating it to the coverage statistics table; Based on the coverage management program in the SSD, the coverage statistics table having periodicity is saved to the NAND memory; When the system is powered on again after being powered off, the coverage management program is used to load the coverage statistics table in the NAND memory into the internal memory; Receive a coverage acquisition command sent by the host end, and return the coverage statistics table in the memory to the host end according to the coverage acquisition command.
2. The SSD code coverage statistics method according to claim 1, characterized in that: The creation and initialization of the coverage statistics table includes: Creating the coverage statistics table, and corresponding each table entry of the coverage statistics table to each CPU execution address of the user program in sequence; Setting all table items of the coverage statistics table to initial values; The table entry address of the coverage rate statistics table is mapped to the memory, so that the coverage rate statistics table can be updated in real time.
3. The SSD code coverage statistics method according to claim 1, characterized in that: The registered interrupt statistics program is used to obtain the CPU execution address of the user program in the SSD in a set time period and update it to the coverage statistics table, including: Register the interrupt statistics program to the interrupt service list of the SSD, and set the time period as a trigger condition; When the time period is triggered, the CPU execution address of the currently running user program is obtained; Using the CPU execution address, searching the memory for an entry corresponding to the coverage statistics table; The table entry corresponding to the CPU execution address in the coverage statistics table is incremented in value to record the number of accesses to the CPU execution address, and the coverage statistics table is updated at the same time.
4. The SSD code coverage statistics method according to claim 3, characterized in that: When the time period is triggered, obtaining the CPU execution address of the currently running user program includes: The CPU status reading function is called through the interrupt statistics program to obtain the CPU execution address of the currently running user program; Verify whether the current CPU execution address belongs to the valid address of the user program; if the CPU execution address is valid, use the CPU execution address as the key value; if the CPU execution address is invalid, skip and verify the CPU execution address of the next running user program.
5. The SSD code coverage statistics method according to claim 1, characterized in that: The coverage management program based on the SSD saves the periodic coverage statistics table to the NAND memory, including: Determine whether the coverage statistics table needs to be saved in the NAND memory, and if necessary, serialize the coverage statistics table according to a predefined data format to adapt to the storage structure of the NAND memory; The data writing interface in the coverage management program is called to write the serialized coverage statistics table into the designated storage area of the NAND memory.
6. The SSD code coverage statistics method according to claim 1, characterized in that: The using the coverage management program to load the coverage statistics table in the NAND memory into the internal memory comprises: Locating, by means of the coverage management program, a target storage area in the NAND memory storing the coverage statistics table; Extracting serialized data of the coverage statistics table from the target storage area; The extracted serialized data is decoded to restore the original coverage statistics table structure, and the decoded coverage statistics table is loaded into the memory.
7. The SSD code coverage statistics method according to claim 1, characterized in that: The receiving a coverage acquisition command sent by the host end, and returning the coverage statistics table in the memory to the host end according to the coverage acquisition command, includes: Parsing the coverage acquisition command through the built-in command processing module of the SSD to obtain the coverage statistical range; Retrieve and extract the coverage rate statistics table in the memory according to the coverage rate statistics range; The extracted coverage statistics table is packaged according to a preset data transmission format and transmitted to the host end through the communication interface of the SSD.
8. A SSD code coverage statistics device, characterized in that: include: A data creation unit, used to create and initialize a coverage statistics table; A data updating unit, used to obtain the CPU execution address of the user program in the SSD in a set time period by using the registered interrupt statistics program, and update it into the coverage statistics table; A data storage unit, configured to save the periodic coverage statistics table to a NAND memory based on a coverage management program in the SSD; A data loading unit, used for loading the coverage statistics table in the NAND memory into the internal memory by using the coverage management program when the system is powered on again after being powered off; The data returning unit is used to receive a coverage acquisition command sent by the host end, and return the coverage statistics table in the memory to the host end according to the coverage acquisition command.
9. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the SSD code coverage statistics method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the SSD code coverage statistics method according to any one of claims 1 to 7 is implemented.