A method and apparatus for program debugging

By using online data recording and playback, the problems of environment consistency and resource consumption in existing program debugging methods have been solved, achieving efficient and low-cost local debugging results.

CN119829407BActive Publication Date: 2026-03-17BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-10
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Existing program debugging methods require repeated program building and deployment, and deploying additional machines requires additional basic environments, making it difficult to reproduce faults and affecting reliability assessments.

Method used

By processing online data recording and playback, bytecode enhancement technology is used to obtain online recording data from pre-recorded data files and play the data back in the local environment, ensuring the consistency between the local debugging environment and the online environment.

Benefits of technology

It enables efficient and low-cost local program debugging, ensures the consistency of the debugging environment, simplifies the debugging process, and reduces resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829407B_ABST
    Figure CN119829407B_ABST
Patent Text Reader

Abstract

This invention discloses a method and apparatus for program debugging, relating to the field of software testing technology. One specific embodiment of the method includes: in response to receiving a local debugging request from a program, obtaining online recording data corresponding to the program from a pre-recorded data file; and running the program by replaying the online recording data to perform local debugging. This embodiment implements a method for local program debugging, ensuring consistency between the local debugging environment and the online environment through online data recording and replay processing, thereby enabling efficient and low-cost local debugging of program code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of software testing technology, and in particular to a method and apparatus for program debugging. Background Technology

[0002] As business continues to grow, the business logic of the software system also iterates, and more and more business code is added to the software system. In the process of testing these code programs through test cases, it is inevitable to encounter program execution exceptions caused by unknown reasons. Existing program debugging methods generally involve adding logs to observe the execution results, or using Java's remote debug (troubleshooting) features to remotely debug and trace the program code from another machine.

[0003] In the process of realizing this invention, the inventors discovered the following problems in the prior art:

[0004] Whether adding logs to the program code or deploying a machine for debugging, it involves repeated builds and deployments. Furthermore, deploying an additional machine requires an additional infrastructure environment, such as a database. Additionally, for interdependent programs, during the build, deployment, and release process, exceptions may arise from other external programs that have already been fixed, making the fault unreproducible and hindering program reliability assessment. Summary of the Invention

[0005] In view of this, embodiments of the present invention provide a method and apparatus for program debugging, which implements a method for local program debugging. By recording and replaying online data, the consistency between the local debugging environment and the online environment is ensured, thereby enabling efficient and low-cost local debugging of program code.

[0006] To achieve the aforementioned objective, according to one aspect of the present invention, a method for program debugging is provided, comprising:

[0007] In response to receiving a local debugging request from the program, the online recording data corresponding to the program is obtained from a pre-recorded data file;

[0008] The program is run by replaying the data recorded online in order to perform local debugging of the program.

[0009] Optionally, before obtaining the online recording data corresponding to the program from the pre-recorded data file, the method further includes: using bytecode enhancement technology to capture target code that meets preset recording conditions from the online running program for recording, and persistently storing the recorded data in the data file, wherein the online running program is a historical version of the program.

[0010] Optionally, the recorded data has a data identifier; persistently storing the recorded data in a data file includes: storing the data identifier in the message queue corresponding to the program; storing the recorded data in the corresponding location of the data file according to the data identifier; obtaining the online recording data corresponding to the program from the pre-recorded data file includes: obtaining the corresponding data identifier from the message queue corresponding to the program; and obtaining the corresponding online recording data from the data file according to the data identifier.

[0011] Optionally, when the target code is recorded multiple times, each recording corresponds to a data identifier; storing the data identifier in the message queue corresponding to the program includes: storing the data identifier of each recording in the message queue corresponding to the program in an orderly manner according to the recording time of each recording; retrieving the corresponding data identifier from the message queue corresponding to the program includes: retrieving the data identifier corresponding to the recording time closest to the request time from the message queue according to the request time of the local debugging request and the sorting rules of the message queue.

[0012] Optionally, the program is run by replaying the online recorded data, including: parsing the online recorded data to obtain the recorded data of the external interaction code in the program; using the recorded data of the external interaction code as the return value of the external interaction code, and replacing the external interaction code in the program with the return value using bytecode enhancement technology; and using a reflection mechanism to reflectively call the external interaction code to trigger the program to run.

[0013] Optionally, after obtaining the online recording data corresponding to the program from the pre-recorded data file, the method further includes: verifying the amount of data of the obtained online recording data according to the integrity verification information in the online recording data, and confirming that the verification is successful.

[0014] Optionally, the recording of the data file and the playback processing of the online recorded data are both implemented through a plugin.

[0015] According to a second aspect of the present invention, an apparatus for program debugging is provided, comprising:

[0016] The online recording data acquisition module is used to obtain the online recording data corresponding to the program from a pre-recorded data file in response to receiving a local debugging request from the program.

[0017] The data playback processing module is used to run the program by performing data playback processing on the online recorded data, so as to perform local debugging of the program.

[0018] According to a third aspect of the present invention, an electronic device for program debugging is provided, comprising:

[0019] One or more processors;

[0020] Storage device for storing one or more programs.

[0021] When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the first aspect of the embodiments of the present invention.

[0022] According to a fourth aspect of the present invention, a computer-readable medium is provided having a computer program stored thereon, which, when executed by a processor, implements the method provided in the first aspect of the present invention.

[0023] One embodiment of the invention has the following advantages or beneficial effects: by responding to a local debugging request from the program, obtaining the online recording data corresponding to the program from a pre-recorded data file; and running the program by replaying the online recording data to perform local debugging, a method for local program debugging is realized. Through the recording and replaying of online data, the consistency between the local debugging environment and the online environment is ensured, thereby enabling efficient and low-cost local debugging of the code program. Attached Figure Description

[0024] The accompanying drawings are provided to better understand the invention and are not intended to unduly limit the scope of the invention. Wherein:

[0025] Figure 1 This is a schematic diagram of the main flow of a program debugging method according to an embodiment of the present invention;

[0026] Figure 2 This is a schematic diagram illustrating the principle of the program debugging method according to an embodiment of the present invention;

[0027] Figure 3 This is a detailed flowchart illustrating the program debugging method according to an embodiment of the present invention;

[0028] Figure 4 This is a schematic diagram of the main modules of a program debugging apparatus according to an embodiment of the present invention;

[0029] Figure 5 This is an exemplary system architecture diagram in which embodiments of the present invention can be applied;

[0030] Figure 6 This is a schematic diagram of the structure of a computer system suitable for implementing terminal devices or servers of the present invention. Detailed Implementation

[0031] It should be noted that the acquisition, storage, and application of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0032] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0033] Current program debugging methods, whether adding logs to the program code or deploying a dedicated debugging machine, involve repeated builds and deployments. Furthermore, deploying an additional machine requires a separate infrastructure, such as a database. Additionally, for interdependent programs, during the build, deployment, and release process, exceptions may arise from external programs that have already been fixed, making the fault unreproducible. This hinders reliability assessment and fails to adequately meet practical application requirements.

[0034] To address the aforementioned problems in existing technologies, this invention proposes a program debugging method. This method involves obtaining online recording data from a pre-recorded data file, performing data playback processing on the online recording data in a local software development environment to obtain playback data, and using this playback data to provide the program with the necessary data for local execution, thus enabling local program debugging. This implements a method for local program debugging, ensuring consistency between the local debugging environment and the online environment through online data recording and playback processing, thereby enabling efficient and low-cost local debugging of program code.

[0035] In the description of the embodiments of the present invention, the terms involved and their meanings are as follows:

[0036] JAVA Agent: A technology that can enhance bytecode without affecting normal compilation;

[0037] MOCK: Use virtual objects / data to perform software testing;

[0038] RPC: Remote Procedure Call, such as calling a method in application B from application A.

[0039] Figure 1 This is a schematic diagram of the main flow of the program debugging method according to an embodiment of the present invention, such as... Figure 1 As shown, the program debugging method of this embodiment includes the following steps S101 to S102.

[0040] Step S101: In response to receiving a local debugging request from the program, obtain the online recording data corresponding to the program from a pre-recorded data file.

[0041] Specifically, as business continues to develop, the business logic of the software system also iterates continuously, with more and more business code being added to the software system. To provide developers with a convenient and efficient method for program debugging, this invention, based on commonly used IDEs (Integrated Development Environments) and the cross-platform Eclipse free integrated development environment, provides a method for program debugging in a local development environment. The key to local debugging lies in resolving the data used by the program during runtime. As long as the data from online runtime interactions with external systems (return values ​​of RPC remote procedure calls, operation results of distributed caches, database insertion / query results, etc.) can be obtained, this data can be used as the interaction data required for local runtime, ensuring program execution in the local environment and enabling online debugging. Considering that the previous version of the program has a history of online runtime, the online runtime data of the previous version can be recorded in advance and stored in a data file, so that the iteratively designed program can directly retrieve the recorded online data from the data file during local debugging.

[0042] Understandably, program debugging can be used not only to troubleshoot abnormalities in the program itself, but also to troubleshoot abnormalities in other related programs. For example, if the result of program B depends on the return value of program A, then debugging program A can help troubleshoot abnormalities in program B. Therefore, program debugging in this embodiment of the invention can be either debugging an iterative program or debugging the original program. The difference is that the recording data required for debugging an iterative program is usually the online data of the previous version of the program, while the recording data required for debugging the original program is the online data of that program.

[0043] According to an embodiment of the present invention, before obtaining the online recording data corresponding to the program from the pre-recorded data file, the method further includes: using bytecode enhancement technology to capture target code that meets preset recording conditions from the online running program for recording, and persistently storing the recorded data in the data file, wherein the online running program is a historical version of the program.

[0044] Specifically, before obtaining the online recording data of the program from the pre-recorded data file, the recording version required by the program for local debugging requests is determined. All input parameters and return values ​​of the interfaces and methods in the program of that recording version are recorded. Alternatively, the names of interfaces and methods involved in external interactions in the program can be configured into the recording conditions. When the program executes online and the interface or method that meets the recording conditions, recording will be performed. This can save resources, avoid unnecessary data recording, and speed up the recording time. For example, if the interface ServiceA#foo is added to the recording conditions, then when the program executes online and calls the interface ServiceA#foo, recording will be performed, and online data of other interfaces will not be recorded.

[0045] This invention primarily targets Java language development environments (IDEs). Utilizing bytecode enhancement technology from the Java Agent, it adds surround events before and after the target code to be recorded. Specifically, it captures the input parameters and return values ​​of the target code of interfaces and methods that meet the recording conditions through the onMethodEnter surround event before method entry and the onMethodExit surround event after method exit. The input parameters and return values ​​are then serialized and persisted to a pre-built data file, thereby completing the recording of online programs.

[0046] By using bytecode enhancement technology to record online programs, it is only necessary to inject the wraparound events onMethodEnter and onMethodExit before and after the target code, achieving zero intrusion into the business code.

[0047] According to another embodiment of the present invention, the recorded data has a data identifier; persistently storing the recorded data in a data file includes: storing the data identifier in a message queue corresponding to the program; storing the recorded data in a corresponding location in the data file according to the data identifier; obtaining online recording data corresponding to the program from a pre-recorded data file includes: obtaining a corresponding data identifier from the message queue corresponding to the program; and obtaining the corresponding online recording data from the data file according to the data identifier.

[0048] Specifically, when recording online data using the JAVA Agent bytecode enhancement technology, a recording task identifier is generated based on the recording task. When the program is called in the online environment, the target code of the interface and method that meets the recording conditions is recorded. For the action of recording data, a corresponding data identifier (data ID) is generated, and a corresponding message queue is established at the program level to store the data ID. Then, based on the data ID, the recorded online data is stored in the corresponding location of the data file. This makes it convenient for subsequent local debugging, where the data ID can be obtained from the message queue corresponding to the program, and the corresponding online recorded data can be quickly found in the data file based on the data ID.

[0049] According to another embodiment of the present invention, when the target code is recorded multiple times, each recording corresponds to a data identifier; storing the data identifier in the message queue corresponding to the program includes: storing the data identifier of each recording in the message queue corresponding to the program in an orderly manner according to the recording time of each recording; retrieving the corresponding data identifier from the message queue corresponding to the program includes: retrieving the data identifier corresponding to the recording time closest to the request time from the message queue according to the request time of the local debugging request and in combination with the sorting rules of the message queue.

[0050] Specifically, considering that this embodiment of the solution triggers the local execution of the program by recording data online, in order to ensure the consistency between the online recorded data and the actual online environment, the recording task is usually executed within a time period. For example, the recording time of recording task 1 is half an hour. During this time period, the online environment will call the program multiple times. Each call will record the target code of the interface and method that meet the recording conditions. Accordingly, a data ID is generated for each call, and these data IDs are stored in the program's message queue in an orderly manner according to the data recording time, for example, in ascending order of time. Understandably, considering that multiple recording tasks typically need to be executed in an online environment, the message queue dimension can be further refined. Message queues can be established based on programs and recording tasks, storing the data identifiers of the same recording task within the same program in the corresponding message queue. For example, for recording task 1 of program A, the queue data structure is: Program A#Recording Task 1: [202309052053, 202309052050, 202309052040], where Program A#Recording Task 1 is the message queue identifier, and [202309052053, 202309052050, 202309052040] are three data IDs. Of course, message queues also have capacity limitations. If data IDs exceed the capacity limit, they can be stored in other storage media as backups, or only the latest data IDs that meet the message queue capacity can be deleted. The specific handling method depends on the needs of the business scenario.

[0051] Furthermore, in order to ensure the consistency between the acquired online recording data and the actual online environment corresponding to the current debugging, based on the request time of the received local debugging request and the sorting rules of the data ID stored in the message queue, the data ID closest to the current request time is obtained. For example, if the data IDs are sorted in ascending order, then only the first data ID in the message queue needs to be obtained.

[0052] Understandably, in some special business scenarios, the online recording data required by the program is not the latest, but rather online data from a specific time. In this case, it is necessary to query the message queue for the data ID corresponding to the data recording time closest to that specific time in order to obtain the online recording data that meets the requirements.

[0053] According to another embodiment of the present invention, the recording of the data file is achieved through a plugin.

[0054] Specifically, this embodiment of the invention integrates the above-described recording method into a recording plugin. The recording plugin not only includes recording the parameters and return values ​​of the target code using a JAVA Agent, but also includes logic for serializing and persisting the recorded data. Recording online data through a plugin not only allows for direct, non-intrusive recording and processing of the target code, but also features lightweight and easy-to-maintain characteristics. Users can directly record online data without complex configuration or invocation, improving user-friendliness and facilitating further application.

[0055] Step S102: Run the program by replaying the online recorded data to perform local debugging of the program.

[0056] Specifically, after obtaining the online recording data of the program, it is necessary to deserialize the online recording data and parse the parameters and return values ​​from the deserialized data to complete the data playback process. This allows the program to be debugged to use the return values ​​obtained from the playback to simulate the interaction with the outside world, ensuring the smooth execution of the program. At the set debugging breakpoints, the context information of the current program execution can be viewed for local debugging.

[0057] According to one embodiment of the present invention, after obtaining the online recording data corresponding to the program from a pre-recorded data file, the method further includes: verifying the data volume of the obtained online recording data according to the integrity verification information in the online recording data, and confirming that the verification is successful.

[0058] Specifically, considering that online recording data may originate from multiple interfaces and methods within a program, and the number of interfaces of that program stored in the data file is unknown when acquiring the online recording data corresponding to the program, to prevent the acquisition of incomplete online recording data, during the recording process, a verification message is generated for each recorded interface and method. The sum of these verification messages is calculated to obtain integrity verification information. This integrity verification information is appended to the initial data of the online recording data, and the verification information for each interface and method is appended to the corresponding recording data. This allows for verification of the completeness of the acquired online recording data based on the program's integrity verification information and the verification information in the currently acquired recording data of the program's interfaces and methods. For example, if five interfaces in a program are recorded, and the verification message for each interface is 1, then the program's integrity verification message is 5. Correspondingly, when the sum of the verification messages for all acquired interfaces is 5, it indicates that the acquired online recording data is complete and can be used for subsequent data playback processing.

[0059] According to one embodiment of the present invention, running the program by replaying the online recorded data includes: parsing the online recorded data to obtain the recording data of external interaction code in the program; using the recording data of the external interaction code as the return value of the external interaction code, replacing the external interaction code in the program with the return value of the external interaction code through bytecode enhancement technology; and using a reflection mechanism to reflectively call the external interaction code to trigger the execution of the program.

[0060] Specifically, after obtaining complete online recording data, the program first deserializes and parses the online recording data to obtain the recording data of the external interaction code in the program. Specifically, this involves parsing the class and method code corresponding to the code in the program that interacts with the external system from the recording data, and then obtaining the return value of that method. This return value is used as the return value of the external interaction code. The Java Agent rewrites the original logic of communicating with the remote / external system to obtain data (i.e., the external interaction code) into a MOCK simulation logic that searches and parses the online recording data and returns the execution return value, thus ensuring that the locally running code does not depend on the remote / external system. Finally, reflection is used to call the method code corresponding to the external interaction code, triggering the program to run in the local environment. At this point, developers can debug the program by setting breakpoints in the IDE. Because the code interacting with the remote / external system has been rewritten, the return results of write and query operations to the cache and database are replaced by the recorded data using enhanced logic, ensuring that the local environment can use the same data as the online system and obtain consistent code behavior.

[0061] According to another embodiment of the present invention, the data playback processing of the online recorded data is implemented in the form of a plugin.

[0062] Specifically, this embodiment of the invention integrates the above-mentioned method for replaying online recorded data into a playback plugin. The playback plugin is installed in the IDE environment and, in conjunction with the recording plugin, the online recorded data obtained by the recording plugin is replayed using the playback plugin. This not only allows for convenient and quick triggering of program execution by obtaining the return value corresponding to the external interaction code in the program, but also features lightweight and easy maintenance. Users do not need to perform complex configurations or calls to directly replay online recorded data, improving user-friendliness and facilitating further promotion and application.

[0063] Figure 2This is a schematic diagram illustrating the principle of the program debugging method according to an embodiment of the present invention. Users utilize various online applications with recording plugins installed in an online environment; they record interfaces and methods in these online applications that meet the recording conditions, and then submit the recordings to a data service; the data service stores the data ID in a message queue and persists the recorded data to a data file in the file system based on the data ID; developers iterate on the application in a local IDE equipped with a playback plugin. Considering data security in both the online and local development environments, this embodiment of the invention establishes a gateway with online-local mutual access permissions. Data is forwarded through this gateway, enabling the local environment to access the online data service; local message subscription is enabled, and the data service is accessed through the gateway to subscribe to the message queue of the iterative application, obtain the corresponding data ID, and then read the corresponding recorded data from the data file in the file system. The recorded data is then replayed to obtain return values ​​for various remote / external interfaces and methods. These return values ​​are used to replace the original logic code for obtaining data through remote / external communication, ensuring program execution.

[0064] Figure 3 This is a detailed flowchart illustrating the program debugging method according to an embodiment of the present invention. When the recording conditions are met, a Java online application equipped with a recording plugin collects and records online data, obtaining online recording data. This online recording data is then persisted to a data file in the file system according to its corresponding data ID. Subsequently, the data IDs of this recording are stored in a message queue in an orderly manner according to a sorting rule. In a local development environment IDE equipped with a playback plugin, the playback plugin is triggered when the project is started, enabling message subscription and retrieving the data ID from the message queue corresponding to the current application. Based on the data ID, the online recording data is downloaded. Specifically, the online recording data is read from the data file using the data ID and downloaded locally. After downloading, the completeness of the downloaded online recording data is verified. If incomplete, the download is restarted. If complete, the data can be replayed using reflection based on the obtained online recording data, allowing for local program breakpoint debugging.

[0065] By obtaining the corresponding online recording data from a pre-recorded data file, and then performing data playback processing on the online recording data in the local software development environment to obtain playback data, the program is provided with the necessary data for local execution, facilitating local program debugging. This implements a method for local program debugging. Through online data recording and playback processing, the consistency between the local debugging environment and the online environment is ensured, thereby enabling efficient and low-cost local debugging of the program code.

[0066] Figure 4This is a schematic diagram of the main modules of a program debugging apparatus according to an embodiment of the present invention. Figure 4 As shown, the program debugging device 400 mainly includes an online recording data acquisition module 401 and a data playback processing module 402.

[0067] The online recording data acquisition module 401 is used to obtain the online recording data corresponding to the program from a pre-recorded data file in response to receiving a local debugging request from the program.

[0068] The data playback processing module 402 is used to run the program by performing data playback processing on the online recorded data, so as to perform local debugging of the program.

[0069] According to an embodiment of the present invention, the program debugging apparatus 400 further includes a data file construction module (not shown in the figure), which is used to: before obtaining the online recording data corresponding to the program from the pre-recorded data file, use bytecode enhancement technology to capture target code that meets the preset recording conditions from the online running program for recording, and persistently store the recorded data in the data file, wherein the online running program is a historical version of the program.

[0070] According to another embodiment of the present invention, the recorded data has a data identifier; the data file construction module (not shown in the figure) is further configured to: store the data identifier in the message queue corresponding to the program; store the recorded data in the corresponding location of the data file according to the data identifier; the online recording data acquisition module 401 is further configured to: acquire the corresponding data identifier from the message queue corresponding to the program; and acquire the corresponding online recording data from the data file according to the data identifier.

[0071] According to another embodiment of the present invention, when the target code is recorded multiple times, each recording corresponds to a data identifier; the data file construction module (not shown in the figure) is further configured to: store the data identifier of each recording in an orderly manner into the message queue corresponding to the program according to the recording time of each recording; the online recording data acquisition module 401 is further configured to: obtain the data identifier corresponding to the recording time closest to the request time from the message queue according to the request time of the local debugging request and in combination with the sorting rules of the message queue.

[0072] According to another embodiment of the present invention, the data playback processing module 402 is further configured to: parse the online recorded data to obtain the recorded data of the external interaction code in the program; use the recorded data of the external interaction code as the run return value of the external interaction code, and replace the external interaction code in the program with the run return value through bytecode enhancement technology; and use a reflection mechanism to reflectively call the external interaction code to trigger the execution of the program.

[0073] According to another embodiment of the present invention, the program debugging apparatus 400 further includes an integrity verification module (not shown in the figure), which is used to: after obtaining the online recording data corresponding to the program from the pre-recorded data file, verify the data volume of the obtained online recording data according to the integrity verification information in the online recording data, and confirm that the verification is successful.

[0074] According to another embodiment of the present invention, the recording of the data file and the data playback processing of the online recorded data are both implemented in the form of a plugin.

[0075] Figure 5 This is an exemplary system architecture diagram in which embodiments of the present invention can be applied.

[0076] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, and 503, a network 504, and a server 505. Network 504 serves as the medium for providing communication links between terminal devices 501, 502, and 503 and server 505. Network 504 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.

[0077] Users can use terminal devices 501, 502, and 503 to interact with server 505 via network 504 to receive or send messages, etc. Various communication client applications, such as program debugging applications, can be installed on terminal devices 501, 502, and 503 (for example only).

[0078] Terminal devices 501, 502, and 503 can be various electronic devices with displays that support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.

[0079] Server 505 can be a server that provides various services, such as a background management server (for example only) that supports program debugging performed by users using terminal devices 501, 502, and 503. The background management server can, in response to receiving a local debugging request from a program, retrieve the online recording data corresponding to the program from a pre-recorded data file; run the program by replaying the online recording data to perform local debugging and other processing, and feed back the processing results (e.g., debugging results – for example only) to the terminal device.

[0080] It should be noted that the program debugging method provided in this embodiment of the invention is generally executed by server 505, and correspondingly, the program debugging device is generally set in server 505.

[0081] It should be understood that Figure 5 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0082] The following is for reference. Figure 6 It shows a schematic diagram of the structure of a computer system 600 suitable for implementing terminal devices or servers of the present invention. Figure 6 The terminal device or server shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.

[0083] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 602 or programs loaded from storage section 608 into random access memory (RAM) 603. The RAM 603 also stores various programs and data required for the operation of the system 600. The CPU 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0084] The following components are connected to I / O interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to I / O interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 610 as needed so that computer programs read from it can be installed into storage section 608 as needed.

[0085] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 609, and / or installed from removable medium 611. When the computer program is executed by central processing unit (CPU) 601, it performs the functions defined above in the system of this invention.

[0086] It should be noted that the computer-readable medium shown in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0087] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0088] The units described in the embodiments of the present invention can be implemented in software or hardware. The described units can also be housed in a processor; for example, a processor can be described as including: an online recording data acquisition module and a data playback processing module.

[0089] In some cases, the names of these modules do not constitute a limitation on the module itself. For example, the data playback processing module can also be described as "a module for running the program by performing data playback processing on the online recorded data in order to perform local debugging of the program".

[0090] On the other hand, the present invention also provides a computer-readable medium, which may be included in the device described in the embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs, which, when executed by the device, cause the device to: in response to receiving a local debugging request from the program, obtain online recording data corresponding to the program from a pre-recorded data file; and run the program by performing data playback processing on the online recording data to perform local debugging of the program.

[0091] The technical solution of the present invention has the following advantages or beneficial effects: by responding to the local debugging request of the program, obtaining the online recording data corresponding to the program from the pre-recorded data file; and running the program by replaying the online recording data to perform local debugging of the program, a method for local debugging of the program is realized. By recording and replaying the online data, the consistency between the local debugging environment and the online environment is ensured, thereby enabling efficient and low-cost local debugging of the code program.

[0092] The specific embodiments described herein do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A method of program debugging, characterized by, The method comprises: using bytecode enhancement technology to record target code of an interface name and a method name involved in external interaction from a program running online, the program running online being a historical version of the program; in response to receiving a local debugging request of the program, obtaining online recording data corresponding to the program from a pre-recorded data file; running the program through data playback processing of the online recording data to perform local debugging of the program; wherein running the program through data playback processing of the online recording data comprises: analyzing the online recording data to obtain a return value of external interaction code in the program; using the bytecode enhancement technology to replace the external interaction code in the program with the return value as a running return value of the external interaction code; reflectively calling the external interaction code using a reflection mechanism to trigger running of the program.

2. The method of claim 1, wherein, The recorded data has a data identifier; persistently storing the recorded data in a data file comprises storing the data identifier in a message queue corresponding to the program and storing the recorded data in a corresponding position in the data file according to the data identifier; obtaining the online recording data corresponding to the program from the pre-recorded data file comprises obtaining a corresponding data identifier from the message queue corresponding to the program and obtaining the online recording data corresponding to the program from the data file according to the data identifier.

3. The method of claim 2, wherein, In the case of multiple recordings of the target code, each recording corresponds to a data identifier; storing the data identifier in the message queue corresponding to the program comprises sequentially storing the data identifier of each recording in the message queue corresponding to the program according to a recording time of each recording; obtaining the corresponding data identifier from the message queue corresponding to the program comprises obtaining a data identifier corresponding to a recording time closest to a request time of the local debugging request from the message queue according to the request time of the local debugging request and in combination with an ordering rule of the message queue.

4. The method of claim 1, wherein, After obtaining the online recording data corresponding to the program from the pre-recorded data file, the method further comprises: verifying a data amount of the obtained online recording data according to integrity verification information in the online recording data and confirming that the verification is passed.

5. The method of claim 1, wherein, The recording of the data file and the data playback processing of the online recording data are both implemented in the form of a plug-in.

6. An apparatus for program debugging, characterized by The method comprises: a data file construction module configured to use bytecode enhancement technology to record target code of an interface name and a method name involved in external interaction from a program running online, the program running online being a historical version of the program, and persistently store recorded data in a data file; an online recording data obtaining module configured to, in response to receiving a local debugging request of the program, obtain online recording data corresponding to the program from a pre-recorded data file; and a program running module configured to run the program through data playback processing of the online recording data to perform local debugging of the program. The data playback processing module is configured to run the program by data playback processing on the online recording data, so as to perform local debugging of the program. The data playback processing module is further configured to parse the online recording data, obtain a return value of external interaction code in the program, and replace the external interaction code in the program by using the return value as a running return value of the external interaction code through bytecode enhancement technology. The external interaction code is called by using a reflection mechanism to trigger running of the program.

7. A mobile electronic device terminal, characterized by The method comprises: one or more processors; a storage device configured to store one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the method as claimed in any one of claims 1-5.

8. A computer readable medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the method as claimed in any one of claims 1-5.

Citation Information

Patent Citations

  • Test method and device

    CN113076251A