Code debugging logic display method and device, equipment, medium and program product
By collecting and displaying the call stack link of object-oriented programs, and generating code display diagrams of code debugging logic, the problem of low code debugging efficiency in the existing technology is solved, and more efficient code problem investigation and debugging is achieved.
Patent Information
- Application Number
- CN202410959809.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-17
- Publication Date
- 2024-11-08
AI Technical Summary
In object-oriented programming, code debugging relies on the code hierarchy structure of the call stack and file-based code display form, resulting in low efficiency in problem detection.
By obtaining the request entry method of the target application, collecting and recording the call stack link during the code debugging process, obtaining the call method content chain based on the call stack link, and generating a code display diagram of the code debugging logic through graphic display technology, and visually displaying it Call relationships and method structures.
It improves the efficiency of troubleshooting code-related issues, enhances the readability and debugging convenience of code.
Smart Images

Figure CN118916276A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of big data technology, and in particular to a method, device, equipment, medium and program product for displaying code debugging logic. Background Art
[0002] Programming languages can usually be divided into different categories according to their programming paradigms and uses, such as procedural languages that emphasize organizing code through procedures (functions or subroutines), such as C; object-oriented languages that emphasize organizing code through objects and classes, such as Java; and other professional languages, such as HyperText Markup Language (HTML). In procedural programming, based on the principle of high cohesion and low coupling, the functions that are dependent and compact in the program are generally placed in the same program file. During program debugging, program calls and jumps will occur in a way that humans are accustomed to most of the time. However, in object-oriented programming, especially when using code that references over-encapsulated framework types, due to the excessively fine code hierarchy division, a class usually has 5-10 levels of inheritance hierarchy. This results in the code calls of the same class frequently jumping between different base classes and inherited classes, resulting in poor code readability, which in turn leads to difficulties in troubleshooting code-related issues.
[0003] In the related art, code-related problems are troubleshooted by tracing the code debugging process. However, current code debugging mainly relies on the code hierarchy structure of the call stack and the file-based code display format, which results in low troubleshooting efficiency in some scenarios. Summary of the invention
[0004] The present application provides a method, apparatus, device, medium and program product for displaying code debugging logic, which is used to solve the problem in the prior art that when code debugging relies on the code hierarchy structure of the call stack and the file-based code display format, the efficiency of troubleshooting code-related problems in tracing the code debugging process is low.
[0005] In a first aspect, the present application provides a method for displaying code debugging logic, comprising: obtaining a request entry method of a target application, the request entry method being a request entry method in which an error has been recorded during the code debugging process; according to the request entry method, in the process of executing the code debugging operation of the target application, based on the tracking component in the target application, collecting and recording a call stack link in the code debugging process, the call stack link including at least one call stack; according to the call stack link, obtaining a call method content chain; according to the call method content chain, obtaining a code display diagram corresponding to the code debugging logic.
[0006] In one possible design, a calling method content chain is obtained according to a call stack link, including: for each call stack included in the call stack link, determining the source code of the calling method corresponding to the call stack from the source code file of the target application; based on the code analysis technology component, preprocessing the source code to obtain a method structured object corresponding to the calling method, the preprocessing includes lexical parsing processing, syntax parsing processing and structuring processing; based on the call stack link, obtaining the calling method content chain according to the method structured object.
[0007] In a possible design, a code display diagram corresponding to the code debugging logic is obtained according to the calling method content chain, including: based on the graphic display technology, the calling method content chain is graphically displayed to obtain the code display diagram.
[0008] In one possible design, the tracking component in the target application is obtained in the following manner: before the target application is started, the bytecode enhancement component is loaded in the loading mode of the bytecode enhancement component corresponding to the target application; based on the bytecode enhancement component, the embedded bytecode is added to the target application, and the embedded bytecode is used as the tracking component.
[0009] In a possible design, the source code file of the target application is obtained in the following manner: based on the data acquisition component, the bytecode file of the target application is collected; based on the decompilation technology, the bytecode file is decompiled to obtain the source code file.
[0010] In one possible design, the code display diagram includes multiple calling method nodes, each calling method node includes a main structure and a relationship structure; the main structure includes a method declaration line and a method content paragraph, the method declaration line includes type information and method declaration information, the type information includes a runtime type and a method declaration type; the relationship structure includes a calling relationship between calling methods.
[0011] In a possible design, the code display diagram also includes type chain information, instance attribute information, and code segment information.
[0012] In a second aspect, the present application provides a display device for code debugging logic, including: an acquisition module, used to acquire a request entry method of a target application, the request entry method being a request entry method in which an error has been recorded during the code debugging process; a collection module, used to collect and record a call stack link in the code debugging process based on a tracking component in the target application during execution of a code debugging operation of the target application according to the request entry method, the call stack link including at least one call stack; a first processing module, used to obtain a call method content chain according to the call stack link; and a second processing module, used to obtain a code display diagram corresponding to the code debugging logic according to the call method content chain.
[0013] In one possible design, the first processing module is specifically used to: for each call stack included in the call stack link, determine the source code of the calling method corresponding to the call stack from the source code file of the target application; based on the code analysis technology component, preprocess the source code to obtain a method structured object corresponding to the calling method, and the preprocessing includes lexical parsing processing, syntax parsing processing and structuring processing; based on the call stack link, obtain the calling method content chain according to the method structured object.
[0014] In a possible design, the second processing module is specifically used to: based on the graphic display technology, perform call chain graphical display processing on the calling method content chain to obtain a code display diagram.
[0015] In one possible design, the tracking component in the target application is obtained in the following manner: before the target application is started, the bytecode enhancement component is loaded in the loading mode of the bytecode enhancement component corresponding to the target application; based on the bytecode enhancement component, the embedded bytecode is added to the target application, and the embedded bytecode is used as the tracking component.
[0016] In a possible design, the source code file of the target application is obtained in the following manner: based on the data acquisition component, the bytecode file of the target application is collected; based on the decompilation technology, the bytecode file is decompiled to obtain the source code file.
[0017] In one possible design, the code display diagram includes multiple calling method nodes, each calling method node includes a main structure and a relationship structure; the main structure includes a method declaration line and a method content paragraph, the method declaration line includes type information and method declaration information, the type information includes a runtime type and a method declaration type; the relationship structure includes a calling relationship between calling methods.
[0018] In a possible design, the code display diagram also includes type chain information, instance attribute information, and code segment information.
[0019] In a third aspect, an embodiment of the present application provides an electronic device, comprising: at least one processor and a memory; the memory stores computer execution instructions; at least one processor executes the computer execution instructions stored in the memory, so that at least one processor executes the code debugging logic display method as described in the first aspect and various possible designs of the first aspect.
[0020] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores computer execution instructions. When a processor executes the computer execution instructions, it implements the method for displaying code debugging logic as described in the first aspect and various possible designs of the first aspect.
[0021] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the method for displaying code debugging logic as described in the first aspect and various possible designs of the first aspect.
[0022] The code debugging logic display method, apparatus, device, medium and program product provided in the present application obtain the request entry method in which the error has been recorded during the code debugging process of the target application, and according to the request entry method, in the process of executing the code debugging operation of the target application, based on the tracking component in the target application, collect and record the call stack link of at least one call stack in the code debugging process, and obtain the call method content chain according to the call stack link, and further obtain the code display diagram corresponding to the code debugging logic according to the call method content chain, based on the code display diagram, intuitively perform code-related problem troubleshooting, and improve the problem troubleshooting efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0024] Figure 1 The process of displaying the code debugging logic provided in the embodiment of the present application Figure 1 ;
[0025] Figure 2 Schematic diagram of the structure of the code display diagram provided in the embodiment of the present application Figure 1 ;
[0026] Figure 3 Schematic diagram of the structure of the code display diagram provided in the embodiment of the present application Figure 2 ;
[0027] Figure 4 The process of displaying the code debugging logic provided in the embodiment of the present application Figure 2 ;
[0028] Figure 5 A schematic diagram of the structure of a display device for code debugging logic provided in one embodiment of the present application;
[0029] Figure 6 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application.
[0030] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0031] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0032] In the technical solution of this application, the collection, storage, use, processing, transmission, provision and disclosure of information such as financial data or user data involved shall comply with the provisions of relevant laws and regulations and shall not violate public order and good morals.
[0033] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0034] During the rise of object-oriented languages, inheritance, encapsulation, polymorphism and other features were widely promoted, and these methods solved the code management and reuse problems in the programming field to a certain extent. However, due to the fine-grained splitting of content, it also brought certain negative effects, such as reduced code readability.
[0035] In the related art, code debugging tools such as Integrated Development Environment (IDE) organize codes in files. Therefore, in the current mainstream program debugging environment, there is currently a lack of code organization and display format for problem tracking and debugging for object-oriented programming languages such as Java.
[0036] In response to the technical problems existing in the relevant technologies, the present application proposes the following technical ideas: first, a tracking component is defined for code tracking and data collection in the code debugging stage, and during the code debugging process, a full-link code call chain structure, namely a call stack link, is formed based on the data collected by the tracking component, and further based on the call chain structure, a code display diagram corresponding to the code debugging logic is formed, and code-related problems are troubleshooted based on the code display diagram to improve the efficiency of problem troubleshooting.
[0037] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0038] The following first describes the application scenarios of the method for displaying the code debugging logic provided in the embodiment of the present application.
[0039] The method for displaying code debugging logic provided in the embodiment of the present application is applicable to the code debugging process in the project development and testing phase. Specifically, it is applicable to the scenario where an error occurs during the debugging process, and the user generally records the request entry method and return value where the error occurs, but when the call stack of the request entry method is too deep, or the user does not understand the code itself, it is difficult to effectively use the naked eye and the existing IDE to perform logic tracking to accurately locate the location of the problem.
[0040] Among them, code debugging in the project development and testing phases can be local debugging or online debugging in the test environment.
[0041] Specifically, the method for displaying code debugging logic provided in the embodiment of the present application is applicable to any object-oriented language or similar language that can perform link tracking based on bytecode or compiled code enhancement.
[0042] Based on the above application scenarios, the following Figure 1 The method for displaying the code debugging logic provided in the embodiment of the present application is described in detail.
[0043] Figure 1 The process of displaying the code debugging logic provided in the embodiment of the present application Figure 1 .like Figure 1 As shown, the specific implementation method of the display method of the code debugging logic includes the following steps:
[0044] S101, obtaining a request entry method of a target application, where the request entry method is a request entry method in which an error has been recorded during code debugging.
[0045] Exemplarily, the target application may be a Java program. In the method for displaying code debugging logic provided in the embodiment of the present application, the type of the target application is not limited.
[0046] Exemplarily, the request entry method may be obtained from a log file of the target application.
[0047] Exemplarily, the request entry method may be a program entry for executing a code debugging operation of a target application.
[0048] S102, according to the request entry method, during the code debugging operation of the target application, based on the tracking component in the target application, collect and record the call stack link in the code debugging process, and the call stack link includes at least one call stack.
[0049] In this step, the code debugging operation of the target application is executed starting from the request entry method, and during the execution of the code debugging operation of the target application, based on the tracking component in the target application, the call stack link in the code debugging process is collected and recorded.
[0050] Optionally, the tracking component can also be used to collect and record input and output parameter values and return values during code debugging.
[0051] Exemplarily, the input and output parameter values include output parameter values and input parameter values, wherein the input parameter value may be a local variable.
[0052] Exemplarily, the return value may be "true" or "false", etc.
[0053] Exemplarily, by recording the call stack link and each call stack contained in the call stack link, the code debugging logic in the code debugging process is recorded, that is, the execution path of the code in the code debugging process and the calling relationship between the calling methods are recorded.
[0054] Exemplarily, the call stack included in the call stack link records the call method declaration of the corresponding call method, wherein the call method can be a call to a class or a call to an object.
[0055] In a possible implementation, the call stack link collected and recorded by the tracing component is output to a predefined output device in the format of a debugging file or a standard communication message format.
[0056] Exemplarily, the format of the debugging file or the standard communication message format may be one or more of the JSON format, the XML format, or other feasible basic formats.
[0057] S103, obtaining a calling method content chain according to the call stack link.
[0058] It should be noted that in the method for displaying code debugging logic provided in the embodiment of the present application, during the execution of code debugging, the file corresponding to the target application is a bytecode file. Therefore, the call stack link collected and recorded by the tracking component during the tracking code debugging process only includes the calling method declaration, and lacks the source code for each calling method.
[0059] In one possible implementation, based on the calling order and calling location of the calling methods during the code debugging process recorded in the call stack link, the source code location corresponding to each calling method is determined, and the corresponding source file is opened from the source code location based on an IDE or text editor, and the source code, parameters, and local variables corresponding to each calling method are recorded to form the source code corresponding to each calling method, thereby obtaining the calling method content chain.
[0060] S104, obtaining a code display diagram corresponding to the code debugging logic according to the calling method content chain.
[0061] In a possible implementation, a code display diagram corresponding to the code debugging logic is obtained by graphically displaying the calling method content chain.
[0062] Exemplarily, the code display diagram may be a call chain tree structure based on a single entry.
[0063] Combine the following Figure 2 The code display diagram provided in the embodiment of the present application is described in detail.
[0064] Figure 2 Schematic diagram of the structure of the code display diagram provided in the embodiment of the present application Figure 1 .like Figure 2 As shown, the code display diagram includes a call method 1 node, a call method 2 node, a call method 3 node, a call method 4 node, and a call method 5 node, and each call method includes the source code corresponding to the call method, such as Figure 2 Data row 1, data row 2, data row 3, data row 4, etc. are shown in .
[0065] For example, Figure 2 The data row shown in is the method content paragraph, and the data row can be folded and displayed, that is, when only the calling method needs to be tracked, the corresponding method content under the calling method can be folded and no longer displayed.
[0066] For example, the calling line number of the code corresponding to the calling method is marked in the calling relationship in the code display diagram provided in the embodiment of the present application, such as Figure 2As shown in , calling method 1 calls calling method 2 when it is in line n1, calling method 1 calls calling method 3 when it is in line n2, calling method 1 calls calling method 4 when it is in line n3, and calling method 4 calls calling method 5.
[0067] The calling relationship between calling methods, i.e., the external calling relationship, can be displayed in an expanded or collapsed manner according to actual application needs. Figure 2 The calling relationship between the calling methods shown in is an expanded display, which can be displayed by clicking Figure 2 The expansion control 21 shown in FIG. is implemented; accordingly, when it is necessary to Figure 2 When the calling relationship between the calling methods shown in the figure is collapsed, you can click Figure 2 The folding control 22 shown in FIG. 2 is used for folding display.
[0068] Exemplarily, the display form of the call relationship can be a broken line arrow form, or can be any valid readable form, which is not limited in the display method of the code debugging logic provided in the embodiment of the present application.
[0069] Above Figure 2 This is only an example of the code display diagram provided in the embodiment of the present application. The method for displaying the code debugging logic provided in the embodiment of the present application does not limit the main structure and relationship structure in the code display diagram, as long as the code debugging logic tracked during the code debugging process of executing the target application can be displayed.
[0070] based on Figure 2 The code display diagram shown, optionally, includes multiple calling method nodes, each calling method node includes a main structure and a relationship structure, wherein the main structure includes a method declaration line and a method content paragraph, the method declaration line includes type information and method declaration information, the type information includes a runtime type and a method declaration type; the relationship structure includes a calling relationship between calling methods.
[0071] For example, the method content paragraph can be a data line in the calling method, as described above Figure 2 shown.
[0072] Exemplarily, the calling relationship between calling methods can be an external calling relationship of a calling relationship. The calling relationship is marked with the calling line number of the code corresponding to the calling method, as mentioned above. Figure 2 shown.
[0073] It should be noted that in the code display diagram provided by the embodiment of the present application, when there are multiple external calls based on loops in the code, the overlapping calls in the multiple loops should be clustered and merged. For differentiated calls, two call chains should be displayed, and if necessary, the call loop sequence number and feature input parameters of each link can be displayed.
[0074] Optionally, when there are multiple levels of call chains, any sub-paragraphs in the entire call chain can be folded and displayed as needed, such as folding the 3rd to 6th level call chains in a 7-level call chain paragraph, and displaying the 1st level call chain, the 2nd level call chain and the 7th level call chain for code focusing.
[0075] For example, the code display diagram provided in the embodiment of the present application may further include the following content for the method declaration line and the method content paragraph:
[0076] 1) In the expanded method content paragraph, you can highlight the external call lines;
[0077] 2) In the method content section, some codes can be displayed in an expanded or folded manner;
[0078] 3) Code tracking coverage technology can be used to highlight the actual code logic covered by this execution in the method content paragraph. For example, the code tracking coverage technology can be the code highlighting technology in tools such as Jacoco;
[0079] 4) In each method declaration, a jump connection can be added by adding a click event control for jumping to another code display diagram provided by the present invention.
[0080] Combine the following Figure 3 Another code display diagram provided in an embodiment of the present application is described in detail.
[0081] Figure 3 Schematic diagram of the structure of the code display diagram provided in the embodiment of the present application Figure 2 .like Figure 3 As shown, the code display diagram includes a base class, an interface, a method declaration area, and a property declaration area.
[0082] For example, Figure 3 The base class 1 and the base class 2 shown in FIG. 1 are types collected during the code debugging process of executing the target application.
[0083] Exemplarily, based on the type integration rule, a type relationship chain is formed by searching all related base classes and interfaces.
[0084] For example, Figure 3 The type relationship chain formed by the base classes and interfaces shown in and the runtime types are collectively referred to as type chain information.
[0085] For example, Figure 3 The method declaration area shown in includes all calling methods in the above call stack link. The calling methods use the runtime type as the aggregation point and aggregate the calling method codes of all inherited types.
[0086] For example, Figure 3 The attribute declaration area shown in includes instance attributes of all types read according to the type chain. When displaying the code display diagram, the range can be distinguished and marked according to the actual type.
[0087] It should be noted that Figure 3 When displaying the code display diagram shown in , each node can be displayed in a collapsed state or an expanded state based on actual needs.
[0088] Exemplarily, the type inheritance chain only displays runtime types in the collapsed state, and can perform collapse operations on any level and node on the chain as needed in the expanded state. When non-runtime types are in the collapsed state, only collapse marks are displayed.
[0089] Exemplarily, each calling method in the method declaration area may include a corresponding method code, and within the method code segment, the code content may be partially contracted and displayed.
[0090] The display of method codes is sorted according to a certain call chain sequence, and between the calling method segments, a specific contact method is used to display the call chain relationship of this execution.
[0091] based on Figure 3 As shown in the code display diagram, optionally, the code display diagram provided in the embodiment of the present application also includes type chain information, instance attribute information and code segment information.
[0092] Exemplarily, the type chain information includes runtime types and type relationship chains, wherein the type relationship chain can also be described as an integration relationship chain.
[0093] For example, the instance attribute information is as above Figure 3 The content displayed in the property declaration area is shown in .
[0094] For example, the code segment information is as above Figure 3 The contents of the method declaration area shown in .
[0095] In an embodiment of the present application, a request entry method in which an error has been recorded during the code debugging process of a target application is obtained. According to the request entry method, during the execution of the code debugging operation of the target application, based on the tracking component in the target application, a call stack link of at least one call stack in the code debugging process is collected and recorded, and according to the call stack link, a call method content chain is obtained, and further according to the call method content chain, a code display diagram corresponding to the code debugging logic is obtained. Based on the code display diagram, code-related problems can be intuitively troubleshooted, thereby improving the efficiency of problem troubleshooting.
[0096] Optionally, a possible implementation of obtaining a code display diagram corresponding to the code debugging logic according to the calling method content chain in step S104 is: based on a graphic display technology, performing a calling chain graphical display processing on the calling method content chain to obtain a code display diagram.
[0097] Exemplarily, the graphics display technology may be a client-side graphics technology or a web page-side graphics component technology, such as Hyper Text Markup Language (HTML) and Scalable Vector Graphics (SVG).
[0098] For example, the type and content of the code display diagram are the same as above Figure 2 or Figure 3 The above is similar to what is shown in the figure and will not be repeated here.
[0099] Combine the following Figure 4 The specific implementation method of obtaining the calling method content chain according to the calling stack link in the above step S103 is described in detail.
[0100] Figure 4 The process of displaying the code debugging logic provided in the embodiment of the present application Figure 2 .like Figure 4 As shown, according to the call stack link, the specific implementation method of obtaining the call method content chain includes the following steps:
[0101] S401 , for each call stack included in the call stack link, determine the source code of the calling method corresponding to the call stack from the source code file of the target application.
[0102] In this step, the source code in the target application can be obtained by decompiling the bytecode file of the target application, or by specifying the root directory location of the source code in the target application in the system and then accessing the source code in the target application through a file manager. The method for displaying the code debugging logic provided in the embodiment of the present application does not limit the method for obtaining the source code of the target application.
[0103] In one possible implementation, in the source code file of the target application, according to the calling method declaration corresponding to each call stack contained in the call stack link, the relevant type (class) and calling method position corresponding to each call stack are located based on the search technology, and then the source code of the calling method corresponding to the call stack is obtained.
[0104] S402, based on the code analysis technology component, preprocessing the source code to obtain a method structured object corresponding to the calling method, the preprocessing includes lexical analysis processing, syntax analysis processing and structural processing.
[0105] Exemplarily, the code analysis technology component may be an independent component or a component deployed in a target application.
[0106] Exemplarily, the code analysis technology component may include a static code analysis tool and a dynamic code analysis tool. The static code analysis tool is used to analyze the source code or bytecode of the target application without executing the code, and the dynamic code analysis tool is used to find errors and other problems when the code is running.
[0107] Exemplarily, the lexical parsing process is used to convert the source code into a series of tokens, which are used to represent keywords, identifiers, operators, etc. in the source code.
[0108] Exemplarily, the syntax parsing process is used to convert the above series of tokens into an Abstract Syntax Tree (AST), which is used to reflect the syntax structure of the source code, with nodes representing syntax elements and edges representing the relationship between elements.
[0109] Exemplarily, structured processing is used to extract structured information of a target calling method, such as a calling method name, parameter list, return type, and method body, by traversing the AST, and organize the extracted structured information into a structured object.
[0110] In this step, based on the code analysis technology component, based on the lexical parsing processing, the source code is converted into a series of tokens, based on the syntax parsing processing, the series of tokens are converted into AST, based on the structured processing, the AST is traversed, and the structured information of the target calling method is extracted, and the extracted structured information is further organized into a method structured object corresponding to the calling method.
[0111] S403, based on the call stack link, according to the method structured object, obtain the call method content chain.
[0112] In this step, a calling method content chain is formed by connecting the method structured objects according to the calling sequence of the calling methods recorded in the call stack link.
[0113] In an embodiment of the present application, for each call stack included in the call stack link, the source code of the calling method corresponding to the call stack is determined from the source code file of the target application, and based on the code analysis technology component, the source code is lexically parsed, syntactically parsed and structured to obtain a method structured object corresponding to the calling method, and further based on the call stack link, according to the method structured object, a calling method content chain corresponding to the code debugging logic during the code debugging process is obtained, and based on the code display diagram obtained based on the calling method content chain, the code debugging logic during code debugging is displayed, thereby improving the efficiency of troubleshooting in the code debugging process.
[0114] Optionally, in the method for displaying code debugging logic provided in the embodiment of the present application, the tracking component of the target application is obtained in the following manner:
[0115] Before the target application is started, the bytecode enhancement component is loaded in the loading mode of the bytecode enhancement component corresponding to the target application; based on the bytecode enhancement component, the embedded bytecode is added to the target application, and the embedded bytecode is used as a tracking component.
[0116] Exemplarily, the loading mode of the bytecode enhancement component corresponding to the target application may be an agent mode, an attach mode, or an embedded mode.
[0117] Exemplarily, the bytecode enhancement component is created based on the bytecode enhancement technology.
[0118] It can be understood that based on the bytecode enhancement component, the embedded bytecode is added to the target application. When the code is debugged, the embedded bytecode will also be executed in addition. That is, when the embedded bytecode is executed, the call stack link and the input and output parameters and return values in the code debugging process are collected and recorded.
[0119] In the code debugging logic display method provided in the embodiment of the present application, the code debugging logic is collected and recorded by tracking the call stack, interface transfer parameters such as input and output parameters and return values in the code debugging process through the tracking component.
[0120] Optionally, in the method for displaying code debugging logic provided in the embodiment of the present application, the source code file of the target application is obtained in the following manner:
[0121] Based on the data collection component, the bytecode files of the target application are collected; based on the decompilation technology, the bytecode files are decompiled to obtain the source code files.
[0122] Exemplarily, the data collection component is used to collect static bytecodes, that is, to collect the bytecode files of the target application when the code debugging process of the target application is not executed.
[0123] It can be understood that the above-mentioned tracking component is used to collect dynamic bytecodes, that is, when the code debugging process of the target application is executed, the bytecodes of the application involved in the code debugging process are collected.
[0124] It should be noted that the static bytecode collection based on the data collection component is a parallel collection outside the execution code debugging process.
[0125] Exemplarily, decompilation technology is a technology that converts a bytecode file (such as a ".class" file) back into a source code file (such as a ".java" file).
[0126] It should be noted that the tracking component, bytecode enhancement component, data acquisition component and code analysis technology component involved in the embodiments of the present application are all independent components. In the method for displaying the code debugging logic provided in the embodiments of the present application, they can be deployed independently or integratedly, and the embodiments of the present application do not limit this.
[0127] To summarize, in the method for displaying code debugging logic provided in the embodiment of the present application, firstly, based on bytecode enhancement technology, the call stack, interface transfer parameters and return values in the code debugging process are tracked, and further based on decompilation technology, code analysis technology, and graphics and text display technology, an aggregate display of code debugging logic for tracking the code debugging process is realized.
[0128] It is understandable to those skilled in the art that the association and display of codes during code debugging have a crucial impact on the efficiency of user's troubleshooting. Compared with the related art, due to the user's understanding of technical means, knowledge and framework, most users do not understand the framework-level call chain and the occurrence of problems. Therefore, when the logical errors of the system cause framework-level errors, it often causes the troubleshooting to get into trouble. In the display method of the code debugging logic provided in the embodiment of the present application, based on the full-link tracking technology and code chain technology, the code execution logic in the code debugging process is effectively displayed in front of the user in the form of a plane display diagram, which solves the problem of user distraction caused by the frequent jumps of the existing framework and object-oriented.
[0129] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0130] Figure 5 This is a schematic diagram of the structure of a display device for code debugging logic provided in one embodiment of the present application. Figure 5 As shown, the display device 50 of the code debugging logic includes: an acquisition module 510, a collection module 520, a first processing module 530 and a second processing module 540;
[0131] The acquisition module 510 is used to acquire the request entry method of the target application, where the request entry method is the request entry method in which an error has been recorded during the code debugging process;
[0132] The collection module 520 is used to collect and record a call stack link in the code debugging process based on the tracking component in the target application program according to the request entry method during the code debugging operation of the target application program, wherein the call stack link includes at least one call stack;
[0133] The first processing module 530 is used to obtain a calling method content chain according to the calling stack link;
[0134] The second processing module 540 is used to obtain a code display diagram corresponding to the code debugging logic according to the calling method content chain.
[0135] In some embodiments, the first processing module 530 is specifically used to: for each call stack included in the call stack link, determine the source code of the calling method corresponding to the call stack from the source code file of the target application; based on the code analysis technology component, preprocess the source code to obtain a method structured object corresponding to the calling method, and the preprocessing includes lexical parsing processing, syntax parsing processing and structuring processing; based on the call stack link, obtain the calling method content chain according to the method structured object.
[0136] In some embodiments, the second processing module 540 is specifically used to: based on the graphic display technology, perform call chain graphical display processing on the calling method content chain to obtain a code display diagram.
[0137] In some embodiments, the tracking component in the target application is obtained in the following manner: before the target application is started, the bytecode enhancement component is loaded in the loading mode of the bytecode enhancement component corresponding to the target application; based on the bytecode enhancement component, the embedded bytecode is added to the target application, and the embedded bytecode is used as the tracking component.
[0138] In some embodiments, the source code file of the target application is obtained in the following manner: based on a data acquisition component, the bytecode file of the target application is acquired; based on a decompilation technology, the bytecode file is decompiled to obtain the source code file.
[0139] In some embodiments, the code display diagram includes multiple calling method nodes, each calling method node includes a main structure and a relationship structure; the main structure includes a method declaration line and a method content paragraph, the method declaration line includes type information and method declaration information, the type information includes a runtime type and a method declaration type; the relationship structure includes a calling relationship between calling methods.
[0140] In some embodiments, the code display diagram also includes type chain information, instance attribute information, and code segment information.
[0141] The display device for code debugging logic provided in the embodiment of the present application can be used to execute the technical solution of the display method for code debugging logic in the above embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0142] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software calling through processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software calling through processing elements, and some modules can be implemented in the form of hardware. For example, the acquisition module 520 can be a separately established processing element, or it can be integrated in a chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a processing element of the above device. The function of the above acquisition module 520. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0143] Figure 6 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Figure 6 As shown, the electronic device 60 may include: at least one processor 601 and a memory 602 .
[0144] Optionally, the electronic device 60 further includes a communication interface 603 and a system bus 604 .
[0145] The memory 602 and the communication interface 603 are connected to the processor 601 via the system bus 604 and communicate with each other. The memory 602 is used to store instructions, and the communication interface 603 is used to communicate with other devices.
[0146] In a specific implementation process, at least one processor 601 executes the computer execution instructions stored in the memory 602, so that at least one processor 601 executes the above method.
[0147] The specific implementation process of the processor 601 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0148] In the above-mentioned embodiment, it should be understood that the processor 601 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. The general-purpose processor can be a microprocessor or the processor can be any conventional processor, etc. The steps of the method disclosed in the invention can be directly embodied as being executed by a hardware processor, or can be executed by a combination of hardware and software modules in the processor.
[0149] The memory 602 may include a high-speed memory (Random Access Memory, RAM for short), and may also include a non-volatile memory (NVM for short), such as at least one disk memory.
[0150] The system bus 604 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The system bus 604 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the system bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0151] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the technical solution of the method for displaying code debugging logic in the above embodiment.
[0152] An embodiment of the present application also provides a chip for executing instructions, which is used to execute the technical solution of the method for displaying code debugging logic in the above embodiment.
[0153] An embodiment of the present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the technical solution of the method for displaying the code debugging logic in the above embodiment is implemented.
[0154] The above-mentioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0155] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0156] The division of units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0157] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0158] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0159] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program codes.
[0160] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0161] Finally, it should be noted that those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention, which follow the general principles of the present invention and include common knowledge or customary technical means in the art not disclosed by the present invention, are not limited to the precise structure described above and shown in the drawings, and may be modified and changed in various ways without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A method for displaying code debugging logic, It is characterized in that include: Obtaining a request entry method of a target application, wherein the request entry method is a request entry method in which an error has been recorded during code debugging; According to the request entry method, during the code debugging operation of the target application, based on the tracking component in the target application, a call stack link in the code debugging process is collected and recorded, wherein the call stack link includes at least one call stack; According to the call stack link, a call method content chain is obtained; According to the calling method content chain, a code display diagram corresponding to the code debugging logic is obtained.
2. The display method according to claim 1, It is characterized in that The step of obtaining a calling method content chain according to the calling stack link includes: For each call stack included in the call stack link, determining the source code of the calling method corresponding to the call stack from the source code file of the target application; Based on the code analysis technology component, the source code is preprocessed to obtain a method structured object corresponding to the calling method, wherein the preprocessing includes lexical analysis processing, grammatical analysis processing and structural processing; Based on the call stack link and according to the method structured object, a call method content chain is obtained.
3. The display method according to claim 1, It is characterized in that The step of obtaining a code display diagram corresponding to the code debugging logic according to the calling method content chain includes: Based on the graphic display technology, the calling method content chain is processed by graphical display of the calling chain to obtain the code display diagram.
4. The display method according to any one of claims 1 to 3, It is characterized in that The tracking component in the target application is obtained in the following way: Before the target application is started, in a loading mode of the bytecode enhancement component corresponding to the target application, loading the bytecode enhancement component; Based on the bytecode enhancement component, embedded bytecode is added to the target application, and the embedded bytecode is used as the tracking component.
5. The display method according to any one of claims 1 to 3, It is characterized in that The source code file of the target application is obtained in the following way: Based on the data collection component, collect the bytecode file of the target application; Based on the decompilation technology, the bytecode file is decompiled to obtain the source code file.
6. The display method according to any one of claims 1 to 3, It is characterized in that The code display diagram includes a plurality of call method nodes, each of which includes a main structure and a relationship structure; The main structure includes a method declaration line and a method content paragraph, the method declaration line includes type information and method declaration information, and the type information includes a runtime type and a method declaration type; The relationship structure includes the calling relationship between calling methods.
7. The display method according to any one of claims 1 to 3, It is characterized in that The code display diagram also includes type chain information, instance attribute information and code segment information.
8. A display device for code debugging logic, It is characterized in that include: An acquisition module is used for a request entry method of a target application, wherein the request entry method is a request entry method in which an error has been recorded during code debugging; A collection module, configured to collect and record a call stack link in the code debugging process based on a tracking component in the target application program according to the request entry method, during the execution of the code debugging operation of the target application program, wherein the call stack link includes at least one call stack; A first processing module, configured to obtain a calling method content chain according to the calling stack chain; The second processing module is used to obtain a code display diagram corresponding to the code debugging logic according to the calling method content chain.
9. An electronic device, It is characterized in that include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.
11. A computer program product, It is characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 7 when being executed by a processor.
