Data code debugging method and terminal
By creating a debug copy and using the simulator to build the running environment, the large amount of debugging code and program context smoothness are solved, and the code slimming and efficient debugging is achieved.
Patent Information
- Application Number
- CN202510217217.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2025-07-29
AI Technical Summary
In the prior art, there is a large amount of debugging code during the debugging process, which affects program performance and is difficult to keep the program context smooth, and the debugging process is time-consuming and labor-intensive.
Create a debug copy of the target code, set up a simulation debugging process, and run the debug copy at different times through the simulator, use the running environment built by the simulator for debugging, and adjust the running order according to the modification instructions when an error occurs.
It reduces the amount of debugging code of the original program, realizes smooth debugging of the program context, and is independent of the debugging process, without affecting the normal operation of the target code.
Smart Images

Figure CN120386709A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data simulation testing, and particularly relates to a method and a terminal for debugging data code. Background Art
[0002] In programming, debug output is a common method for checking the running status and behavior of a program. Rich debug functions are provided in an IDE (Integrated Development Environment), such as breakpoints, variable monitoring, call stack viewing, etc., which facilitate the discovery and repair of program bugs. After determining that the program is stable, these debug statements are removed or disabled to avoid leaking sensitive information or affecting performance.
[0003] Current debugging is controlled by a switch for output. The program is not completely clean and tidy; the debugging process enhances the output code in the compilation environment. It is equivalent to that part of the bloat of the program is due to the debug code. Moreover, a large amount of key data in the debugging is easily obtained by tools such as IDA. When a code error is found, it may not be possible to record it in time because the debugging itself is the program itself, and the log may not have time to be recorded before a crash occurs. It is necessary to re-step through the debugging for memory analysis, which is time-consuming and laborious. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to provide a method and a terminal for debugging data code, reduce the amount of debug code in the original program, achieve code slimming, and at the same time ensure smooth debugging of the program context.
[0005] In order to solve the above technical problem, the technical solution adopted by the present invention is as follows: A method for debugging data code, comprising the following steps: S1. Create a code copy containing the target code, and add a preset number of simulated debug processes in the code copy to obtain a debug copy; S2. Control at least two simulators to start running the debug copy in sequence, so that the simulated debug processes of the debug copy run by different simulators are different at the same time; S3. If an error result occurs when one of the simulators is running, wait to obtain a modification instruction corresponding to the error result, and modify the content of the debug copy corresponding to the simulator whose running order is after the simulator with the error result according to the modification instruction. In order to solve the above technical problem, another technical solution adopted by the present invention is as follows: A data code debugging terminal, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor runs the computer program, the following steps are implemented: S1. Create a code copy containing the target code, and add a preset number of simulated debugging processes to the code copy to obtain a debugging copy; S2. Control at least two simulators to start running the debugging copy in sequence, so that the simulated debugging processes of the debugging copy run by different simulators are different at the same time; S3. If an error result occurs when a simulator is running, wait to obtain a modification instruction corresponding to the error result, and modify the content of the debugging copy corresponding to the simulator whose running order is after the simulator with the error result according to the modification instruction. The beneficial effects of the present invention are as follows: A data code debugging method and a terminal are provided. A debugging copy corresponding to the target code is created, and then simulated debugging processes are set on the debugging copy. The debugging copy is run using the operating environment built by the simulator. The simulated debugging processes of the debugging copy run by different simulators have a sequential relationship at the same time, so as to present the effect of running the context of the code simultaneously. When an error occurs in the code running of a simulator, the debugger gives a corresponding modification instruction and applies it to the debugging copy run by other simulators with a later running order, so that other simulators can continue to execute the debugging copy. The debugging process is isolated while not affecting the normal operation of the target code, thereby reducing the debugging code volume of the original program and ensuring the smooth debugging of the program context. Description of the Drawings
[0006] Figure 1 It is a step schematic diagram of a data code debugging method of the present invention; Figure 2 It is a data flow schematic diagram of the callback device and the message device of a data code debugging method of the present invention during the debugging process; Figure 3 It is a system block diagram of a data code debugging terminal of the present invention.
[0007] Label Description: 1. A data code debugging terminal; 2. A memory; 3. A processor. Detailed Embodiment
[0008] To illustrate the technical content, achieved objectives and effects of the present invention in detail, the following is described in conjunction with the embodiments and with reference to the drawings.
[0009] Please refer to Figure 1 and Figure 2 , a data code debugging method, includes the following steps: S1. Create a code copy containing the target code, and add a preset number of simulated debugging processes to the code copy to obtain a debugging copy; S2. Control at least two simulators to start running the debug copy in sequence one after another, so that the simulation debug processes of the debug copies run by different simulators are different at the same time; S3. If an error result occurs when one of the simulators is running, wait to obtain a modification instruction corresponding to the error result, and modify the content of the debug copy corresponding to the simulator after the simulator where the error result occurs in the running order according to the modification instruction.
[0010] As can be seen from the above description, the beneficial effects of the present invention are as follows: Create a debug copy corresponding to the target code, then set a simulation debug process on the debug copy, and use the running environment built by the simulator to run the debug copy. The simulation debug processes of the debug copies run by different simulators have a sequence relationship at the same time, so as to present the effect of running the context of the code simultaneously. When an error occurs in the code running of one simulator, the debugger gives a corresponding modification instruction and applies it to the debug copy run by other simulators with a later running order, so that other simulators can continue to execute the debug copy, isolate the debug process without affecting the normal running of the target code, thereby reducing the amount of debug code of the original program and ensuring the smooth debugging of the program context. Further, the step S1 further includes the following steps: Obtain a function template according to the function addresses and call orders of all functions called in the debug copy; Set a memory address for each function in the function template; The step S3 further includes: Feed back the function template to the debugger when waiting to obtain a modification instruction corresponding to the error result.
[0011] As can be seen from the above description, the function addresses and call orders of all functions called in the debug copy are counted as a function template, and a memory address is allocated to each function, so as to know the address to be modified and the function memory data when setting a modification instruction later, improving the debug efficiency.
[0012] Further, the step S3 further includes: Real-time collect the process unique identifier, called function name, function address, and function parameter data arrangement when each simulator runs the simulation debug process to obtain a real-time debug record.
[0013] As can be seen from the above description, when the simulator runs the simulation debug process, collect and use the called function name and function parameters as the current process unique identifier, so as to facilitate the debugger to confirm the execution progress of the current code and distinguish the execution situations of different simulators.
[0014] Further, step S1 further includes: Determine the number of simulators for running the debug copy according to the number of debugging parameters of the target code.
[0015] As can be seen from the above description, determine the number of simulators for running the debug copy according to the number of debugging parameters of the target code, so as to ensure that all debugging parameters can be traversed by the simulator during the entire debugging process, and at the same time, rely on the sequence relationship between different simulators to flexibly adjust each debugging parameter.
[0016] Further, step S3 further includes: Set up a callback device to generate the real-time debugging records of all the simulators in real time through the callback device; Determine whether there is a real-time debugging record with an error result. If so, forward the modification instruction to the corresponding simulator and the device for running the target code through the callback device.
[0017] As can be seen from the above description, establish a callback device to realize centralized data collection and forwarding processing, and efficiently monitor the running status of multiple simulators.
[0018] Please refer to Figure 3 , a data code debugging terminal 1, including a memory 2, a processor 3, and a computer program stored on the memory 2 and operable on the processor 3. When the processor 3 runs the computer program, the following steps are implemented: S1. Create a code copy containing the target code, and add a preset number of simulated debugging processes in the code copy to obtain a debug copy; S2. Control at least two simulators to start running the debug copy in sequence one by one, so that the simulated debugging processes of the debug copy run by different simulators are different at the same time; S3. If an error result occurs when one of the simulators is running, wait to obtain a modification instruction for the corresponding error result, and modify the content of the debug copy corresponding to the simulator whose running order is after the simulator with the error result according to the modification instruction. As can be seen from the above description, the beneficial effects of the present invention are as follows: creating a debug copy corresponding to the target code, then setting up a simulated debugging process on the debug copy, and using the operating environment built by the simulator to run the debug copy, thereby reducing the amount of debugging code in the original program and achieving code slimming. The simulated debugging processes of the debug copies run by different simulators at the same time have a sequential relationship, thus presenting the effect of running the context of the code simultaneously. When an error occurs in the code running of one simulator, the debugger gives a modification instruction correspondingly and applies it to the debug copy run by other simulators with a later running order, so that other simulators can continue to execute the debug copy, isolating the debugging process without affecting the normal running of the target code, thereby reducing the amount of debugging code in the original program and ensuring smooth debugging of the program context. Further, step S1 further includes the following steps: Obtaining a function template according to the function addresses and call order of all functions called within the debug copy; Setting a memory address for each function within the function template; Step S3 further includes: Feeding back the function template to the debugger when waiting to obtain a modification instruction corresponding to the error result.
[0019] As can be seen from the above description, the function addresses and call order of all functions called within the debug copy are counted as a function template, and at the same time, a memory address is allocated for each function, so as to know the address to be modified and the function memory data when setting a modification instruction later, improving the debugging efficiency.
[0020] Further, step S3 further includes: Real-time collecting the process unique identifier, called function name, function address, and function parameter data arrangement when each simulator runs the simulated debugging process to obtain a real-time debugging record.
[0021] As can be seen from the above description, when the simulator runs the simulated debugging process, the function name and function parameters called by the simulator are collected as the current process unique identifier, so as to facilitate the debugger to confirm the execution progress of the current code and distinguish the execution situations of different simulators.
[0022] Further, step S1 further includes: Determining the number of simulators for running the debug copy according to the number of debugging parameters of the target code.
[0023] As can be seen from the above description, the number of simulators for running the debug copy is determined according to the number of parameters to be debugged in the target code, so as to ensure that all parameters to be debugged can be traversed by the simulators during the entire debugging process, and at the same time, rely on the sequence relationship between different simulators to flexibly adjust each parameter to be debugged.
[0024] Further, step S3 further includes: Setting up a callback device to generate in real time the real-time debug records of all the simulators through the callback device; Judging whether there are real-time debug records with error results. If so, forwarding the modification instruction to the corresponding simulator and the device for running the target code through the callback device.
[0025] As can be seen from the above description, a callback device is established to realize centralized data collection and forwarding processing, and efficiently supervise the running conditions of multiple simulators.
[0026] Please refer to Figure 1 and Figure 2 , the first embodiment of the present invention is: A data code debugging method includes the following steps: S1. Creating a code copy containing the target code, and adding a preset number of simulated debug processes in the code copy to obtain a debug copy; In this embodiment, the target code does not contain debug code, and the debug content is set in the simulated debug processes of the debug copy. That is, the debug copy includes not only all the content of the target code, but also the debug statements forming each simulated debug process. The preset number of simulated debug processes is determined according to the actual debugging requirements.
[0027] When generating the debug copy, according to the function addresses and call sequences of all functions called in the debug copy, a function template is obtained. For example: Test: 0x13000. Memory addresses are set for each function in the function template; the memory addresses are the parameter memory data, which is equivalent to storing the memory data of a function and keeping it in a waiting state.
[0028] S2. Controlling at least two simulators to run the debug copy, so that the simulated debug processes of the debug copies run by different simulators are different at the same time; In this embodiment, the simulator can imitate the operating environment of other systems or devices, or build an operating environment identical to the target code. During debugging, the first simulator starts running the first simulation debugging process. When the first simulator finishes the first simulation debugging process and starts the second simulation debugging process, the second simulator starts running the first simulation debugging process, and so on, forming a sequence. Moreover, according to the number of debugging parameters of the target code, the number of simulators for running the debugging copies is determined. Generally, the number of simulators is set equal to the number of debugging parameters. In this case, the number of simulators in the same position in the running sequence can be more than one, and they can debug different debugging parameters involved in the same simulation debugging process with other simulators in the same position.
[0029] Regarding the debugging process, taking five debugging copies of program A1 - A5 and simulation debugging processes 01 - 05 as examples, the list is as follows:
[0030] Table 1 Sequence table of different simulators during simulation debugging Referring to the above table, the first simulator is used to first execute the simulation debugging process 01 of program A1, and the second simulator waits for the first simulator to finish executing the simulation debugging process 01 and then starts to execute the simulation debugging process 01 of program A2. At this time, if an error occurs when the first simulator executes the simulation debugging process 01 of program A1, the function parameters involved in the simulation debugging process 01 need to be modified, and the modified result is applied to the simulation debugging process 01 of program A2. In this way, even if the first simulator crashes due to an error when executing the simulation debugging process 01, the second simulator can execute the simulation debugging process 01 of program A2 and continue to try to execute the simulation debugging process 02, and so on for the subsequent simulation process.
[0031] Taking program A3 as an example, a certain parameter transfer causes a crash. Normally, the program directly disappears, but after the simulator debugs to this parameter; at this time, the number of processes is 3, that is, there are 2 processes when crashing; one is the one that has not been transferred, and the other is the next one to be transferred; thus, as long as the data in the message callback is modified to let the next one to be transferred continue to be transferred, the simulation can be completed.
[0032] S3. If an error result occurs when a simulator is running, wait to obtain a modification instruction for the corresponding error result, and modify the content of the debugging copy corresponding to the simulator after the simulator with the error result in the running order according to the modification instruction. In this embodiment, when waiting to obtain the modification instruction for the corresponding error result, a function template is fed back to the debugger to facilitate the debugger to confirm the address and function memory data that need to be modified. During the debugging process, the unique process identifier, the names of the called functions, the function addresses, and the data arrangement of the function parameters are collected in real time when the simulator runs the simulation debugging process, obtaining real-time debugging records. In this way, the data structure of the simulator is as follows: 2196:Test01:0x120F400:0xF21000:0x85-Test02:0x120F700:0x63:0x50; 1762:Test01:0x100F400:0xE01000:0x85-Test02:0x12F700:0x63:0x50; Among them, taking the first piece of data as an example, 2196 represents the unique process identifier, Test01 represents the function name, 0x120F400 represents the function address, and 0xF21000:0x85-Test02:0x120F700:0x63:0x50 represents the data arrangement of the function parameters.
[0033] In addition, as shown in Figure 2 Taking the parameters to be debugged in function 1, function 2, and function 3 as examples respectively, a callback device and a message device are set up. The callback device generates the current unique process identifier of all simulators in real time; the callback device forwards the modification instruction to the corresponding simulator and the target code to achieve the modification of the parameters to be debugged; the message device is responsible for delivering the data of each simulation debugging process.
[0034] Please refer to Figure 3 , Embodiment 2 of the present invention is: A data code debugging terminal 1 includes a memory 2, a processor 3, and a computer program stored on the memory 2 and executable on the processor 3. When the processor 3 runs the computer program, it implements a data code debugging method as in Embodiment 1.
[0035] In summary, a data code debugging method and a terminal provided by the present invention create a debugging copy corresponding to the target code, then set up a simulated debugging process on the debugging copy, and use the operating environment built by the simulator to run the debugging copy, thereby reducing the amount of debugging code in the original program and achieving code slimming. The simulated debugging processes of the debugging copies run by different simulators at the same time have a sequence relationship, so as to present the effect of running the context of the code simultaneously. When an error occurs in the code running of a simulator, the debugger gives a modification instruction correspondingly and applies it to the debugging copy run by other simulators with a later running order, so that other simulators can continue to execute the debugging copy. At the same time, a function template is provided to record the addresses, call sequences, and memory addresses of different functions of the debugging copy, so as to facilitate the completion of the modification operation, disconnect from the operating environment built by the simulator, isolate the debugging process without affecting the normal operation of the target code, and ensure the smooth debugging of the program context.
[0036] The above are only embodiments of the present invention, and do not limit the patent scope of the present invention accordingly. Any equivalent transformation made by using the content of the specification and drawings of the present invention, or directly or indirectly applied in the relevant technical field, shall be similarly included in the patent protection scope of the present invention.
Claims
1. A data code debugging method, characterized in that, It includes the following steps: S1. Create a code copy containing the target code, and add a preset number of simulated debugging processes within the code copy to obtain a debugging copy; S2. Control at least two simulators to start running the debugging copy in sequence one after another, so that the simulated debugging processes of the debugging copy run by different simulators are different at the same time; S3. If an error result occurs when one of the simulators is running, wait to obtain a modification instruction corresponding to the error result, and modify the content of the debugging copy corresponding to the simulator whose running order is after the simulator with the error result according to the modification instruction.
2. The data code debugging method according to claim 1, wherein The step S1 further includes the following steps: Obtain a function template according to the function addresses and call order of all functions called within the debugging copy; Set a memory address for each function within the function template; The step S3 further includes: Feed back the function template to the debugger when waiting to obtain a modification instruction corresponding to the error result.
3. A data code debugging method according to claim 2, wherein The step S3 further includes: Collect in real time the process unique identifier, called function name, function address, and function parameter data arrangement when each simulator runs the simulated debugging process to obtain a real-time debugging record.
4. A data code debugging method according to claim 2, characterized in that The step S1 further includes: Determine the number of simulators for running the debugging copy according to the number of parameters to be debugged in the target code.
5. A data code debugging method according to claim 3, characterized in that The step S3 further includes: Set a callback device, and generate the real-time debugging records of all the simulators in real time through the callback device; Judge whether there is a real-time debugging record with an error result. If so, forward the modification instruction to the corresponding simulator and the device for running the target code through the callback device.
6. A data code debugging terminal, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor runs the computer program, the following steps are implemented: S1. Create a code copy containing the target code, and add a preset number of simulated debugging processes within the code copy to obtain a debugging copy; S2. Control at least two simulators to start running the debugging copy in sequence one after another, so that the simulated debugging processes of the debugging copy run by different simulators are different at the same time; S3. If an error result occurs when one of the simulators is running, wait to obtain a modification instruction corresponding to the error result, and modify the content of the debugging copy corresponding to the simulator whose running order is after the simulator with the error result according to the modification instruction.
7. A data code debugging terminal according to claim 6, characterized in that, The step S1 further includes the following steps: Obtain a function template according to the function addresses and call order of all functions called within the debugging copy; Set a memory address for each function within the function template; The step S3 further includes: Feed back the function template to the debugger when waiting to obtain a modification instruction corresponding to the error result.
8. A data code debugging terminal according to claim 7, characterized in that, The step S3 further includes: Collect in real time the process unique identifier, called function name, function address, and function parameter data arrangement when each simulator runs the simulated debugging process to obtain a real-time debugging record.
9. A data code debugging terminal according to claim 7, characterized in that, The step S1 further includes: Determine the number of simulators for running the debugging copy according to the number of parameters to be debugged in the target code.
10. A data code debugging terminal according to claim 8, characterized in that, The step S3 further includes: Setting a callback device to generate in real time the real-time debugging records of all the simulators through the callback device; Judging whether there are real-time debugging records with error results, and if so, forwarding the modification instruction to the corresponding simulator and the device for running the target code through the callback device.