Abnormality location method, device and readable storage medium

By calling the interrupt handling function to obtain debugging information when the system or program is abnormal, the problem of not being able to obtain debugging information in the existing technology is solved, the efficiency of quickly locate the cause of the abnormality is achieved, and manpower and material investment is reduced.

CN114691481BActive Publication Date: 2024-12-20龙芯中科(成都)技术有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011625618.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-30
Publication Date
2024-12-20
Estimated Expiration
2040-12-30

AI Technical Summary

Technical Problem

When the system or program is abnormal, the prior art cannot obtain debug information, resulting in the inability to determine the cause of the exception, especially when human-computer interaction cannot be used.

Method used

By calling the interrupt handler function during an interrupt request, the value of the target register and the stack information of the target function stack are obtained and output to the target device to display, so as to analyze the cause of the exception.

Benefits of technology

When the system or program is abnormal, debugging information can be quickly obtained to help technicians analyze and locate the causes of the abnormality, improve the efficiency of abnormal positioning, and reduce manpower and material investment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114691481B_ABST
    Figure CN114691481B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides an exception location method, device and readable storage medium. The exception location method of the embodiment of the present invention: when it is determined that the interrupt source issues an interrupt request, in response to the interrupt request, the interrupt processing function is called to obtain debugging information through the interrupt processing function, the debugging information includes the value of the target register and the stack information of the target function stack of the target program, and the value of the target register and the stack information of the target function stack are output to the target device for display. Because the embodiment of the present invention can output the value of the target register and the stack information obtained by the interrupt processing function to the target device when an exception occurs in the program, the technician can analyze the cause of the system or program exception based on the debugging information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an abnormality locating method, device and readable storage medium. Background Art

[0002] When testing a large-scale system or program, various unexpected exceptions may occur in the system or program. In this case, there needs to be a way to diagnose the current state of the system or program to determine the cause of the exception.

[0003] In the prior art, debugging information is added when designing a system or program, so that when an exception occurs during the operation of the system or program, the debugging information can be used to assist in determining the abnormal location of the system or program. However, if the system or program abnormality causes human-computer interaction to be unusable, the debugging information cannot be obtained, and thus the cause of the system or program abnormality cannot be determined. Summary of the invention

[0004] In view of the above problems, embodiments of the present invention are proposed to provide an abnormality locating method, device and readable storage medium that overcome the above problems or at least partially solve the above problems.

[0005] A first aspect of the present invention provides an abnormality locating method, the method comprising:

[0006] In the case where it is determined that the interrupt source issues an interrupt request, in response to the interrupt request, an interrupt handling function is called to obtain debugging information through the interrupt handling function, wherein the debugging information includes a value of a target register and stack information of a target function stack of a target program, the target function stack includes a function stack of a current function in the target program interrupted by the interrupt request, and function stacks of P functions before the current function, wherein P is a positive integer greater than or equal to 1, and the P functions are functions in the target program;

[0007] The value of the target register and the stack information of the target function stack are output to the target device for display.

[0008] A second aspect of the present invention provides an abnormality locating device, the device comprising:

[0009] A calling module, configured to, when it is determined that an interrupt source issues an interrupt request, call an interrupt handling function in response to the interrupt request, so as to obtain debugging information through the interrupt handling function; wherein the debugging information includes the value of a target register and stack information of a target function stack of a target program, wherein the target function stack includes a function stack of a current function in the target program interrupted by the interrupt request, and function stacks of P functions before the current function, wherein P is an integer greater than or equal to 0, and the P functions are functions in the target program;

[0010] The output module is used to output the value of the target register and the stack information of the target function stack to the target device for display.

[0011] According to a third aspect of the present invention, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned abnormality locating methods are implemented.

[0012] According to a fourth aspect of the present invention, there is provided an abnormality locating device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of any of the abnormality locating methods described above when executed by the processor.

[0013] The embodiments of the present invention include the following advantages:

[0014] The exception location method, device and readable storage medium of the embodiment of the present invention, in the case of determining that the interrupt source issues an interrupt request, responds to the interrupt request, calls the interrupt processing function to obtain debugging information through the interrupt processing function, the debugging information includes the value of the target register and the stack information of the target function stack of the target program, and outputs the value of the target register and the stack information of the target function stack to the target device for display. In the prior art, if the system or program is abnormal and the human-computer interaction cannot be used, the debugging information cannot be obtained, and thus the cause of the system or program abnormality cannot be determined. In this embodiment, when an abnormality occurs in the program, an interrupt request can be issued through the interrupt source, and the central processing unit responds to the interrupt request to obtain debugging information including the value of the target register and the stack information of the target function stack of the target program, and outputs the value of the target register and the stack information obtained by the interrupt processing function to the target device, so that the technician can analyze the cause of the system or program abnormality based on the debugging information.

[0015] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] 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 invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0017] Figure 1 A flowchart of a method for locating an abnormality provided by an embodiment of the present invention;

[0018] Figure 2 is a structural schematic diagram of an abnormality locating system provided by an embodiment of the present invention;

[0019] Figure 3 This is a schematic diagram of a function stack provided in an embodiment of the present application;

[0020] Figure 4 A schematic diagram of a stack space of a program provided by an embodiment of the present invention;

[0021] Figure 5 A schematic diagram of the structure of an abnormality locating device provided by an embodiment of the present invention;

[0022] Figure 6 A schematic diagram of the structure of another abnormality locating device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0023] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0024] It should be understood that the specific embodiments described herein are only used to explain the present invention, are only a part of the embodiments of the present invention, rather than all the embodiments, and are not used to limit the present invention.

[0025] Reference Figure 1 , Figure 1 A flowchart of a method for locating an abnormality provided by an embodiment of the present invention, the method for locating an abnormality may include the following steps:

[0026] Step 101 : When it is determined that an interrupt source issues an interrupt request, an interrupt processing function is called in response to the interrupt request to obtain debugging information through the interrupt processing function.

[0027] The debugging information includes the value of the target register and the stack information of the target function stack of the target program, the target function stack includes the function stack of the current function in the target program interrupted by the interrupt request, and the function stacks of P functions before the current function, where P is an integer greater than or equal to 0, and the P functions are functions in the target program. The P functions are functions that have been started in the target program before the interrupt source issues the interrupt request.

[0028] It should be noted that the target program's operating environment includes the values ​​of general registers, such as program counter (pc), stack pointer (sp) register, and return address (ra) register. For example, the target operating environment includes the values ​​of pc, sp register, and ra register. Before calling the interrupt handling function, the values ​​of pc, sp register, and ra register can be stored first, so as to call the interrupt handling function without destroying the target program's operating environment. Among them, the address of the instruction currently being executed is stored in pc. In this embodiment, when a certain instruction of the current function is executed, the central processing unit receives an interrupt request, and the value of pc is the address of the instruction of the current function. The sp register is used to store the value of the top of the function stack of the current function, that is, the value of the sp register is equal to the top of the function stack of the current function. The value of the ra register is used to save the address of the subroutine of the calling function of the current function, wherein the subroutine refers to a certain step in the calling function, and the address of the subroutine of the calling function can be determined by the value of the ra register. For example, if the second step (subroutine) of the called function is currently being executed, and the current function is called while executing the second step, the address of the third step of the called function can be stored in the ra register. After the current function call is completed, the third step of the called function can be located based on the value of the ra register, and then the third step of the called function can be executed.

[0029] Optionally, before calling the interrupt handling function, the following steps may also be included:

[0030] Register the interrupt handling function to the target program's running environment.

[0031] The interrupt processing function can be registered in the target program's running environment during the target program's startup process, or after the target program has been started, the interrupt processing function can be registered in the target program's running environment.

[0032] Optionally, before responding to an interrupt request and calling an interrupt processing function to obtain the value of a target register and stack information of a target function stack of a target program through the interrupt processing function, the following steps may also be included:

[0033] Detect the level signal on the general purpose input and output GPIO pin of the central processing unit;

[0034] When the level signal on the GPIO pin changes, it is determined that the GPIO pin sends an interrupt request, wherein the interrupt source is the GPIO pin.

[0035] In the embodiment of the present invention, a general-purpose input / output (GPIO) pin can be used as an interrupt source. For specific implementation, please refer to Figure 2 As shown, Figure 2 It is a structural diagram of an abnormality locating system provided by an embodiment of the present invention, and the system includes a control unit, an interrupt response unit, an information output unit and a display device. The control unit can cause the level of the GPIO pin to change, and the level change of the GPIO pin can be detected by the central processing unit (CPU). When the CPU detects the level change of the GPIO pin, it responds to the interrupt through the interrupt response unit, obtains the value of the target register and the stack information of the target function stack of the target program, and then outputs the value of the target register and the stack information of the target function stack of the target program to the target device for display through the information output unit.

[0036] It should be noted that, in the embodiment of the present invention, when the system or program is abnormal, an external target device is connected, and an interrupt request is issued through the interrupt source to obtain debugging information and output the debugging information from the target device. That is, when there is no system or program abnormality, there is no need to connect an external target device, thereby reducing certain manpower and material resources. Moreover, when the interrupt source is a GPIO pin, the interrupt is a hardware interrupt. Compared with a software interrupt, a hardware interrupt can quickly locate the cause of the abnormality of the target program, thereby improving the efficiency of analyzing the cause of the abnormality of the target program.

[0037] An interruption means that when some unexpected situation occurs during the operation of the computer and the host intervention is required, the machine can automatically stop the running program and switch to the program to handle the new situation. After the processing is completed, it returns to the original suspended program to continue running.

[0038] When the CPU determines that the interrupt source issues an interrupt request, the CPU responds to the interrupt request and calls the interrupt processing function to obtain the value of the target register and the stack information of the target function stack of the target program through the interrupt processing function. The stack information of the target function stack of the target program can be obtained by the following steps:

[0039] Get the stack information of the function stack of the current function;

[0040] When P is greater than 1, based on the stack information of the function stack of the current function, the stack information of the function stack of P functions is obtained;

[0041] Among them, the stack information of the function stack of the Mth function among P functions is determined based on the stack information of the function stack of the next function of the Mth function, the Mth function is the calling function of the next function, M is a positive integer, and M is any integer in the interval greater than or equal to 1 and less than or equal to P.

[0042] In the embodiment of the present invention, the target program refers to the program in which an exception occurs. The target program may be one or more. When the central processing unit is a single-core central processing unit, the target program is one; when the central processing unit is a multi-core central processing unit, the target program may be multiple. When there are multiple target programs, an interrupt request may be issued to each core. In response to the interrupt request, the central processing unit calls the interrupt processing function, and obtains the stack information of the target function stack of the target program through the interrupt processing function. In order to facilitate the understanding of the embodiment of the present invention, the function stack related content is introduced here:

[0043] In the computer field, a stack is a dynamic storage space that allows insertion and deletion operations at the same end. It stores data according to the first-in-last-out principle. The first data entered is pushed to the bottom of the stack, and the last data is at the top of the stack. The function stack is dynamically allocated when the program is running. It is used to store information that needs to be maintained when a function is called. This information is referred to as stack information. The stack information includes the function's return address parameters, temporary variables, and stack positions. Figure 3 , Figure 3 This is a schematic diagram of a function stack provided in an embodiment of the present application. A typical function stack is as follows Figure 3 Shown:

[0044] In some architectures, the function stack grows downward, that is, the bottom of the stack is at a high address and the top of the stack is at a low address. Figure 3 In the code, GPR[sp] represents the general register sp ($29) pointing to the top of the stack, also known as the stack pointer. Each time a function is called, sp moves down by n bytes, and sp pre-specifies a storage area. These n bytes are the stack space for this function. Here n must be a multiple of 16. Typical instructions for allocating function stacks:

[0045] daddiu sp,sp,-48

[0046] The instruction daddiu is an addition instruction with a constant. The above instruction is equivalent to the C language expression sp=sp-48. It is equivalent to moving the sp pointer down by 48 bytes, that is, applying for a 48-byte stack. When the function returns, the stack is restored by moving the sp pointer up by 48 bytes. The instruction is as follows:

[0047] daddiu sp,sp,48

[0048] Usually, after allocating space through the sp stack pointer, you can save and restore the function information as needed. Generally, the values ​​of the general registers ra and fp are pushed onto the stack first. If there is a gp operation, the gp value is also pushed onto the stack. When this function calls other functions, the local variables, register variables, parameters, etc. inside this function must also be pushed onto the stack and saved. Among them, fp points to the bottom of the function stack of the function, and fp is called the frame pointer. Since sp points to the top of the function stack of the function, the boundary of the function stack can be limited according to the values ​​of sp and fp.

[0049] In today's popular computer architecture, most computers' parameter passing, local variable allocation and release are implemented by manipulating the program stack. The stack is used to pass function parameters, store return value information, and save registers for restoring the processor state before the call. When the program starts, the system will specify a fixed-size stack space for the storage of the program's function parameters and local variables. The initial value of sp points to the bottom of this fixed-size stack. For each function call in the program, a space in the stack space will be allocated for the function as a function stack by moving the sp pointer. For example, Figure 4 As shown, Figure 4 A schematic diagram of a stack space of a program provided by an embodiment of the present invention, Figure 4 The thicker line in the figure divides the stack space into two parts, the upper part is the function stack of function 1, and the lower part is the function stack of function 2. When function 1 calls function 2, a space is allocated for function 2 in the stack space by moving the sp pointer, and sp points to the top of function stack 2, as shown in the figure. Figure 4 The GPR[sp] outside the bar grid points to the top of function stack 2.

[0050] Each program has its own stack, and all functions allocate space on the same stack to store information related to the function. The space used by each function is called a stack frame.

[0051] sp and fp define the boundaries of each function stack. All function stacks are allocated in a downward-growing manner in the stack space of the current program. With fp and sp, the boundaries of each function stack are defined. The fp inside each function stack points to the bottom of the function stack of the caller function, such as Figure 4 As shown in the figure, fp in function stack 2 points to the bottom of function stack 1 of function 1, and the value of fp in function stack 2 is the value of fp in function stack 1. When the program is abnormal, an interrupt can be triggered through the GPIO pin, and the function call relationship can be traced back to analyze the cause of the program abnormality. Specifically, the function call relationship can be traced back through the following two methods:

[0052] Method 1: The sp value and fp value of the function stack of P functions can be obtained by using the sp value and fp value stored in the function stack of the current function, where the current function refers to the function of the exception program interrupted by the interrupt request, and the stack information of the function stack of the Mth function among the P functions is determined based on the stack information of the function stack of the next function of the Mth function, the Mth function is the calling function of the next function of the Mth function, the sp value stored in the function stack of the next function of the Mth function is the sp value of the function stack of the Mth function, and the fp value stored in the function stack of the next function of the Mth function is the fp value of the function stack of the Mth function. For example, when the program executes to the 10th function, the GPIO pin triggers an interrupt, then the 10th function is the current function, the 9th function is the calling function of the 10th function, based on the stack information of the 10th function's function stack, the stack information of the 9th function's function stack can be obtained, based on the stack information of the 9th function's function stack, the stack information of the 8th function's function stack can be obtained, and so on, until the stack information of the 1st function's function stack is obtained. The stack information of the function stack includes the value of sp and the value of fp of the function stack.

[0053] Method 2: It should be noted that Figure 4The GPR[sp] of function stack 1 is not shown in the stack space of function stack 2, but the value of sp of function stack 1 of function 1 can be obtained based on the value of fp of function stack 2 of function 2. That is, the value of GPR[fp] outside the bar grid is equal to the value of sp of function stack 1, that is, the bottom of the function stack of the next function of the Mth function is equal to the top of the function stack of the Mth function. By obtaining the value of the bottom of the function stack of the next function of the Mth function, the value of the top of the function stack of the Mth function can be determined. At the same time, since the value of GPR[fp] stored in function stack 2 is equal to the value of fp of function stack 1, the stack information of function stack 1 can be obtained based on the stack information of function stack 2. For example, when the program executes to the 10th function, the GPIO pin triggers an interrupt, then the 10th function is the current function, the 9th function is the calling function of the 10th function, and based on the value of fp of the function stack of the 10th function, the value of sp of the function stack of the 9th function can be determined, and the value of GPR[fp] stored in the function stack of the 10th function is equal to the value of fp of the function stack of the 9th function, that is, based on the stack information of the function stack of the 10th function, the stack information of the function stack of the 9th function can be determined. Similarly, based on the stack information of the function stack of the 9th function, the stack information of the function stack of the 8th function can be determined, and so on, until the stack information of the function stack of the first function is obtained.

[0054] It should be noted that since each function of the target program corresponds to a function stack and a corresponding relationship between functions and function stacks is established, after the central processing unit receives the value of sp and the value of fp when the interrupt request, the current function stack can be determined based on the value of sp and the value of fp. After determining the current function stack, it can be determined which function the current function stack corresponds to. Based on the stack information of the current function stack of the current function, the stack information of the previous function stack of the current function stack can be determined. Based on the stack information of the previous function stack, the previous function stack can be determined, and then the function corresponding to the previous function stack can be determined. The previous function stack is the function stack of the calling function of the current function, that is, it is determined which function is the calling function of the current function, and so on, until the function stack and the first function of the first function are determined, and the P functions and the function stack of P functions before the current function are determined.

[0055] Step 102: Output the target register value and the stack information of the target function stack to the target device for display.

[0056] The target device may have its own display mode. The target device may be a display or other host that has a communication connection with the CPU. For example, when the target device is a display, a display output mode may be used; when the target device is other host, a serial port output mode may be used for display. The embodiments of the present invention introduce these two modes.

[0057] For the display output mode: before outputting the value of the target register and the stack information of the target function stack to the target device for display, the following steps may also be included:

[0058] Write the target register value and the target function stack information into the video memory in the format required by the display;

[0059] Get the value of the target register and the stack information of the target function stack from the video memory;

[0060] Correspondingly, step 102 outputs the value of the target register and the stack information of the target function stack to the target device for display, which can be specifically implemented by the following steps:

[0061] The obtained target register value and stack information of the target function stack are output to a display for display, and the target device is the display.

[0062] Display output requires a graphics card to drive the output. For most modern display technologies, whether using integrated graphics or independent graphics cards, they interact with the system in the form of video memory.

[0063] Video memory, also known as frame buffer, is used to store rendering data that has been processed or is about to be extracted by the graphics chip. Just like the computer's memory, video memory is a component used to store graphics information to be processed. The picture we see on the display is composed of pixels, and each pixel uses 4 to 32 or even 64 bits of data to control its brightness and color. This data must be saved in the video memory, and then allocated by the display chip and CPU, and finally the calculation results are converted into graphics and output to the display.

[0064] Therefore, in order to display the debugging information obtained by the output interrupt processing function, which includes the value of the target register and the stack information of the target function stack, you only need to write the debugging information into the video memory in the format required for display. The graphics card will automatically output the debugging information to the display. The video memory can be used as a section of ordinary memory for the system. Therefore, as long as the data meets the display requirements, it can be directly written into the video memory for output.

[0065] Regarding the serial port output mode: before outputting the value of the target register and the stack information of the target function stack to the target device for display in step 102, the following steps may also be included:

[0066] Performing data conversion on the target register value and the stack information of the target function stack to obtain the target register value and the stack information of the target function stack after the data conversion;

[0067] Accordingly, step 102 outputs the value of the target register and the stack information of the target function stack to the target device for display, which can be achieved by the following steps:

[0068] The target register value after data conversion and the stack information of the target function stack are output to the target device for display.

[0069] RS-232 is also called standard serial port, the most commonly used serial communication interface. The traditional RS-232-C interface standard has 22 wires and uses a standard 25-pin D-type plug socket (DB25). Later, it was simplified to a 9-pin D-type socket (DB9). Now the 25-pin plug socket is rarely used in applications. RS-232 adopts an unbalanced transmission method, which is the so-called single-ended communication. Since the difference between its sending level and receiving level is only about 2V to 3V, its common mode suppression ability is poor. In addition, the distributed capacitance on the twisted pair cable has a maximum transmission distance of about 15 meters and a maximum rate of 20kb / s. RS-232 is designed for point-to-point communication (that is, only one pair of receiving and transmitting devices is used), and its driver load is 3~7kΩ. Therefore, RS-232 is suitable for communication between local devices.

[0070] The serial port output of the present invention does not need to use a full-function serial port, and only requires a three-wire connection of tx, rx, and gnu (ground).

[0071] The basic process of serial communication is: baud rate configuration, data conversion, and data output. Among them, the baud rate represents the rate of data output. The other device must be set at the same rate to correctly identify the data.

[0072] Data conversion is to convert debugging information into a format that is easily recognizable to humans for output. Debugging information is pure digital information, while character information (ASCII code) is easy for humans to read and understand. Therefore, we convert the debugging information into data. The debugging information after data conversion is in the form of characters, so that the debugging information can be output in the form of characters, which is convenient for technical personnel to analyze the debugging information and quickly locate the cause of program abnormalities.

[0073] Serial port output generally has a serial port register to convert the written data into a level signal that meets the requirements of RS-232 to achieve the purpose of data output. Here, the converted debugging information can be written into the serial port output register of the target device.

[0074] It should be noted that the value of the target register can reflect the state of the current execution environment of the CPU. After the technician obtains the value of the target register and the stack information of the target function stack of the target program, the value of the target register and the stack information of the target function stack of the target program can be analyzed to locate the abnormal position of the target program, the cause of the abnormality of the target program, the value of the variable when the target program is executed, and other information, thereby achieving the purpose of debugging the device and the system. In addition, since the embodiment of the present invention only needs to access the target device after the program is abnormal, and the value of the target register and the stack information obtained by the interrupt processing function are output to the target device for display, the target device is occupied less. In the prior art, when testing a large-scale system or program, the abnormal position of the system or program is assisted by debugging information, and it is necessary to detect whether the system or program on all devices is abnormal, and it is necessary to access a large number of external devices on these devices. If there is an abnormality, the external device needs to record the abnormal information. Therefore, a large amount of manpower and material resources are required to complete this task, resulting in a waste of manpower and material resources.

[0075] The exception locating method provided by the embodiment of the present invention responds to the interrupt request and calls the interrupt handling function in response to the interrupt request when it is determined that the interrupt source issues an interrupt request, so as to obtain debugging information through the interrupt handling function, and the debugging information includes the value of the target register and the stack information of the target function stack of the target program, and the value of the target register and the stack information of the target function stack are output to the target device for display. In the prior art, if the human-computer interaction cannot be used due to the system or program exception, the debugging information cannot be obtained, and thus the cause of the system or program exception cannot be determined. In the embodiment of the present invention, when an exception occurs in the program, an interrupt request can be issued through the interrupt source, and the central processing unit responds to the interrupt request to obtain debugging information including the value of the target register and the stack information of the target function stack of the target program, and the value of the target register and the stack information obtained by the interrupt handling function are output to the target device, so that the technician can analyze the cause of the system or program exception based on the debugging information.

[0076] Reference Figure 5 , Figure 5 This is a schematic diagram of the structure of an abnormality locating device provided by an embodiment of the present invention. The abnormality locating device provided by this embodiment can be deployed in a computer system. The abnormality locating device includes:

[0077] A calling module 510 is used to call an interrupt processing function in response to an interrupt request issued by an interrupt source, so as to obtain debugging information through the interrupt processing function; wherein the debugging information includes the value of a target register and stack information of a target function stack of a target program, wherein the target function stack includes a function stack of a current function in the target program interrupted by the interrupt request and function stacks of P functions before the current function, wherein P is an integer greater than or equal to 0, and the P functions are functions in the target program;

[0078] The output module 520 is used to output the value of the target register and the stack information of the target function stack to the target device for display.

[0079] The exception locating device provided by the embodiment of the present invention responds to the interrupt request and calls the interrupt handling function in response to the interrupt request when it is determined that the interrupt source issues an interrupt request, so as to obtain debugging information through the interrupt handling function, and the debugging information includes the value of the target register and the stack information of the target function stack of the target program, and the value of the target register and the stack information of the target function stack are output to the target device for display. In the prior art, if the human-computer interaction cannot be used due to the system or program exception, the debugging information cannot be obtained, and thus the cause of the system or program exception cannot be determined. In the embodiment of the present invention, when an exception occurs in the program, an interrupt request can be issued through the interrupt source, and the central processing unit responds to the interrupt request to obtain debugging information including the value of the target register and the stack information of the target function stack of the target program, and outputs the value of the target register and the stack information obtained by the interrupt handling function to the target device, so that the technician can analyze the cause of the system or program exception based on the debugging information. Optionally, it also includes:

[0080] A detection module is used to detect the level signal on the general purpose input and output GPIO pin of the central processing unit;

[0081] A determination module is used to determine that the GPIO pin sends the interrupt request when the level signal on the GPIO pin changes, wherein the interrupt source is the GPIO pin.

[0082] Optionally, the device further comprises:

[0083] A first acquisition module is used to acquire stack information of the function stack of the current function; when P is greater than 1, based on the stack information of the function stack of the current function, acquire stack information of the function stacks of the P functions;

[0084] Among them, the stack information of the function stack of the Mth function among the P functions is determined based on the stack information of the function stack of the next function of the Mth function, the Mth function is the calling function of the next function, M is a positive integer, and M is any integer in the interval greater than or equal to 1 and less than or equal to P.

[0085] Optionally, also include:

[0086] A writing module, used for writing the value of the target register and the stack information of the target function stack into the video memory in a format required for display;

[0087] A second acquisition module, used for acquiring the value of the target register and the stack information of the target function stack from the video memory;

[0088] The output module is specifically used to output the acquired value of the target register and the stack information of the target function stack to a display for display, and the target device is the display.

[0089] Optionally, also include:

[0090] A data conversion module, used for performing data conversion on the value of the target register and the stack information of the target function stack to obtain the value of the target register and the stack information of the target function stack after data conversion;

[0091] The output module is specifically used to output the value of the target register and the stack information of the target function stack after the data conversion to the target device for display.

[0092] Optionally, also include:

[0093] A registration module is used to register the interrupt processing function in the running environment of the target program.

[0094] In addition, the embodiment of the present invention also provides an abnormality locating device, such as Figure 6 As shown, Figure 6 A schematic diagram of the structure of another abnormality locating device provided in an embodiment of the present invention. The abnormality locating device 600 includes a processor 610, a memory 620, and a computer program stored in the memory 620 and executable on the processor 610. When the computer program is executed by the processor 610, each process of the abnormality locating method embodiment of the above embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0095] The embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process of the above-mentioned abnormality location method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. Among them, the computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.

[0096] The embodiment of the present invention further provides a computer program, which can be stored in a cloud or local storage medium. When the computer program is run by a computer or a processor, it is used to execute the corresponding steps of the anomaly location method of the embodiment of the present invention, and is used to implement the corresponding modules in the anomaly location device according to the embodiment of the present invention.

[0097] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0098] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0099] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The above-mentioned program can be stored in a computer-readable storage medium.

[0100] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for locating an abnormality, characterized in that: The method comprises: Detect the level signal on the general purpose input and output GPIO pin of the central processing unit; When a level signal on the GPIO pin changes, determining that the GPIO pin sends an interrupt request, wherein the interrupt source is the GPIO pin; In the case where it is determined that the interrupt source issues an interrupt request, in response to the interrupt request, an interrupt handling function is called to obtain debugging information through the interrupt handling function; wherein the debugging information includes the value of the target register and the stack information of the target function stack of the target program, and the target function stack includes the function stack of the current function in the target program interrupted by the interrupt request and the function stacks of P functions before the current function, wherein P is an integer greater than or equal to 0, and the P functions are functions in the target program; Outputting the value of the target register and the stack information of the target function stack to a target device for display; wherein, accessing the target device after an exception occurs in the target program; Before calling the interrupt processing function in response to the interrupt request, the method further includes: registering the interrupt processing function in the running environment of the target program; wherein the target running environment at least includes the value of the stack pointer sp register and the return address ra register; Before calling the interrupt processing function, the value of the sp register and the value of the ra register are stored; the sp register is used to save the value of the top of the function stack of the current function, and the value of the sp register is equal to the top of the function stack of the current function; the ra register is used to save the address of the subroutine of the calling function of the current function, and the subroutine refers to a specified step in the calling function; The stack information of the target function stack of the target program is obtained through the following steps: when P is greater than 1, the function stack of the current function is determined through the running environment of the target program, and the value of the sp register and the value of the fp of the function stack of the current function are obtained; according to the value of the sp register and the value of the fp of the function stack of the current function, the value of the sp register and the value of the fp of the function stack of P functions are obtained; wherein, the stack information of the function stack of the Mth function among the P functions is determined based on the stack information of the function stack of the next function of the Mth function, the Mth function is the calling function of the next function, the value of the sp register stored in the function stack of the next function of the Mth function is the value of the sp register of the function stack of the Mth function, the value of the fp stored in the function stack of the next function of the Mth function is the value of the fp of the function stack of the Mth function, and M is a positive integer, and M is any integer in the interval greater than or equal to 1 and less than or equal to P.

2. The method according to claim 1, characterized in that Before outputting the value of the target register and the stack information of the target function stack to the target device for display, the method further includes: Writing the value of the target register and the stack information of the target function stack into the video memory in a format required by the display; Acquire the value of the target register and the stack information of the target function stack from the video memory; Outputting the value of the target register and the stack information of the target function stack to the target device for display includes: The acquired value of the target register and the stack information of the target function stack are output to a display for display, and the target device is the display.

3. The method according to claim 1, characterized in that Before outputting the value of the target register and the stack information of the target function stack to the target device for display, the method further includes: Performing data conversion on the value of the target register and the stack information of the target function stack to obtain the value of the target register and the stack information of the target function stack after the data conversion; Outputting the value of the target register and the stack information of the target function stack to the target device for display includes: The value of the target register after the data conversion and the stack information of the target function stack are output to the target device for display.

4. An abnormality locating device, characterized in that: The device comprises: A calling module, configured to, when it is determined that an interrupt source issues an interrupt request, call an interrupt handling function in response to the interrupt request, so as to obtain debugging information through the interrupt handling function; wherein the debugging information includes the value of a target register and stack information of a target function stack of a target program, wherein the target function stack includes a function stack of a current function in the target program interrupted by the interrupt request, and function stacks of P functions before the current function, wherein P is an integer greater than or equal to 0, and the P functions are functions in the target program; An output module, used for outputting the value of the target register and the stack information of the target function stack to a target device for display; wherein the target device is accessed after an exception occurs in the target program; A detection module is used to detect the level signal on the general purpose input and output GPIO pin of the central processing unit; A determination module, configured to determine that the GPIO pin sends the interrupt request when a level signal on the GPIO pin changes, wherein the interrupt source is the GPIO pin; It also includes: a registration module, which is used to register the interrupt processing function to the running environment of the target program, wherein the target running environment at least includes the value of the stack pointer sp register and the return address ra register; before calling the interrupt processing function, the value of the sp register and the value of the ra register are stored; the sp register is used to save the value of the top of the function stack of the current function, and the value of the sp register is equal to the top of the function stack of the current function; the ra register is used to save the address of the subroutine of the calling function of the current function, and the subroutine refers to a specified step in the calling function; The device also includes: a first acquisition module, which is used to determine the function stack of the current function through the running environment of the target program when P is greater than 1, and obtain the value of the sp register and the value of the fp of the function stack of the current function; obtain the value of the sp register and the value of the fp of the function stack of P functions according to the value of the sp register and the value of the fp of the function stack of the current function; wherein the stack information of the function stack of the Mth function among the P functions is determined based on the stack information of the function stack of the next function of the Mth function, the Mth function is the calling function of the next function, the value of the sp register stored in the function stack of the next function of the Mth function is the value of the sp register of the function stack of the Mth function, the value of the fp stored in the function stack of the next function of the Mth function is the value of the fp of the function stack of the Mth function, and M is a positive integer, and M is any integer in the interval greater than or equal to 1 and less than or equal to P.

5. The device according to claim 4, characterized in that Also includes: A writing module, used for writing the value of the target register and the stack information of the target function stack into the video memory in a format required for display; A second acquisition module, used for acquiring the value of the target register and the stack information of the target function stack from the video memory; The output module is specifically used to output the acquired value of the target register and the stack information of the target function stack to a display for display, and the target device is the display.

6. The device according to claim 4, characterized in that Also includes: A data conversion module, used for performing data conversion on the value of the target register and the stack information of the target function stack to obtain the value of the target register and the stack information of the target function stack after data conversion; The output module is specifically used to output the value of the target register and the stack information of the target function stack after the data conversion to the target device for display.

7. 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 steps of the abnormality locating method according to any one of claims 1 to 3 are implemented.

8. An abnormality locating device, characterized in that: The method comprises a processor, a memory and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the abnormality locating method according to any one of claims 1 to 3 when executed by the processor.