Configuration project debugging method and device, electronic equipment and storage medium
By converting the configuration project of PLC product into a binary program and determining the interrupt address, breakpoint debugging of the configuration project is realized, and the safety hazards caused by the lack of breakpoint debugging function in the existing technology are solved, ensuring that the configuration program is stable and safe operation.
Patent Information
- Application Number
- CN202411211138.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-12-13
AI Technical Summary
The existing PLC products lack breakpoint debugging functions during the development process, resulting in the inability to detect abnormal programming programs in the industrial control field, which in turn affects the stable and safe operation of the configuration project in the formal production environment.
By obtaining the configuration project corresponding to the first language, converting it into a binary program, determining the target instruction address mapping relationship between the configuration project and the binary program, and determining the interrupt address based on the breakpoint debugging address and the target instruction address mapping relationship, realizing the Breakpoint debugging of configuration project.
It realizes interrupt debugging of the configuration project and obtains debugging information, avoids safety hazards caused by inability to debug breakpoints, and ensures the stable and safe operation of the configuration program in the production environment.
Smart Images

Figure CN119126623A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information technology, and in particular to a debugging method, device, electronic equipment and storage medium for configuration engineering. Background Art
[0002] In the field of industrial control, the widespread application of programmable logic controllers (PLC) has become indispensable. It occupies an important position in the automation control systems of many industries. PLC control technology has the characteristics of powerful functions, high flexibility of use and strong practicality, making it one of the three major technical pillars of modern industrial automation. However, in the development process of PLC products, the programming languages used in the field of industrial control lack breakpoint debugging functions due to language-specific limitations, which is not conducive to users to debug abnormal configuration programs formed by programming languages in the field of industrial control. For example, programming languages such as ST, SFC, LD, and FBD lack breakpoint debugging functions. In related technologies, the configuration functions formed by the above programming languages can only be debugged by remote debugging methods, resulting in the inability to determine whether there are logical problems in the operation of the configuration project, and thus it is impossible to ensure that the configuration program can run stably and safely after it is officially launched in the production environment. Summary of the invention
[0003] In view of this, the embodiments of the present application provide a configuration project debugging method, device, electronic device and storage medium to solve the problem in the prior art that breakpoint debugging cannot be performed on configuration projects in a specific language, resulting in the inability to detect safety hazards.
[0004] A first aspect of an embodiment of the present application provides a debugging method for a configuration project, the method comprising: obtaining a configuration project corresponding to a first language, and converting the configuration project into a binary program; determining a target instruction address mapping relationship between the configuration project and the binary program, and determining a breakpoint debugging address of the configuration project; determining an interrupt address corresponding to the binary program according to the mapping relationship between the breakpoint debugging address and the target instruction address, and performing breakpoint debugging on the configuration project based on the interrupt address.
[0005] According to a second aspect of an embodiment of the present application, a debugging device for a configuration project is provided, the device comprising: a conversion module, used to obtain a configuration project corresponding to a first language, and convert the configuration project into a binary program; a mapping module, used to determine a target instruction address mapping relationship between the configuration project and the binary program, and determine a breakpoint debugging address of the configuration project; a debugging module, used to determine an interrupt address corresponding to the binary program according to the mapping relationship between the breakpoint debugging address and the target instruction address, and perform breakpoint debugging on the configuration project based on the interrupt address.
[0006] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0007] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0008] Compared with the prior art, the embodiments of the present application have the following beneficial effects: in the embodiments of the present application, the configuration project corresponding to the first language is obtained, and the configuration project is converted into a binary program; the target instruction address mapping relationship between the configuration project and the binary program is determined, and the breakpoint debugging address of the configuration project is determined; according to the mapping relationship between the breakpoint debugging address and the target instruction address, the interrupt address corresponding to the binary program is determined, and the configuration project is breakpoint debugged based on the interrupt address, thereby realizing the interruption of the binary program through the interrupt address and obtaining debugging information. Since the binary program is converted from the configuration project, the debugging information obtained by interrupt debugging the binary program can reflect the interrupt debugging information corresponding to the configuration project. Therefore, breakpoint debugging of the binary program realizes debugging of the configuration project, avoiding the problem in the related technology that the configuration project of a specific language cannot be breakpoint debugged, resulting in the inability to detect safety hazards. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0010] Figure 1 It is a flowchart of a configuration engineering debugging method provided in an embodiment of the present application;
[0011] Figure 2 It is a flowchart of another configuration engineering debugging method provided in an embodiment of the present application;
[0012] Figure 3 It is a flowchart of another configuration engineering debugging method provided in an embodiment of the present application;
[0013] Figure 4 It is a flowchart of another configuration engineering debugging method provided in an embodiment of the present application;
[0014] Figure 5It is a flowchart of another configuration engineering debugging method provided in an embodiment of the present application;
[0015] Figure 6 This is a flow chart of another optional configuration engineering debugging method provided in the embodiment of the present application.
[0016] Figure 7 It is a flowchart of another optional configuration engineering debugging method provided in an embodiment of the present application;
[0017] Figure 8 It is a flowchart of another optional configuration engineering debugging method provided in an embodiment of the present application;
[0018] Fig. 9 It is a structural schematic diagram of a debugging device for configuration engineering provided in an embodiment of the present application;
[0019] Fig.10 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0020] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0021] A configuration engineering debugging method and device according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0022] Figure 1 This is a configuration engineering debugging method provided by an embodiment of the present application, such as Figure 1 As shown, the method includes:
[0023] S101, obtaining a configuration project corresponding to a first language, and converting the configuration project into a binary program;
[0024] S102, determining the mapping relationship between the target instruction address of the configuration project and the binary program, and determining the breakpoint debugging address of the configuration project;
[0025] S103: Determine the interrupt address corresponding to the binary program according to the mapping relationship between the breakpoint debugging address and the target instruction address, and perform breakpoint debugging on the configuration project based on the interrupt address.
[0026] It can be understood that the above-mentioned first language is a programming language used for industrial automation and control systems, wherein the above-mentioned first language complies with the IEC 61131-3 standard, and the above-mentioned first language includes but is not limited to: Ladder Diagram (LD) language, Structured Text (ST) language, Function Block Diagram (FBD) language, Sequential Function Chart (SFC) language, and Instruction List (IL) language.
[0027] It can be understood that configuration development is performed based on the first language to obtain a configuration project corresponding to the first language, wherein configuration development refers to configuring and programming the control system using the first language to meet specific automation and control requirements. The specific steps are as follows.
[0028] 1. Project planning: define the requirements, objectives and scope of the project, and determine the first language to be used (such as one of LD, ST, FBD, SFC, IL). Different first languages are used according to different control tasks.
[0029] 2. Create a project: Use a programming tool that supports the first language (such as PLC programming software) to create a new project.
[0030] 3. Write code: Write the code of the control system in the first language of your choice to form a configuration project. For example, use LD for logic diagram design, ST for structured text programming, FBD for graphical programming, SFC for state machine design, and IL for instruction list programming.
[0031] In some examples, after the configuration project is constructed, the example further converts the configuration project into a binary program. It can be understood that a binary program is a form of computer program, using binary coding and directly executed by computer hardware. The instructions that the central processing unit (CPU) in the computer can understand and execute are expressed in binary form. Therefore, after the configuration project is converted into a binary program, an interrupt instruction is directly sent to the central processing unit, and the configuration project can be interrupted during the operation of the configuration project, so that breakpoint debugging of the configuration project can be realized later.
[0032] In some examples, after converting the configuration project into a binary program, this example further determines the target instruction address mapping relationship between the configuration project and the binary program; wherein, the target instruction address mapping relationship is used to characterize the positional relationship between each code in the configuration project and each code in the binary program; illustratively, the configuration project consists of N lines of code (the code is written in a first language), and the binary program has M lines of code, wherein, if the Jth (J∈N) line of code in the configuration project corresponds to the Kth (K∈M) line of code in the binary program, then the Jth line of code in the configuration project and the Kth line of code in the binary program form a mapping relationship, and the correspondence between each line of code in the configuration project and each line of code in the binary program is determined based on the above principle to form the above-mentioned target instruction mapping relationship.
[0033] Continuing with the above example, in addition to determining the mapping relationship between the target instruction address of the configuration project and the binary program, this example will further determine the breakpoint debugging address of the configuration project, wherein when the configuration project runs to the breakpoint debugging address, the configuration project will be in a suspended state; it can be understood that the breakpoint debugging address is an address flexibly set by relevant personnel according to actual needs; illustratively, the configuration project consists of N lines of code (the code is written in the first language), and relevant personnel can set the location of any line (one or more lines) of code in 1-N as the above breakpoint debugging address.
[0034] In some examples, this example determines the interrupt address corresponding to the binary program according to the mapping relationship between the breakpoint debugging address and the target instruction address, so that the interrupt address corresponds to the determined breakpoint debugging address; for example, in the target instruction address mapping relationship, the J (J∈N) line of code in the configuration project corresponds to the K (K∈M) line of code in the binary program, and the determined breakpoint debugging address of the configuration project is the J line of code, then the K line of code in the binary program is used as the interrupt position.
[0035] Continuing with the above example, after determining the interrupt address, this example further performs breakpoint debugging on the configuration project based on the interrupt address. Specifically, the binary program is interrupted through the interrupt address and debugging information is obtained. Since the binary program is converted from the configuration project, the debugging information obtained by interrupt debugging the binary program can reflect the interrupt debugging information corresponding to the configuration project. Exemplarily, the J (J∈N) line of code in the configuration project corresponds to the K (K∈M) line of code in the binary program, and the K line of code in the binary program is the interrupt address. When the binary program is interrupted at the K line, the debugging information reflected is the same as the debugging information reflected at the interruption of the configuration project at the J line of code.
[0036] According to the technical solution provided in the embodiment of the present application, a configuration project corresponding to a first language is obtained, and the configuration project is converted into a binary program; a mapping relationship between a target instruction address of the configuration project and the binary program is determined, and a breakpoint debugging address of the configuration project is determined; an interrupt address corresponding to the binary program is determined according to a mapping relationship between the breakpoint debugging address and the target instruction address, and breakpoint debugging is performed on the configuration project based on the interrupt address, thereby realizing interruption of the binary program through the interrupt address and obtaining debugging information. Since the binary program is converted from the configuration project, the debugging information obtained by interrupt debugging the binary program can reflect the interrupt debugging information corresponding to the configuration project. Therefore, breakpoint debugging of the binary program realizes debugging of the configuration project, thereby avoiding the problem in the related art that breakpoint debugging of the configuration project of a specific language cannot be performed, resulting in an inability to troubleshoot safety hazards.
[0037] In some embodiments, Figure 2 As shown, convert the configuration project into a binary program, including:
[0038] S201, converting the configuration project into a debugging program, where the debugging program is built based on a second language, and the first language and the second language are different;
[0039] S202: Convert the debugging program into a binary program.
[0040] Specifically, since binary programs are machine-oriented, they are unreadable to users and do not have program logic. Therefore, it is impossible to directly convert a readable configuration project with program logic into an unreadable binary program. This example first converts the configuration project into a debugging program. Since the second language is an object-oriented language, the second language is unreadable to users and has program logic. The debugging program is built based on the second language, so the debugging program is readable to users and can understand the program logic. The debugging program is then converted into a binary program, wherein the second language has a mature compiler that can compile the readable debugging program with program logic constructed in the second language into a binary program.
[0041] Exemplarily, the second language is C language as an example, wherein C language has a mature compiler, which can compile the debugging program built in C language into a binary program. Therefore, after building the configuration project, this example converts the configuration project into a debugging program through the following steps: Step 1: Understand the role of each element in the configuration project and determine the program logic. Step 2: Convert the program logic in the configuration project into equivalent logic in C language, wherein the process of converting the program logic into equivalent logic involves mapping elements such as function blocks and functions to functions and structures in C language. Step 3: Data model conversion, since the configuration project uses a data model different from that of C language, including data types and variable declarations. Convert these elements into equivalent elements in C language. Step 4: Determine the processing timing, convert the loop and timing control used in the configuration project into the loop and timing control in C language; Step 5: Process time trigger, determine the trigger mechanism of the configuration project, and convert the trigger mechanism into the corresponding trigger mechanism in C language. Among them, based on the above steps, the codes in the configuration project are converted into C language one by one, thereby realizing the construction of the debugging program.
[0042] According to the technical solution provided in the embodiment of the present application, the configuration project is converted into a debugging program, and the debugging program is built based on a second language, and the first language and the second language are different; the debugging program is converted into a binary program, thereby realizing the conversion of the configuration project with program logic into a debugging program with program logic, and then the debugging program is converted into a binary program based on a compiler, thereby realizing the conversion of the configuration project to the binary program, avoiding the problem in the related art that a readable configuration project with program logic cannot be converted into an unreadable binary program.
[0043] In some embodiments, Figure 3 As shown, determine the target instruction address mapping relationship between the configuration project and the binary program, including:
[0044] S301, obtaining a first instruction address mapping relationship between a configuration project and a debugging program, and determining a second instruction address mapping relationship between the debugging program and a binary program;
[0045] S302: Determine a target instruction address mapping relationship according to the first instruction address mapping relationship and the second instruction address mapping relationship.
[0046] Specifically, through the above steps, the codes in the configuration project are converted into C language one by one to build the debugging program. Therefore, this example can obtain the first instruction mapping relationship between the code lines / blocks when the configuration project is converted into the debugging program; for example, the configuration project consists of N lines of code, and the debugging program consists of L lines of code. When the configuration project is converted into the debugging program, the correspondence between the Jth (J∈N) line of code in the configuration project and the Hth (H∈L) line of code in the debugging program can be known, and the correspondence between the Jth line of code in the configuration project and the Hth line of code in the debugging program is used as the first instruction address mapping relationship.
[0047] Similarly, in the step of determining the second instruction address mapping relationship between the debugger and the binary program, when the debugger is converted into a binary program through the compiler, the correspondence between the Hth (H∈L)th line of code in the debugger and the Kth (K∈M)th line of code in the binary program can also be obtained, and the correspondence between the Hth line of code in the debugger and the Kth line of code in the binary program is used as the second instruction address mapping relationship.
[0048] It can be understood that after obtaining the first instruction address mapping relationship and the second instruction address mapping relationship, the solution provided in this example determines the target instruction address mapping relationship based on the first instruction address mapping relationship and the second instruction address mapping relationship. Exemplarily, according to the first instruction address mapping relationship and the second instruction address mapping relationship, it can be known that "the correspondence between the Jth line of code in the configuration project and the Hth line of code in the debugging program, and the correspondence between the Hth line of code in the debugging program and the Kth line of code in the binary program", and the mapping relationship between the Jth line of code in the configuration project and the Kth line of code in the binary program can be obtained, and the target instruction address mapping relationship is determined based on the above mapping relationship.
[0049] According to the technical solution provided in the embodiment of the present application, a first instruction address mapping relationship between a configuration project and a debugging program is obtained, and a second instruction address mapping relationship between the debugging program and a binary program is determined; based on the first instruction address mapping relationship and the second instruction address mapping relationship, a target instruction address mapping relationship is determined, wherein accurate acquisition of the target instruction address mapping relationship between the configuration project and the binary program is achieved by respectively acquiring the first instruction address mapping relationship and the second instruction address mapping relationship, thereby avoiding the problem in the related art that the configuration project cannot be directly converted into a binary program, resulting in the inability to obtain the target instruction address mapping relationship.
[0050] In some embodiments, Figure 4 As shown, according to the mapping relationship between the breakpoint debugging address and the target instruction address, the interrupt address corresponding to the binary program is determined, including:
[0051] S401, matching the breakpoint debugging address with the debugging address carried in the target instruction address mapping relationship to obtain a matching result;
[0052] S402: Determine an interrupt address corresponding to the breakpoint debugging address according to the matching result.
[0053] Specifically, after determining the mapping relationship between the breakpoint debugging address and the target instruction address, the debug address carried in the mapping relationship between the breakpoint debugging address and the target instruction address is matched, and the interrupt address corresponding to the breakpoint debugging address is determined according to the matching result.
[0054] Exemplarily, taking the target instruction address mapping relationship as displayed in a table form, the table contains at least two columns of elements, where the value of one column of elements is the debug address, and the original value of the other column is the interrupt address, wherein the debug address is the address corresponding to the code in the debugger, and the interrupt address is the address corresponding to the code in the binary program. The determined breakpoint debug address is matched with the debug address to obtain the interrupt address corresponding to the breakpoint debug address.
[0055] According to the technical solution provided in the embodiment of the present application, the debug address carried in the breakpoint debugging address and the target instruction address mapping relationship are matched; the interrupt address corresponding to the breakpoint debugging address is determined based on the matching result, thereby achieving accurate determination of the interrupt address in the binary program.
[0056] In some embodiments, Figure 5 As shown in the figure, breakpoint debugging is performed on the configuration project based on the interrupt address, including:
[0057] S501, determining an execution instruction corresponding to the interrupt address, and storing the execution instruction;
[0058] S502: Replace the execution instruction with the interrupt instruction of the controller, so that when the operation pointer of the controller jumps to the interrupt address, the interrupt instruction is triggered.
[0059] Specifically, after determining the interrupt address, in order to enable the program to be interrupted when running to this point, this example will further insert an interrupt instruction at the interrupt address. It can be understood that the interrupt instruction changes with the change of the system architecture of the controller; for example, if the system architecture is x86, the interrupt instruction is 0xCC under the x86 system architecture; for another example, the system architecture is ARM architecture, and the interrupt instruction is 0xEF under the ARM architecture; for another example, the system architecture is MIPS architecture, and the interrupt instruction is 0x0000 0x0C under the MIPS architecture.
[0060] It can be understood that after determining the interrupt instruction, this example further determines the execution instruction corresponding to the interrupt address, stores the execution instruction, and then replaces the execution instruction with the interrupt instruction, so that when the running pointer corresponding to the controller reaches the interrupt address, the interrupt instruction will be triggered to realize interrupt debugging of the binary program. Since the binary program is converted from the configuration project, the debugging information obtained by interrupt debugging of the binary program can reflect the interrupt debugging information corresponding to the configuration project. Therefore, breakpoint debugging of the binary program realizes breakpoint debugging of the configuration project.
[0061] It can be understood that if there are multiple interrupt addresses, the execution instructions to the multiple interrupt addresses are replaced by interrupt instructions respectively.
[0062] It can be understood that by storing the execution instructions corresponding to the interrupt address and storing the execution instructions, after the interrupt debugging of the current interrupt address is completed, the interrupt address can be replaced with the execution instruction, and the subsequent other interrupt addresses can be debugged, thereby improving the debugging efficiency of the binary program and thus improving the debugging efficiency of the configuration project.
[0063] In order to better understand this method, this example proposes a more specific example for illustration, such as Figure 6 As shown, Figure 6 This is a flowchart of another optional configuration engineering debugging method provided by this example. Figure 6As shown, the debugging method of the configuration project provided in this example is applied to a control system, which includes a host computer and a controller; the method comprises the following steps: first, the user first uses the IEC61131-3 programming language to perform configuration development through the AT host computer control station to obtain a configuration project; second, compile the configuration project formed by IEC61131-3 into an executable binary program, and parse and obtain various debugging information from the compiled program; third, download the compiled binary program to the controller for operation; fourth, determine the interrupt address according to the breakpoint debugging address of the configuration project; fifth, obtain the corresponding debugging information from the host computer software; sixth, send the interrupt address to the controller; seventh, back up and save the execution instruction corresponding to the interrupt instruction in the controller, and modify the execution instruction of the interrupt address to the CPU interrupt instruction (for example: the next byte 0xCC of x86); eighth, when the binary program runs to the interrupt address, it encounters an interrupt instruction, automatically suspends the program, and reports the interrupt address and context information; ninth, the controller reports the information after the interrupt to the AT host computer to display the interrupt position. Among them, the above nine steps realize the interrupt debugging of the configuration project based on the CPU interrupt instruction. The above method can simplify the influence of the interrupt on the controller, such as the consumption of resources such as memory, code area and CPU idling. Through the conversion to C solution, various open source compilers can be used for compilation, and the generated debugging information DWARF has a standard format, without the need for additional adaptation of different compilers, and one-time development is sufficient. The generation and use of debugging information are saved in the host computer. During debugging, only the instruction address at the breakpoint is downloaded and replaced in the original code area. The resource overhead is almost negligible. The CPU interrupt response speed can quickly respond to the interrupt information and report it to the controller. The controller presents it to the user after matching the debugging information saved in the host computer according to the reported address and context information. It has fast response speed and good user experience, and can achieve various types of breakpoint operations and conditional breakpoints, data breakpoints and other advantages.
[0064] According to the technical solution provided in the embodiment of the present application, the execution instruction corresponding to the interrupt address is determined, and the execution instruction is stored; the execution instruction is replaced with the interrupt instruction of the controller, so that when the running pointer of the controller jumps to the interrupt address, the interrupt instruction is triggered, thereby realizing interrupt debugging of the binary program. Since the binary program is converted from the configuration project, the debugging information obtained by interrupt debugging of the binary program can reflect the interrupt debugging information corresponding to the configuration project. Therefore, breakpoint debugging of the binary program realizes breakpoint debugging of the configuration project.
[0065] In some examples, such as Figure 7As shown, after performing breakpoint debugging on the configuration project based on the interrupt address, the method further includes:
[0066] S601, obtaining debugging information triggered in response to an interrupt instruction;
[0067] S602: Analyze the debugging information, and debug the configuration project based on the analyzed debugging information.
[0068] Specifically, the debugging information generated by the binary program has a standard format, and includes parameters such as the interrupt address, binary program running status, and variable values. By parsing the debugging information, the above parameters can be obtained, thereby debugging the configuration project corresponding to the binary program.
[0069] It can be understood that if there are multiple interrupt addresses, in some examples, a debugging information can be returned for each interrupt address, and each debugging information can be parsed to debug the configuration project at each interrupt address; in some examples, the debugging information corresponding to each interrupt address can be collected to obtain a debugging information set, and after the interrupt instructions corresponding to all interrupt addresses are executed, the debugging information set is returned, and by parsing the debugging information set, the debugging information corresponding to each interrupt address can be obtained, and each debugging information can be parsed to debug the configuration project at each interrupt address.
[0070] According to the technical solution provided in the embodiment of the present application, debugging information triggered in response to an interrupt instruction is obtained; the debugging information is parsed, and the configuration project is debugged based on the parsed debugging information, thereby debugging the binary program through the debugging information of the binary program.
[0071] In some examples, such as Figure 8 As shown, after replacing the execution instruction with the interrupt instruction of the controller, the method further includes:
[0072] S701, in response to the received run instruction, obtaining an execution instruction corresponding to the interrupt address;
[0073] S702: Replace the interrupt instruction with an execution instruction to run the binary program at the interrupt address.
[0074] Specifically, in response to the received run instruction, an execution instruction corresponding to the interrupt address is obtained; the interrupt instruction is replaced with the execution instruction to run the binary program at the interrupt address, and the binary program continues to run, thereby improving the running efficiency of the binary program.
[0075] It can be understood that if there are multiple interrupt addresses, after executing the interrupt instruction at any interrupt address, the interrupt instruction at the interrupt address is replaced by the original execution instruction to run the binary program at the interrupt address, and the binary program continues to run, thereby improving the debugging efficiency of the binary program.
[0076] According to the technical solution provided in the embodiment of the present application, in response to the received run instruction, the execution instruction corresponding to the interrupt address is obtained; the interrupt instruction is replaced with the execution instruction to run the binary program at the interrupt address, thereby realizing the running of the binary program at the interrupt address, continuing to run the binary program, and improving the debugging efficiency of the binary program.
[0077] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0078] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0079] This embodiment also provides a debugging device for configuration engineering, such as Fig. 9 As shown, the device comprises:
[0080] The conversion module 801 is used to obtain a configuration project corresponding to the first language and convert the configuration project into a binary program;
[0081] A mapping module 802 is used to determine the mapping relationship between the target instruction address of the configuration project and the binary program, and determine the breakpoint debugging address of the configuration project;
[0082] The debugging module 803 is used to determine the interrupt address corresponding to the binary program according to the mapping relationship between the breakpoint debugging address and the target instruction address, and perform breakpoint debugging on the configuration project based on the interrupt address.
[0083] In some examples, the conversion module 801 is further used to convert the configuration project into a debugging program, where the debugging program is built based on a second language, and the first language and the second language are different; and convert the debugging program into a binary program.
[0084] In some examples, the mapping module 802 is also used to obtain a first instruction address mapping relationship between the configuration project and the debugging program, and determine a second instruction address mapping relationship between the debugging program and the binary program; and determine the target instruction address mapping relationship based on the first instruction address mapping relationship and the second instruction address mapping relationship.
[0085] In some examples, the mapping module 802 is further used to match the debug address carried in the breakpoint debug address and the target instruction address mapping relationship; and determine the interrupt address corresponding to the breakpoint debug address according to the matching result.
[0086] In some examples, the debugging module 803 is also used to determine the execution instruction corresponding to the interrupt address and store the execution instruction; replace the execution instruction with the interrupt instruction of the controller, so that when the running pointer of the controller jumps to the interrupt address, the interrupt instruction is triggered.
[0087] In some examples, the debugging module 803 is further used to obtain debugging information triggered in response to an interrupt instruction; parse the debugging information, and debug the configuration project based on the parsed debugging information.
[0088] In some examples, the debugging module 803 is further used to obtain an execution instruction corresponding to the interrupt address in response to the received run instruction; and replace the interrupt instruction with the execution instruction to run the binary program at the interrupt address.
[0089] According to the technical solution provided in the embodiment of the present application, the debugging device for the configuration project provided in the embodiment converts the configuration project into a binary program by acquiring the configuration project corresponding to the first language; determines the target instruction address mapping relationship between the configuration project and the binary program, and determines the breakpoint debugging address of the configuration project; determines the interrupt address corresponding to the binary program according to the mapping relationship between the breakpoint debugging address and the target instruction address, and performs breakpoint debugging on the configuration project based on the interrupt address, thereby realizing interruption of the binary program through the interrupt address and obtaining debugging information. Since the binary program is converted from the configuration project, the debugging information obtained by interrupt debugging the binary program can reflect the interrupt debugging information corresponding to the configuration project. Therefore, breakpoint debugging of the binary program realizes debugging of the configuration project, avoiding the problem in the related art that breakpoint debugging of the configuration project of a specific language cannot be performed, resulting in the inability to detect safety hazards.
[0090] Fig. 9 Schematic diagram of an electronic device 9 provided in an embodiment of the present application. Fig. 9 As shown, the electronic device 9 of this embodiment includes: a processor 901, a memory 902, and a computer program 903 stored in the memory 902 and executable on the processor 901. When the processor 901 executes the computer program 903, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 901 executes the computer program 903, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0091] The electronic device 9 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 9 may include, but is not limited to, a processor 901 and a memory 902. Those skilled in the art will appreciate that Fig. 9 The electronic device 9 is merely an example and does not limit the electronic device 9 , and may include more or less components than those shown in the figure, or different components.
[0092] The processor 901 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0093] The memory 902 may be an internal storage unit of the electronic device 9, for example, a hard disk or memory of the electronic device 9. The memory 902 may also be an external storage device of the electronic device 9, for example, a plug-in hard disk, a smart memory card (Smart Med ia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. equipped on the electronic device 9. The memory 902 may also include both an internal storage unit of the electronic device 9 and an external storage device. The memory 902 is used to store computer programs and other programs and data required by the electronic device.
[0094] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0095] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, and the computer program code may be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of regional requirements and patent practice. For example, in some areas, according to regional requirements and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.
[0096] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application 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 make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A configuration engineering debugging method, characterized in that: The method comprises: Obtaining a configuration project corresponding to the first language, and converting the configuration project into a binary program; Determine the target instruction address mapping relationship between the configuration project and the binary program, and determine the breakpoint debugging address of the configuration project; According to the mapping relationship between the breakpoint debugging address and the target instruction address, the interrupt address corresponding to the binary program is determined, and the configuration project is breakpoint debugged based on the interrupt address.
2. The method according to claim 1, characterized in that Convert the configuration project into a binary program, including: Converting the configuration project into a debugging program, wherein the debugging program is constructed based on a second language, and the first language and the second language are different; The debug program is converted into the binary program.
3. The method according to claim 2, characterized in that Determining a target instruction address mapping relationship between the configuration project and the binary program includes: Acquire a first instruction address mapping relationship between the configuration project and the debugging program, and determine a second instruction address mapping relationship between the debugging program and the binary program; The target instruction address mapping relationship is determined according to the first instruction address mapping relationship and the second instruction address mapping relationship.
4. The method according to claim 2, characterized in that: Determining an interrupt address corresponding to the binary program according to a mapping relationship between the breakpoint debugging address and the target instruction address includes: Matching the breakpoint debugging address with the debugging address carried in the target instruction address mapping relationship to obtain a matching result; The interrupt address corresponding to the breakpoint debugging address is determined according to the matching result.
5. The method according to claim 2, characterized in that: Performing breakpoint debugging on the configuration project based on the interrupt address includes: Determine an execution instruction corresponding to the interrupt address, and store the execution instruction; The execution instruction is replaced with an interrupt instruction of the controller, so that when the operation pointer of the controller jumps to the interrupt address, the interrupt instruction is triggered.
6. The method according to claim 5, characterized in that After performing breakpoint debugging on the configuration project based on the interrupt address, the method further includes: Acquire debugging information triggered in response to the interrupt instruction; The debugging information is parsed, and the configuration project is debugged based on the parsed debugging information.
7. The method according to claim 5, characterized in that After replacing the execution instruction with the interrupt instruction of the controller, the method further includes: In response to the received run instruction, obtaining the execution instruction corresponding to the interrupt address; The interrupt instruction is replaced by the execution instruction to run the binary program at the interrupt address.
8. A debugging device for configuration engineering, characterized in that: The device comprises: A conversion module, used to obtain a configuration project corresponding to the first language, and convert the configuration project into a binary program; A mapping module, used to determine the mapping relationship between the configuration project and the target instruction address of the binary program, and determine the breakpoint debugging address of the configuration project; The debugging module is used to determine the interrupt address corresponding to the binary program according to the mapping relationship between the breakpoint debugging address and the target instruction address, and perform breakpoint debugging on the configuration project based on the interrupt address.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
