Program debugging method and device

Through the recording and playback of online data, the consistency between the local debugging environment and the online environment is achieved, the problems of high program debugging costs and difficulty in evaluating reliability in the existing technology are solved, and efficient and low-cost local debugging is achieved.

CN119829407AActive Publication Date: 2025-04-15BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311308128.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-10
Publication Date
2025-04-15
Estimated Expiration
2043-10-10

AI Technical Summary

Technical Problem

The prior art requires repeated construction, release and deployment in program debugging, and the deployment of additional machines requires additional basic environment, resulting in high costs and difficulty in assessing reliability.

Method used

Through the recording and playback of online data, the consistency between the local debugging environment and the online environment is achieved, the program's online recording data is obtained from the pre-recorded data files, and the program is run through the data playback processing to realize local debugging.

Benefits of technology

It realizes efficient and low-cost local debugging of code programs, ensuring the consistency of the local debugging environment and the online environment, and improving the reliability evaluation ability of the program.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829407A_ABST
    Figure CN119829407A_ABST
Patent Text Reader

Abstract

The invention discloses a program debugging method and device, and relates to the technical field of software testing. A specific embodiment of the method comprises the following steps: in response to a received local debugging request of a program, obtaining online recorded data corresponding to the program from a pre-recorded data file; the program is run by a data playback process of the online recorded data to facilitate local debugging of the program. According to the embodiment, the method for locally debugging the program is realized, and the consistency of a local debugging environment and an online environment is ensured through recording and playback processing of online data, so that the code program can be efficiently and locally debugged at low cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software testing, and in particular to a method and device for program debugging. Background Art

[0002] With the continuous development of business, the business logic of software systems is constantly iterating, and more and more business codes are added to the software system. When testing these code programs through test cases, it is inevitable to encounter program execution exceptions caused by unknown reasons. The existing program debugging methods generally observe the execution results by adding logs, or remotely debug and track program codes through another machine based on JAVA's remote debugging (troubleshooting) debugging features.

[0003] In the process of implementing the present invention, the inventors found that the prior art has the following problems:

[0004] Whether adding logs to the program code or deploying a machine for debugging, it involves repeated operations such as building and publishing programs, and deploying additional machines also requires an additional set of basic environments, such as databases. In addition, for programs that are interdependent, during the building, publishing, and deployment process, it may be other external programs that cause exceptions, but the external programs have been repaired, resulting in the inability to reproduce the fault, which is not conducive to the reliability assessment of the program. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a method and device for program debugging, which implements a method for local debugging of programs. By recording and replaying online data, the consistency of the local debugging environment and the online environment is ensured, so that the code program can be locally debugged efficiently and at low cost.

[0006] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for debugging a program is provided, comprising:

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

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

[0009] Optionally, before obtaining the online recorded data corresponding to the program from a pre-recorded data file, the method further includes: using bytecode enhancement technology to capture target code that meets preset recording conditions from the program running online for recording, and persistently storing the recorded data in a data file, wherein the program running online 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 a message queue corresponding to the program; based on the data identifier, storing the recorded data in a corresponding position of the data file; obtaining online recorded data corresponding to the program from a pre-recorded data file includes: obtaining a corresponding data identifier from a message queue corresponding to the program; and based on the data identifier, obtaining corresponding online recorded data from the data file.

[0011] Optionally, in the case of multiple recordings of the target code, each recording corresponds to a data identifier; the data identifier is stored in the message queue corresponding to the program, including: according to the recording time of each recording, the data identifier of each recording is stored in the message queue corresponding to the program in order; the corresponding data identifier is obtained from the message queue corresponding to the program, including: according to the request time of the local debugging request, combined with the sorting rule of the message queue, the data identifier corresponding to the recording time closest to the request time is obtained from 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 running return value of the external interaction code, and using the running return value to replace the external interaction code in the program through bytecode enhancement technology; using the reflection mechanism to reflectively call the external interaction code to trigger the running of the program.

[0013] Optionally, after obtaining the online recorded data corresponding to the program from a pre-recorded data file, the method further comprises: verifying the data volume of the obtained online recorded data according to integrity verification information in the online recorded data, and confirming that the verification passes.

[0014] Optionally, the recording of the data file and the data playback processing of the online recorded data are both implemented in the form of a plug-in.

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

[0016] An online recording data acquisition module, configured to acquire online recording data corresponding to the program from a pre-recorded data file in response to receiving a local debugging request of the program;

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

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

[0019] one or more processors;

[0020] a 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 embodiment of the present invention.

[0022] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method provided by the first aspect of the embodiment of the present invention is implemented.

[0023] An embodiment of the invention has the following advantages or beneficial effects: by responding to a local debugging request for a program, obtaining online recorded data corresponding to the program from a pre-recorded data file; running the program by replaying the online recorded data so as to perform local debugging of the program. A method for locally debugging the program is implemented, and the consistency of the local debugging environment and the online environment is ensured through the recording and playback of online data, so that the code program can be locally debugged efficiently and at a low cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

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

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

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

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

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

[0030] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

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

[0032] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0033] The current program debugging methods, whether adding logs to the program code or deploying a machine for debugging, involve repeated operations such as building and publishing programs, and deploying additional machines also requires an additional set of basic environments, such as databases. In addition, for programs that are interdependent, during the process of building, publishing, and deploying, it may be other external programs that cause exceptions, but the external programs have been repaired, resulting in the inability to reproduce the fault, which is not conducive to the reliability assessment of the program and cannot meet the actual application requirements.

[0034] In order to solve the above problems existing in the prior art, the present invention proposes a method for debugging a program, which obtains the online recording data of the program from a pre-recorded data file, performs data playback processing on the online recording data in a local software development environment to obtain playback data, and uses the playback data to provide the program with the data necessary for local operation, so as to debug the program locally. A method for debugging a program locally is implemented, and the consistency of the local debugging environment and the online environment is ensured through the recording and playback processing of online data, so that the code program can be debugged locally efficiently and at a low cost.

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

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

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

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

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

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

[0041] Specifically, with the continuous development of business, the business logic of the software system is also constantly iterating, and more and more business codes are added to the software system. In order to provide a convenient and efficient program debugging method for program developers, the embodiment of the present invention is based on the IDE (Integrated Development Environment) local integrated development environment commonly used by program developers and the Eclipse cross-platform free integrated development environment, etc., to provide a method for debugging a program in a local development environment. To solve local debugging, the focus is on solving the data used in program operation. As long as the data interacting with the external system during online operation (the return value of the RPC remote procedure call, the operation result of the distributed cache, the insertion / query result of the database, etc.) can be obtained, the data obtained for interacting with the external system can be used as the interactive data required for local operation, ensuring the execution of the program in the local environment, and then debugging the program online. Considering that the previous version of the iterative design has a history of online operation, the online operation data of the previous version of the program can be recorded in advance and stored in a data file, so that the iterative design program can directly obtain the online recording data from the data file when performing local debugging.

[0042] It can be understood that program debugging can not only be used to troubleshoot abnormal problems of the program itself, but also to troubleshoot abnormalities of other related programs. For example, the running result of program B depends on the return value of program A, then the abnormality of program B can be troubleshooted by debugging program A. Therefore, the program debugging in the embodiment of the present invention can be the debugging of the iterative program or the debugging of the original program. The difference is that the recorded data required for the debugging of the iterative program is usually the online data of the previous version of the program, and the recorded data required for the debugging of the original program is the online data of the program.

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

[0044] Specifically, before obtaining the online recording data of the program from the pre-recorded data file, determine the recording version of the program required by the local debugging request, and record the input parameters and return values ​​of all interfaces and methods in the recorded version of the program. You can also configure the interface names and method names involved in external interactions in the program into the recording conditions, and record when the interfaces and methods that meet the recording conditions are executed online. 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 is executed online to call the interface ServiceA#foo, it will be recorded, and the online data of other interfaces will no longer be recorded.

[0045] The embodiment of the present invention is mainly aimed at the JAVA language development environment IDE, and uses the bytecode enhancement technology of JAVA Agent to add surround events before and after the target code to be recorded, that is, through the onMethodEnter surround event before the method enters, and the onMethodExit surround event after the method exits, the input parameters and return values ​​of the target code of the interface and method that meet the recording conditions are captured, the input parameters and return values ​​are serialized, and persisted to the data file constructed in advance, thereby completing the recording of the online program.

[0046] To record online programs using bytecode enhancement technology, you only need to implant the surround 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; the recorded data is persistently stored in a data file, including: storing the data identifier in a message queue corresponding to the program; based on the data identifier, storing the recorded data in a corresponding position of the data file; obtaining the online recorded data corresponding to the program from a pre-recorded data file, including: obtaining the corresponding data identifier from the message queue corresponding to the program; based on the data identifier, obtaining the corresponding online recorded data from the data file.

[0048] Specifically, when the JAVA Agent bytecode enhancement technology is used to record online data, a recording task identifier is generated according to the recording task. When the online environment calls the program, 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 with the program as the dimension to store the data ID; then, according to the data ID, the recorded online data is stored in the corresponding position of the data file, so that when performing local debugging later, the data ID can be obtained from the message queue corresponding to the program, and the corresponding online recording data can be quickly found from the data file according to the data ID.

[0049] According to another embodiment of the present invention, in the case where the target code is recorded multiple times, each recording corresponds to a data identifier; the data identifier is stored in the message queue corresponding to the program, including: according to the recording time of each recording, the data identifier of each recording is stored in the message queue corresponding to the program in order; the corresponding data identifier is obtained from the message queue corresponding to the program, including: according to the request time of the local debugging request, combined with the sorting rule of the message queue, the data identifier corresponding to the recording time closest to the request time is obtained from the message queue.

[0050] Specifically, considering that the embodiment of the present scheme triggers the local execution of the program through online recording data, in order to ensure the consistency between the online recording data and the actual online environment, the usual recording task is executed within a time period. For example, the recording time of recording task 1 is half an hour, and within this time period, the online environment will call the program multiple times, and each call will record the target code of the interface and method that meets 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 order according to the time of data recording, for example, stored in ascending time order. Understandably, considering that in general, multiple recording tasks need to be performed in an online environment, the dimension of the message queue can be further granularized, and a message queue can be established with the program and recording task as the dimension, and the data identifier of the same recording task of the program is stored in the corresponding message queue. For example: the recording task 1 of program A, the data structure of the queue 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, the message queue also has capacity limits. If there are data IDs that exceed the capacity limit, they can be stored in other storage media as a backup, or they can be deleted and only the latest data ID that meets the capacity of the message queue can be retained. The specific processing method is determined according to the needs of the business scenario.

[0051] Furthermore, in order to ensure the consistency of the acquired online recording data and the actual online environment corresponding to the current debugging, the data ID closest to the current request time is obtained according to the request time of the received local debugging request and the sorting rule of the above data ID stored in the message queue. For example, when the data IDs are arranged in ascending order, 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 the online data at a specific time needs to be obtained. At this time, it is necessary to query the data ID corresponding to the data recording time closest to the specific time from the message queue to obtain the online recording data that meets the needs.

[0053] According to yet another embodiment of the present invention, the recording of the data file is implemented in the form of a plug-in.

[0054] Specifically, the embodiment of the present invention integrates the above-mentioned recording method into a recording plug-in, which not only includes the use of JAVA Agent to record the parameters and return values ​​of the target code, but also includes the logic of serialization and persistence of the recorded data. The recording of online data through the plug-in can not only directly record and process the target code without intrusion, but also has the characteristics of being lightweight and easy to maintain. The user can directly record online data without complex configuration or calling, which improves the user-friendliness and is useful for further promotion and 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 recorded data of the program, it is necessary to deserialize the online recorded data, parse the parameters and return values ​​from the deserialized data, and complete the data playback processing, so that the program to be debugged can use the return value obtained by playback to simulate the action of interacting with the outside world, ensure the smooth execution of the program, and view the context information of the current program running at the set debugging breakpoint 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 passes.

[0058] Specifically, considering that the online recording data may come from multiple interfaces and methods in a program, and the number of interfaces of the program stored in the data file is unknown when obtaining the online recording data corresponding to the program, in order to prevent the acquisition of incomplete online recording data, in the above-mentioned online data recording process, a verification information is generated for each recorded interface and method, and the sum of these verification information is calculated to obtain integrity verification information, and the integrity verification information is attached to the starting data of the online recording data, and the verification information of each interface and method is attached to the corresponding recording data, so as to verify whether the data volume of the obtained online recording data is complete according to the integrity verification information of the obtained program and the verification information in the recording data of the interface and method of the program currently obtained. For example, if 5 interfaces in the program are recorded, and the verification information of each interface is 1, then the integrity verification information of the program is 5. Correspondingly, when the sum of the verification information in each interface obtained is 5, it means that the obtained online recording data is complete and can be used for subsequent data playback processing.

[0059] According to one embodiment of the present invention, 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 running return value of the external interaction code, and using the running return value to replace the external interaction code in the program through bytecode enhancement technology; and using the reflection mechanism to reflectively call the external interaction code to trigger the running of the program.

[0060] Specifically, after obtaining the complete online recording data, firstly, the recording data of the external interaction code in the program is obtained by deserializing and parsing the online recording data. Specifically, the class code and method code corresponding to the code in the program that involves external interaction in the recording data are parsed from the recording data, and then the return value of the method code is obtained; the return value of the method code is used as the running return value of the external interaction code, and the original logic of the program that interacts with the remote / external communication to obtain data (that is, the external interaction code) is rewritten through JAVA Agent into a MOCK simulation logic that searches and parses the online recording data and returns the running return value, so that the local running code does not depend on the remote / external system; finally, the method code corresponding to the external interaction code is reflected and called through the reflection mechanism to trigger the running of the program in the local environment. Accordingly, at this time, the R&D personnel can debug the program by breaking points in the IDE. Since the code that interacts with the remote / external system is rewritten, the return results of the write and query operations on the cache, database, etc. are replaced by the enhanced logic using the recording data, so as to ensure that the local environment can use the same data as the online one when running, and obtain the code behavior consistent with the online one.

[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 plug-in.

[0062] Specifically, the embodiment of the present invention integrates the above-mentioned method for data playback processing of online recorded data into a playback plug-in, and installs the playback plug-in in an IDE environment. In conjunction with the above-mentioned recording plug-in, the playback plug-in is used to perform playback processing on the online recorded data obtained by the recording plug-in. This not only can quickly and conveniently trigger the running of the program by obtaining the return value corresponding to the external interaction code in the program, but also has the characteristics of being lightweight and easy to maintain. The user can directly play back the online recorded data without complicated configuration or calling, which improves the user-friendliness and is useful for further promotion and application.

[0063] Figure 2It is a schematic diagram of the principle of the method for debugging a program in an embodiment of the present invention. The user uses various online applications with recording plug-ins installed in the online environment; the interfaces and methods that meet the recording conditions in various online applications are recorded and then submitted to the data service; the data service stores the data ID in the message queue, and persists the recorded data in the data file of the file system according to the data ID; the R&D personnel perform iterative design of the application in the local IDE equipped with the playback plug-in. Considering the data security of the online environment and the local development environment, a gateway with online-local mutual access permissions is built in the embodiment of the present invention, and data is forwarded through this gateway, so that the local environment can access the online data service; the local message subscription is turned on, and the data service is accessed through the gateway, subscribed to the message queue of the iterative application, and the corresponding data ID is obtained, and then the corresponding recorded data is read from the data file of the file system, and the recorded data is played back to obtain the return values ​​of various remote / external interfaces and methods, and the original logic code for interacting with the remote / external communication to obtain data is replaced by these return values ​​to ensure the execution of the program.

[0064] Figure 3 It is a detailed flow chart of the method for debugging a program in an embodiment of the present invention. When the recording conditions are met, the JAVA online application equipped with a recording plug-in collects and records online data to obtain online recording data; then the online recording data is persisted to a data file in the file system according to the corresponding data ID; then the data ID of this data recording is orderly stored in the message queue according to the sorting rules. In the development environment IDE with a playback plug-in installed locally, the playback plug-in is triggered when the project is started, the message subscription is turned on, and the data ID is queried from the message queue corresponding to the current application to which the project belongs; according to the data ID, the online recording data is started to be downloaded, and the online recording data in the data file is read through the data ID, and downloaded to the local computer. After the download is completed, it is verified whether the downloaded online recording data is complete. If it is incomplete, the download of the online recording data is restarted; if it is complete, the data playback processing can be performed through reflection call based on the obtained online recording data, so as to perform breakpoint debugging of the program locally.

[0065] By obtaining the online recorded data corresponding to the program from the pre-recorded data file, the online recorded data is played back in the local software development environment to obtain the playback data, and the playback data is used to provide the program with the data necessary for local operation, so as to debug the program locally. A method for local debugging of the program is implemented, and the consistency of the local debugging environment and the online environment is ensured through the recording and playback processing of online data, so that the code program can be debugged locally efficiently and at a low cost.

[0066] Figure 4Schematic diagram of the main modules of the program debugging device 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 the pre-recorded data file in response to receiving a local debugging request of the program;

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

[0069] According to one embodiment of the present invention, the program debugging device 400 also 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 the target code that meets the preset recording conditions from the program running online for recording, and store the recorded data persistently in the data file. The program running online 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 also used to: store the data identifier in the message queue corresponding to the program; according to the data identifier, store the recorded data in the corresponding position of the data file; the online recorded data acquisition module 401 is also used to: obtain the corresponding data identifier from the message queue corresponding to the program; according to the data identifier, obtain the corresponding online recorded data from the data file.

[0071] According to another embodiment of the present invention, in the case where 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 also used to: store the data identifier of each recording in an orderly manner in the message queue corresponding to the program according to the recording time of each recording; the online recording data acquisition module 401 is also used 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 the sorting rule of the message queue.

[0072] According to another embodiment of the present invention, the data playback processing module 402 is also used 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 running return value of the external interaction code, and use the running return value to replace the external interaction code in the program through bytecode enhancement technology; use the reflection mechanism to reflectively call the external interaction code to trigger the running of the program.

[0073] According to another embodiment of the present invention, the program debugging device 400 also 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 a 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 passes.

[0074] According to yet 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 plug-in.

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

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

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

[0078] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0079] The server 505 may be a server that provides various services, such as a background management server (only an example) that provides support for program debugging performed by users using the terminal devices 501, 502, and 503. In response to receiving a local debugging request for a program, the background management server may obtain 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 of the program, and feed back the processing results (such as debugging results, etc. - only an example) to the terminal device.

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

[0081] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0082] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 6 The terminal device or server shown is only an example and should not bring any limitation to the functions 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 according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other 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 the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, 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, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.

[0085] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.

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

[0087] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0088] The units involved in the embodiments of the present invention may be implemented by software or hardware. The units described may also be arranged in a processor, for example, it may be described as follows: a processor includes: an online recording data acquisition module and a data playback processing module.

[0089] Among them, the names of these modules do not constitute a limitation of the modules themselves in certain cases. For example, the data playback processing module can also be described as "a module used to run the program by data playback processing of the online recorded data so as 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 embodiment; or may exist independently without being assembled into the device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by the device, the device includes: in response to receiving a local debugging request of the program, obtaining the online recording data corresponding to the program from a pre-recorded data file; and running the program by playing back the data of the online recording data, so as to perform local debugging of the program.

[0091] The technical solution according to the embodiment of the present invention has the following advantages or beneficial effects: by responding to a local debugging request received from a program, the online recorded data corresponding to the program is obtained from a pre-recorded data file; the program is run by replaying the online recorded data so as to perform local debugging of the program. A method for local debugging of the program is implemented, and the consistency of the local debugging environment and the online environment is ensured through the recording and playback of online data, so that the code program can be locally debugged efficiently and at a low cost.

[0092] The specific implementation methods described herein do not constitute limitations on the scope of protection of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention shall be included in the scope of protection of the present invention.

Claims

1. A method for debugging a program, characterized in that: include: In response to receiving a local debugging request for a program, acquiring online recording data corresponding to the program from a pre-recorded data file; The program is run by replaying the online recorded data so as to perform local debugging of the program.

2. The method according to claim 1, characterized in that Before obtaining the online recorded data corresponding to the program from the pre-recorded data file, the method further includes: By using bytecode enhancement technology, target codes that meet preset recording conditions are captured from the online running program for recording, and the recorded data is persistently stored in a data file. The online running program is a historical version of the program.

3. The method according to claim 2, characterized in that 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 position of the data file according to the data identifier; Acquiring online recorded data corresponding to the program from a pre-recorded data file includes: acquiring a corresponding data identifier from a message queue corresponding to the program; and acquiring corresponding online recorded data from the data file according to the data identifier.

4. The method according to claim 3, characterized in that In the case where the target code is recorded multiple times, each recording corresponds to a data identifier; Storing the data identifier in a message queue corresponding to the program includes: storing the data identifier of each recording in the message queue corresponding to the program in order according to the recording time of each recording; Obtaining a corresponding data identifier from a message queue corresponding to the program includes: obtaining a data identifier corresponding to a recording time closest to the request time from the message queue according to a request time of the local debugging request and a sorting rule of the message queue.

5. The method according to claim 1, characterized in that The program is run by playing back the online recorded data, including: Parsing the online recording data to obtain the online recording data of the external interaction code in the program; Using the online recording data of the external interaction code as the running return value of the external interaction code, and using the running return value to replace the external interaction code in the program through bytecode enhancement technology; The external interaction code is reflectively called using a reflection mechanism to trigger the running of the program.

6. The method according to claim 1, characterized in that After acquiring the online recorded data corresponding to the program from the pre-recorded data file, the method further includes: According to the integrity check information in the online recording data, the data volume of the obtained online recording data is checked, and it is confirmed that the check passes.

7. The method according to claim 1, characterized in that The recording of the data file and the data playback processing of the online recorded data are both implemented in the form of plug-ins.

8. A program debugging device, characterized in that: include: An online recording data acquisition module, configured to acquire online recording data corresponding to the program from a pre-recorded data file in response to receiving a local debugging request of the program; The data playback processing module is used to run the program by playing back the online recorded data so as to perform local debugging of the program.

9. A mobile electronic device terminal, characterized in that: include: one or more processors; a storage device for storing 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 according to any one of claims 1 to 7.

10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Test method and device

    CN113076251A