Embedded virtual machine application debugging method and device, operating system, virtual machine, equipment, terminal, medium and program
By generating target debug files in the application converter, including data structure information and a global data flow table, the problems of complex parsing and frequent interaction in embedded virtual machine application debugging are solved, thus improving debugging efficiency and performance and optimizing the debugging experience.
Patent Information
- Application Number
- CN202411197176.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2044-08-29
AI Technical Summary
When debugging existing embedded virtual machine applications, the process of parsing debugging information is complex and the debugger interacts frequently with the embedded virtual machine, resulting in a poor debugging experience.
When the application converter converts the binary intermediate file into a binary loadable file, the target debug file is obtained and generated, including data structure information, line number address relationship table and global data flow table, reducing the interaction between the debugger and the embedded virtual machine and optimizing the debug information parsing process.
It improves the debugging efficiency and performance of embedded virtual machine applications and optimizes the debugging experience.
Smart Images

Figure CN121501412A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computer software application technology, and in particular to an embedded virtual machine application debugging method, apparatus, operating system, virtual machine, device, terminal, medium and program. Background Technology
[0002] An embedded virtual machine is a virtual machine technology that enables the operation of embedded systems. It allows higher-level applications to be executed on embedded devices, thereby improving the flexibility and functionality of embedded systems.
[0003] Currently, common embedded virtual machines use a debugging information format that conforms to the Dwarf (Debug With Arbitrary RecordFormat) standard. This format loads debugging information along with the compiled binary file of the program into the object being debugged. The format uses a debug information entry and a line program to store the debugging information. When a debugger actually debugs an embedded virtual machine application, it first needs to parse the line program corresponding to the application, then determine the correspondence between the source code and machine instructions to form multiple code blocks, further determine the logical relationships between different code blocks, and finally generate a program control flow graph, thereby achieving the debugging function.
[0004] In the process of realizing this invention, the inventors discovered the following defects in the prior art: because the embedded virtual machine runs on the embedded device, while the debugger runs on the host computer, the standard debugging information used for debugging embedded virtual machine applications is compressed debugging information. Its parsing process consumes a high load, and the process of parsing debugging information requires a lot of interaction between the debugger and the embedded virtual machine, resulting in a poor debugging experience on the embedded device. Summary of the Invention
[0005] This invention provides an embedded virtual machine application debugging method, apparatus, operating system, virtual machine, device, terminal, medium, and program, which can optimize the debugging information parsing process, improve the debugging efficiency and performance of embedded virtual machine applications, and thus optimize the debugging experience.
[0006] According to one aspect of the present invention, an embedded virtual machine application debugging method is provided, comprising:
[0007] When the application converter converts the binary intermediate file into a binary loadable file, the debugging information generated during the compilation of the binary intermediate file is obtained;
[0008] During the process of the application converter compressing and converting the compiled binary intermediate file into a binary executable file, a target debug file is generated based on the debug information.
[0009] The embedded virtual machine application is debugged according to the target debug file.
[0010] According to another aspect of the present invention, a debug file is provided, including data structure information, a row number address relationship table, and a global data flow table.
[0011] According to another aspect of the present invention, an embedded virtual machine application debugging apparatus is provided, comprising:
[0012] The debugging information acquisition module is used to acquire debugging information generated during the compilation of the binary intermediate file when the application converter converts the binary intermediate file into a binary loadable file;
[0013] The target debug file generation module is used to generate a target debug file based on the debugging information during the process of the application converter compressing and converting the compiled binary intermediate file into a binary executable file.
[0014] The virtual machine application debugging module is used to debug the embedded virtual machine application according to the target debugging file.
[0015] According to another aspect of the present invention, an operating system is provided, wherein a runtime environment is executed in the operating system, and the operating system executes the embedded virtual machine application debugging method provided in any embodiment of the present invention through the runtime environment.
[0016] According to another aspect of the present invention, an embedded virtual machine is provided, which runs on an operating system, and the operating system executes a runtime environment, through which the operating system executes the embedded virtual machine application debugging method provided in any embodiment of the present invention.
[0017] According to another aspect of the present invention, an electronic device is provided, wherein the electronic device is equipped with the operating system described above, the electronic device comprising:
[0018] At least one processor; and
[0019] A memory communicatively connected to the at least one processor; wherein,
[0020] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to execute the embedded virtual machine application debugging method according to any embodiment of the present invention.
[0021] According to another aspect of the present invention, a terminal is provided, comprising the electronic device described in any embodiment of the present invention.
[0022] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the embedded virtual machine application debugging method according to any embodiment of the present invention.
[0023] According to another aspect of the present invention, a computer program product is also provided, comprising a computer program that, when executed by a processor, implements the embedded virtual machine application debugging method described in any embodiment of the present invention.
[0024] This invention addresses the problems of complex debugging information parsing and frequent interaction between the debugger and the embedded virtual machine in existing embedded virtual machine application debugging. It optimizes the debugging information parsing process, improves the debugging efficiency and performance of embedded virtual machine applications, and ultimately enhances the debugging experience. By acquiring debugging information during the compilation of the binary intermediate file into a binary loadable file by the application converter, and then using the target debugging file to debug the embedded virtual machine application, this invention solves these problems.
[0025] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0026] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 This is a flowchart of an embedded virtual machine application debugging method provided in an embodiment of the present invention;
[0028] Figure 2 This is a flowchart of another embedded virtual machine application debugging method provided by an embodiment of the present invention;
[0029] Figure 3 This is a schematic diagram of a process for generating a global data flow table provided by an embodiment of the present invention;
[0030] Figure 4 This is a schematic diagram illustrating the correspondence between debugging information and example application flowcharts provided in an embodiment of the present invention;
[0031] Figure 5 This is a schematic diagram of the structure of a debugging file provided in an embodiment of the present invention;
[0032] Figure 6 This is a schematic diagram of another debugging file structure provided in an embodiment of the present invention;
[0033] Figure 7 This is a schematic diagram of an embedded virtual machine application debugging device provided in an embodiment of the present invention;
[0034] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention;
[0035] Figure 9 This is a structural diagram of a terminal provided according to an embodiment of the present invention. Detailed Implementation
[0036] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0037] It should be noted that the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such process, method, product or device.
[0038] Figure 1 This is a flowchart of an embedded virtual machine application debugging method provided by an embodiment of the present invention. This embodiment is applicable to debugging embedded virtual machine applications based on debugging information including code block logic relationships. The method can be executed by an embedded virtual machine application debugging device, which can be implemented in software and / or hardware, and is generally integrated into an electronic device. This electronic device can be a terminal device or a server device, as long as it can debug the embedded virtual machine application. This embodiment of the present invention does not limit the specific device type of the electronic device. Correspondingly, as... Figure 1 As shown, the method includes the following operations:
[0039] S110. When the application converter converts the binary intermediate file into a binary loadable file, obtain the debugging information generated during the compilation of the binary intermediate file.
[0040] The application converter, also known as a conversion device, is an external application linking conversion tool used to convert the binary intermediate files of a module into binary executable files. The binary intermediate file can be a file generated by an application compiler from the source code, adhering to a unified technical standard so that different language compilers can generate a consistent intermediate file. For example, if an embedded virtual machine is used in a WebAssembly (WASM) implementation execution environment, the binary intermediate file can be a WebAssembly or WASM file. The binary loadable file can be a binary file generated by the application converter that can be loaded into the system in SEF (Structured Exception Format, a file format in Microsoft Windows). For example, a binary loadable file can be loaded into an AOS (multi-application smartcard operation system) system.
[0041] In this embodiment of the invention, the application converter can compile the source code to generate a binary intermediate file. After obtaining the binary intermediate file, the application converter can further convert the binary intermediate file to generate a binary loadable file. During the process of converting the binary intermediate file to a binary loadable file, some debugging information is generated simultaneously. Accordingly, the application converter can obtain the debugging information generated during the compilation of the binary intermediate file. Optionally, the debugging information may include, but is not limited to, data such as symbols, type information, and debugging symbol tables in the source code, which can be used to support program debugging and error finding.
[0042] S120. During the process of the application converter compressing and converting the compiled binary intermediate file into a binary executable file, a target debug file is generated based on the debug information.
[0043] The binary executable file can be generated by the application installer and can be directly executed by the executor, including executable modules. For example, a binary loadable file loaded into AOS is a binary executable file. The target debug file can be a debug file provided to the debugger. The debugger can directly debug the embedded virtual machine application based on the target debug file.
[0044] Correspondingly, after the application converter compiles the binary intermediate file, it can further compress and convert the compiled binary intermediate file into a binary executable file. That is, the application compiler can first compile the application source program into a binary intermediate file, then convert the binary intermediate file into a binary loadable file, then load the binary loadable file into the operating system to become a binary executable file, and finally install the modules included in the binary executable file as an application instance. The application executor can then be responsible for interpreting and executing the modules.
[0045] In this embodiment of the invention, to avoid downloading the debug file along with the program binary file into the embedded virtual machine being debugged, the target debug file can be generated based on the acquired debug information during the process of the application converter compressing and converting the compiled binary intermediate file into a binary executable file. Since the debug information generated by the application converter during the compilation of the binary intermediate file can record the logical relationships of code blocks, the target debug file generated based on the acquired debug information also includes these logical relationships. Optionally, the logical relationships of code blocks can be the correspondence between source code and intermediate code instructions.
[0046] Optionally, multiple source files can be combined to generate a complete target debug file. That is, a target debug file can include debug files for all source files corresponding to a module. A target debug file corresponds to a module. A module can be a container of application executable code contained in a binary file, including the application's instructions, data, and metadata, which can be directly executed by the operating system.
[0047] S130. Debug the embedded virtual machine application according to the target debugging file.
[0048] Embedded virtual machine applications, also known as applications running through embedded virtual machines, are applications that are being debugged. These applications consist of data structures, data elements, and program modules required to fulfill specific functionalities.
[0049] Because the target debug file is generated during application compilation, it does not depend on the binary executable file and can exist independently, thus reducing the parsing process in the debugger's debugging workflow. The generation of the target debug file does not require interaction with the embedded virtual machine running the application being debugged; interaction is only needed when retrieving specific variable information from the embedded virtual machine's memory. Therefore, the interaction between the debugger and the embedded virtual machine can be significantly reduced. Consequently, after the target debug file is generated, the debugger can debug the embedded virtual machine application based on it.
[0050] The target debug file contains the correspondence between source code and intermediate code instructions. Therefore, it does not need to be downloaded along with the program binary file to the embedded virtual machine being debugged. When debugging an embedded virtual machine application, only the target debug file needs to be loaded to complete the debugging process. Thus, the above-described embedded virtual machine application debugging method can optimize the debugger's process of parsing debug information, improve the debugger's performance, and thereby optimize the user's debugging experience.
[0051] Optionally, embedded virtual machines can be applied in various scenarios, including but not limited to WebAssembly, trusted computing environments, federated computing, hardware acceleration, and blockchain smart contracts. WebAssembly (WASM) is a method for running non-JavaScript (JS, a lightweight, interpreted or just-in-time compiled programming language with function-first approach) script code in a browser. Non-JavaScript code includes languages such as C, C++, or Rust (a memory-safe programming language focused on performance and concurrency).
[0052] This invention addresses the problems of complex debugging information parsing and frequent interaction between the debugger and the embedded virtual machine in existing embedded virtual machine application debugging. It optimizes the debugging information parsing process, improves the debugging efficiency and performance of embedded virtual machine applications, and ultimately enhances the debugging experience. By acquiring debugging information during the compilation of the binary intermediate file into a binary loadable file by the application converter, and then using the target debugging file to debug the embedded virtual machine application, this invention solves these problems.
[0053] Figure 2 This is a flowchart of another embedded virtual machine application debugging method provided by an embodiment of the present invention. This embodiment is based on the above embodiment and is further specified. In this embodiment, various specific optional implementation methods are given for generating a target debugging file based on debugging information and debugging the embedded virtual machine application based on the target debugging file. Correspondingly, as Figure 2 As shown, the method in this embodiment may include:
[0054] S210. When the application converter converts the binary intermediate file into a binary loadable file, obtain the debugging information generated during the compilation of the binary intermediate file.
[0055] S220. Generate data structure information, row number address relationship table and global data flow table based on the debugging information.
[0056] The data structure information can be related to the data structures and strings of debugging information, such as, but not limited to, function information, structure information, and the correspondence between logical objects and intermediate compilation code. The line number and address relationship table can be used to record the correspondence between line numbers and addresses. The global data flow table can be used to record the overall data flow relationship of the embedded virtual machine application to be debugged, which may include, but is not limited to, the data flow relationship between the main data flow and branch data flows.
[0057] Specifically, when generating the target debug file from debug information, the debug information can be parsed, and data structure information, a line number address relationship table, and a global data flow table can be generated based on the parsing results. The data structure information characterizes the data structure features of the debug information. The line number address relationship table records the mapping relationship between the source code line numbers and the relative addresses of the intermediate compilation code; each member in the table represents a line of source code. The intermediate compilation code can be the code in the binary loadable file generated by compiling the source code. The global data flow table records the data flow between all nodes in the debug information. Each node can be a data structure abstracted from the information of each line in the debug information, used to store source code line numbers and corresponding executable file addresses, etc. The data flow represents a sequence of digitally encoded signals used in the transmission; it is an ordered sequence of bytes with a start and end point, including input and output streams.
[0058] In an optional embodiment of the present invention, generating data structure information based on the debugging information may include: obtaining the original data structure information recorded in the debugging information; preprocessing the original data structure information and then converting it to generate the data structure information.
[0059] The original data structure information can be the unprocessed data structure information included in the debugging information.
[0060] Specifically, when generating data structure information based on debugging information, the original data structure information recorded in the debugging information can be obtained first. Then, the obtained original data structure information can be preprocessed, such as deleting some redundant information and adding some personalized debugging information as needed. In this way, the preprocessed original data structure information can be converted into the data structure information required to generate the target debugging file.
[0061] In an optional embodiment of the present invention, generating a line number address relationship table based on the debugging information may include: obtaining a program for obtaining line number information included in the debugging information; wherein the line number information program includes line number information; parsing the line number information program to obtain a mapping relationship between source code line numbers and target PC (Program Counter Register) addresses; wherein the target PC address is used to store the code in the binary loadable file generated by compiling the source code marked by the source code line number; and generating the line number address relationship table based on the mapping relationship between the source code line numbers and the target PC address.
[0062] The line number information program can be a program that displays line numbers on the left side of the source code in development tools or editing software. Line numbers start from 1 and represent each line of the source code, providing a reference for line numbering during programming and code editing, facilitating quick location of specific code positions. The target PC address can be a relative address used to store the code in the binary loadable file generated from the compiled source code, i.e., the relative address of the intermediate compilation code. Optionally, the code in the binary loadable file can be marked with source code line numbers.
[0063] Specifically, when generating the line number address relationship table based on debugging information, the line number information program included in the debugging information can be obtained first. This program is then parsed to obtain the line number information of the source code lines included in the line number information program. Furthermore, the mapping relationship between the source code line numbers and the target PC address is obtained. Based on this mapping relationship, the line number address relationship table is generated. Since the target PC address stores the code in the binary loadable file generated from the compiled source code, and the source code line numbers can also simultaneously mark the code in the binary loadable file generated from the compiled source code, the final generated line number address relationship table can record the mapping relationship between the source code line numbers and the corresponding code in the binary loadable file generated from the compiled source code.
[0064] In an optional embodiment of the present invention, generating a global data flow table based on the debugging information may include: obtaining the branch point marker storage information generated by the application converter during the process of compressing and converting the compiled binary intermediate file into a binary executable file; and generating the global data flow table based on the line number address relationship table and the branch point marker storage information.
[0065] The branch point marker storage information can be related to marking and storing branch points, such as storing the PC address of the branch intermediate code corresponding to the branch point. A branch point can be a node in the global data flow table that can generate branch intermediate codes. A branch intermediate code can be an intermediate code (a simple, meaningful notation system designed to be easy to generate and translate into target code) that controls data flow and jumps. For example, branch intermediate codes can include, but are not limited to, br (forced jump), brif (conditional jump), and brtable (lookup table jump) types.
[0066] Figure 3 This is a flowchart illustrating a process for generating a global data flow table, provided by an embodiment of the present invention. In a specific example, such as... Figure 3 As shown, the application converter processes the compiled binary intermediate file (i.e. Figure 3 During the process of compressing intermediate code (in the middle code) into a binary executable file, it is possible to determine in real time whether branch intermediate code is generated. If it is determined that branch intermediate code has been generated, the branch points that generated the branch intermediate code can be stored to obtain branch point marker storage information. After all intermediate code conversions are completed, a global data flow table can be generated based on the stored branch point marker storage information.
[0067] Accordingly, when generating a global data flow table based on debugging information, the initial global data flow table can be generated by first obtaining the storage information of all branch point markers generated during the process of compressing and converting the compiled binary intermediate file into a binary executable file by the application converter. The initial global data flow table is then generated by sequentially connecting each branch point based on this information. After generating the initial global data flow table, the reference relationships of the line number address relationship table can be further stored for each node in the initial global data flow table. Optionally, the global data flow table can include a start node and an end node. The start node can be an abstraction of the code line used to initiate debugging in the debugging information, representing the valid code line at the beginning of the debugged program's function; the end node can be an abstraction of the code line used to terminate debugging in the debugging information, representing the last valid code line before the debugged program's function ends. Optionally, a branch point can also include a branch start point and a branch end point. The branch start point can be the node corresponding to the intermediate branch code. The branch end point can include two types: one is the end point node corresponding to the branch that satisfies the intermediate branch code jump condition, and the other is the end point node corresponding to the branch that does not satisfy the intermediate branch code jump condition.
[0068] In an optional embodiment of the present invention, after generating the global data flow table based on the row number address relationship table and the branch point marker storage information, the method may further include: filtering the trunk data flow table and the branch data flow table from the global data flow table; wherein, the trunk data flow table is the flow table corresponding to the data flow with the most nodes, which is counted starting from the lowest row number node of the sub-function.
[0069] The backbone data flow table can be the flow table consisting of the data flow with the largest number of nodes. The branch data flow table can be the flow table consisting of other data flows in the global data flow table besides the backbone data flow table.
[0070] To further refine the global data flow table, after its generation, it can be further filtered to include the main data flow table with the most nodes and the branch data flow tables generated at each branch point. In other words, the flow table corresponding to the data flow with the most nodes can be obtained by starting from the node corresponding to the lowest row number of the sub-function in the global data flow table. It can be understood that the main data flow table can include the start and end nodes of the sub-function's main data flow. The sub-function's main data flow can be the main data flow of the sub-function corresponding to the debugging information. The start and end nodes of the sub-function's main data flow can include references to the row number address relationship table.
[0071] Figure 4 This is a schematic diagram illustrating the correspondence between debugging information and example application flowcharts provided in an embodiment of the present invention. In a specific example, such as... Figure 4 As shown, each line of code in an embedded virtual machine application corresponds to a line relationship table entry. For example, a sample embedded virtual machine application is simply called a sample application. Line 1 of the sample application corresponds to the first line of source code in the sample application, and there is a mapping relationship between it and line relationship table entry 1. A line relationship table entry can be an unoptimized line of code from the application's source code. The nodes line 1, line 2, line 3, line 4, line 5, and line 9 of the sample application can form a main data flow table, i.e. Figure 4 The main data flow table entry A is shown. Line 7 and line 9 of the example application can form a branch data flow table, i.e. Figure 4 The branch data flow table entry B is shown.
[0072] In an optional embodiment of the present invention, the branch data flow table may include a single branch data flow table and a multi-branch data flow table; the multi-branch data flow table may include parent data flow table entries and child branch data flow table entries.
[0073] In this context, a single-branch data flow table can be a table containing only one branch. A multi-branch data flow table can be a table containing multiple branches. A parent data flow entry can be a parent-level branch data flow in a multi-branch data flow table, and a child branch data flow entry can be a child-level branch data flow in a multi-branch data flow table. That is, branch data flows can have a multi-level structure, and a branch data flow can have its own branch data flows. If a branch data flow has its own branch data flows, then that branch data flow becomes the parent data flow entry of that branch data flow, and the branch data flows of that branch data flow are called child branch data flow entries.
[0074] Optionally, the branching start point stored in the branch data flow table can be the node where the corresponding branch data flow diverges from the main data flow or the corresponding parent data flow. The branching end point stored in the branch data flow table can be the node where the corresponding branch data flow returns to the main data flow or the corresponding parent data flow, or it can also be the node where the sub-function exits.
[0075] S230. Generate the target debug file based on the data structure information, the row number address relationship table, and the global data flow table.
[0076] Accordingly, after generating data structure information, row number address relationship table and global data flow table based on debugging information, the generated data structure information, row number address relationship table and global data flow table can be organized and laid out to finally generate the target debugging file.
[0077] S240. When debugging the embedded virtual machine application in the debugger, load the target debug file.
[0078] The data structure information, line number address relationship table, and global data flow table in the target debug file can all include the logical relationship of code blocks. Therefore, the target debug file does not need to be downloaded into the embedded virtual machine being debugged along with the program binary file. It can be loaded by the debugger only when debugging the embedded virtual machine application.
[0079] S250. Assemble the target debug file into a program control flow graph, and debug the embedded virtual machine application using the debugger based on the program control flow graph.
[0080] The Control Flow Graph (CFG) is a graphical representation of the possible directions of control flow during program execution. It is a directed graph that reflects the possible execution paths of basic blocks in the program, and also reflects the real-time execution process of the program.
[0081] Specifically, after the debugger loads the target debug file, it can directly assemble the target debug file to generate a program control flow graph, which in turn supports the debugger in debugging embedded virtual machine applications.
[0082] In an optional embodiment of the present invention, the step of debugging the embedded virtual machine application according to the target debug file may further include: loading the target debug file into the binary executable file during the process of the application converter compressing and converting the compiled binary intermediate file into a binary executable file; obtaining the target debug file through the binary executable file when the debugger debugs the embedded virtual machine application; assembling the target debug file into a program control flow graph; and debugging the embedded virtual machine application according to the program control flow graph through the debugger.
[0083] In this embodiment of the invention, optionally, the target debug file can be loaded into the binary executable file during the process of the application converter compressing and converting the compiled binary intermediate file into a binary executable file. In this case, when the debugger debugs the embedded virtual machine application, it can access the binary executable file corresponding to the embedded virtual machine application to obtain the target debug file, thereby assembling the target debug file into a program control flow graph, and finally using the program control flow graph to support the debugger in debugging the embedded virtual machine application.
[0084] The above technical solution obtains debugging information generated during the compilation of the binary intermediate file when the application converter converts the binary intermediate file into a binary loadable file. Then, during the process of compressing and converting the compiled binary intermediate file into a binary executable file, the application converter uses this debugging information to generate a target debug file, which includes data structure information, a line number address relationship table, and a global data flow table storage format. When the debugger debugs the embedded virtual machine application, it loads the target debug file and assembles it into a program control flow graph. The debugger then uses this program control flow graph to debug the embedded virtual machine application, reducing the parsing operations during debugging and minimizing the interaction between the debugger and the embedded virtual machine, thereby optimizing the debugging performance of the embedded virtual machine application.
[0085] Figure 5 This is a schematic diagram of the structure of a debugging file provided in an embodiment of the present invention, such as... Figure 5 As shown, the debug file includes: data structure information, a row number address relationship table, and a global data flow table.
[0086] In an optional embodiment of the present invention, the debug file can be generated in the following manner: when the application converter converts the binary intermediate file into a binary loadable file, the debug information generated during the compilation of the binary intermediate file is obtained; during the process of the application converter compressing the compiled binary intermediate file into a binary executable file, the debug file is generated based on the debug information.
[0087] Figure 6 This is a schematic diagram of another debugging file structure provided in an embodiment of the present invention. In a specific example, such as... Figure 6 As shown, multiple source files can be combined to generate a complete debug file. That is, a debug file can include debug files for all the source files corresponding to a module. A debug file corresponds to a module. A module can be a container of executable application code contained in a binary file, including the application's instructions, data, and metadata, which can be directly executed by the operating system.
[0088] In an optional embodiment of the present invention, the data structure information can be generated by: obtaining the original data structure information of the debugging information record; preprocessing the original data structure information, and then converting it to generate the data structure information.
[0089] In an optional embodiment of the present invention, the line number address relationship table can be generated in the following manner: obtaining the line number information program included in the debugging information; wherein, the line number information program includes line number information; parsing the line number information program to obtain the mapping relationship between source code line numbers and target PC addresses; wherein, the target PC address is used to store the code in the binary loadable file generated by compiling the source code marked by the source code line number; generating the line number address relationship table according to the mapping relationship between the source code line numbers and the target PC address.
[0090] In an optional embodiment of the present invention, the global data flow table can be generated by: obtaining the branch point marker storage information generated by the application converter during the process of compressing and converting the compiled binary intermediate file into a binary executable file; and generating the global data flow table according to the line number address relationship table and the branch point marker storage information.
[0091] The debug file provided in this embodiment of the invention consists of data structure information, a line number address relationship table, and a global data flow table. Specifically, the debug file is generated when the application converter converts the binary intermediate file into a binary loadable file. It obtains the debug information generated during the compilation of the binary intermediate file, and then generates the debug file based on this obtained debug information during the application converter's compression and conversion of the compiled binary intermediate file into a binary executable file. Debugging embedded virtual machine applications using the debug file generated in this way can solve problems such as the complex debug information parsing process and frequent interaction between the debugger and the embedded virtual machine in existing embedded virtual machine application debugging. It optimizes the debug information parsing process, improves the debugging efficiency and performance of embedded virtual machine applications, and thus optimizes the debugging experience.
[0092] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information in this technical solution comply with relevant laws and regulations and do not violate public order and good morals.
[0093] It should be noted that any arrangement or combination of the technical features in the above embodiments also falls within the protection scope of this invention.
[0094] Figure 7 This is a schematic diagram of an embedded virtual machine application debugging device 300 provided in an embodiment of the present invention, as shown below. Figure 7 As shown, the embedded virtual machine application debugging device 300 includes: a debugging information acquisition module 310, a target debugging file generation module 320, and a virtual machine application debugging module 330, wherein:
[0095] The debugging information acquisition module 310 is used to acquire debugging information generated during the compilation of the binary intermediate file when the application converter converts the binary intermediate file into a binary loadable file;
[0096] The target debug file generation module 320 is used to generate a target debug file based on the debugging information during the process of the application converter compressing and converting the compiled binary intermediate file into a binary executable file.
[0097] The virtual machine application debugging module 330 is used to debug the embedded virtual machine application according to the target debugging file.
[0098] This invention addresses the problems of complex debugging information parsing and frequent interaction between the debugger and the embedded virtual machine in existing embedded virtual machine application debugging. It optimizes the debugging information parsing process, improves the debugging efficiency and performance of embedded virtual machine applications, and ultimately enhances the debugging experience. By acquiring debugging information during the compilation of the binary intermediate file into a binary loadable file by the application converter, and then using the target debugging file to debug the embedded virtual machine application, this invention solves these problems.
[0099] Optionally, the target debug file generation module 320 is further configured to: generate data structure information, a row number address relationship table, and a global data flow table based on the debug information; and generate the target debug file based on the data structure information, the row number address relationship table, and the global data flow table.
[0100] Optionally, the target debug file generation module 320 is further configured to: obtain the original data structure information of the debug information record; preprocess the original data structure information, and then convert it to generate the data structure information.
[0101] Optionally, the target debug file generation module 320 is further configured to: obtain the line number information program included in the debug information; wherein the line number information program includes line number information; parse the line number information program to obtain the mapping relationship between the source code line numbers and the target PC address; wherein the target PC address is used to store the code in the binary loadable file generated by compiling the source code marked by the source code line number; and generate the line number address relationship table according to the mapping relationship between the source code line numbers and the target PC address.
[0102] Optionally, the target debug file generation module 320 is further configured to: obtain the branch point marker storage information generated by the application converter during the process of compressing and converting the compiled binary intermediate file into a binary executable file; and generate the global data flow table based on the line number address relationship table and the branch point marker storage information.
[0103] Optionally, the target debug file generation module 320 is further configured to: filter the trunk data flow table and the branch data flow table from the global data flow table; wherein, the trunk data flow table is the flow table corresponding to the data flow with the most nodes, which is counted starting from the lowest row number node of the sub-function.
[0104] Optionally, the main data flow table includes the start node and end node of the main data flow of the sub-functions.
[0105] Optionally, the start and end nodes of the main data stream of the sub-function include the reference relationship of the row number address relationship table.
[0106] Optionally, the branch data flow table includes a single-branch data flow table and a multi-branch data flow table; the multi-branch data flow table includes parent data flow table entries and child branch data flow table entries.
[0107] Optionally, the virtual machine application debugging module 330 is further configured to: load the target debugging file when the debugger is debugging the embedded virtual machine application; assemble the target debugging file into a program control flow graph; and debug the embedded virtual machine application according to the program control flow graph through the debugger.
[0108] Optionally, the virtual machine application debugging module 330 is further configured to: load the target debugging file into the binary executable file during the process of the application converter compressing and converting the compiled binary intermediate file into a binary executable file; obtain the target debugging file through the binary executable file when the debugger debugs the embedded virtual machine application; assemble the target debugging file into a program control flow graph; and debug the embedded virtual machine application according to the program control flow graph through the debugger.
[0109] The aforementioned embedded virtual machine application debugging device can execute the embedded virtual machine application debugging method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the method. Technical details not described in detail in this embodiment can be found in the embedded virtual machine application debugging method provided in any embodiment of the present invention.
[0110] Since the embedded virtual machine application debugging device described above is an apparatus capable of executing the embedded virtual machine application debugging method in the embodiments of the present invention, those skilled in the art can understand the specific implementation methods and various variations of the embedded virtual machine application debugging device in this embodiment based on the embedded virtual machine application debugging method described in the embodiments of the present invention. Therefore, how the embedded virtual machine application debugging device implements the embedded virtual machine application debugging method in the embodiments of the present invention will not be described in detail here. Any apparatus used by those skilled in the art to implement the embedded virtual machine application debugging method in the embodiments of the present invention falls within the scope of protection of this application.
[0111] This invention also provides an operating system, in which a runtime environment is executed, and the operating system executes the embedded virtual machine application debugging method provided in any embodiment of this invention through the runtime environment.
[0112] This invention also provides a virtual machine that runs on an operating system. The operating system contains a runtime environment, and the operating system executes the embedded virtual machine application debugging method provided in any embodiment of this invention through the runtime environment.
[0113] Figure 8 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown.
[0114] like Figure 8 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as non-volatile memory (NVM) 12, random access memory (RAM) 13, etc., communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the NVM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, NVM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0115] The I / O interface 15 in the electronic device 10 may include: ISO7816, ISO14443, eSPI (Enhanced Serial Peripheral Interface), and SPI (Serial Peripheral Interface), etc.
[0116] Processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, central processing unit (CPU), graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, for example, performing an embedded virtual machine application debugging method as described in various embodiments of the present invention, executed by a runtime environment in an operating system installed in an electronic device, the method comprising:
[0117] When the application converter converts the binary intermediate file into a binary loadable file, the debugging information generated during the compilation of the binary intermediate file is obtained;
[0118] During the process of the application converter compressing and converting the compiled binary intermediate file into a binary executable file, a target debug file is generated based on the debug information.
[0119] The embedded virtual machine application is debugged according to the target debug file.
[0120] In some embodiments, an embedded virtual machine application debugging method as described in the various embodiments of the present invention can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 10 via NVM 12. When processor 11 executes a computer program stored in NVM 12 or a computer program loaded into random access memory (RAM) 13 by execution storage unit 18, it can perform one or more steps of the embedded virtual machine application debugging method described above in the various embodiments of the present invention. Alternatively, in other embodiments, processor 11 can be configured by any other suitable means (e.g., by means of firmware) to execute an embedded virtual machine application debugging method as described in the various embodiments of the present invention.
[0121] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0122] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0123] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0124] Figure 9 This is a structural diagram of a terminal provided according to an embodiment of the present invention. Figure 9 The terminal includes the electronic device 10 as described in any embodiment of the present invention.
[0125] The electronic device 10 can be a restricted device. Optionally, the restricted device can include, but is not limited to, an embedded secure element, a smart card, an SE (Secure Element), and an embedded device.
[0126] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0127] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A method for debugging embedded virtual machine applications, characterized in that, include: When the application converter converts the binary intermediate file into a binary loadable file, the debugging information generated during the compilation of the binary intermediate file is obtained; During the process of the application converter compressing and converting the compiled binary intermediate file into a binary executable file, a target debug file is generated based on the debug information. The embedded virtual machine application is debugged according to the target debug file.
2. The method according to claim 1, characterized in that, The step of generating a target debug file based on the debug information includes: Generate data structure information, a row number address relationship table, and a global data flow table based on the debugging information; The target debug file is generated based on the data structure information, the row number address relationship table, and the global data flow table.
3. The method according to claim 2, characterized in that, Data structure information is generated based on the debugging information, including: Obtain the original data structure information of the debugging information record; After preprocessing the original data structure information, the data structure information is transformed and generated.
4. The method according to claim 2, characterized in that, A row number address relationship table is generated based on the debugging information, including: A program for obtaining the line number information included in the debugging information; wherein, the line number information program includes line number information; The line number information is parsed to obtain the mapping relationship between the source code line numbers and the target PC address; wherein, the target PC address is used to store the code in the binary loadable file generated by compiling the source code marked by the source code line number; The line number address relationship table is generated based on the mapping relationship between the source code line numbers and the target PC address.
5. The method according to claim 2, characterized in that, A global data flow table is generated based on the debugging information, including: Obtain the branch point marker storage information generated by the application converter during the process of compressing and converting the compiled binary intermediate file into a binary executable file; The global data flow table is generated based on the row number address relationship table and the branch point marker storage information.
6. The method according to claim 5, characterized in that, After generating the global data flow table based on the row number address relationship table and the branch point marker storage information, the method further includes: Filter the main data flow table and branch data flow table from the global data flow table; The main data flow table is a flow table corresponding to the data flow with the most nodes, starting from the lowest row number node of the sub-function.
7. The method according to claim 6, characterized in that, The main data flow table includes the start and end nodes of the main data flow of the sub-functions.
8. The method according to claim 7, characterized in that, The starting and ending nodes of the main data stream of the sub-function include the reference relationships in the row number address relationship table.
9. The method according to claim 6, characterized in that, The branch data flow table includes a single-branch data flow table and a multi-branch data flow table; the multi-branch data flow table includes parent data flow table entries and child branch data flow table entries.
10. The method according to claim 1, characterized in that, The debugging of the embedded virtual machine application based on the target debug file includes: When debugging the embedded virtual machine application in the debugger, the target debug file is loaded; The target debug file is assembled into a program control flow graph; The embedded virtual machine application is debugged using the debugger based on the program control flow graph.
11. The method according to claim 1, characterized in that, The debugging of the embedded virtual machine application based on the target debug file includes: During the process of the application converter compressing and converting the compiled binary intermediate file into a binary executable file, the target debug file is loaded into the binary executable file; When debugging an embedded virtual machine application in a debugger, the target debug file is obtained through the binary executable file; The target debug file is assembled into a program control flow graph; The embedded virtual machine application is debugged using the debugger based on the program control flow graph.
12. A debugging file, characterized in that, This includes data structure information, a row number address relationship table, and a global data flow table.
13. The debugging file according to claim 12, characterized in that, The debug file is generated in the following way: When the application converter converts the binary intermediate file into a binary loadable file, the debugging information generated during the compilation of the binary intermediate file is obtained; During the process of the application converter compressing and converting the compiled binary intermediate file into a binary executable file, the debug file is generated based on the debug information.
14. The debugging file according to claim 13, characterized in that, The data structure information is generated in the following way: Obtain the original data structure information of the debugging information record; After preprocessing the original data structure information, the data structure information is transformed and generated.
15. The debugging file according to claim 13, characterized in that, The row number address relationship table is generated in the following way: A program for obtaining the line number information included in the debugging information; wherein, the line number information program includes line number information; The line number information is parsed to obtain the mapping relationship between the source code line numbers and the target PC address; wherein, the target PC address is used to store the code in the binary loadable file generated by compiling the source code marked by the source code line number; The line number address relationship table is generated based on the mapping relationship between the source code line numbers and the target PC address.
16. The debugging file according to claim 13, characterized in that, The global data flow table is generated in the following way: Obtain the branch point marker storage information generated by the application converter during the process of compressing and converting the compiled binary intermediate file into a binary executable file; The global data flow table is generated based on the row number address relationship table and the branch point marker storage information.
17. An embedded virtual machine application debugging device, characterized in that, include: The debugging information acquisition module is used to acquire debugging information generated during the compilation of the binary intermediate file when the application converter converts the binary intermediate file into a binary loadable file; The target debug file generation module is used to generate a target debug file based on the debugging information during the process of the application converter compressing and converting the compiled binary intermediate file into a binary executable file. The virtual machine application debugging module is used to debug the embedded virtual machine application according to the target debugging file.
18. An operating system, characterized in that, The operating system executes a runtime environment, and the operating system executes the embedded virtual machine application debugging method of any one of claims 1-12 through the runtime environment.
19. An embedded virtual machine, characterized in that, The embedded virtual machine runs on an operating system, and the operating system executes a runtime environment. The operating system executes the embedded virtual machine application debugging method of any one of claims 1-12 through the runtime environment.
20. An electronic device, characterized in that, The electronic device is equipped with the operating system of claim 18, and the electronic device comprises: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the embedded virtual machine application debugging method of any one of claims 1-12.
21. The electronic device according to claim 20, characterized in that, The electronic device includes a restricted device.
22. The electronic device according to claim 21, characterized in that, The restricted devices include: smart cards, security elements (SEs), security chips, or embedded devices.
23. A terminal, characterized in that, Including the electronic device as described in any one of claims 20-22.
24. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that are used to cause a processor to execute the embedded virtual machine application debugging method of any one of claims 1-12.
25. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the embedded virtual machine application debugging method according to any one of claims 1-12.
Citation Information
Patent Citations
File processing method and device, electronic equipment and storage medium
CN113377370A
Code upgrading method and device for smart card, electronic equipment and storage medium
CN115291918A
Method and device for debugging application program, electronic equipment and computer readable storage medium
CN117648258A
Dynamic code switching in debugging process
US20140289707A1
Identifying a source file for use in debugging compiled code
US20190377662A1