Method and device for checking dynamic debugging online problems
Through dynamic debugging technology, Java proxy and bytecode enhancement are used to effectively investigate online problems, solve the problem of low online problem investigation efficiency in the existing technology, and improve the investigation efficiency and user experience.
Patent Information
- Application Number
- CN202510276433.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-07
- Publication Date
- 2025-06-27
AI Technical Summary
The online product problem investigation of existing medical and health-related products and financial products is relatively low and cannot meet the users' unsensible and efficient needs.
Provides a method to dynamically debug online problems. By responding to problem troubleshooting instructions indicating the target application, parsing the instructions to obtain target program elements and target troubleshooting objects to be performed bytecode enhancement, mounts Java agents to the virtual machine process of the target application, and injects monitoring code through bytecode enhancement, collects target information to determine the troubleshooting result.
Without affecting the operation of the target application, the key information required for problem investigation is dynamically collected, which improves the efficiency of problem investigation and meets the user's unawareness requirements.
Smart Images

Figure CN120216340A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to software operation and maintenance, and can be applied to the fields of medical health and finance. In particular, it relates to a method and device for troubleshooting dynamic debugging of online problems. Background Art
[0002] In the modern software development and operation and maintenance environment, the timely discovery and efficient resolution of online problems are crucial. These problems may stem from various factors such as code defects, resource contention, configuration errors, or external environment changes. Once triggered in the production environment, they often have a serious impact on user experience, system stability, and business continuity. Therefore, developing a set of efficient and real-time online problem troubleshooting methods and devices is of great significance for improving software quality and operation and maintenance efficiency. Especially for financial and medical health software products, such as digital medical platforms, medical health applications, health monitoring programs, etc., which contain a large number of complex interface calls, the probability of problems occurring during the service process for users is greater, and once problems occur, the resulting impact is also more serious.
[0003] In the development and testing environment, once problems occur during the testing process, the main problem troubleshooting means include breakpoint debugging, adding key logs, etc. However, the use of the above methods requires pausing at the breakpoint position or repackaging and releasing the version after injecting relevant code, which will seriously affect the normal operation of the software product and consume a long time, thus unable to meet the requirements of user imperceptibility and high efficiency for online product problem troubleshooting. Summary of the Invention
[0004] In view of this, the present invention provides a method and device for troubleshooting dynamic debugging of online problems, mainly aiming to solve the problem of low efficiency in troubleshooting online product problems of existing medical health-related products and financial products.
[0005] According to one aspect of the present invention, a method for troubleshooting dynamic debugging of online problems is provided, including:
[0006] In response to a problem troubleshooting instruction indicating a target application program, parsing the problem troubleshooting instruction to obtain a target program element to be bytecode enhanced, a target troubleshooting object under the target program element, and a target bytecode enhancement position;
[0007] Obtaining a process identifier of the target application program from a virtual machine process in which the target application program runs, and mounting a Java agent to the virtual machine process of the target application program according to the process identifier;
[0008] Enhancing the bytecode for monitoring target information of the target troubleshooting object to the target bytecode enhancement position through the Java agent to obtain an updated target program element;
[0009] Reload the updated target program element, and collect the target information of the target troubleshooting object during the running of the updated target program element, so as to determine the online problem troubleshooting result based on the target information.
[0010] The step of enhancing the bytecode for monitoring the target information of the target troubleshooting object to the target bytecode enhancement position to obtain the updated target program element includes:
[0011] Generate new bytecode for monitoring the target information of the target troubleshooting object according to the target troubleshooting object;
[0012] Perform a re-conversion class operation on the target program element to allow bytecode modification of the running target program element;
[0013] Insert the new bytecode into the target bytecode enhancement position by triggering a callback mechanism to generate an updated target program element.
[0014] Further, the step of parsing the problem troubleshooting instruction to obtain the target program element to be bytecode-enhanced includes:
[0015] Parse the target program element carried in the problem troubleshooting instruction and the identifier of the preset enhancement option, where the preset enhancement option is a visualization option corresponding to different target troubleshooting objects in the enhanced debugging configuration interface;
[0016] Identify the target troubleshooting object that matches the identifier from the global troubleshooting objects, and store the target troubleshooting object and the target program element in the cache space.
[0017] Further, before obtaining the process identifier of the target application from the process of the virtual machine where the target application runs, the method further includes:
[0018] Query the troubleshooting objects and program elements stored in the cache space;
[0019] If the target troubleshooting object and the target program element are queried, load the previously updated target program element and run it.
[0020] Further, before parsing the problem troubleshooting instruction, the method further includes:
[0021] Perform instruction legality verification and user permission verification on the problem troubleshooting instruction;
[0022] Generate an instruction processing start timestamp when the results of the verification are all passed;
[0023] After collecting the target information of the target troubleshooting object during the running of the updated target program element, the method further includes:
[0024] Mark the instruction processing start timestamp for the target information.
[0025] Further, the method further includes:
[0026] Monitor the running and debugging status of the target program element;
[0027] When the running and debugging status is debugging completed, debugging abnormal, or debugging execution timeout is determined based on the instruction processing start timestamp, disconnect the connection between the Java agent and the target application;
[0028] When the running and debugging status is debugging completed, unlock the new bytecode from the updated target program element to restore the original code of the target program element before bytecode enhancement.
[0029] Further, the target troubleshooting object includes method input parameters, method return values, local variables, exception information, method call times, execution time, and real-time memory usage information.
[0030] According to another aspect of the present invention, there is provided a troubleshooting device for dynamically debugging online problems, including:
[0031] A parsing module, configured to, in response to a problem troubleshooting instruction indicating a target application, parse the problem troubleshooting instruction to obtain a target program element to be bytecode enhanced, a target troubleshooting object under the target program element, and a target bytecode enhancement position;
[0032] A mounting module, configured to obtain a process identifier of the target application from a virtual machine process in which the target application runs, and mount a Java agent to the virtual machine process of the target application according to the process identifier;
[0033] An enhancement module, configured to enhance bytecode for monitoring target information of the target troubleshooting object to the target bytecode enhancement position through the Java agent to obtain an updated target program element;
[0034] A collection module, configured to reload the updated target program element, and collect target information of the target troubleshooting object during the running of the updated target program element to determine an online problem troubleshooting result based on the target information.
[0035] Further, the enhancement module includes:
[0036] A determination unit, configured to generate new bytecode for monitoring the target information of the target troubleshooting object according to the target troubleshooting object;
[0037] A callback unit, configured to perform a retransformation class operation on the target program element to allow bytecode modification of the running target program element;
[0038] A first generation unit, configured to insert the new bytecode into the target bytecode enhancement position by triggering a callback mechanism to generate an updated target program element.
[0039] Further, the parsing module includes:
[0040] A parsing unit, configured to parse the target program element carried by the problem troubleshooting instruction and the identifier of a preset enhancement option, where the preset enhancement option is a visualization option corresponding to different target troubleshooting objects in an enhanced debugging configuration interface;
[0041] A caching unit, configured to identify a target troubleshooting object that matches the identifier from global troubleshooting objects, and store the target troubleshooting object and the target program element in a cache space.
[0042] Further, the device includes:
[0043] A query module, configured to query the troubleshooting object and the program element stored in the cache space;
[0044] A loading module, configured to, if the target troubleshooting object and the target program element are queried, load the previously updated target program element and run it.
[0045] Further, the device includes:
[0046] A verification unit, configured to perform instruction legality verification and user permission verification on the problem troubleshooting instruction;
[0047] A second generation unit, configured to generate an instruction processing start timestamp when the results of the verification all pass;
[0048] A marking unit, configured to mark the instruction processing start timestamp for the target information.
[0049] Further, the device further includes:
[0050] A monitoring module, configured to monitor the running and debugging state of the target program element;
[0051] A determination module, configured to disconnect the connection between the Java agent and the target application when the running and debugging state is debugging completed, debugging abnormal, or debugging execution timeout is determined according to the instruction processing start timestamp;
[0052] An unlocking module, configured to unlock the newly added bytecode from the updated target program element when the running and debugging state is debugging completed, so as to restore the original code of the target program element before bytecode enhancement.
[0053] According to another aspect of the present invention, there is provided a storage medium storing at least one executable instruction, and the executable instruction causes a processor to perform operations corresponding to the method for troubleshooting dynamic debugging online problems as described above.
[0054] According to still another aspect of the present invention, there is provided a computer device, including: a processor, a memory, a communication interface, and a communication bus, and the processor, the memory, and the communication interface complete communication with each other through the communication bus;
[0055] The memory is used to store at least one executable instruction, and the executable instruction causes the processor to perform operations corresponding to the method for troubleshooting dynamic debugging online problems as described above.
[0056] By means of the above technical solutions, the technical solutions provided by the embodiments of the present invention have at least the following advantages:
[0057] The present invention provides a method and device for troubleshooting online problems in dynamic debugging. First, in response to a problem troubleshooting instruction indicating a target application program, the problem troubleshooting instruction is parsed to obtain a target program element to be bytecode enhanced, a target troubleshooting object under the target program element, and a target bytecode enhancement position; from the virtual machine process in which the target application program runs, the process identifier of the target application program is obtained, and a Java agent is mounted to the target application program according to the process identifier; through the Java agent, the bytecode for monitoring the target information of the target troubleshooting object is enhanced to the target bytecode enhancement position to obtain an updated target program element; the updated target program element is reloaded, and during the running of the updated target program element, the target information of the target troubleshooting object is collected to determine the online problem troubleshooting result based on the target information. Compared with the prior art, in the embodiments of the present invention, by mounting a Java agent to the virtual machine process of the target application program and performing bytecode enhancement on the target program element to inject bytecode for collecting information of the target troubleshooting object, key information required for problem troubleshooting can be collected during dynamic debugging without affecting the running of the target application program and without packaging and releasing, thereby improving the efficiency of problem troubleshooting. Applying the Java agent technology of the embodiments of the present invention to target application programs (such as electronic medical record systems, remote medical service platforms, medical data analysis systems, etc.) can significantly improve the efficiency and quality of medical services. Especially in terms of problem troubleshooting and fault handling, it can not only improve the efficiency of problem troubleshooting, but also play an important role in ensuring the quality and safety of medical services, optimizing data processing processes, enhancing the stability of remote medical services, promoting medical data analysis and scientific research, and simplifying maintenance and upgrade processes, providing strong support for the digital transformation of the medical industry.
[0058] The above description is only an overview of the technical solution of the present invention. In order to be able to understand the technical means of the present invention more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of the present invention more obvious and understandable, the following specifically illustrates the embodiments of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] By reading the following detailed description of the preferred embodiments, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of showing the preferred embodiments and are not considered to be a limitation of the present invention. And throughout the drawings, the same reference numerals are used to represent the same components. In the drawings:
[0060] Figure 1 It shows a flowchart of a method for troubleshooting online problems in dynamic debugging provided by an embodiment of the present invention;
[0061] Figure 2Shows a flowchart of a bytecode enhancement judgment process provided by an embodiment of the present invention;
[0062] Figure 3 Shows a flowchart of another method for troubleshooting online problems in dynamic debugging provided by an embodiment of the present invention;
[0063] Figure 4 Shows a flowchart of a bytecode enhancement process provided by an embodiment of the present invention;
[0064] Figure 5 Shows a block diagram of a device for troubleshooting online problems in dynamic debugging provided by an embodiment of the present invention;
[0065] Figure 6 Shows a schematic structural diagram of a computer device provided by an embodiment of the present invention. Detailed implementation manners
[0066] Hereinafter, exemplary embodiments of the present disclosure will be described in more detail with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present disclosure can be more thoroughly understood and the scope of the present disclosure can be fully conveyed to those skilled in the art.
[0067] To solve the problem of low efficiency in troubleshooting online product problems of existing medical health-related products and financial products. Embodiments of the present invention provide a method for troubleshooting online problems in dynamic debugging, as Figure 1 shown, the method includes:
[0068] 101. In response to a problem troubleshooting instruction indicating a target application program, parse the problem troubleshooting instruction to obtain a target program element to be bytecode-enhanced, and a target program element under the target program element.
[0069] In an embodiment of the present invention, the current execution entity is a dynamic debugging tool that can dynamically modify class bytecodes and change the logic of existing methods during the runtime of an application. The target application is an application that needs to be debugged and is in an online operation state, such as a medical and health application, a health monitoring application, an intelligent consultation application, a smart healthcare application, a payment application, a wealth management application, a credit application, an insurance application, a financial integrated service platform, etc. The problem troubleshooting instruction can be triggered by a user's operation on the debugging configuration interface of the dynamic debugging tool, including configuration content generated based on the user's input or selection of the target application and target program elements through the debugging configuration interface. The target program element is any method or class in the target application code. The target program element is a certain parameter or certain running information under a method or class. For example, in the scenario of intelligent consultation, the input parameters when a method enters (user basic information, disease description information, inquiry target, etc.), and the return value when the method exits (consultation recommendation information, consultation reply information), etc. Taking the target application as a digital medical platform as an example, if a user feedbacks that the discharge summary generation is abnormal, the operation and maintenance personnel can select the discharge summary generation method as the target program element based on the debugging configuration interface and select the method return value module, so that the problem troubleshooting instruction includes the identifiers of the target application element and the return value module, and then through subsequent bytecode enhancement, the execution data of the discharge summary method can be obtained. Taking the target application as a financial trading system as an example, if a user feedbacks that the transaction verification code reception is abnormal, the operation and maintenance personnel can select the verification code sending method as the target program element based on the debugging configuration interface and select the method return value module, so that the problem troubleshooting instruction includes the identifiers of the target application element and the return value module, and then through subsequent bytecode enhancement, the execution data of the verification code generation method can be obtained.
[0070] In an embodiment of the present invention, for further illustration and limitation, parsing the problem troubleshooting instruction to obtain the target program element to be bytecode-enhanced includes:
[0071] Parsing the target program element carried in the problem troubleshooting instruction and the identifier of the preset enhancement option;
[0072] Identifying the target troubleshooting object that matches the identifier from the global troubleshooting object and storing the target troubleshooting object and the target program element in the cache space.
[0073] In an embodiment of the present invention, the preset enhancement option is a visualization option corresponding to different target troubleshooting objects in the enhanced debugging configuration interface. The bytecode enhancement technology is used to obtain information about the method execution, such as method input and output parameters, local variables, exceptions, etc., and can be enhanced at different bytecode positions. The process of byte enhancement can also be called "instrumentation", and different bytecode enhancement positions can be called instrumentation points. In an embodiment of the present invention, each instrumentation point is packaged into a module (preset enhancement option). During the process of configuring the problem troubleshooting instruction based on the client-side debugging configuration interface, the corresponding preset enhancement option identifier can be set in the instruction based on the preset enhancement option selected by the user. During the bytecode enhancement process, the current execution entity can match the corresponding target bytecode enhancement position based on the identifier.
[0074] It should be noted that since debuggers may want to view different information for different methods. For example, in the product display method of a financial trading system, the information to be viewed is the call count and execution time. In the trading interface call method of a bank trading system, the input and output parameters are required. Another example is that in the contract generation method of an insurance system, if the generation is slow, the debugger needs to pay attention to the method's time consumption. If an exception occurs in a certain payment method, the debugger needs to print the exception information but does not care about other information. Therefore, modular and configurable management of the instrumentation points, without performing instrumentation operations on unnecessary information, can improve the flexibility of the troubleshooting process, allowing debuggers to quickly collect and focus more on the desired data.
[0075] In an embodiment of the present invention, for further explanation and limitation, before parsing the problem troubleshooting instruction, the method further includes:
[0076] Performing instruction legality verification and user permission verification on the problem troubleshooting instruction;
[0077] In the case where the results of both verifications pass, generating an instruction processing start timestamp;
[0078] After collecting the target information of the target troubleshooting object during the running of the updated target program element, the method further includes:
[0079] Marking the instruction processing start timestamp for the target information.
[0080] In the embodiments of the present invention, in the financial field, security is of utmost importance. Before performing the action of debugging the target application according to the problem troubleshooting instruction, it is necessary to verify the legality of the instruction, specifically including checking whether the debugging command input by the user conforms to the expected format and rules. In addition, the debugging permissions of different personnel with different authorities for the program are also different. Therefore, it is also necessary to perform permission verification, specifically including verifying whether the user has the permission to execute the debugging instruction to ensure the security of the debugging and program running information. In addition, in order to provide basic data for subsequent analysis and log recording, a timestamp indicating the start of the record command processing, that is, the instruction processing start timestamp, is generated and filled in the target information.
[0081] 102. Obtain the process identifier of the target application from the virtual machine process in which the target application runs, and mount the Java agent to the virtual machine process of the target application according to the process identifier.
[0082] In the embodiments of the present invention, the dynamic debugging tool is based on the Java agent technology and bytecode technology to achieve injecting debugging code and collecting key running information required for problem troubleshooting without interrupting the running of the application program. The target application is always in the online running state. By using the jps command to traverse all virtual machine processes of the virtual machine, the process identifier of the target virtual machine process corresponding to the target application, that is, the pid, can be matched. After obtaining the process identifier, a Java agent can be created through an interface, and based on the process identifier, this Java agent is dynamically attached to the target virtual machine process and the agent is loaded to mount the Java agent to the target application.
[0083] It should be noted that by mounting the Java agent to the virtual machine process of the target application, the function of dynamically modifying the class bytecode and injecting debugging code while the target application is running is realized. It avoids breakpoint insertion and also avoids re-releasing after modifying the code, improving the code injection efficiency while making the user unaware of the debugging process. For application programs related to digital medical and healthcare services, users have relatively high requirements for timeliness when using them. For example, in a registration system, a 1-second delay will affect the registration result. If there is an obvious unresponsiveness or lag, it will seriously affect the user operation. The user's unawareness of the debugging process can improve the user experience while meeting the debugging requirements.
[0084] In one embodiment of the present invention, for further illustration and limitation, before obtaining the process identifier of the target application from the process of the virtual machine in which the target application runs, the method further includes:
[0085] Query the troubleshooting object and program element stored in the cache space;
[0086] If the target troubleshooting object and the target program element are queried, then load the previously updated target program element and run it;
[0087] If the target troubleshooting object and the target program element are not queried, then perform the step of attaching the Java agent to the virtual machine process of the target application according to the process identifier.
[0088] In an embodiment of the present invention, when receiving a problem troubleshooting instruction for the first time, store the target class name or method name and the target troubleshooting object in a cache. Before each execution of bytecode enhancement, first query the content in the cache. As Figure 2 shown, if the current target troubleshooting object and the target program element are queried in the cache, it indicates that the problem troubleshooting instruction for the target troubleshooting object and the target program element is not issued for the first time, and the target bytecode enhancement position of the target method or class has been updated previously. Then directly jump to the step of executing the new method, so as to output the target information. If the current target troubleshooting object and the target program element are not queried in the cache, it indicates that the problem troubleshooting instruction for the target troubleshooting object and the target program element is issued for the first time. Then it is necessary to perform bytecode enhancement, obtain the updated target program element, and then reload the updated target program element to modify the running logic and collect the information of the target troubleshooting object.
[0089] It should be noted that the bytecode replacement operation has a certain performance loss, and the fewer times this operation occurs, the better. Therefore, it is necessary to record the bytecode replacement operation. When the debugger issues a debugging instruction, the current execution entity will determine whether the current class or method, and the instrumentation points of the troubleshooting object have been enhanced. If they have been enhanced, the new method can be directly executed to avoid repeated bytecode enhancement.
[0090] 103. Through the Java agent, enhance the bytecode for monitoring the target information of the target troubleshooting object to the target bytecode enhancement position to obtain an updated target program element.
[0091] In an embodiment of the present invention, problem troubleshooting is a process of troubleshooting one or several methods or classes in a target application. Therefore, it is necessary to inject bytecode into a specified position in the target method or class to obtain the running information of the corresponding target troubleshooting object through this bytecode. Among them, the bytecode injection process can be the addition of bytecode or the replacement of the original bytecode. The embodiment of the present invention does not make specific limitations. The specific bytecode injection process can modify the bytecode of the target class based on bytecode operation libraries such as javaassist to generate new bytecode.
[0092] In an embodiment of the present invention, for further illustration and limitation, as Figure 3 shown, step 103 of enhancing the bytecode of the target information for monitoring the target troubleshooting object to the target bytecode enhancement position to obtain an updated target program element includes:
[0093] 201. Generate new bytecode for monitoring the target information of the target troubleshooting object according to the target troubleshooting object.
[0094] 202. Perform a retransformation class operation on the target program element to allow bytecode modification of the running target program element.
[0095] 203. Insert the new bytecode into the target bytecode enhancement position by triggering a callback mechanism to generate an updated target program element.
[0096] In an embodiment of the present invention, after the Java agent is attached to the target virtual machine process, the bytecode in the target program element can be modified according to the process as Figure 4 shown. Load the tools and logic for modifying bytecode included in the Java agent. When it is necessary to dynamically modify the behavior of a class, a retransformation operation will be triggered. This operation is usually provided by the Instrumentation API of the virtual machine, which allows the bytecode of a class to be modified at runtime. Further, trigger the ClassFileLoadHook callback. Since the ClassFileLoadHook callback provides a mechanism that enables developers to insert custom logic during the class loading and transformation process, in this solution, the generated new bytecode is inserted into the target bytecode enhancement position based on this callback mechanism, thereby generating a method or class with the new bytecode inserted, that is, an updated target program element.
[0097] It should be noted that by connecting the dynamic modification logic and the target virtual machine process through the Java agent, it is possible to modify the information acquisition logic during the running process while the target application is running normally, so as to improve the information acquisition efficiency while meeting the information acquisition requirements for problem troubleshooting. By using tools such as Javaassist, developers can operate bytecode programmatically without manually editing bytecode files, which greatly improves the efficiency and flexibility of dynamic class transformation.
[0098] 104. Reload the updated target program element and collect the target information of the target troubleshooting object during the running of the updated target program element to determine the online problem troubleshooting result based on the target information.
[0099] In an embodiment of the present invention, a lightweight information collection component operating inside the virtual machine is further configured in the dynamic debugging tool to collect target information of the target object to be troubleshot through this component. A core interface method "match" is also configured in this component to match the instruction content. If the target information collected currently successfully matches the debugging instruction, the target information is retained; otherwise, the currently collected target information is cleared, and this component is remounted to the target method or class to wait for the generation of the next debugging data. The collected target information is stored in a preset storage space for the user to obtain, or returned to the user side that issues the problem troubleshooting instruction, so that the debugger can clarify the reason corresponding to the problem of the target program element in the target application program based on the target information and obtain the online problem troubleshooting result.
[0100] In an embodiment of the present invention, for further illustration and limitation, the method further includes:
[0101] Monitoring the running and debugging status of the target program element;
[0102] When the running and debugging status is debugging completed, debugging abnormal, or it is determined that the debugging execution times out based on the instruction processing start timestamp, disconnect the connection between the Java agent and the target application program;
[0103] When the running and debugging status is debugging completed, unlock the new bytecode from the updated target program element to restore the original code of the target program element before bytecode enhancement.
[0104] In an embodiment of the present invention, after bytecode enhancement is completed and target information is obtained based on the updated bytecode, it is also necessary to monitor the running and debugging status of the target program element. If it is monitored that the debugging status is any one of debugging completed, debugging abnormal, and debugging execution timeout, disconnect the connection between the Java agent and the target virtual machine process to achieve the purpose of releasing resources. Among them, the debugging completed status can be determined based on the problem troubleshooting end instruction issued by the user side, that is, there is no need to obtain information based on the updated bytecode subsequently. Debugging abnormal is determined according to the exception error message. Debugging execution timeout is determined according to the interval duration between the processing start timestamp and the current system time, that is, when the above interval duration is greater than the preset timeout duration, it is determined that the debugging execution times out. When the running and debugging status is debugging completed, in order to avoid the collection of unnecessary information during the debugging process, bytecode unlocking is performed on the new bytecode to restore the bytecode of the updated target program element to the state before bytecode enhancement.
[0105] In an embodiment of the present invention, for further illustration and limitation, the target troubleshooting object includes method input parameters, method return values, local variables, exception information, method call times, execution time, and real-time memory usage information.
[0106] In an embodiment of the present invention, in a financial application, when problems such as performance bottlenecks, error location, and resource optimization occur, it is usually necessary to troubleshoot one or more of the parameters such as method input parameters, method return values, local variables, exception information, method call times, execution time, and real-time memory usage information. For example, when a certain financial trading system has a response delay during peak hours and users report that the transaction confirmation time is too long, it is necessary to collect method input parameters, method return values, execution time, and real-time memory usage information to detect whether the data volume of transaction requests is reasonable, confirm whether the data volume returned to the client is too large, analyze the execution time of each transaction processing method, find out the time-consuming links, count the call frequency of each method, and identify whether there are unnecessary repeated calls.
[0107] Another example is that when a user frequently encounters the situation of the application crashing when using a certain financial wealth management application and the error log does not contain enough information to locate the problem, it is necessary to collect local variables, exception information, and method call times to check the values of local variables at the time of error, identify whether there are errors caused by illegal values or uninitialized variables, record and analyze the exception information in detail, and analyze the method call sequence before and after the exception occurs to identify possible triggering conditions.
[0108] The present invention provides a method for troubleshooting dynamic debugging online problems. First, in response to a problem troubleshooting instruction indicating a target application, the problem troubleshooting instruction is parsed to obtain a target program element to be bytecode enhanced, a target troubleshooting object under the target program element, and a target bytecode enhancement position; from the virtual machine process in which the target application runs, the process identifier of the target application is obtained, and a Java agent is mounted to the target application according to the process identifier; through the Java agent, the bytecode for monitoring the target information of the target troubleshooting object is enhanced to the target bytecode enhancement position to obtain an updated target program element; the updated target program element is reloaded, and during the operation of the updated target program element, the target information of the target troubleshooting object is collected to determine the online problem troubleshooting result based on the target information. Compared with the prior art, in the embodiment of the present invention, by mounting a Java agent to the virtual machine process of the target application and performing bytecode enhancement on the target program element to inject bytecode for collecting information of the target troubleshooting object, key information required for problem troubleshooting can be collected during dynamic debugging without affecting the operation of the target application and without packaging and releasing. Thereby, the efficiency of problem troubleshooting is improved. Applying the Java agent technology of the embodiment of the present invention to a target application (such as an electronic medical record system, a remote medical service platform, a medical data analysis system, etc.) can significantly improve the efficiency and quality of medical services. Especially in terms of problem troubleshooting and fault handling, it can not only improve the efficiency of problem troubleshooting, but also play an important role in ensuring the quality and safety of medical services, optimizing the data processing process, enhancing the stability of remote medical services, promoting medical data analysis and scientific research, and simplifying the maintenance and upgrade process, providing strong support for the digital transformation of the medical industry.
[0109] Further, as an implementation of the method described above Figure 1 The embodiment of the present invention provides a device for troubleshooting dynamic debugging online problems, as Figure 5 shown, the device includes:
[0110] A parsing module 31, configured to parse the problem troubleshooting instruction in response to a problem troubleshooting instruction indicating a target application, and obtain a target program element to be bytecode enhanced, a target troubleshooting object under the target program element, and a target bytecode enhancement position;
[0111] A mounting module 32, configured to obtain the process identifier of the target application from the virtual machine process in which the target application runs, and mount a Java agent to the virtual machine process of the target application according to the process identifier;
[0112] An enhancement module 33 for enhancing the bytecode for monitoring the target information of the target troubleshooting object to the target bytecode enhancement position through the Java agent to obtain an updated target program element;
[0113] A collection module 34 for reloading the updated target program element and collecting the target information of the target troubleshooting object during the running of the updated target program element to determine the online problem troubleshooting result based on the target information.
[0114] Further, the enhancement module includes:
[0115] A determination unit for generating new bytecode for monitoring the target information of the target troubleshooting object according to the target troubleshooting object;
[0116] A callback unit for performing a retransformation class operation on the target program element to allow bytecode modification of the running target program element;
[0117] A first generation unit for inserting the new bytecode into the target bytecode enhancement position by triggering a callback mechanism to generate an updated target program element.
[0118] Further, the parsing module includes:
[0119] A parsing unit for parsing the target program element carried by the problem troubleshooting instruction and the identifier of the preset enhancement option, where the preset enhancement option is a visualization option corresponding to different target troubleshooting objects in the enhanced debugging configuration interface;
[0120] A caching unit for identifying the target troubleshooting object that matches the identifier from the global troubleshooting objects and storing the target troubleshooting object and the target program element in a cache space.
[0121] Further, the device includes:
[0122] A query module for querying the troubleshooting objects and program elements stored in the cache space;
[0123] A loading module for loading and running the previously updated target program element if the target troubleshooting object and the target program element are queried.
[0124] Further, the device includes:
[0125] A verification unit for performing instruction legality verification and user permission verification on the problem troubleshooting instruction;
[0126] A second generation unit, configured to generate an instruction processing start timestamp when the results of the verification are all passed;
[0127] A marking unit, configured to mark the instruction processing start timestamp for the target information.
[0128] Further, the apparatus further includes:
[0129] A monitoring module, configured to monitor the running and debugging status of the target program element;
[0130] A determination module, configured to disconnect the connection between the Java agent and the target application when the running and debugging status is debugging completed, debugging abnormal, or debugging execution timeout is determined according to the instruction processing start timestamp;
[0131] An unlocking module, configured to unlock the newly added bytecode from the updated target program element when the running and debugging status is debugging completed, so as to restore the original code of the target program element before bytecode enhancement.
[0132] According to an embodiment of the present invention, there is provided a storage medium storing at least one executable instruction, and the computer executable instruction can execute the method for troubleshooting dynamic debugging online problems in any of the above method embodiments.
[0133] The present invention provides a method and apparatus for troubleshooting dynamic debugging online problems. First, in response to a problem troubleshooting instruction indicating a target application, the problem troubleshooting instruction is parsed to obtain a target program element to be bytecode enhanced, a target troubleshooting object under the target program element, and a target bytecode enhancement position; from the virtual machine process in which the target application runs, the process identifier of the target application is obtained, and the Java agent is mounted to the target application according to the process identifier; through the Java agent, the bytecode for monitoring the target information of the target troubleshooting object is enhanced to the target bytecode enhancement position to obtain an updated target program element; the updated target program element is reloaded, and during the running of the updated target program element, the target information of the target troubleshooting object is collected to determine the online problem troubleshooting result based on the target information. Compared with the prior art, in the embodiment of the present invention, the Java agent is mounted to the virtual machine process of the target application, and the target program element is bytecode enhanced to inject the bytecode for collecting the information of the target troubleshooting object, so that without affecting the running of the target application, key information required for problem troubleshooting can be collected during dynamic debugging without packaging and releasing, thereby improving the efficiency of problem troubleshooting.
[0134] Figure 6The schematic structural diagram of a computer device provided according to an embodiment of the present invention is shown. The specific embodiments of the present invention do not limit the specific implementation of the computer device.
[0135] As Figure 6 shown, the computer device may include: a processor 402, a communications interface 404, a memory 406, and a communication bus 408.
[0136] Among them: the processor 402, the communications interface 404, and the memory 406 communicate with each other through the communication bus 408.
[0137] The communications interface 404 is used for network communication with other devices such as clients or other servers.
[0138] The processor 402 is used to execute the program 410, and specifically can execute the relevant steps in the above embodiments of the method for troubleshooting dynamic debugging online problems.
[0139] Specifically, the program 410 may include program code, and the program code includes computer operation instructions.
[0140] The processor 402 may be a central processing unit CPU, or a specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present invention. One or more processors included in the computer device may be of the same type of processor, such as one or more CPUs; or may be of different types of processors, such as one or more CPUs and one or more ASICs.
[0141] The memory 406 is used to store the program 410. The memory 406 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk memory.
[0142] The program 410 is specifically used to cause the processor 402 to perform the following operations:
[0143] In response to a problem troubleshooting instruction indicating a target application, parse the problem troubleshooting instruction to obtain a target program element to be bytecode enhanced, a target troubleshooting object under the target program element, and a target bytecode enhancement position;
[0144] Obtain the process identifier of the target application from the virtual machine process in which the target application runs, and mount the Java agent to the virtual machine process of the target application according to the process identifier;
[0145] Through the Java agent, enhance the bytecode for monitoring the target information of the target troubleshooting object to the target bytecode enhancement position to obtain an updated target program element;
[0146] Reload the updated target program element, and collect the target information of the target troubleshooting object during the running of the updated target program element, so as to determine the online problem troubleshooting result based on the target information.
[0147] Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the present invention can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. Optionally, they can be implemented by program codes executable by the computing device, so that they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a different order from here, or they can be made into individual integrated circuit modules respectively, or multiple modules or steps among them can be made into a single integrated circuit module to implement. Thus, the present invention is not limited to any specific combination of hardware and software.
[0148] The above are only the preferred embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A method for troubleshooting online problems during dynamic debugging, characterized in that: include: In response to a problem troubleshooting instruction indicating a target application program, the problem troubleshooting instruction is parsed to obtain a target program element to be bytecode enhanced, a target troubleshooting object under the target program element, and a target bytecode enhancement position; Obtaining a process identifier of the target application from the virtual machine process in which the target application is running, and mounting a Java agent to the virtual machine process of the target application according to the process identifier; By means of the Java agent, the bytecode for monitoring the target information of the target screening object is enhanced to the target bytecode enhancement position to obtain an updated target program element; Reload the updated target program element, and during the running of the updated target program element, collect the target information of the target troubleshooting object to determine the online problem troubleshooting result based on the target information.
2. The method according to claim 1, characterized in that: The step of enhancing the bytecode for monitoring the target information of the target screening object to the target bytecode enhancement position to obtain an updated target program element includes: Generating a new bytecode for monitoring target information of the target inspection object according to the target inspection object; Performing a re-conversion type operation on the target program element to allow bytecode modification of the target program element in operation; By triggering the callback mechanism, the newly added bytecode is inserted into the target bytecode enhancement position to generate an updated target program element.
3. The method according to claim 1, characterized in that The step of parsing the problem troubleshooting instruction to obtain a target program element to be bytecode enhanced includes: Parsing the target program elements carried by the troubleshooting instruction and the identifiers of the preset enhancement options, wherein the preset enhancement options are visualization options corresponding to different target troubleshooting objects in the enhanced debugging configuration interface; A target check object matching the identifier is identified from the global check objects, and the target check object and the target program element are stored in a cache space.
4. The method according to claim 3, characterized in that Before obtaining the process identifier of the target application from the process of the virtual machine in which the target application is running, the method further includes: Querying the check objects and program elements stored in the cache space; If the target screening object and the target program element are found, the previously updated target program element is loaded and executed; If the target screening object and the target program element are not found, the step of mounting the Java agent to the virtual machine process of the target application according to the process identifier is performed.
5. The method according to claim 1, characterized in that Before parsing the troubleshooting instruction, the method further includes: Performing instruction legitimacy verification and user authority verification on the troubleshooting instructions; If the verification results are all passed, generating an instruction processing start timestamp; In the process of running the updated target program element, after collecting the target information of the target screening object, the method further includes: The target information is marked with the instruction processing start timestamp.
6. The method according to claim 5, characterized in that The method further comprises: Monitoring the running and debugging status of the target program element; When the debugging operation status is debugging completion, debugging exception, or debugging execution timeout is determined according to the instruction processing start timestamp, disconnecting the connection between the Java agent and the target application; When the running debugging state is debugging completed, the newly added bytecode is unlocked from the updated target program element to restore the original code of the target program element before bytecode enhancement.
7. The method according to any one of claims 1 to 6, characterized in that The target inspection objects include method input parameters, method return values, local variables, exception information, number of method calls, execution time and real-time memory usage information.
8. A device for troubleshooting online problems during dynamic debugging, characterized in that: include: A parsing module, configured to respond to a troubleshooting instruction indicating a target application program, parse the troubleshooting instruction, and obtain a target program element to be bytecode enhanced, a target troubleshooting object under the target program element, and a target bytecode enhancement position; A mounting module, used to obtain a process identifier of the target application from the virtual machine process in which the target application is running, and mount the Java agent to the virtual machine process of the target application according to the process identifier; An enhancement module, used to enhance the bytecode used to monitor the target information of the target screening object to the target bytecode enhancement position through the Java agent to obtain an updated target program element; The collection module is used to reload the updated target program element and collect the target information of the target troubleshooting object during the operation of the updated target program element, so as to determine the online problem troubleshooting result based on the target information.
9. A storage medium storing at least one executable instruction, wherein the executable instruction enables a processor to execute an operation corresponding to the method for troubleshooting online problems in dynamic debugging according to any one of claims 1 to 7.
10. A computer device comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the method for troubleshooting online problems in dynamic debugging according to any one of claims 1 to 7.