Program testing method, device, electronic device and storage medium
By monitoring device information and obtaining process information without interrupting the operation of the processor, the problem of the processor in the EJTAG abnormal state for a long time in the existing technology is solved, and the accuracy of program analysis and the stability of the processor operation are improved. .
Patent Information
- Application Number
- CN202111676623.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-31
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2041-12-31
AI Technical Summary
In the existing technology, the process of reading device information from EJTAG dmseg puts the processor in the EJTAG abnormal state for a long time, causing indicators such as CPU TIMER to deviate from the actual situation, affecting the accuracy of program analysis.
Through the debugging interface of the processor, the device information is monitored without changing the device execution state, and process information is obtained when an exception handling address is detected to reduce the time the processor is in an abnormal state.
It reduces the time the processor is in an abnormal state, improves the accuracy of program analysis and the stability of normal operation of the processor.
Smart Images

Figure CN116414682B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and in particular, relates to a program testing method, device, electronic device and storage medium. Background Art
[0002] Generally, software needs to be debugged and performance optimized during the software development phase, or when an exception occurs in the operating system, information such as registers and processes needs to be analyzed. However, when debugging software, especially for released versions of software, which often do not have integrated debugging functions, debugging is very difficult. The processor may include some debugging interfaces for debugging the processor. Common debugging interfaces include JTAG (Joint Test Action Group) debugging interface and EJTAG (Enhanced Joint Test Action Group) debugging interface.
[0003] In the prior art, in the process of debugging the processor, different debugging methods are determined according to the different protocols followed by the debugging interface. For some debugging interfaces, when the processor enters the debugging mode (i.e., the state of debugging the processor), the processor core will stop running, and the processor core will not return to the normal operating state until the debugging mode ends. Exemplarily, the method of debugging using the EJTAG interface is to control the processor to enter the EJTAG abnormal state by repeatedly accessing the three registers ADDRESS (address register), DATA (data register), and CONTROL (control register) corresponding to the EJTAG interface in the processor, and then obtain the device information when the processor enters the abnormal state in the EJTAG dmseg (fault register), and control the processor to exit the EJTAG abnormality after completing the device information acquisition, and return to the position before the EJTAG abnormality to continue the normal operation process.
[0004] However, in the existing debugging method, the process of reading device information from EJTAG dmseg will cause the processor to be in an EJTAG abnormal state for a long time, so that indicators such as the processor's central processing unit timer (CPU TIMER) deviate from the actual situation, resulting in a deviation between the obtained test data and the data when the program is actually running, thereby affecting the accuracy of program analysis. Summary of the invention
[0005] In view of this, the embodiments of the present application propose a program testing method, device, electronic device and storage medium, which are used to solve the problem in the prior art that the process of reading device information from the dmseg space will cause the processor to be in an EJTAG abnormal state for a long time, causing the processor's CPU TIMER and other indicators to deviate from the actual situation, resulting in a deviation between the obtained test data and the data when the program is actually running, thereby affecting the accuracy of program analysis.
[0006] A first aspect of the present application provides a program testing method, the method comprising:
[0007] When a test program is run on a device under test provided with a processor, the terminal monitors device information of the device under test through a target register corresponding to a debug interface of the processor without changing an execution state of the device under test;
[0008] The terminal writes an execution instruction carrying an exception handling address into the debugging interface of the processor, so that the processor executes the execution instruction;
[0009] When detecting that the exception handling address exists in the device information, obtaining process information from the debugging interface of the processor so that the processor runs normally;
[0010] The device information and the process information are tested and analyzed.
[0011] Optionally, the target register includes: a PC sampling register, and the terminal monitors the device information of the device under test through the target register corresponding to the debug interface of the processor without changing the execution state of the device under test, including:
[0012] The terminal monitors the device information of the device under test through the PC sampling register corresponding to the debugging interface of the processor without changing the execution state of the device under test.
[0013] Optionally, the testing and analyzing the device information and the process information includes:
[0014] Dividing the process information into target process information corresponding to each process;
[0015] A process function corresponding to the target process information that meets the test requirements is obtained, and the obtained process function is used as an analysis result.
[0016] Optionally, dividing the process information into target process information corresponding to each process includes:
[0017] In the case where the test program uses a memory management unit to switch processes, the process information is divided according to breakpoints in the device information to obtain target process information corresponding to each process, and the execution code of the breakpoint is pre-set in the process switching function of the program.
[0018] Optionally, dividing the process information into target process information corresponding to each process includes:
[0019] In the case where the test program does not use a memory management unit to switch processes, the process number in the device information is analyzed to divide the process information and obtain target process information corresponding to each process.
[0020] Optionally, when the debug interface support window is configured to the memory, the execution instruction is configured to map the exception handling address window to a memory address location.
[0021] Optionally, when the debugging interface does not support window configuration to memory, the execution instruction is configured to instruct the processor to jump to memory to access the exception handling address.
[0022] According to a second aspect of the present application, a program testing device is provided, the device comprising:
[0023] A monitoring module, configured to enable a terminal to monitor device information of a device under test through a target register corresponding to a debugging interface of the processor without changing an execution state of the device under test when a test program is run on the device under test provided with a processor;
[0024] A writing module configured to enable the terminal to write an execution instruction carrying an exception handling address into the debugging interface of the processor, so that the processor executes the execution instruction;
[0025] an acquisition module, configured to acquire process information from a debugging interface of the processor when detecting that the exception handling address exists in the device information, so as to enable the processor to run normally;
[0026] The analysis module is configured to test and analyze the device information and the process information.
[0027] According to the third aspect of the present application, an electronic device is provided, comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the test method of the program described in the first aspect.
[0028] According to a fourth aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the test method of the program described in the first aspect is implemented.
[0029] With respect to the prior art, this application has the following advantages:
[0030] The present application provides a program testing method, apparatus, electronic device and storage medium. In the process of a processor running a program, the scheme monitors device information through a target register corresponding to a debugging interface of the processor without interrupting the normal operation of the processor, and determines that the processor enters an abnormal state when an abnormal access address is included in the monitored device information, thereby obtaining process information from the debugging interface, so that the device under test runs normally, and the obtained device information and process information are used for test analysis, thereby minimizing the time that the processor is in an abnormal state during the program testing process, thereby reducing the impact on the normal operation of the processor.
[0031] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0033] Figure 1 This is a schematic diagram of a hardware debugging connection provided by an embodiment of the present application;
[0034] Figure 2 It is a standard state machine transition diagram of JTAG provided in an embodiment of the present application;
[0035] Figure 3 It is a flowchart of a method for testing a program provided in an embodiment of the present application;
[0036] Figure 4 is a flowchart of the steps of another program testing method provided in an embodiment of the present application;
[0037] Figure 5 It is a structural block diagram of a program testing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0038] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0039] Figure 1 This is a schematic diagram of hardware debugging connection. The terminal is connected to the debugged processor through the emulator. The program code is compiled in the terminal, and the compiled generated code is downloaded to the processor's memory through the emulator.
[0040] like Figure 1 As shown, the aforementioned terminal may be a debugging host, which is connected to a test access port channel (TAP access) via interfaces such as Ethernet and / or RS-232 (asynchronous transmission standard interface). In a specific implementation, the test access port channel may be an EJTAG emulator, which is used to perform EJTAG detection (EJTAG probe) and is connected to a system prototype (System Prototype) via an interface (JTAG TAP interface) of a JTAG test access port type, wherein in the system prototype, other system logic (Other System Logic) is connected to a system on chip (SOC, System OnChip), an application specific integrated circuit (ASIC, Application Specific Integrated Circuit) and / or an application specific standard product (ASSP, Application Specific Standard Parts) via a JTAG scan chain (JTAG scan chain); wherein the system on chip, the application specific integrated circuit or the application specific standard product are respectively a system on chip, an application specific integrated circuit and / or an application specific standard product including a central processing unit (such as CPU with EJTAG) having a debugging interface.
[0041] In order to illustrate the debugging process of the processor, the EJTAG boundary test is taken as an example to introduce the debugging implementation details of the processor.
[0042] The EJTAG standard adds three registers: address (ADDRESS), data (DATA), and control (CONTROL) on the basis of the JTAG standard to control and record the status of the processor. Figure 2This is the standard state machine transition diagram of JTAG. TAP access plays an important role in the implementation of the JTAG standard. The control of TAP aceess is completed by the TAP controller. The TAP controller mainly includes four logic signals, namely TCK signal (clock signal), TMS signal (state machine transition signal), TDI signal and TDO signal (input and output signals). The three logic signals of TMS signal, TDI signal and TDO signal need to be synchronized with the TCK signal, that is, according to the beat of the TCK signal, drive each bit of data from TDI input and drive each bit of data from TDO output; each TAP controller accesses two types of registers, namely IR (instruction register) and DR (data register). The data register (DR) is used to monitor and control the input and output of the processor, and the instruction register (IR) is used to realize the control of the data register. For example, the data register determined by the instruction in the instruction register is contained between the TDI signal pin and the TDO signal pin.
[0043] exist Figure 2 The 16 synchronization state transition mechanisms of the TAP controller are shown in the figure. Each synchronization state is described below. In the following content, low level is represented by 0 and high level is represented by 1. First, after the system is powered on, the TAP controller enters the Test-Logic-Reset state (test logic reset state); then, the TAP controller takes the test logic reset state as the starting point and changes the TMS signal to a high level / low level according to the rising edge of the TCK signal (see Figure 2 The TAP controller jumps to the corresponding intermediate state according to the TMS signal being at a high level or a low level at the rising edge of the TCK signal in each intermediate state, until reaching the end state. The intermediate states and end states to which the TAP controller can jump include Run-Test / Idle, Select-DR-Scan, Capture-DR, Shift-DR, Exitl-DR, Pause-DR, Exit2-DR, Update-DR, Select-IR-Scan, Capture-IR, Shift-IR, Exitl-IR, Pause-IR, Exit2-IR, Update-IR.
[0044] In an embodiment of the present application, the processor is locally configured with a control register, an address register, and a data register for the debug interface, and the terminal can directly access the above three registers through the debug interface. Among them, the first designated bit in the control register contains whether the processor has an access request sent to the fault register of the debug interface; the second designated bit in the control register contains whether the access request sent by the processor is a read request or a write request; the third designated bit in the control register contains the read and write width of the above access request; the above first designated bit, second designated bit, and third designated bit are positions pre-set according to actual conditions. Exemplarily, PRACC (bit 18) of the control register is the first designated bit, PRnW (bit 19) of the control register is the second designated bit, and the Psz bit of the control register is the third designated bit. The data register is used to store data / instructions; the address register is used to store the address of the access instruction (read instruction / write instruction).
[0045] Figure 3 The present invention provides a flowchart of the steps of a method for testing a program, wherein the method is applied to a process of testing (or debugging) a processor, wherein the processor includes a debug interface, and the processor includes a target register configured for the debug interface, including:
[0046] Step 101, when a test program is run on a device under test provided with a processor, a terminal monitors device information of the device under test through a target register corresponding to a debugging interface of the processor without changing an execution state of the device under test.
[0047] In an embodiment of the present application, the target register refers to a register that reads device information during the processor running the test program before the processor enters an abnormal state, that is, the target register stores the device information of the device under test; the reading process of the target register will not interrupt the normal operation of the test program. Among them, the device information refers to the information in the PC register of the device under test, and the PC register is used to store the instruction address that the device under test needs to execute. Optionally, the above-mentioned test program is a pre-set program for performing various functional tests on the processor; in specific implementation, the test program can be a program executed by the processor at high frequency.
[0048] Compared with the prior art method of accessing the fault status register to read device information after the processor enters the debug exception state (such as EJTAG exception), since the processor can continue normal operation only after exiting the debug exception state, the processor is in the abnormal state for a long time; the embodiment of the present application controls the target register to continuously read device information before the processor enters the debug exception state, which can effectively improve the reading efficiency of the device information and reduce the time the processor is in the debug exception state, thereby minimizing the impact on the normal operation of the processor.
[0049] Step 102: The terminal writes an execution instruction carrying an exception handling address into the debugging interface of the processor, so that the processor executes the execution instruction.
[0050] In an embodiment of the present application, the exception handling address is the address mapped to the debug interface that is accessed when the processor enters a debug exception. When the test program is running, the terminal can trigger a debug exception through the debug interface, or the processor encounters a breakpoint instruction during execution and enters a debug exception. The processor can access the address mapped to the debug interface only when it executes a debug exception, and request to read instructions or store data from the exception handling address that needs to be accessed. At this time, the emulator will provide the debug interface with the execution instruction or data corresponding to the exception handling address, so that the processor can obtain the device information and process information of the processor entering the abnormal state according to the execution instruction, and the device information and process information are used together for debugging analysis of the processor.
[0051] Optionally, the debug exception scenario of the processor includes: the processor encounters a preset breakpoint when executing a test program; or the break bit in the control register corresponding to the debug interface is set to an exception value, which is the value of the processor entering the debug exception state when executing to a specified position of the test program.
[0052] Specifically, when a debug exception occurs in the processor, the processor has two exception vector entry addresses, which are determined by the exception bit of the control register corresponding to the debug interface, and the exception bit is a position pre-set according to the actual situation for characterizing the abnormal situation; when the exception bit is 1, it indicates that the exception vector entry address is the first address; when the exception bit is 0, it indicates that the exception vector entry address is the second address. Exemplarily, the exception bit can be ProbeTrap (the 14th bit in the control register), when ProbeTrap is 1, it indicates that the first address is 0xff200200, and 0xff200200 is located in the fault register; when ProbeTrap is 0, it indicates that the second address is 0xbfc00000.
[0053] Furthermore, ProbeTrap==1, the processor obtains the execution instruction from 0xff200200. At this time, the terminal writes the execution instruction through the data register corresponding to the debug interface, clears the first designated bit in the control register, and the processor takes the execution instruction. ProbeTrap==0, the processor obtains the execution instruction from 0xbfc00000; when the second method is used, since 0xbfc00000 can obtain the execution instruction by mapping the window to the memory, this method can realize the execution instruction from the local without the need for the processor and the terminal to interact through the debug interface, so this method obtains the execution instruction faster.
[0054] Optionally, when the processor accesses the abnormal address range determined by the first address, it is implemented through the debug interface; specifically, the processor accesses the abnormal address range through the data register and / or control register corresponding to the debug interface. Exemplarily, the abnormal address range is 0xff200000-0xff300000.
[0055] When the exception vector entry is the second address, the processor can write the process information generated by the test program running to the starting address of the fault register (such as 0xff200000), and then read the process information from the starting address and write it to the data register. In this way, the terminal can obtain the process information from the debug interface as the returned test data, that is, when the terminal reads the control register and finds that the exception bit is 1, the process information is read from the data register, and the first designated bit is set to 0 and then written to the control register; the debug mode returns from the second address, exits the exception, and returns to the instruction before the exception to continue execution.
[0056] With the above technical solution, when the processor obtains the execution instruction from 0xff200200, the processor needs to interact with the terminal through the debugging interface, so the speed of obtaining the execution instruction is slower. The slow instruction fetching speed will cause the program to run discontinuously, making the test program running inconsistent with the actual running status, resulting in inaccurate test results. Based on this, when the processor uses the method of obtaining instructions from 0xbfc00000, combined with the window mapping function, 0xbfc00000 is mapped to the memory address, thereby reducing the time interval between the test program running different instructions, so that the test program running status is consistent with the actual running status, and the test program is kept running continuously.
[0057] Step 103: When the terminal detects that the exception handling address exists in the device information, the terminal obtains process information from the debugging interface of the processor to enable the processor to run normally.
[0058] In the embodiment of the present application, the processor continuously reads device information from the target register and detects whether there is an exception handling address in the device information during the process of running the test program, and the data register corresponding to the debug interface can obtain the information read by the target register in real time; based on this, the terminal can timely monitor the existence of the corresponding exception access address in the process information obtained by the data register corresponding to the debug interface, so as to timely determine whether the processor enters an abnormal state. That is, when the terminal detects that there is an execution instruction written to the debug interface carrying an exception handling address in the device information, it is determined that the processor enters an abnormal state. At this time, the terminal can obtain the process information of the processor from the data register in the debug interface, and transfer the process information and the read device information to the emulator, so that the abnormal state can be maintained on the emulator for subsequent analysis; and when the exception handling address no longer exists in the process information of the device under test, the device under test can continue to execute the instructions before the execution instruction carrying the exception handling address to continue normal operation. Specifically, the exception handling address can be pre-set in the device information of the device under test by the tester according to the test requirements.
[0059] Step 104: test and analyze the device information and the process information.
[0060] In an embodiment of the present application, the terminal debugs the running performance of the test program on the processor by testing and analyzing the device information and process information maintained when the processor on the tested device enters an abnormal state.
[0061] A program testing method provided by an embodiment of the present application monitors device information through a target register corresponding to a debugging interface of a processor without interrupting the normal operation of the processor, and determines that the processor enters an abnormal state when an abnormal access address is included in the monitored device information, thereby obtaining process information from the debugging interface, so that the device under test runs normally, and the obtained device information and process information are used for testing and analysis, thereby minimizing the time that the processor is in an abnormal state during the testing of the program, thereby reducing the impact on the normal operation of the processor.
[0062] Based on the above embodiments, Figure 4 is a flowchart of another test method of a program provided in an embodiment of the present application. Figure 4 In the process shown, the target register bit may be a PC sampling register (PC SAMPLE register), and the method includes:
[0063] Step 201, when a test program is run on a device under test provided with a processor, the terminal monitors the device information of the device under test through the PC sampling register corresponding to the debugging interface without changing the execution state of the device under test.
[0064] In the embodiment of the present application, the PC sampling register is a register corresponding to the debug interface that periodically reads the device information of the device under test; the terminal reading the PC SAMPLE register is the same as reading the address register, and neither will interrupt the execution of the test program.
[0065] Step 202: The terminal writes an execution instruction carrying an exception handling address into the debugging interface of the processor, so that the processor executes the execution instruction.
[0066] This step can refer to the detailed description of step 102 and will not be repeated here.
[0067] Step 203: When it is detected that the exception handling address exists in the device information, process information is obtained from the debugging interface of the processor to enable the processor to run normally.
[0068] This step can refer to the detailed description of step 103 and will not be repeated here.
[0069] Step 204: divide the process information into target process information corresponding to each process.
[0070] In the embodiment of the present application, the process information read by the terminal may belong to various processes generated when various programs are running, such as the program startup process, update process, window opening process, etc. Therefore, if the process to which the process information belongs is not distinguished, it is impossible to accurately find the process with problems, that is, for a process in an abnormal running state, determine which part of the program in the test program has a corresponding process function error when running, resulting in the abnormal running situation. The target process information is the process information corresponding to the process with problems.
[0071] Step 205: Acquire the process function corresponding to the target process information that meets the test requirements, and use the acquired process function as the analysis result.
[0072] In the embodiment of the present application, the test requirement may be a determination condition obtained by setting an indicator condition to limit the process information of the required analysis result according to the actual debugging needs.
[0073] Optionally, a function that is sampled a large number of times in the same process is determined as a hotspot function, and the hotspot function is used as the analysis result.
[0074] Optionally, step 204 may include: when the test program uses a memory management unit to switch processes, dividing the process information according to the set breakpoints in the device information to obtain target process information corresponding to each process, and the execution code of the breakpoint is pre-set in the process switching function of the program.
[0075] In an embodiment of the present application, a memory management unit (MMU) is a control device for managing virtual memory and physical memory, and is also responsible for mapping virtual addresses to physical addresses, as well as providing memory access authorization and multi-task multi-process operating systems of hardware mechanisms. Since the test program needs to call a process switching function when using a memory management unit to switch processes, a breakpoint can be set in the process switching function of the test program so that the execution code of the breakpoint will be executed during the execution of the process switching function to read the process information; the specific location of the breakpoint setting can be the program code location indicated by the address in the identifier register (such as the mtc0 entryhi register) in the process switching function (such as the schedule function), wherein the identifier register is used to store the virtual page number of the input keyword and the address space identifier of the current activity.
[0076] Optionally, the step 204 may include: when the test program does not use a memory management unit to switch processes, analyzing the process numbers in the device information to divide the process information and obtain target process information corresponding to each process.
[0077] In the embodiment of the present application, if the test program does not use the memory management unit to switch the process, the terminal can analyze the process number in the processor core to obtain the process number of each process information, thereby dividing the process information. Specifically, the operating system of the processor will increment the value in the counter register when the process is switched, that is, the initial value in the counter register is prid, and prid+1 is added each time the process is switched. Therefore, the process number when the value in the counter register changes can be used as the process number corresponding to the generated process information.
[0078] Optionally, when the debug interface support window is configured to the memory, the execution instruction is configured to map the exception handling address window to a memory address location.
[0079] In an embodiment of the present application, in order to achieve fast processing of breakpoints during process switching, if the debugging interface supports window configuration to memory, the exception vector entry address corresponding to the exception handling address in the program can be set to a fixed storage address (such as 0xbfc00480), thereby mapping the exception handling address from the fixed storage address to the corresponding position in the memory through the processor window, where the processor window refers to an extended window used by the processor for data calculation.
[0080] Optionally, when the debugging interface does not support window configuration to memory, the execution instruction is configured to instruct the processor to jump to memory to access the exception handling address.
[0081] In an embodiment of the present application, if the debugging interface does not support window configuration to memory, the address routing window can be used to route the exception handling address to the memory, and jump to the memory through a jump instruction to control the processor to enter an exception state, wherein the address routing window is an extended function window that can route the address to the memory.
[0082] Another program testing method provided by an embodiment of the present application monitors device information through a target register corresponding to a processor's debug interface without interrupting the normal operation of the processor, and determines that the processor has entered an abnormal state when the monitored device information contains an abnormal access address, thereby reading process information from the debug interface, allowing the device under test to operate normally, and using the acquired device information and process information for test analysis, thereby minimizing the time that the processor is in an abnormal state during the program testing process, thereby reducing the impact on the normal operation of the processor.
[0083] Figure 5 : is a structural block diagram of a program testing device 30 provided in an embodiment of the present application, the device comprising:
[0084] The monitoring module 301 is configured to enable the terminal to monitor the device information of the device under test through the target register corresponding to the debugging interface of the processor without changing the execution state of the device under test when the test program is run on the device under test provided with the processor;
[0085] A writing module 302 is configured to enable the terminal to write an execution instruction carrying an exception handling address into the debugging interface of the processor, so that the processor executes the execution instruction;
[0086] The acquisition module 303 is configured to acquire process information from the debugging interface of the processor when detecting that the exception handling address exists in the device information, so as to enable the processor to run normally;
[0087] The analysis module 304 is configured to test and analyze the device information and the process information.
[0088] Optionally, the target register includes: a PC sampling register, and the monitoring module 301 is further configured to enable the terminal to monitor the device information of the device under test through the PC sampling register corresponding to the debugging interface of the processor without changing the execution state of the device under test.
[0089] Optionally, the analysis module 304 includes:
[0090] a process information division unit, configured to divide the process information into target process information corresponding to each process;
[0091] The process function acquisition unit is configured to acquire the process function corresponding to the target process information that meets the test requirements, and use the acquired process function as the analysis result.
[0092] Optionally, the process information division unit is further configured to:
[0093] In the case where the test program uses a memory management unit to switch processes, the process information is divided according to the set breakpoints in the device information to obtain target process information corresponding to each process, and the execution code of the breakpoint is pre-set in the process switching function of the program.
[0094] Optionally, the process information division unit is further configured to:
[0095] In the case that the test program does not use the memory management unit to switch processes, the process information is divided by analyzing the process number in the device information to obtain the target process information corresponding to each process.
[0096] Optionally, when the debug interface support window is configured to the memory, the execution instruction is configured to map the exception handling address window to a memory address location.
[0097] Optionally, when the debugging interface does not support window configuration to memory, the execution instruction is configured to instruct the processor to jump to memory to access the exception handling address.
[0098] A program testing device provided in an embodiment of the present application monitors device information through a target register corresponding to a debugging interface of a processor without interrupting the normal operation of the processor, and determines that the processor enters an abnormal state when an abnormal access address is included in the monitored device information, thereby obtaining process information from the debugging interface, so that the device under test runs normally, and uses the obtained device information and process information for testing and analysis, thereby minimizing the time that the processor is in an abnormal state during the testing of the program, thereby reducing the impact on the normal operation of the processor.
[0099] An embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the test method of the program described in any of the above embodiments.
[0100] An electronic device provided by an embodiment of the present application obtains device information through a target register corresponding to a debugging interface of a processor before the processor enters an abnormal state during the process of the processor running a program, and determines that the processor enters an abnormal state when the obtained device information contains an abnormal access address, thereby transferring the obtained device information and process information to a simulation machine for testing and analysis, thereby minimizing the time that the processor is in an abnormal state during the testing of the program, thereby reducing the impact on the normal operation of the processor.
[0101] An embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the program testing method of any of the above embodiments can be implemented.
[0102] An embodiment of the present application provides a computer storage medium, which, during the process of a processor running a program, obtains device information through a target register corresponding to a debugging interface of the processor before the processor enters an abnormal state, and determines that the processor enters an abnormal state when the acquired device information contains an abnormal access address, thereby transferring the read device information and process information to the device for use in testing and analysis, thereby minimizing the time that the processor is in an abnormal state during the testing of the program, thereby reducing the impact on the normal operation of the processor.
[0103] It will be appreciated by those skilled in the art that the present application includes devices for performing one or more of the operations described in the present application. These devices may be specially designed and manufactured for the desired purpose, or may also include known devices in general-purpose computers. These devices have computer programs stored therein, which are selectively activated or reconstructed. Such computer programs may be stored in a storage medium of a device (e.g., a computer) or in any type of medium suitable for storing electronic instructions and coupled to a bus, respectively, the computer storage medium including but not limited to any type of disk (including floppy disk, hard disk, optical disk, CD-ROM and magneto-optical disk), ROM (Read-Only Memory), RAM (Random Access Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory, magnetic card or optical card. That is, the storage medium includes any medium that stores or transmits information in a readable form by a device (e.g., a computer).
[0104] Those skilled in the art can understand that each frame in these structure diagrams and / or block diagrams and / or flow charts and the combination of frames in these structure diagrams and / or block diagrams and / or flow charts can be implemented by computer program instructions. Those skilled in the art can understand that these computer program instructions can be provided to a processor of a general-purpose computer, a professional computer or other programmable program test method to implement, so that the scheme specified in the frame or multiple frames of the structure diagram and / or block diagram and / or flow chart disclosed in the present application is executed by the processor of the computer or other programmable program test method.
[0105] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A program testing method, characterized in that: The method comprises: When a test program is run on a device under test provided with a processor, the terminal monitors the device information of the device under test through the target register corresponding to the debugging interface of the processor without changing the execution state of the device under test; the device information includes the address of the instruction executed by the device under test; the target register refers to the register for reading the device information during the process of the processor running the test program before the processor enters an abnormal state, and the reading process of the target register will not interrupt the normal operation of the test program; The terminal writes an execution instruction carrying an exception handling address into the debug interface of the processor so that the processor executes the execution instruction; the exception handling address is an address mapped to the debug interface and accessed by the processor when entering a debug exception; When the exception handling address is detected in the device information, it is determined that the processor enters an abnormal state, and process information and device information are obtained from the debugging interface of the processor so that the processor can operate normally; wherein, the normal operation of the processor includes: when the exception handling address no longer exists in the process information of the device under test, the device under test continues to execute the instruction before the execution instruction carrying the exception handling address so as to continue normal operation; The device information and the process information are tested and analyzed.
2. The method according to claim 1, characterized in that The target register includes a PC sampling register, and the terminal monitors the device information of the device under test through the target register corresponding to the debug interface of the processor without changing the execution state of the device under test, including: The terminal monitors the device information of the device under test through the PC sampling register corresponding to the debugging interface of the processor without changing the execution state of the device under test.
3. The method according to claim 1, characterized in that The testing and analyzing the device information and the process information includes: Dividing the process information into target process information corresponding to each process; A process function corresponding to the target process information that meets the test requirements is obtained, and the obtained process function is used as an analysis result.
4. The method according to claim 3, characterized in that The dividing the process information into target process information corresponding to each process includes: In the case where the test program uses a memory management unit to switch processes, the process information is divided according to the set breakpoints in the device information to obtain target process information corresponding to each process, and the execution code of the breakpoint is pre-set in the process switching function of the program.
5. The method according to claim 3, characterized in that: The dividing the process information into target process information corresponding to each process includes: In the case where the test program does not use a memory management unit to switch processes, the process number in the device information is analyzed to divide the process information and obtain target process information corresponding to each process.
6. The method according to any one of claims 1 to 5, characterized in that: When the debug interface support window is configured to the memory, the execution instruction is configured to map the exception handling address window to a memory address location.
7. The method according to any one of claims 1 to 5, characterized in that: When the debugging interface does not support window configuration to the memory, the execution instruction is configured to instruct the processor to jump to the memory to access the exception handling address.
8. A program testing device, characterized in that: The device comprises: The monitoring module is configured to enable the terminal to monitor the device information of the device under test through the target register corresponding to the debugging interface of the processor without changing the execution state of the device under test when the test program is run on the device under test provided with the processor; the device information includes the address of the instruction executed by the device under test; the target register refers to the register for reading the device information in the process of the processor running the test program before the processor enters the abnormal state, and the reading process of the target register will not interrupt the normal operation of the test program; A writing module configured to enable the terminal to write an execution instruction carrying an exception handling address into the debug interface of the processor so that the processor executes the execution instruction; the exception handling address is an address mapped to the debug interface and accessed by the processor when entering a debug exception; The acquisition module is configured to determine that the processor enters an abnormal state when detecting that the exception handling address exists in the device information, and obtain process information and device information from the debugging interface of the processor to enable the processor to operate normally; wherein enabling the processor to operate normally includes: when the exception handling address no longer exists in the process information of the device under test, the device under test continues to execute the instruction before the execution instruction carrying the exception handling address so as to continue to operate normally; The analysis module is configured to test and analyze the device information and the process information.
9. An electronic device, characterized in that: The invention comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the test method of the program according to any one of claims 1 to 7.
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 test method of the program described in any one of claims 1 to 7 is implemented.
