Hybrid debugging method and device of programming language, electronic equipment and storage medium
By pre-setting unified symbol rules and syntax tree rules, programming files in high-level and industrial languages are compiled and compiled files with the same format are generated, which solves the problem that hybrid debugging cannot be performed in the existing technology and improves the efficiency of software development.
Patent Information
- Application Number
- CN202411789936.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-03-18
AI Technical Summary
In the prior art, high-level and industrialized languages cannot perform mixed debugging, resulting in inefficient software development.
By obtaining the programming files corresponding to at least two programming languages, and pre-setting unified symbol rules and syntax tree rules, programming files of different programming languages are compiled, and compiling files with the same format are generated, thereby realizing hybrid debugging.
It realizes mixed debugging of compiled files in different programming language formats, improves software development efficiency, and avoids the problem of inefficient software development caused by the inability to mix debugging of high-level and industrial languages in related technologies.
Smart Images

Figure CN119645418A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a mixed debugging method, device, electronic device and storage medium for programming languages. Background Art
[0002] With the continuous development of industrial automation technology, the application scenarios of configuration languages are becoming increasingly diverse. In addition, with the general improvement of the professional quality of configuration personnel, in certain scenarios, the need for configuration personnel to use high-level languages (such as C, C++, etc.) for programming becomes more urgent. Especially in the (programmable logic controller PLC) industry, facing increasingly complex and diverse control requirements and flexible and changeable scenarios, high-level languages are gradually favored by configuration personnel for their strong flexibility and expressiveness. However, standardized industrial languages (such as IEC languages) are still the most widely used programming languages in industrial automation configuration and occupy a core position in the industry.
[0003] In this context, in order to solve the problems encountered in mixed programming of high-level languages and industrialized languages, a mixed debugging method of high-level languages and industrialized languages is urgently needed. Summary of the invention
[0004] In view of this, the embodiments of the present application provide a mixed debugging method, device, electronic device and storage medium for programming languages to solve the problem in the prior art that high-level languages and industrial languages cannot be mixed debugged, resulting in low software development efficiency.
[0005] According to a first aspect of an embodiment of the present application, a mixed debugging method for programming languages is provided, the method comprising: obtaining programming files corresponding to at least two programming languages respectively, and obtaining preset compilation rules, the compilation rules including syntax tree rules and symbol rules; compiling each programming file according to the preset compilation rules to obtain a compilation file corresponding to each programming file, each compilation file including a symbol file and a syntax tree file; generating an executable program according to the symbol file and the syntax tree file corresponding to each programming file, and debugging each programming file based on the executable program.
[0006] According to a second aspect of an embodiment of the present application, a mixed debugging device for programming languages is provided, the device comprising: an acquisition module for acquiring programming files corresponding to at least two programming languages respectively, and acquiring preset compilation rules, the compilation rules comprising syntax tree rules and symbol rules; a compilation module for compiling each programming file according to the preset compilation rules to obtain a compilation file corresponding to each programming file, each compilation file comprising a symbol file and a syntax tree file; a debugging module for generating an executable program according to the symbol file and the syntax tree file corresponding to each programming file, and debugging each programming file based on the executable program.
[0007] 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.
[0008] 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.
[0009] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the method of the embodiments of the present application obtains programming files corresponding to at least two programming languages respectively, and obtains pre-set compilation rules; compiles each programming file according to the pre-set compilation rules to obtain a compiled file corresponding to each programming file, each compiled file including a symbol file and a syntax tree file; generates an executable program according to the symbol file and the syntax tree file corresponding to each programming file, and debugs each programming file based on the executable program. The present application pre-sets unified symbol rules and syntax tree rules, and then compiles programming files of different programming languages according to the unified symbol rules and syntax tree rules to generate compiled files of the same format, so that the compiled files of the same format can be subsequently linked to generate executable files, and finally each programming file is debugged based on the executable file, thereby realizing mixed debugging of compiled files in different programming language formats, improving software development efficiency, and avoiding the problem in the related technology that high-level languages and industrialized languages cannot be mixed debugged, resulting in low software development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] 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.
[0011] Figure 1 It is a flowchart of a hybrid debugging method of a programming language provided in an embodiment of the present application;
[0012] Figure 2 It is a basic flow chart of a hybrid debugging method of a programming language provided in an embodiment of the present application;
[0013] Figure 3 It is a flowchart of a hybrid debugging method of another programming language provided in an embodiment of the present application;
[0014] Figure 4 It is a flowchart of a hybrid debugging method of another programming language provided in an embodiment of the present application;
[0015] Figure 5 It is a basic schematic diagram of a syntax tree structure provided in an embodiment of the present application;
[0016] Figure 6 It is a flowchart of another hybrid debugging method of a programming language provided in an embodiment of the present application;
[0017] Figure 7 This is a basic schematic diagram of determining debugging information according to an interruption position provided by an embodiment of the present application;
[0018] Figure 8 It is a flowchart of a hybrid debugging method of another programming language provided in an embodiment of the present application;
[0019] Fig. 9 It is a basic schematic diagram of a control logic to target programming language provided by an embodiment of the present application;
[0020] Fig.10 It is a basic schematic diagram of debugging based on the target type of the next statement provided by an embodiment of the present application;
[0021] Fig.11 It is a flowchart of another optional hybrid debugging method of a programming language provided in an embodiment of the present application;
[0022] Fig.12 It is a structural schematic diagram of a mixed debugging device of a programming language provided in an embodiment of the present application;
[0023] Fig.13 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] 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.
[0025] A mixed debugging method and device for a programming language according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0026] Figure 1 A hybrid debugging method of a programming language provided in an embodiment of the present application is as follows: Figure 1 As shown, the method includes:
[0027] S101, obtaining programming files corresponding to at least two programming languages, and obtaining pre-set compilation rules, where the compilation rules include syntax tree rules and symbol rules;
[0028] S102, compiling each programming file according to a preset compilation rule to obtain a compilation file corresponding to each programming file, each compilation file including a symbol file and a syntax tree file;
[0029] S103 : Generate an executable program according to the symbol file and syntax tree file corresponding to each programming file, and debug each programming file based on the executable program.
[0030] It can be understood that the hybrid debugging method of the programming language provided in the present application is applied to the terminal and / or the server, that is, the hybrid debugging method of the programming language can be executed by the terminal or the server alone, and the hybrid debugging method of the programming language can also be executed by the terminal and the server together, wherein the above-mentioned terminal includes but is not limited to mobile phones, tablet computers, desktop computers and other devices.
[0031] In some examples, at least two programming languages in step S101 of the present application include a high-level programming language and an industrial programming language, wherein the high-level programming language includes but is not limited to one of C and C++, and the industrial programming language includes an IEC language (a programming language that complies with the IEC61131-3 standard is an IEC language, and the IEC language includes but is not limited to one of a ladder diagram and a function block diagram).
[0032] In some examples, the present application will obtain programming files corresponding to at least two programming languages, each programming language corresponding to at least one programming file; it can be understood that one programming language can correspond to multiple programming files. For example, taking two programming languages including C language and IEC language as an example, the present application refers to the programming file corresponding to C language as C file, and the programming file corresponding to IEC language as IEC file, then the present application will obtain one or more C files and one or more IEC files.
[0033] In some examples, the present application obtains pre-set compilation rules, and then compiles each programming file according to the pre-set compilation rules to obtain a compilation file corresponding to each programming file, each compilation file includes a symbol file and a syntax tree file, and the compilation rules include syntax tree rules and symbol rules; wherein, in order to achieve mixed debugging of C files and IEC files, the present application pre-sets unified symbol rules and syntax tree rules, and subsequently generates compilation files with the same format according to the symbol rules and syntax tree rules, thereby enabling subsequent mixed debugging of compilation files with the same format.
[0034] Specifically, Figure 2 As shown, taking two programming languages including C language and IEC language as examples, the present application refers to the programming file corresponding to the C language as a C file, and the programming file corresponding to the IEC language as an IEC file. The present application compiles each C file through syntax tree rules and symbol rules to obtain a symbol file and syntax tree file corresponding to each C file; and compiles each IEC file through syntax tree rules and symbol rules to obtain a symbol file and syntax tree file corresponding to each IEC file.
[0035] It can be understood that, in the process of compiling each programming file, the present application will also generate an object file (object file, obj) corresponding to each programming file; illustratively, Figure 2 As shown, the present application compiles each C file to obtain an obj file corresponding to each C file; and compiles each IEC file to obtain an obj file corresponding to each IEC file.
[0036] In some examples, the present application also generates an executable program according to the symbol file and syntax tree file corresponding to each programming file, and debugs each programming file based on the executable program; specifically, the present application links the obtained compiled files to obtain the executable program; illustratively, Figure 2As shown, the present application compiles each C file to obtain the obj file, symbol file and syntax tree file corresponding to each C file; compiles each IEC file to obtain the obj file, symbol file and syntax tree file corresponding to each IEC file, and then links all the obj files, symbol files and syntax tree files to obtain an executable program.
[0037] In some examples, after generating an executable program, the present application can debug each programming file according to the executable program; specifically, Figure 2 As shown, the present application downloads the generated executable program into the controller memory to execute the executable program to implement debugging of each programming file.
[0038] According to the technical solution provided in the embodiment of the present application, programming files corresponding to at least two programming languages are obtained, and pre-set compilation rules are obtained; each programming file is compiled according to the pre-set compilation rules to obtain a compiled file corresponding to each programming file, and each compiled file includes a symbol file and a syntax tree file; an executable program is generated according to the symbol file and the syntax tree file corresponding to each programming file, and each programming file is debugged based on the executable program. The present application pre-sets unified symbol rules and syntax tree rules, and then compiles programming files of different programming languages according to the unified symbol rules and syntax tree rules to generate compiled files with the same format, so that the compiled files with the same format can be subsequently linked to generate executable files, and finally each programming file is debugged based on the executable file, thereby realizing mixed debugging of compiled files in different programming language formats, improving software development efficiency, and avoiding the problem in related technologies that high-level languages and industrialized languages cannot be mixed debugged, resulting in low software development efficiency.
[0039] In some embodiments, Figure 3 As shown, each programming file is compiled according to the preset compilation rules to obtain a compiled file corresponding to each programming file, including:
[0040] S301, obtaining an identifier corresponding to each programming file;
[0041] S302: Record the identifier corresponding to each programming file according to a preset symbol rule to obtain a symbol file corresponding to each programming file.
[0042] Specifically, the symbol file records the mapping relationship between identifiers in the programming file (such as variables (global variables, local variables), functions, classes, etc.) and their corresponding memory addresses or locations, and is used to track the operation of the program during the debugging and linking stages.
[0043] Based on the above principles, this application will scan each programming file, identify the variable names, function names, type names and other identifiers in each programming file, and then record the identifiers corresponding to each programming file according to the pre-set symbol rules to obtain the symbol file corresponding to each programming file.
[0044] It can be understood that the pre-set symbol rules define data such as symbol type, symbol position, binary position, symbol offset, etc., among which, symbol type: used to identify the type of identifier, symbol types include: global variables, local variables, global functions, objects, etc. Symbol position: used to identify the position of the identifier in the source code. After the program runs to the breakpoint position, the position is queried to mark the breakpoint. Binary position: used as a query condition. Symbol offset: The offset of the symbol in the data area or stack, used to resolve the value of the symbol.
[0045] According to the technical solution provided in the embodiment of the present application, an identifier corresponding to each programming file is obtained; according to the pre-set symbol rules, the identifier corresponding to each programming file is recorded to obtain a symbol file corresponding to each programming file. The present application compiles programming files corresponding to different programming languages through a unified symbol rule, so that the symbol files compiled from programming files corresponding to different programming languages have the same format, and the symbol files of the same format can be subsequently linked to generate executable files, thereby realizing mixed debugging of programming files in different programming languages.
[0046] In some embodiments, Figure 4 As shown, each programming file is compiled according to the preset compilation rules to obtain a compiled file corresponding to each programming file, including:
[0047] S401, determining the compilation unit corresponding to each programming file;
[0048] S402: Perform syntax tree file analysis on the compilation unit corresponding to each programming file according to preset syntax tree rules to obtain a syntax tree file corresponding to each programming file.
[0049] It can be understood that the syntax tree is a tree-structured data generated based on each compilation unit. Therefore, the present application will determine the compilation unit corresponding to each programming file.
[0050] Exemplarily, taking two programming languages including C language and IEC language as an example, this application refers to the programming file corresponding to the C language as a C file, and the programming file corresponding to the IEC language as an IEC file, wherein the compilation unit of the C (same for C++) language is a single file, and the compilation unit of the IEC is a POU file.
[0051] In some examples, the present application will perform syntax tree file analysis on the compilation unit corresponding to each programming file according to pre-set syntax tree rules to obtain a syntax tree file corresponding to each programming file, wherein the syntax tree rules are as follows: the programming language generates a unified syntax tree structure based on statements, branches, and loops, and the statement, branch, and loop syntax tree structure includes: node type, symbol index, code position, and binary position.
[0052] For example, taking two programming languages including C language (or C++ language) and IEC language as an example, the present application refers to the programming file corresponding to C language as C file (the programming file corresponding to C++ language as C++ file), and the programming file corresponding to IEC language as IEC file, such as Figure 5 As shown, the C / C++ file is converted into a syntax tree structure, and the IEC POU (IEC compilation unit) is converted into a syntax tree structure.
[0053] According to the technical solution provided in the embodiment of the present application, the compilation unit corresponding to each programming file is determined; according to the pre-set syntax tree rules, the syntax tree file analysis is performed on the compilation unit corresponding to each programming file to obtain the syntax tree file corresponding to each programming file. The present application compiles the programming files corresponding to different programming languages through a unified syntax tree rule, so that the syntax tree files compiled from the programming files corresponding to different programming languages have the same format, and the syntax tree files of the same format can be subsequently linked to generate executable files, thereby realizing mixed debugging of programming files in different programming languages.
[0054] In some embodiments, Figure 6 As shown, each programming file is debugged based on the executable program, including:
[0055] S601, setting an interrupt position corresponding to the executable program according to the debugging instruction;
[0056] S602: When the executable program runs to an interrupt position, determine a current function symbol corresponding to the executable program, and determine debugging information based on the current function symbol.
[0057] Specifically, the present application sets the interrupt position corresponding to the executable program according to the debugging instruction, and the debugging instruction is an instruction input by the user for setting the interrupt position.
[0058] In some examples, after the executable program runs to the interrupt position, the executable program will be interrupted. At this time, the executable program will report the current function symbol to the debugging tool by communicating with the controller.
[0059] Continuing with the above example, Figure 7As shown, after obtaining the current function symbol reported by the executable program, the present application will query the current function symbol based on the symbol file obtained in step 301 and step 302, obtain the file location corresponding to the current function symbol, and then locate the corresponding compiled file, and then parse the current function symbol. It can be understood that since the symbols in the symbol file are stored according to the compilation unit, all the symbols in the compilation file are queried and all the symbols of the compilation unit are obtained after parsing the symbol table. Through the offset information in the symbol, the online value in the corresponding offset information is obtained by communicating with the controller; the present application will also parse the current function symbol position, specifically, there is symbol position information in all symbol information, and the online value obtained from the controller and the symbol position information are parsed into the memory. Finally, the above-mentioned obtained file information (compiled file confidence), position information, and online value are drawn to the interactive interface as debugging information, so that relevant personnel can know the debugging results.
[0060] According to the technical solution provided in the embodiment of the present application, the interrupt position corresponding to the executable program is set according to the debugging instruction; when the executable program runs to the interrupt position, the current function symbol corresponding to the executable program is determined, and the debugging information is determined based on the current function symbol, so that relevant personnel can clearly know the debugging results.
[0061] In some examples, such as Figure 8 As shown, debugging information is determined based on the current function symbol, including:
[0062] S801, obtaining a symbol file table, where the symbol file table is generated according to the symbol file corresponding to each programming file;
[0063] S802: query the symbol file table according to the current function symbol to obtain debugging information.
[0064] Specifically, in order to avoid the inefficiency problem caused by querying each symbol file one by one, the present application will obtain a symbol file table, which is generated based on the symbol file corresponding to each programming file.
[0065] like Figure 2 As shown, the present application generates a symbol file table based on the symbol file corresponding to each programming file, so that the symbol file table contains the contents of the symbol file corresponding to each programming file. Subsequently, the symbol file table can be queried according to the current function symbol to obtain debugging information without querying each symbol file one by one, thereby improving debugging efficiency.
[0066] According to the technical solution provided in the embodiment of the present application, a symbol file table is obtained, and the symbol file table is generated according to the symbol file corresponding to each programming file; the symbol file table is queried according to the current function symbol to obtain debugging information. The present application realizes rapid acquisition of debugging information by querying the symbol file table containing each symbol file, avoiding querying each symbol file one by one, thereby improving debugging efficiency.
[0067] In some examples, such as Fig. 9 As shown, the interrupt position corresponding to the executable program is set according to the debugging instruction, including:
[0068] S901, setting a current debugging breakpoint according to a debugging instruction, and querying a syntax tree file based on the current debugging breakpoint to determine a target type of a next statement corresponding to the current debugging breakpoint;
[0069] S902: Determine a target debugging breakpoint according to the determined target type, and set a break position based on the target debugging breakpoint.
[0070] Specifically, this application will set the current debugging breakpoint according to the debugging instruction, and query the syntax tree file based on the current debugging breakpoint to determine the target type of the next statement corresponding to the current debugging breakpoint. It can be understood that different target types of the next statement correspond to different target debugging breakpoints;
[0071] Exemplarily, taking the target type of the next statement as a conditional statement, all branch nodes under the conditional statement are searched, and the position of each branch node is used as the target debugging breakpoint, and the target debugging breakpoint position is used as the interruption position; if the target type of the next statement is a loop statement, the first branch node of the loop statement is queried, and the position of the first branch node is used as the target debugging breakpoint.
[0072] It can be understood that the present application can obtain the target type of the next statement by querying the syntax tree. After obtaining the target type of the next statement, the present application will determine the target debugging breakpoint according to the determined target type. The target debugging breakpoint is used to determine the interrupt position of the executable program, such as Fig.10 As shown, the executable program is then executed, and when the executable program triggers the interruption position of the target debugging breakpoint, the executable program is interrupted and reported to the debugging software.
[0073] According to the technical solution provided in the embodiment of the present application, the current debugging breakpoint is set according to the debugging instruction, and the syntax tree file is queried based on the current debugging breakpoint to determine the target type of the next statement corresponding to the current debugging breakpoint; according to the determined target type, the target debugging breakpoint is determined, and the interrupt position is set based on the target debugging breakpoint. The current debugging breakpoint is set according to the debugging instruction, and the syntax tree file is queried based on the current debugging breakpoint to determine the target type of the next statement corresponding to the current debugging breakpoint; according to the determined target type, the target debugging breakpoint is determined, and the interrupt position is set based on the target debugging breakpoint. This solution realizes single-step debugging of the executable program, and then realizes debugging of each programming file.
[0074] In some examples, such as Fig.11 As shown, after debugging each programming file based on the executable program, the method further includes:
[0075] S1101, obtaining the program running efficiency of the executable program;
[0076] S1102. Generate a program optimization strategy based on program operation efficiency.
[0077] Specifically, the present application uses performance analysis tools (such as perf, valgrind or Visual Studio Profiler) to analyze the program running efficiency of the executable program and identify performance bottlenecks in the program, such as time-consuming algorithms or unnecessary resource usage.
[0078] Among them, program running efficiency is usually measured in the following aspects: Execution time: the time required for the program to complete a specific task. Resource utilization: such as CPU occupancy, memory utilization, I / O consumption, etc. Throughput: the number of tasks processed by the program per unit time. Latency: the average time delay for processing each task.
[0079] After obtaining the program running efficiency, this application will analyze whether the execution time, resource utilization, throughput, and delay exceed the preset standard values. When they exceed the preset standard values, a program optimization strategy will be generated so that relevant personnel can optimize the executable program according to the program optimization strategy.
[0080] According to the technical solution provided in the embodiment of the present application, the program running efficiency of the executable program is obtained; a program optimization strategy is generated based on the program running efficiency, so that relevant personnel can optimize the executable program according to the program optimization strategy, thereby improving the availability of the executable program.
[0081] 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.
[0082] 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.
[0083] This embodiment also provides a mixed debugging device for programming languages, such as Fig.12 As shown, the device comprises:
[0084] The acquisition module 1201 is used to acquire programming files corresponding to at least two programming languages, and acquire preset compilation rules, where the compilation rules include syntax tree rules and symbol rules;
[0085] A compiling module 1202, used to compile each programming file according to a preset compiling rule to obtain a compiled file corresponding to each programming file, each compiled file including a symbol file and a syntax tree file;
[0086] The debugging module 1203 is used to generate an executable program according to the symbol file and the syntax tree file corresponding to each programming file, and debug each programming file based on the executable program.
[0087] In some examples, the compiling module 1202 is further used to obtain an identifier corresponding to each programming file; and record the identifier corresponding to each programming file according to a preset symbol rule to obtain a symbol file corresponding to each programming file.
[0088] In some examples, the compilation module 1202 is further used to determine the compilation unit corresponding to each programming file; perform syntax tree file analysis on the compilation unit corresponding to each programming file according to preset syntax tree rules to obtain the syntax tree file corresponding to each programming file.
[0089] In some examples, the debugging module 1203 is also used to set an interrupt position corresponding to the executable program according to the debugging instruction; when the executable program runs to the interrupt position, determine the current function symbol corresponding to the executable program, and determine the debugging information based on the current function symbol.
[0090] In some examples, the debugging module 1203 is also used to obtain a symbol file table, which is generated according to a symbol file corresponding to each programming file; the symbol file table is queried according to the current function symbol to obtain debugging information.
[0091] In some examples, the debugging module 1203 is also used to set the current debugging breakpoint according to the debugging instruction, and query the syntax tree file based on the current debugging breakpoint to determine the target type of the next statement corresponding to the current debugging breakpoint; determine the target debugging breakpoint based on the determined target type, and set the interrupt position based on the target debugging breakpoint.
[0092] In some examples, the debugging module 1203 is also used to obtain the program running efficiency of the executable program; and generate a program optimization strategy according to the program running efficiency.
[0093] According to the technical solution provided by the embodiment of the present application, the mixed debugging device of programming languages provided by the present embodiment obtains programming files corresponding to at least two programming languages respectively, and obtains pre-set compilation rules; compiles each programming file according to the pre-set compilation rules to obtain a compiled file corresponding to each programming file, and each compiled file includes a symbol file and a syntax tree file; generates an executable program according to the symbol file and the syntax tree file corresponding to each programming file, and debugs each programming file based on the executable program. The present application pre-sets unified symbol rules and syntax tree rules, and then compiles programming files of different programming languages according to the unified symbol rules and syntax tree rules to generate compiled files with the same format, so that the compiled files with the same format can be subsequently linked to generate executable files, and finally debugs each programming file based on the executable file, thereby realizing mixed debugging of compiled files in different programming language formats, improving software development efficiency, and avoiding the problem in related technologies that high-level languages and industrialized languages cannot be mixed debugged, resulting in low software development efficiency.
[0094] Fig.13 Schematic diagram of an electronic device 13 provided in an embodiment of the present application. Fig.13 As shown, the electronic device 13 of this embodiment includes: a processor 1301, a memory 1302, and a computer program 1303 stored in the memory 1302 and executable on the processor 1301. When the processor 1301 executes the computer program 1303, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 1301 executes the computer program 1303, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0095] The electronic device 13 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 13 may include, but is not limited to, a processor 1301 and a memory 1302. Those skilled in the art will appreciate that Fig.13 The electronic device 13 is merely an example and does not limit the electronic device 13 , and may include more or fewer components than those shown in the figure, or different components.
[0096] The processor 1301 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.
[0097] The memory 1302 may be an internal storage unit of the electronic device 13, for example, a hard disk or memory of the electronic device 13. The memory 1302 may also be an external storage device of the electronic device 13, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card (FlashCard), etc. equipped on the electronic device 13. The memory 1302 may also include both an internal storage unit of the electronic device 13 and an external storage device. The memory 1302 is used to store computer programs and other programs and data required by the electronic device.
[0098] 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.
[0099] 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.
[0100] 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 hybrid debugging method for a programming language, characterized in that: The method comprises: Obtain programming files corresponding to at least two programming languages respectively, and obtain preset compilation rules, wherein the compilation rules include syntax tree rules and symbol rules; Compile each of the programming files according to a preset compilation rule to obtain a compilation file corresponding to each of the programming files, each of the compilation files including a symbol file and a syntax tree file; An executable program is generated according to the symbol file and the syntax tree file corresponding to each programming file, and each programming file is debugged based on the executable program.
2. The method according to claim 1, characterized in that Compiling each of the programming files according to a preset compilation rule to obtain a compiled file corresponding to each of the programming files includes: Obtaining an identifier corresponding to each of the programming files; According to the preset symbol rule, the identifier corresponding to each programming file is recorded to obtain the symbol file corresponding to each programming file.
3. The method according to claim 1, characterized in that Compiling each of the programming files according to a preset compilation rule to obtain a compiled file corresponding to each of the programming files includes: Determine a compilation unit corresponding to each of the programming files; According to the preset syntax tree rules, syntax tree file analysis is performed on the compilation unit corresponding to each programming file to obtain the syntax tree file corresponding to each programming file.
4. The method according to claim 1, characterized in that: Debugging each of the programming files based on the executable program includes: Setting an interrupt position corresponding to the executable program according to a debugging instruction; When the executable program runs to the interrupt position, a current function symbol corresponding to the executable program is determined, and debugging information is determined based on the current function symbol.
5. The method according to claim 1, characterized in that Determining debugging information based on the current function symbol includes: Obtaining a symbol file table, wherein the symbol file table is generated according to the symbol file corresponding to each programming file; The symbol file table is queried according to the current function symbol to obtain the debugging information.
6. The method according to claim 1, characterized in that Setting an interrupt position corresponding to the executable program according to the debugging instruction includes: Setting a current debugging breakpoint according to the debugging instruction, and querying a syntax tree file based on the current debugging breakpoint to determine a target type of a next statement corresponding to the current debugging breakpoint; According to the determined target type, a target debugging breakpoint is determined, and the break position is set based on the target debugging breakpoint.
7. The method according to claim 1, characterized in that After debugging each of the programming files based on the executable program, the method further includes: Obtaining program running efficiency of the executable program; A program optimization strategy is generated according to the program operation efficiency.
8. A mixed debugging device for programming languages, characterized in that: The device comprises: An acquisition module, used to acquire programming files corresponding to at least two programming languages, and to acquire preset compilation rules, wherein the compilation rules include syntax tree rules and symbol rules; A compiling module, used to compile each of the programming files according to a preset compiling rule to obtain a compiled file corresponding to each of the programming files, each of the compiled files including a symbol file and a syntax tree file; A debugging module is used to generate an executable program according to the symbol file and the syntax tree file corresponding to each programming file, and debug each programming file based on the executable program.
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.