Application debugging method, device, equipment and storage medium
By generating and updating code structure models, analyzing and obtaining data snapshots, and directly debugging applications, the problems of low debugging efficiency and insufficient data security in the existing technology are solved, and an efficient and safe application debugging process is achieved.
Patent Information
- Application Number
- CN202410955057.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-17
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-07-17
AI Technical Summary
The existing technology is inefficient in application debugging and lacks data security, resulting in a long debugging process and the possibility of leaking user private data.
By generating a primary code structure model, analyze the target class and build a knowledge graph, obtain request parameters and data snapshots, update the code structure model, generate code structure chains and graph branches, obtain script programs and data snapshots, and directly debug applications to avoid adding Log and obtain running parameters.
It improves the efficiency of application debugging, ensures data security, avoids leakage of private data, and improves debugging efficiency and security.
Smart Images

Figure CN118503138B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of program debugging, and in particular to an application debugging method, device, equipment and storage medium. Background Art
[0002] The intranet of user organizations generally uses applications provided by application providers to perform operations. Due to the slow operation of the application's program interface and / or the generation of dirty data in the application, the application is prone to running errors, which require debugging.
[0003] Currently, one way to debug an application is: when an application runs into an error, the application provider adds a log to the application, obtains the application's running parameters through the log, and then analyzes the running parameters to determine where the application's breakpoints are, and then fixes the breakpoints to debug the application.
[0004] However, if the above method is used to debug the application every time an application running error occurs, it will take up more time of the application provider and the user organization, resulting in low efficiency of application debugging; and, when the application provider uses the above method to debug the application, it is possible to obtain the private data of the user organization through the obtained operating parameters, thereby reducing the data security of the user's intranet; in summary, it can be seen that the debugging efficiency and data security of debugging applications using existing technologies are both low. Summary of the invention
[0005] In order to improve debugging efficiency and data security when debugging an application, embodiments of the present application provide an application debugging method, apparatus, device, and storage medium.
[0006] In a first aspect, an embodiment of the present application provides an application debugging method, comprising:
[0007] Generate a primary code structure model based on the obtained directory operation structure of the target application;
[0008] Determine the target class based on the primary code structure model, analyze the target class to obtain the corresponding knowledge graph; process the acquired request parameters based on the target class and the constructed program console to obtain an identifier and a data snapshot corresponding to the identifier;
[0009] Based on the request parameter, the identifier and the data snapshot, the primary code structure model is updated to obtain a target code structure model; the target code structure model includes a code structure chain corresponding to a plurality of the request parameters one by one; the code structure chain has a corresponding graph branch in the knowledge graph;
[0010] A script program is obtained based on the selected code structure chain and the graph branch corresponding to the code structure chain, and in response to the script program corresponding to a third-party class, a data snapshot corresponding to an identifier corresponding to the script program is obtained to obtain a target data snapshot;
[0011] The target application is debugged based on the target data snapshot.
[0012] In a second aspect, an embodiment of the present application provides an application debugging device, including:
[0013] A primary model generation module, used for generating a primary code structure model based on the obtained directory operation structure of the target application;
[0014] An identification snapshot acquisition module is used to determine the target class based on the primary code structure model, analyze the target class to obtain the corresponding knowledge graph; based on the target class and the constructed program console, process the obtained request parameters to obtain the identification and the data snapshot corresponding to the identification;
[0015] A target model generation module, used for updating the primary code structure model based on the request parameter, the identifier and the data snapshot to obtain a target code structure model; the target code structure model includes a code structure chain corresponding to a plurality of the request parameters one by one; the code structure chain has a corresponding graph branch in the knowledge graph;
[0016] A target snapshot acquisition module, configured to obtain a script program based on a selected code structure chain and a graph branch corresponding to the code structure chain, and in response to the script program corresponding to a third-party class, obtain a data snapshot corresponding to an identifier corresponding to the script program to obtain a target data snapshot;
[0017] The target program debugging module is used to debug the target application program based on the target data snapshot.
[0018] In a third aspect, an embodiment of the present application provides a computer device, the computer device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the above method when executing the computer program.
[0019] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps in the above-mentioned method when executed by a processor.
[0020] In a fifth aspect, the embodiments of the present application further provide a computer program product, wherein the computer program product includes a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0021] The embodiments of the above-mentioned application debugging method, device, equipment and storage medium generate a primary code structure model based on the directory operation structure of the acquired target application; determine the target class based on the primary code structure model, analyze the target class to obtain the corresponding knowledge graph; obtain the identification and the data snapshot corresponding to the identification by processing the acquired request parameters based on the target class and the constructed program console; update the primary code structure model based on the request parameters, the identification and the data snapshot to obtain the target code structure model; the target code structure model includes a code structure chain corresponding to a plurality of the request parameters one by one; the code structure chain has a corresponding graph branch in the knowledge graph; based on the selected code structure chain with and the graph branch corresponding to the code structure chain obtains the script program, in response to the script program corresponding to the third-party class, obtains the data snapshot corresponding to the identifier corresponding to the script program to obtain the target data snapshot; debugs the target application based on the target data snapshot; through the implementation of the above embodiment, when the application has a running error, the debugger does not need to add a log to the application, but can directly debug it, which is convenient to improve the debugging efficiency of the application; and, during the debugging process, there is no need to obtain the application log and the operating parameters of the application in the log, so as to avoid the leakage of private data of the user organization, so that the implementation of the above embodiment is convenient to improve the debugging efficiency and data security when debugging the application.
[0022] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0024] Figure 1 This is an application environment diagram of an application debugging method in one embodiment of the present application;
[0025] Figure 2 A flowchart of an application debugging method provided in Embodiment 1 of the present application;
[0026] Figure 3 A schematic diagram of a primary code structure model provided in Example 1 of the present application;
[0027] Figure 4A schematic diagram of a knowledge graph corresponding to a target class provided in Example 1 of the present application;
[0028] Figure 5 A schematic diagram of a target code structure model provided in Example 1 of the present application;
[0029] Figure 6 A flowchart of an application debugging method provided in Embodiment 2 of the present application;
[0030] Figure 7 A flowchart of an application debugging method provided in Embodiment 3 of the present application;
[0031] Figure 8 A flowchart of an application debugging method provided in Embodiment 4 of the present application;
[0032] Fig. 9 A flowchart of an application debugging method provided in Embodiment 5 of the present application;
[0033] Fig.10 A flowchart of an application debugging method provided in Embodiment 6 of the present application;
[0034] Fig.11 A schematic diagram of the structure of an application debugging device provided in one embodiment of the present application;
[0035] Fig.12 A schematic diagram of the structure of a computer device provided in one embodiment of the present application;
[0036] Fig.13 An internal structure diagram of a computer-readable storage medium provided in one embodiment of the present application. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solution and advantages of the present disclosure more clear, the present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present disclosure and are not used to limit the present disclosure.
[0038] It should be noted that the terms "first", "second", etc. in the specification and claims of this article and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of this article described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0039] In this article, the term "and / or" is only a description of the association relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the related objects before and after are in an "or" relationship.
[0040] To solve the above problems, the present disclosure provides an application debugging method, which can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. Among them, the terminal 102 can be but is not limited to various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.
[0041] Embodiment 1
[0042] Figure 2 A flowchart of an application debugging method provided in Example 1 of the present application, refer to Figure 2 The method may be performed by a device for performing the method, and the device may be implemented by software and / or hardware. The method includes:
[0043] S110 . Generate a primary code structure model based on the acquired directory operation structure of the target application.
[0044] Among them, the target application is an application that runs incorrectly in the intranet of the user organization. Exemplarily, the application in this embodiment is a JAVA application provided by the application provider, which runs in the intranet of the user organization; the directory operation structure is a third-party library or framework that the user relies on for storing the application; Exemplarily, the directory operation structure in this embodiment is a library file directory (lib directory); The content in the directory operation structure can obtain the corresponding compiled file through compilation processing; Different program classes are set in the target application, such as Controller class, Action class, etc., each program class has different methods, each method has a corresponding code snippet in the application, and the code snippet has its code parameters; the code snippet can be developed and generated by the application provider, or obtained from open source code. If the code snippet is obtained from open source code, the open source code is a third-party code; Reference Figure 3 ,The primary code structure model includes the class names of different ,program classes in the target application, the file name of the compiled file, the ,names of different methods under each class, the code parameters and ,code snippets corresponding to each method, and whether each code snippet is third ,party.
[0045] Specifically, after determining that the target application is generated, the directory operation structure of the target application is obtained, and then the directory operation structure is processed to generate a primary code structure model.
[0046] S120. Determine the target class based on the primary code structure model, analyze the target class to obtain the corresponding knowledge graph; obtain the request parameters obtained based on the target class and the constructed program console to obtain an identifier and a data snapshot corresponding to the identifier.
[0047] The target application includes multiple program classes. When debugging the target application, only specific program classes need to be obtained. The specific program classes are recorded as target classes, such as the TestControl class. For example, refer to Figure 4Each target class contains different methods, such as method A and method B; each method may call other program classes, such as BService (B service) and CService (C service); BService (B service) or CService (C service) may contain different methods, such as b1 method and c1 method; b1 method or c1 method may call other program classes, such as EService (E service), and EService (E service) contains other methods, such as e1 method, ..., in this way, corresponding links are established through mind mapping to form a knowledge graph corresponding to each target class; the program console is used to process the target class and the request parameters issued by the operation and maintenance personnel, so as to obtain the identification corresponding to the request parameters and the data snapshot corresponding to the identification. Exemplarily, the program console is a web program console; the operation and maintenance personnel are the personnel who debug the target application, the identification corresponds to a code snippet under the target class, and the program console executes the code snippet to generate a return result, which is the data snapshot corresponding to the identification.
[0048] Specifically, the target class is determined from the primary code structure model, and the target class is analyzed to obtain the corresponding knowledge graph; further, a program console is built, and the target class and the request parameters issued by the operation and maintenance personnel are processed through the program console to generate an identification and a data snapshot corresponding to the identification.
[0049] S130. Based on the request parameters, the identifier and the data snapshot, the primary code structure model is updated to obtain a target code structure model; the target code structure model includes a code structure chain corresponding to a plurality of the request parameters one by one; the code structure chain has a corresponding graph branch in the knowledge graph.
[0050] Among them, reference Figure 5 The target code structure model is a primary code structure model after adding request parameters, identifiers and data snapshots; each line of the target code structure model is a corresponding code structure chain; the target class corresponding to the class name in each code structure chain corresponds to a knowledge graph, and the knowledge graph has multiple graph branches, and the multiple graph branches correspond one-to-one to the multiple code structure chains in the target code structure model.
[0051] Specifically, the obtained request parameters, identifiers, and data snapshots are added to corresponding positions in the primary code structure model to obtain a target code structure model.
[0052] S140. Obtain a script program based on the selected code structure chain and the graph branch corresponding to the code structure chain. In response to the script program corresponding to a third-party class, obtain a data snapshot corresponding to an identifier corresponding to the script program to obtain a target data snapshot.
[0053] Among them, the script program corresponds to the code snippet in the corresponding code structure chain, and each line of code in the code snippet corresponds to a script program; exemplarily, the script program is a groovy script; if the method corresponding to the code snippet belongs to the method under a third-party class, then the script program corresponding to the code snippet corresponds to the third-party class; the data snapshot of the identification pair corresponding to the script program is also the target data snapshot.
[0054] Specifically, the code snippets in the code structure chain are processed through the graph branches corresponding to the code structure chain to obtain script programs corresponding to each line of code in the code snippets; after each script program is generated, it is determined whether the script program corresponds to a third-party class, and if not, the return result of executing the script program is displayed; if so, the code snippet corresponding to the script program in the target code structure model is determined, and then the identifier corresponding to the code snippet is determined, and a data snapshot corresponding to the identifier in the target code structure model is obtained, thereby obtaining the target data snapshot.
[0055] S150: Debug the target application based on the target data snapshot.
[0056] Specifically, a target data snapshot is obtained and analyzed to determine the problem of the target application, and then the target application is debugged until the target application no longer runs with errors.
[0057] It should be noted that this embodiment generates a primary code structure model based on the directory operation structure of the acquired target application; determines the target class based on the primary code structure model, analyzes the target class to obtain the corresponding knowledge graph; obtains the request parameters based on the target class and the constructed program console to obtain an identifier and a data snapshot corresponding to the identifier; updates the primary code structure model based on the request parameters, the identifier and the data snapshot to obtain a target code structure model; the target code structure model includes a code structure chain corresponding to a plurality of the request parameters one by one; the code structure chain has a corresponding graph branch in the knowledge graph; based on the selected code structure chain and the code structure chain A script program is obtained from the corresponding graph branch, and in response to the script program corresponding to a third-party class, a data snapshot corresponding to an identifier corresponding to the script program is obtained to obtain a target data snapshot; the target application is debugged based on the target data snapshot; through the implementation of the above embodiment, when a debugger performs an application with a running error, there is no need to add a log to the application, but the debugger can directly debug the application, which helps improve the debugging efficiency of the application; and, during the debugging process, there is no need to obtain the application log and the operating parameters of the application in the log, so as to avoid the leakage of private data of the user organization, so that the implementation of the above embodiment helps improve the debugging efficiency and data security when debugging the application.
[0058] Embodiment 2
[0059] Figure 6 A flowchart of an application debugging method provided in Example 2 of this application, refer to Figure 6 This method optimizes the "generating a primary code structure model based on the directory operation structure of the acquired target application" in implementation 1. It should be noted that for the parts not described in detail in this embodiment, reference can be made to the descriptions of other embodiments; Figure 6 An application debugging method is shown, comprising:
[0060] S211. Obtain the directory operation structure of the target application.
[0061] The directory operation structure may be a library file directory (lib directory) of the target application.
[0062] Specifically, the directory operation structure of the target application is obtained. Exemplarily, the library file directory (lib directory) of the target application is obtained.
[0063] S212: Query all program compressed archive files in the directory operation structure to obtain an archive file set.
[0064] The program compressed archive file is all files ending with jar. in the directory operation structure, and the archive file set is the collection of all files ending with jar. in the directory operation structure.
[0065] Specifically, all files ending with jar. are queried from the directory operation structure, and all files ending with jar. are collected to obtain an archive file set.
[0066] S213, decompiling the archive file set to obtain program source code.
[0067] There is a preset decompiler for the archive file set, and the decompiler is used to pre-decompile the archive file set to obtain the program source code, which is also the source code of the target application program.
[0068] S214, scanning the program source code to obtain a primary code structure model.
[0069] The program source code has its file name; the program source code includes various program classes corresponding to the target application, such as the Controller class, the Action class, etc., each program class has multiple methods, each method has a corresponding code snippet in the application, and the code snippet has its code parameters;
[0070] Specifically, the file name of the program source code is first obtained, and the program source code is scanned to obtain the class name of each program class in the program source code, the method name of each method under each program class, the code snippet corresponding to each method, and the code parameter corresponding to each code snippet. Furthermore, it is also determined whether each code snippet is a third-party code snippet to obtain a corresponding judgment result; then, the file name, the class name of each program class, the method name, the code parameter, the code snippet, and the judgment result are combined into Figure 3 The primary code structure model shown.
[0071] S220. Determine the target class based on the primary code structure model, analyze the target class to obtain the corresponding knowledge graph; obtain the identifier and the data snapshot corresponding to the identifier based on the target class and the constructed program console processing the acquired request parameters.
[0072] S230. Based on the request parameters, the identifier and the data snapshot, the primary code structure model is updated to obtain a target code structure model; the target code structure model includes a code structure chain corresponding to a plurality of the request parameters one by one; the code structure chain has a corresponding graph branch in the knowledge graph.
[0073] S240. Obtain a script program based on the selected code structure chain and the graph branch corresponding to the code structure chain. In response to the script program corresponding to a third-party class, obtain a data snapshot corresponding to an identifier corresponding to the script program to obtain a target data snapshot.
[0074] S250: Debug the target application based on the target data snapshot.
[0075] Embodiment 3
[0076] Figure 7 A flowchart of an application debugging method provided in Example 3 of this application, refer to Figure 7 This method optimizes the "obtaining an identifier and a data snapshot corresponding to the identifier based on the target class and the constructed program console processing the obtained request parameters" in implementation 1. It should be noted that for the parts not described in detail in this embodiment, reference can be made to the descriptions of other embodiments; Figure 7 An application debugging method is shown, comprising:
[0077] S310: Generate a primary code structure model based on the acquired directory operation structure of the target application.
[0078] S321. Determine a target class based on the primary code structure model, and analyze the target class to obtain a corresponding knowledge graph.
[0079] S322, construct a program console, add the target class to the program console, and construct a proxy class of the target class.
[0080] The program console is used to debug the target class added therein; in this embodiment, the target class is the Controller class and the Action class; when the target application is started, the loader of the target application will create a corresponding proxy class for the target class.
[0081] Specifically, a program console for debugging the target class is first constructed, exemplarily, the program console is a web program console; then the determined target class is added to the program console; and a corresponding proxy class is also established for the target class when the target application is started.
[0082] S323: Obtain an identifier based on the request parameters obtained by the proxy class processing, and add the identifier to the mapping debugging context of the target application.
[0083] Among them, the identifier is established based on the request parameters sent by the operation and maintenance personnel, who can be personnel of the application provider or personnel of the user organization; the target application has a corresponding log, and the log has a corresponding mapping debugging context. After the identifier is generated, it can be added to the mapping debugging context corresponding to the target application.
[0084] Specifically, after the operation and maintenance personnel send request parameters to the program console, the proxy class further obtains the request parameters, establishes a corresponding identifier based on the request parameters, and then adds the identifier to the mapping debugging context corresponding to the target application.
[0085] S324: Processing the code snippet corresponding to the identifier based on the program console to obtain the data snapshot, and extracting the identifier from the mapping context.
[0086] Among them, reference Figure 4 , the identifier in the target code structure model has a corresponding code snippet, and the program console executes the code snippet to obtain the corresponding return result, that is, the data snapshot of the code snippet.
[0087] Specifically, after receiving the request parameters sent by the operation and maintenance personnel, the program console also executes the code snippet corresponding to the identifier corresponding to the request parameter until the part of the code snippet involving the third-party class is executed, and the execution of the code snippet is stopped. The corresponding return result is generated in the process of executing the code snippet, and the return result is recorded as a data snapshot of the code snippet; further, when the part of the code snippet involving the third-party class is executed, the corresponding identifier is obtained from the mapped debugging context through a preset interceptor.
[0088] S330. Based on the request parameters, the identifier and the data snapshot, the primary code structure model is updated to obtain a target code structure model; the target code structure model includes a code structure chain corresponding to a plurality of the request parameters one by one; the code structure chain has a corresponding graph branch in the knowledge graph.
[0089] S340, obtaining a script program based on the selected code structure chain and the graph branch corresponding to the code structure chain, and in response to the script program corresponding to a third-party class, obtaining a data snapshot corresponding to an identifier corresponding to the script program to obtain a target data snapshot.
[0090] S350: Debug the target application based on the target data snapshot.
[0091] Embodiment 4
[0092] Figure 8 A flowchart of an application debugging method provided in Example 4 of this application, refer to Figure 8 This method optimizes the "obtaining an identifier based on the request parameters obtained by the proxy class processing" in implementation three. It should be noted that for the parts not described in detail in this embodiment, reference can be made to the descriptions of other embodiments; Figure 8 An application debugging method is shown, comprising:
[0093] S410: Generate a primary code structure model based on the acquired directory operation structure of the target application.
[0094] S421. Determine a target class based on the primary code structure model, and analyze the target class to obtain a corresponding knowledge graph.
[0095] S422: Build a program console, add the target class to the program console, and build a proxy class of the target class.
[0096] S423A. Obtain request parameters based on the proxy class.
[0097] Among them, the proxy class is used to automatically hijack the request parameters when the operation and maintenance personnel send the request parameters.
[0098] Specifically, in response to the operation and maintenance personnel sending a request parameter to the program console, the proxy class automatically hijacks the request parameter.
[0099] S423B, determine the initiation time of the request parameter, and the target class and method corresponding to the request parameter.
[0100] The initiation time of the request parameter is the time when the operation and maintenance personnel send the request parameter to the program console, and the request parameter has a corresponding target class and method in the target code structure model.
[0101] Specifically, when obtaining the request parameters, the initiation time of the request parameters is also determined, the corresponding target class and method in the code structure model are marked, and the class name of the corresponding target class and the method name of the corresponding method are obtained.
[0102] S423C: Create an identifier corresponding to the request parameter based on the target class, the method, the request parameter and the initiation time.
[0103] Specifically, determine the class name of the target class corresponding to the request parameter, determine the method name of the method corresponding to the request parameter, and obtain the initiation time of the request parameter; further, combine the class name, method name, request parameter and initiation time in sequence to form an identifier corresponding to the request parameter, exemplarily, the identifier is an identifier in MD5 format.
[0104] S423D, and adding the identifier to the mapping debugging context of the target application.
[0105] S424: Processing the code snippet corresponding to the identifier based on the program console to obtain the data snapshot, and extracting the identifier from the mapping context.
[0106] S430. Based on the request parameters, the identifier and the data snapshot, the primary code structure model is updated to obtain a target code structure model; the target code structure model includes a code structure chain corresponding to a plurality of the request parameters one by one; the code structure chain has a corresponding graph branch in the knowledge graph.
[0107] S440, obtaining a script program based on the selected code structure chain and the graph branch corresponding to the code structure chain, and in response to the script program corresponding to a third-party class, obtaining a data snapshot corresponding to an identifier corresponding to the script program to obtain a target data snapshot.
[0108] S450: Debug the target application based on the target data snapshot.
[0109] Embodiment 5
[0110] Fig. 9 A flowchart of an application debugging method provided in Example 5 of this application is provided. Fig. 9 This method optimizes the "obtaining a script program based on the selected code structure chain and the graph branch corresponding to the code structure chain" in implementation one. It should be noted that for the parts not described in detail in this embodiment, reference can be made to the descriptions of other embodiments; Fig. 9 An application debugging method is shown, comprising:
[0111] S510: Generate a primary code structure model based on the acquired directory operation structure of the target application.
[0112] S520. Determine the target class based on the primary code structure model, analyze the target class to obtain the corresponding knowledge graph; obtain the request parameters obtained based on the target class and the constructed program console to obtain an identifier and a data snapshot corresponding to the identifier.
[0113] S530. Based on the request parameters, the identifier and the data snapshot, the primary code structure model is updated to obtain a target code structure model; the target code structure model includes a code structure chain corresponding to a plurality of the request parameters one by one; the code structure chain has a corresponding graph branch in the knowledge graph.
[0114] S541. Select a code structure chain from the target code structure model, and determine a graph branch of the code structure chain from the knowledge graph.
[0115] Among them, the target code structure model has identifiers corresponding to the request parameters issued by the operation and maintenance personnel, and all the data in the row where each identifier is located in the target code structure model is the code structure chain corresponding to the identifier; each code structure chain has a corresponding graph branch in the knowledge graph.
[0116] Specifically, in response to obtaining a request parameter, a code structure chain corresponding to an identifier corresponding to the request parameter is selected from a target code structure model, and a graph branch corresponding to the code structure chain in the knowledge graph is determined.
[0117] S542: Slice the code fragments in the code structure chain based on the graph branches to obtain a script program.
[0118] Among them, the code structure chain includes the code snippet corresponding to the identifier corresponding to the request parameter, and the graph branch includes the methods called under the corresponding target class and / or the called program class; the code snippet in the corresponding code structure chain can be sliced line by line through the graph branch, so as to generate a script program corresponding to each line of code. Exemplarily, the script program is a groovy script.
[0119] Specifically, the code structure chain and graph branch corresponding to the request parameters are obtained; then the code fragments in the code structure chain are sliced line by line according to the graph branch, so as to generate a script program corresponding to each line of code.
[0120] S543: In response to the script program corresponding to a third-party class, a data snapshot corresponding to an identifier corresponding to the script program is obtained to obtain a target data snapshot.
[0121] Part of the code in the code snippet may belong to the code under the third-party class. The script program is generated based on the corresponding code snippet, so a script program may also correspond to the code under the third-party class.
[0122] Specifically, after generating a script program, determine whether the script program corresponds to a third-party class. If so, obtain the code snippet corresponding to the script program, and then determine the identifier corresponding to the code snippet in the target code structure model, and further determine the data snapshot corresponding to the identifier in the target code structure model, and record the determined data snapshot as the target data snapshot.
[0123] S550: Debug the target application based on the target data snapshot.
[0124] Embodiment 6
[0125] Fig.10 A flowchart of an application debugging method provided in Example 6 of this application, refer to Fig.10 This method optimizes the "debugging the target application based on the target data snapshot" in implementation 1. It should be noted that for the parts not described in detail in this embodiment, reference can be made to the descriptions of other embodiments; Fig.10 An application debugging method is shown, comprising:
[0126] S610: Generate a primary code structure model based on the acquired directory operation structure of the target application.
[0127] S620. Determine the target class based on the primary code structure model, analyze the target class to obtain the corresponding knowledge graph; obtain the identifier and the data snapshot corresponding to the identifier based on the target class and the constructed program console processing the obtained request parameters.
[0128] S630. Based on the request parameters, the identifier and the data snapshot, the primary code structure model is updated to obtain a target code structure model; the target code structure model includes a code structure chain corresponding to a plurality of the request parameters one by one; the code structure chain has a corresponding graph branch in the knowledge graph.
[0129] S640, obtaining a script program based on the selected code structure chain and the graph branch corresponding to the code structure chain, and in response to the script program corresponding to a third-party class, obtaining a data snapshot corresponding to an identifier corresponding to the script program to obtain a target data snapshot.
[0130] S651: Obtain a code snippet in the code structure chain corresponding to the target data snapshot.
[0131] Specifically, a code snippet of the target data snapshot in the corresponding code structure chain is obtained.
[0132] S652: Determine whether the code snippet is correct based on the target data snapshot.
[0133] Specifically, the code snippet is analyzed according to the target data snapshot to determine whether the code snippet is correct.
[0134] S653: If not, modify the code snippet to debug the target application.
[0135] Specifically, if the code snippet is determined to be incorrect, the code snippet is modified until it is determined to be correct, thereby debugging the code snippet; if the code snippet is correct, the next request parameter is obtained, and the code snippet corresponding to the next request parameter is debugged.
[0136] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0137] Based on the same inventive concept, the embodiment of the present disclosure also provides an application debugging device for implementing the above-mentioned application debugging method. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above-mentioned method, so the specific limitations in one or more application debugging device embodiments provided below can refer to the limitations of the application debugging method above, and will not be repeated here.
[0138] In one embodiment, Fig.11 As shown, an application debugging device is provided, comprising:
[0139] A primary model generation module, used for generating a primary code structure model based on the obtained directory operation structure of the target application;
[0140] An identification snapshot acquisition module is used to determine the target class based on the primary code structure model, analyze the target class to obtain the corresponding knowledge graph; based on the target class and the constructed program console, process the obtained request parameters to obtain the identification and the data snapshot corresponding to the identification;
[0141] A target model generation module, configured to update the primary code structure model based on the request parameter, the identifier and the data snapshot to obtain a target code structure model; the target code structure model includes a code structure chain corresponding to a plurality of the request parameters one by one; the code structure chain has a corresponding graph branch in the knowledge graph;
[0142] A target snapshot acquisition module, configured to obtain a script program based on a selected code structure chain and a graph branch corresponding to the code structure chain, and in response to the script program corresponding to a third-party class, obtain a data snapshot corresponding to an identifier corresponding to the script program to obtain a target data snapshot;
[0143] The target program debugging module is used to debug the target application program based on the target data snapshot.
[0144] Each module in the above application debugging device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.
[0145] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.12 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, an application debugging method is implemented.
[0146] Those skilled in the art will understand that Fig.12 The structure shown in the figure is only a block diagram of a part of the structure related to the scheme of the present disclosure, and does not constitute a limitation on the computer device to which the scheme of the present disclosure is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0147] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0148] In one embodiment, a computer readable storage medium is provided. Fig.13 As shown, a computer program is stored thereon, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0149] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0150] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0151] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided by the present disclosure can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided by the present disclosure may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided by the present disclosure may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, etc., but are not limited to this.
[0152] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0153] The above-described embodiments only express several implementation methods of the present disclosure, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present invention. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present disclosure, and these all belong to the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be subject to the attached claims.
Claims
1. A method for debugging an application, characterized in that: include: Generate a primary code structure model based on the obtained directory operation structure of the target application; Determine a target class based on the primary code structure model, and analyze the target class to obtain a corresponding knowledge graph; Processing the acquired request parameters based on the target class and the constructed program console to obtain an identifier and a data snapshot corresponding to the identifier; Based on the request parameters, the identifier and the data snapshot, the primary code structure model is updated to obtain a target code structure model; the target code structure model includes code structure chains corresponding to a plurality of the request parameters one by one; The code structure chain has a corresponding graph branch in the knowledge graph; A script program is obtained based on the selected code structure chain and the graph branch corresponding to the code structure chain, and in response to the script program corresponding to a third-party class, a data snapshot corresponding to an identifier corresponding to the script program is obtained to obtain a target data snapshot; The target application is debugged based on the target data snapshot.
2. The method according to claim 1, characterized in that The step of generating a primary code structure model based on the acquired directory operation structure of the target application program includes: Get the directory running structure of the target application; Querying all program compressed archive files in the directory operation structure to obtain an archive file set; Decompiling the archive file set to obtain program source code; The program source code is scanned to obtain a primary code structure model.
3. The method according to claim 1, characterized in that The program console based on the target class and the constructed program console processes the obtained request parameters to obtain an identifier and a data snapshot corresponding to the identifier, including: Building a program console, adding the target class to the program console, and building a proxy class of the target class; Obtaining an identifier based on the request parameters obtained by the proxy class processing, and adding the identifier to the mapping debugging context of the target application; The data snapshot is obtained by processing the code snippet corresponding to the identifier based on the program console, and the identifier is extracted from the mapping context.
4. The method according to claim 3, characterized in that The request parameters obtained based on the proxy class processing are identified, including: Obtaining request parameters based on the proxy class; Determine the initiation time of the request parameter, and the target class and method corresponding to the request parameter; An identifier corresponding to the request parameter is created based on the target class, the method, the request parameter and the initiation time.
5. The method according to claim 1, characterized in that The step of obtaining a script program based on the selected code structure chain and the graph branch corresponding to the code structure chain includes: Selecting a code structure chain from the target code structure model, and determining a graph branch of the code structure chain from the knowledge graph; The code fragments in the code structure chain are sliced based on the graph branches to obtain a script program.
6. The method according to claim 1, characterized in that The debugging of the target application based on the target data snapshot includes: Obtaining a code snippet of the target data snapshot in the corresponding code structure chain; Determining whether the code snippet is correct based on the target data snapshot; If not, modify the code snippet to debug the target application.
7. An application debugging device, characterized in that: The device comprises: A primary model generation module, used for generating a primary code structure model based on the obtained directory operation structure of the target application; An identification snapshot acquisition module is used to determine the target class based on the primary code structure model, analyze the target class to obtain the corresponding knowledge graph; based on the target class and the constructed program console, process the obtained request parameters to obtain the identification and the data snapshot corresponding to the identification; A target model generation module, used for updating the primary code structure model based on the request parameter, the identifier and the data snapshot to obtain a target code structure model; the target code structure model includes a code structure chain corresponding to a plurality of the request parameters one by one; the code structure chain has a corresponding graph branch in the knowledge graph; A target snapshot acquisition module, configured to obtain a script program based on a selected code structure chain and a graph branch corresponding to the code structure chain, and in response to the script program corresponding to a third-party class, obtain a data snapshot corresponding to an identifier corresponding to the script program to obtain a target data snapshot; The target program debugging module is used to debug the target application program based on the target data snapshot.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
