Abnormal Code Handling Method, Device, Computer Equipment and Storage Medium

By analyzing the source code execution results of the software program and filtering and displaying abnormal codes, the problem of difficult to identify and repair code failures in complex software programs is solved, and development efficiency is improved.

CN115185833BActive Publication Date: 2025-05-27PING AN BANK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210731867.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-25
Publication Date
2025-05-27
Estimated Expiration
2042-06-25

AI Technical Summary

Technical Problem

In complex software programs, it is difficult to accurately identify and prioritize the repair of code failures to be repaired from source code, resulting in inefficient development.

Method used

By obtaining the source code, executing and analyzing the code execution results, determining the function execution results and the number of times called for each function code segment, and filtering out the function code segment with the function execution results empty or the number of times called zero as exception code. Calculate the code exception parameters based on the code parameters of the exception code, and receive the target parameter type to display the exception code.

Benefits of technology

It realizes accurate identification and display of exception codes in software programs, reduces the difficulty of users to find exception codes, improves the processing efficiency of exception codes and the development efficiency of software program source code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115185833B_ABST
    Figure CN115185833B_ABST
Patent Text Reader

Abstract

The present application provides an abnormal code processing method, apparatus, computer device, and storage medium. By obtaining source code and executing the source code to obtain a code execution result; determining abnormal code in the source code based on the code execution result, and obtaining code abnormal parameters corresponding to the abnormal code; receiving a target parameter type, and displaying the abnormal code based on the code abnormal parameters corresponding to the target parameter type, it is possible to accurately identify the abnormal code in the source code, and quickly screen and display the abnormal code corresponding to the target parameter type through the code abnormal parameters corresponding to the abnormal code, reducing the difficulty for users to find abnormal code, and improving the processing efficiency of abnormal code and the development efficiency of the source code of software programs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular, to an abnormal code processing method, apparatus, computer device, and storage medium. Background Art

[0002] With the development of mobile terminals, the types of software programs running on mobile terminals are increasing. In addition to writing the source code of software programs, the source code also needs to be inspected and tested to eliminate faults during the operation of the software programs. However, as the business functions provided by software programs are also increasing, their corresponding code architectures are becoming more and more complex. When eliminating faults during the operation of software programs, it is difficult to find the code faults to be repaired first from the source code of the software programs, and the development efficiency of the source code of the software programs is low. Summary of the Invention

[0003] Based on this, it is necessary to provide an abnormal code processing method, apparatus, computer device, and storage medium for the above technical problems.

[0004] In a first aspect, this application provides an abnormal code processing method, which includes:

[0005] Obtain the source code and execute the source code to obtain a code execution result;

[0006] Determine the function execution results of each function code segment in the source code from the execution result;

[0007] According to the parameter call relationship in the source code, determine the number of times each function execution result of the function code segment is called;

[0008] Based on the function execution results of each function code segment and the number of times the function execution result is called, screen out the function code segments whose function execution results are empty or the number of calls is zero as abnormal codes;

[0009] Calculate the code abnormal parameter corresponding to the abnormal code according to the code parameter of the abnormal code;

[0010] Receive the target parameter type, and display the abnormal code based on the code abnormal parameter corresponding to the target parameter type.

[0011] In some embodiments of this application, the obtaining the source code and executing the source code to obtain a code execution result includes:

[0012] Divide the source code into multiple function code segments;

[0013] Execute each function code segment separately to obtain the function execution results of each function code segment.

[0014] In some embodiments of the present application, the code anomaly parameters include at least one of, but are not limited to, the code anomaly type, the code repair time, and the code function level.

[0015] In some embodiments of the present application, calculating the code anomaly parameters corresponding to the abnormal code according to the code parameters of the abnormal code includes:

[0016] Determining the code complexity of the abnormal code based on the number of code lines of the abnormal code;

[0017] Determining the execution complexity of the abnormal code based on the number of variables of the input variables in the abnormal code;

[0018] Determining the execution complexity of the abnormal code based on the number of call objects of the output variables of the abnormal code;

[0019] Calculating the code repair time of the abnormal code according to the code complexity, the execution complexity, and the result output complexity.

[0020] In some embodiments of the present application, displaying the abnormal code based on the code anomaly parameters corresponding to the target parameter type includes:

[0021] Determining the target value of the abnormal code on the target parameter type according to the code anomaly parameters of the abnormal code;

[0022] Sorting the abnormal code according to the target value of the abnormal code to obtain a sorting result;

[0023] Displaying the abnormal code according to the sorting result.

[0024] In some embodiments of the present application, displaying the abnormal code according to the sorting result includes:

[0025] Obtaining the position information of the abnormal code in the source code and constructing the abnormal code name of the abnormal code;

[0026] Generating an abnormal location identifier corresponding to the abnormal code according to the abnormal code name and the position information of the abnormal code;

[0027] Displaying the abnormal code based on the abnormal location identifier of the abnormal code according to the sorting result.

[0028] In some embodiments of the present application, after displaying the abnormal code based on the abnormal location identifier of the abnormal code according to the sorting result, it further includes:

[0029] Responding to a trigger operation on the displayed abnormal location identifier, and obtaining a target location identifier corresponding to the trigger operation;

[0030] The parsing target positioning identifier obtains the target position information corresponding to the target positioning identifier;

[0031] Display the abnormal code at the target position information in the source code.

[0032] In a second aspect, the present application provides an abnormal code processing device, which includes:

[0033] A source code acquisition module, configured to acquire the source code and execute the source code to obtain a code execution result;

[0034] An execution result acquisition module, configured to determine the function execution results of each function code segment in the source code from the execution result;

[0035] A call count acquisition module, configured to determine the number of times each function code segment's function execution result is called according to the parameter call relationship in the source code;

[0036] An abnormal code determination module, configured to screen out the function code segments whose function execution results are empty or the call count is zero based on the function execution results of each function code segment and the number of times the function execution result is called, as abnormal codes;

[0037] An abnormal parameter acquisition module, configured to calculate the code abnormal parameter corresponding to the abnormal code according to the code parameter of the abnormal code;

[0038] An abnormal function display module, configured to receive the target parameter type and display the abnormal code based on the code abnormal parameter corresponding to the target parameter type.

[0039] In a third aspect, the present application further provides a computer device, which includes:

[0040] One or more processors;

[0041] A memory; and

[0042] One or more applications, where one or more applications are stored in the memory and configured to be executed by the processor to implement the abnormal code processing method.

[0043] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program is loaded by the processor to execute the steps in the abnormal code processing method.

[0044] In a fifth aspect, an embodiment of the present application provides a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method provided in the first aspect above.

[0045] For the above abnormal code processing method, device, computer device and storage medium, by obtaining source code and executing the source code to obtain a code execution result; determining abnormal code in the source code based on the code execution result, and obtaining code abnormal parameters corresponding to the abnormal code; receiving a target parameter type, and displaying the abnormal code based on the code abnormal parameters corresponding to the target parameter type, it is possible to accurately identify the abnormal code in the source code, and quickly screen and display the abnormal code corresponding to the target parameter type through the code abnormal parameters corresponding to the abnormal code, reducing the difficulty for users to find abnormal code, and improving the processing efficiency of abnormal code and the development efficiency of the source code of software programs. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application. For those skilled in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0047] Figure 1 is a schematic diagram of the scenario of the abnormal code processing method in the embodiment of the present application;

[0048] Figure 2 is a schematic flowchart of the abnormal code processing method in the embodiment of the present application;

[0049] Figure 3 is a schematic flowchart of the abnormal code determination step in the embodiment of the present application;

[0050] Figure 4 is a schematic flowchart of the step of obtaining code abnormal parameters corresponding to the abnormal code in the embodiment of the present application;

[0051] Figure 5 is a schematic structural diagram of the abnormal code processing device in the embodiment of the present application;

[0052] Figure 6 is a schematic structural diagram of the computer device in the embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0053] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present application.

[0054] In the description of the present application, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of the described features. In the description of the present application, "a plurality" means two or more, unless otherwise specifically defined.

[0055] In the description of the present application, the term "for example" is used to mean "serving as an example, illustration, or explanation". Any embodiment described as "for example" in the present application is not necessarily construed as being more preferred or more advantageous than other embodiments. In order for any person skilled in the art to implement and use the present invention, the following description is given. In the following description, details are set forth for the purpose of explanation. It should be understood that those of ordinary skill in the art can recognize that the present invention can be implemented without using these specific details. In other instances, well-known structures and processes are not described in detail to avoid unnecessary details from obscuring the description of the present invention. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the broadest scope that conforms to the principles and features disclosed in the present application.

[0056] Figure 1 It is an application environment diagram of the method for obtaining an interface class file in an embodiment. This exception code processing method can be applied to a computer device, which can be a server or a terminal. As Figure 1 shown, taking the computer device as server 100 as an example, server 100 obtains the source code and executes the source code to obtain the code execution result; determines the exception code in the source code based on the code execution result, and obtains the code exception parameter corresponding to the exception code; receives the target parameter type, and based on the code exception parameter corresponding to the target parameter type, displays the exception code, so as to accurately identify the exception code in the source code, and quickly screen and display the exception code corresponding to the target parameter type through the code exception parameter corresponding to the exception code, reducing the difficulty for the user to find the exception code, and improving the processing efficiency of the exception code and the development efficiency of the source code of the software program.

[0057] Those skilled in the art can understand, Figure 1The application environment shown is only one application scenario of the solution of this application, and does not constitute a limitation on the application scenarios of the solution of this application. Other application environments may also include more or fewer computer devices than those shown in Figure 1 For example, Figure 1 only 1 server is shown in . It can be understood that this exception code processing system may also include one or more other servers, which are not specifically limited here. In addition, as Figure 1 shown, this exception code processing system may also include a memory for storing data, such as source code, exception code parameters, etc.

[0058] It should also be noted that Figure 1 The scenario schematic diagram of the exception code processing system shown is only an example. The exception code processing system and scenario described in the embodiments of the present invention are for more clearly illustrating the technical solutions of the embodiments of the present invention, and do not constitute a limitation on the technical solutions provided by the embodiments of the present invention. Those skilled in the art know that with the evolution of the exception code processing system and the emergence of new business scenarios, the technical solutions provided by the embodiments of the present invention are equally applicable to similar technical problems.

[0059] Referring to Figure 2 , the embodiments of the present application provide an exception code processing method, which is mainly illustrated by taking this method applied to the server in the above Figure 1 . This method includes steps S210 to S230, which are specifically as follows:

[0060] S210, obtain the source code and execute the source code to obtain the code execution result.

[0061] Among them, the source code refers to the source code of the software program to be tested and evaluated. For example, the source code of financial software, social software, shopping software, etc. The code execution result refers to the data information obtained after running the source code. Specifically, after obtaining the source code of the software program, the source code of the software program can be executed to obtain the code execution result of the source code.

[0062] S220, determine the function execution results of each function code segment in the source code from the execution result.

[0063] Among them, the function code segment refers to one or more lines of code for implementing a certain function; the function execution result is the function execution result obtained by running the function code segment, which is the intermediate execution result in the process of executing the source code.

[0064] Among them, the source code of a software program often includes multiple lines of code. One line of code or consecutive multiple lines of code can implement a basic function. Specifically, in one embodiment, the steps of obtaining the source code and executing the source code to obtain the code execution result may specifically include: dividing the source code into multiple function code segments; respectively executing each function code segment to obtain the function execution result of each function code segment.

[0065] Among them, different function code segments are used to implement different functions, and the code within the same function code segment implements the same function. Before executing the source code, the source code can be divided into function code segments that implement different functions based on the functions implemented by each line of code in the source code; when executing the source code, each function code segment is sequentially executed in the order of each function code segment in the source code to obtain the function execution result of each function code segment and the code execution result of the source code.

[0066] Further, the code sequence of each line of code in the source code can be traversed. When the code sequence of the current line is a function body sequence, logging is performed at this line of code to implement dividing the source code into multiple function code segments; after executing the source code, the function execution result of each function code segment is obtained through logging.

[0067] S230. Determine the number of times the function execution result of each function code segment is called according to the parameter call relationship in the source code.

[0068] Among them, the parameter call relationship refers to the information that different parameters in the source code are called or referenced by different function methods in the source code; during the execution process of the source code, the execution result of a certain execution step is often referenced or called by subsequent steps. After obtaining the source code, the parameter call relationship in the source code can be traversed, and then the number of times each function execution result is called can be calculated based on the parameter call relationship.

[0069] S240. Based on the function execution result of each function code segment and the number of times the function execution result is called, filter out the function code segments whose function execution result is empty or the number of times called is zero as abnormal code.

[0070] Among them, after obtaining the function execution result of each function code segment and the number of times the function execution result is called, the function code segments with an empty function execution result and the function code segments with a zero number of times the function execution result is called are determined as abnormal code.

[0071] Among them, the abnormal codes include but are not limited to error codes and useless codes in the source code; for example, it can be the source code that fails to output the code execution result due to various errors (such as no input or not being called and run, code error, etc.), or it can be the source code whose output code execution result is not referenced in the source code. After obtaining the code execution result, the code execution result can be analyzed to determine the abnormal code.

[0072] When analyzing the code execution result to determine the abnormal code, the source code can be first divided into code segments with fine granularity, and then the abnormal code can be screened based on the code execution result of the code segments with fine granularity to improve the accuracy of locating the abnormal code. In addition, when introducing the function execution result of the function code segment in the source code, the number of times the function execution result is called is also introduced for the identification of the abnormal code, realizing the identification of the abnormal code in multiple dimensions, improving the accuracy of the abnormal code, and reducing the omission of the abnormal code.

[0073] S250, calculate the code abnormal parameter corresponding to the abnormal code according to the code parameter of the abnormal code.

[0074] Among them, the code parameters include but are not limited to the number of code lines, the number of input variables, the number of output variables, the number of call objects of the output variables, etc.

[0075] Among them, the code abnormal parameter is used to reflect the relevant information of the abnormal code in different attributes, and can include the code abnormal type, the time-consuming for code repair, the code function level, etc. Specifically, the code abnormal type represents the abnormal type of the abnormal code, which is used to reflect the reason why the abnormal code is identified as abnormal. The code abnormal type includes but is not limited to useless code, minor error code, and serious error code. For example, the code abnormal type of the abnormal code whose output code execution result is not referenced in the source code is identified as useless code, while among the abnormal codes with no code execution result output, the code abnormal type of the abnormal code with no code execution result due to no input data is identified as minor error code, and the code abnormal type of the abnormal code with no code execution result due to code error is identified as serious error code. The time-consuming for code repair represents the approximate time-consuming for repairing the abnormal code, which can be predicted based on the complexity of the abnormal code. The code function level represents the function level of the function implemented by the abnormal code.

[0076] In addition, the code abnormal parameter can also include the number of code lines, the line error ratio, the number of variables, the execution duration, the loading time, the binary length, etc.; among them, the number of code lines refers to the total number of code lines in the abnormal code; the line error ratio refers to the ratio of the number of code lines with running errors in the abnormal code to the total number of lines; the number of interface analogy is the number of input variables and output variables in the abnormal code; the execution duration refers to the duration of executing the abnormal code.

[0077] Specifically, at least one of the code exception type, code repair time, code function level, number of code lines, line error ratio, number of variables, execution duration, loading time, and binary length of the exception code can be obtained as the code exception parameter of the exception code.

[0078] After obtaining the exception code, complexity analysis can be performed based on code parameters such as the number of code lines, the number of input variables, and the number of call objects of the output variables to predict the code repair time of the exception code.

[0079] Specifically, in one embodiment, as Figure 3 shown, according to the code parameters of the exception code, calculate the code exception parameters corresponding to the exception code, including:

[0080] S310, determine the code complexity of the exception code based on the number of code lines of the exception code;

[0081] S320, determine the execution complexity of the exception code based on the number of variables in the exception code; S330, determine the execution complexity of the exception code based on the number of call objects of the output variables of the exception code;

[0082] S340, calculate the code repair time of the exception code according to the code complexity, execution complexity, and result output complexity.

[0083] Among them, the code complexity can be measured based on the number of code lines of the exception code. For example, when the number of code lines is less than 5, the code complexity can be determined to be 1; when the number of code lines is greater than or equal to 5 and less than 10, the code complexity can be determined to be 2, and so on; the execution complexity can be measured by the number of input variables processed by the exception code. For example, when the number of input variables is less than 3, the code complexity can be determined to be 1; when the number of input variables is greater than or equal to 3 and less than 5, the code complexity can be determined to be 2; when the number of input variables is greater than or equal to 5 and less than 7, the code complexity can be determined to be 3, and so on; the result output complexity can be measured by the number of call objects of the output variables of the exception code. For example, when the number of call objects of the output variables is less than 5, the code complexity can be determined to be 1; when the number of call objects of the output variables is greater than or equal to 5 and less than 10, the code complexity can be determined to be 2, and so on.

[0084] Taking a software program as a financial software and an exception code as a function code segment for implementing the payment order record function as an example, the number of lines of the exception code is 9 lines, and the code complexity of the exception code is determined to be 2; the variable input to the exception code is order information, and the order information includes order number, paying user, receiving user, amount, and payment channel, a total of 5, then the execution complexity of the exception code is determined to be 3; the output variable of the exception code is also order information, which is usually only called by the code implementing the query function, that is, the number of calling objects is 1, then the result output complexity of the exception code is determined to be 1.

[0085] For the convenience of further data processing, the code complexity, execution complexity, and result output complexity can also be normalized. For example, the specific values of the code complexity, execution complexity, and result output complexity can be multiplied by a preset coefficient respectively as the actual values of the code complexity, execution complexity, and result output complexity.

[0086] After obtaining the code complexity, execution complexity, and result output complexity of the exception code, based on the code complexity, execution complexity, and result output complexity, the corresponding code repair time can be found in the repair time table as the code repair time of the exception code; or the code complexity, execution complexity, and result output complexity can be input into a pre-trained time prediction model, and the code repair time of the exception code can be obtained through the time prediction model. Among them, the time prediction model can be a machine learning model, and the machine learning model is pre-trained with training samples to obtain the time prediction model, and the training samples include code samples and the repair time corresponding to the code samples.

[0087] Among them, the code complexity, execution complexity, and result output complexity respectively reflect the complexity of the exception code in different dimensions. By combining the code complexity, execution complexity, and result output complexity, the complexity of the exception code can be accurately and effectively determined, and then accurate data basis can be provided for predicting the code repair time of the exception code subsequently.

[0088] S260, receive the target parameter type, and display the exception code based on the code exception parameter corresponding to the target parameter type.

[0089] Among them, the target parameter type refers to the parameter type selected by the user; after the server obtains the target parameter type, it determines the target value on the target parameter type from the code exception parameters of each exception code, and then displays the exception code based on the parameter value on the target parameter type.

[0090] Specifically, an exception code processing interface can be set up. The user can input the target parameter type through the exception code processing interface. After the server obtains the target parameter type through the exception code processing interface, it obtains each exception code to determine the target value on the target parameter type, and then based on the target values of each exception code, displays the exception codes in the exception code processing interface for the user to view.

[0091] Further, in one embodiment, displaying the exception codes based on the code exception parameters corresponding to the target parameter type includes: determining the target value of the exception code on the target parameter type according to the code exception parameters of the exception code; sorting the exception codes according to the target values of the exception codes to obtain a sorting result; and displaying the exception codes according to the sorting result.

[0092] Sorting the exception codes according to the target values of the exception codes on the target parameter type realizes the display of the exception codes in combination with the attribute information that the user is more concerned about (i.e., the target parameter type), reduces the difficulty for the user to find the exception codes, and improves the development efficiency of the software program.

[0093] Taking the code repair time as an example of the target parameter type, the server determines the code repair time corresponding to each exception code from the code exception parameters of each exception code. Then, based on the specific values of the code repair time (i.e., the target values), sorts each exception code to obtain a sorting result based on the code repair time, and then based on the sorting result of the code repair time, displays the exception codes. For example, the exception codes with shorter code repair time can be sorted at the back, and the exception codes with longer code repair time can be sorted at the front; or the exception codes with longer code repair time can be sorted at the front, and the exception codes with shorter code repair time can be sorted at the back.

[0094] Further, when displaying the exception codes, if the exception code includes multiple lines of code, it will cause the number of exception codes displayed on one page to be too small. Therefore, in one embodiment, displaying the exception codes according to the sorting result includes: obtaining the position information of the exception code in the source code and constructing the exception code name of the exception code; generating an exception location identifier corresponding to the exception code according to the exception code name and the position information of the exception code; and displaying the exception codes based on the exception location identifier of the exception code according to the sorting result.

[0095] Among them, software programs are often developed in the form of project projects, and the source code of the software program is saved in the form of multiple program files in the project project. The position information of the exception code can include the path information of the program file where the exception code is located in the project project and the line number information in the program file. The exception code name is used to name and identify the exception code. For example, the function name of the main function in the function code segment corresponding to the exception code can be obtained as the exception code name.

[0096] After obtaining the location information and the name of the exception code, an exception location identifier corresponding to the exception code can be constructed based on the location information and the name of the exception code. Specifically, the location information of the exception code can be used as the link information of the exception location identifier, and the name of the exception code can be used as the identifier name of the exception location identifier to generate the exception location identifier. This exception location identifier is used to uniquely identify and locate the exception code.

[0097] By constructing the exception location identifier corresponding to the exception code and using the exception location identifier to represent the exception code when displaying the exception code, the content to be displayed can be greatly reduced, enabling more exception codes to be displayed on the same display interface, reducing the difficulty for users to find exception codes, and improving the development efficiency of software programs.

[0098] In the above exception code processing method, the source code is obtained and the code execution result is obtained by executing the source code; the exception code in the source code is determined based on the code execution result, and the code exception parameter corresponding to the exception code is obtained; the target parameter type is received, and based on the code exception parameter corresponding to the target parameter type, the exception code is displayed, achieving accurate identification of the exception code in the source code, and quickly filtering and displaying the exception code corresponding to the target parameter type through the code exception parameter corresponding to the exception code, reducing the difficulty for users to find the exception code, and improving the processing efficiency of the exception code and the development efficiency of the source code of the software program.

[0099] In one embodiment, as Figure 4 shown, after displaying the exception code based on the exception location identifier of the exception code according to the sorting result, it further includes:

[0100] S410, in response to a trigger operation on the displayed exception location identifier, obtain the target location identifier corresponding to the trigger operation;

[0101] S420, parse the target location identifier to obtain the target location information corresponding to the target location identifier;

[0102] S430, display the exception code at the target location information in the source code.

[0103] Among them, the trigger operation refers to an operation on the interface for displaying the exception code (such as the exception code processing interface), such as a touch operation, a cursor operation, or a key operation, etc. Taking the touch operation as an example, when the user touches a certain exception location identifier (i.e., the target location identifier) in the exception code processing interface, a corresponding trigger operation will be triggered and sent to the server. After receiving the trigger operation, the server obtains the target location identifier corresponding to the trigger operation.

[0104] After obtaining the target positioning identifier, parse the target positioning identifier to obtain the corresponding target location information, and then locate the corresponding abnormal code from the source code based on the target location information, and make the abnormal code processing interface jump to display the abnormal code of the target location information, so as to quickly locate the abnormal code.

[0105] To better implement the abnormal code processing method provided in the embodiments of the present application, based on the abnormal code processing method proposed in the embodiments of the present application, an abnormal code processing device is also provided in the embodiments of the present application, as Figure 5 shown, the abnormal code processing device 500 includes:

[0106] The source code acquisition module 510 is used to acquire the source code and execute the source code to obtain the code execution result;

[0107] The execution result acquisition module 520 is used to determine the function execution results of each function code segment in the source code from the execution result;

[0108] The call times acquisition module 530 is used to determine the called times of the function execution results of each function code segment according to the parameter call relationship in the source code;

[0109] The abnormal code determination module 540 is used to screen out the function code segments with empty function execution results or zero called times based on the function execution results of each function code segment and the called times of the function execution results as the abnormal code;

[0110] The abnormal parameter acquisition module 550 is used to calculate the code abnormal parameters corresponding to the abnormal code according to the code parameters of the abnormal code;

[0111] The abnormal function display module 560 is used to receive the target parameter type and display the abnormal code based on the code abnormal parameters corresponding to the target parameter type.

[0112] In some embodiments of the present application, the source code acquisition module 510 is used to divide the source code into multiple function code segments; execute each function code segment respectively to obtain the function execution results of each function code segment.

[0113] In some embodiments of the present application, the code abnormal parameters include at least one of, but not limited to, code abnormal type, code repair time-consuming, and code function level.

[0114] In some embodiments of the present application, the code exception parameter includes the time taken to repair the code; the exception parameter acquisition module 550 is specifically configured to determine the code complexity of the exception code based on the number of lines of the exception code; determine the execution complexity of the exception code based on the number of input variables in the exception code; determine the execution complexity of the exception code based on the number of call objects of the output variable of the exception code; and calculate the time taken to repair the exception code according to the code complexity, the execution complexity, and the result output complexity.

[0115] In some embodiments of the present application, the exception function display module 560 is specifically configured to determine the target value of the exception code for the target parameter type according to the code exception parameter of the exception code; sort the exception code according to the target value of the exception code to obtain a sorting result; and display the exception code according to the sorting result.

[0116] In some embodiments of the present application, the exception function display module 560 is specifically configured to obtain the position information of the exception code in the source code and construct the exception code name of the exception code; generate an exception location identifier corresponding to the exception code according to the exception code name and the position information of the exception code; and display the exception code based on the exception location identifier of the exception code according to the sorting result.

[0117] In some embodiments of the present application, the exception function display module 560 is specifically configured to, in response to a trigger operation on the displayed exception location identifier, obtain a target location identifier corresponding to the trigger operation; parse the target location identifier to obtain the target position information corresponding to the target location identifier; and display the exception code at the target position information in the source code.

[0118] For the specific limitations of the exception code processing device, reference may be made to the limitations of the exception code processing method described above, which will not be elaborated here. Each module in the above exception code processing device can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor of the computer device in hardware form or be independent of it, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.

[0119] In some embodiments of the present application, the exception code processing device 500 can be implemented in the form of a computer program, and the computer program can run on a computer device as shown in Figure 6 The memory of the computer device can store each program module that composes the exception code processing device 500. For example, Figure 5The source code acquisition module 510, execution result acquisition module 520, call count acquisition module 530, exception code determination module 540, exception parameter acquisition module 550, and exception function display module 560 as shown. The computer program composed of each program module enables the processor to execute the steps in the exception code processing method of each embodiment of the present application described in this specification.

[0120] For example, Figure 6 The computer device shown can execute step S210 through the source code acquisition module 510 in the exception code processing device 500 as shown in 5. The computer device can execute step S220 through the execution result acquisition module 520. The computer device can execute step S230 through the call count acquisition module 530. The computer device can execute step S240 through the exception code determination module 540. The computer device can execute step S250 through the exception parameter acquisition module 550. The computer device can execute step S260 through the exception function display module 560. 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 and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external computer device through a network connection. When the computer program is executed by the processor, it implements an exception code processing method.

[0121] Those skilled in the art can understand that Figure 6 the structure shown in is only a block diagram of some structures related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application 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 component layout.

[0122] In some embodiments of the present application, a computer device is provided, including one or more processors; a memory; and one or more application programs, where one or more application programs are stored in the memory and configured to be executed by the processor to perform the steps of the above-mentioned exception code processing method. The steps of the exception code processing method here may be the steps in the exception code processing method of the above-mentioned various embodiments.

[0123] In some embodiments of the present application, a computer-readable storage medium is provided, storing a computer program, and the computer program is loaded by the processor so that the processor executes the steps of the above-mentioned exception code processing method. The steps of the exception code processing method here may be the steps in the exception code processing method of the above-mentioned various embodiments.

[0124] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. 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 various methods. Any reference to a memory, storage, database, or other medium used in the various embodiments provided in the present application can include at least one of non-volatile and volatile memories. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.

[0125] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the various technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered to be within the scope described in this specification.

[0126] The above has introduced in detail an abnormal code processing method, device, computer device, and storage medium provided by the embodiments of the present application. Specific examples are used in this article to elaborate on the principles and implementation manners of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for those skilled in the art, based on the idea of the present invention, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to the present invention.

Claims

1. An abnormal code processing method, characterized in that, it includes: Obtain the source code and execute the source code to obtain the code execution result; Determine the function execution results of each function code segment in the source code from the execution result; According to the parameter call relationship in the source code, determine the number of times each function code segment's function execution result is called; Based on the function execution results of each function code segment and the number of times the function execution result is called, filter out the function code segments with an empty function execution result or a zero call count as abnormal codes; Based on the number of lines of code of the abnormal code, determine the code complexity of the abnormal code; Based on the number of input variables in the abnormal code, determine the execution complexity of the abnormal code; Based on the number of call objects of the output variables of the abnormal code, determine the result output complexity of the abnormal code; According to the code complexity, the execution complexity, and the result output complexity, calculate the code repair time of the abnormal code; Receive the target parameter type, and display the abnormal code based on the code abnormal parameters corresponding to the target parameter type, where the code abnormal parameters include at least one of the code abnormal type, the code repair time, and the code function level.

2. The method according to claim 1, characterized in that, The step of obtaining the source code and executing the source code to obtain the code execution result includes: Divide the source code into multiple function code segments; Execute each function code segment separately to obtain the function execution results of each function code segment.

3. The method according to any one of claims 1 to 2, characterized in that, The step of displaying the abnormal code based on the code abnormal parameters corresponding to the target parameter type includes: Determine the target value of the abnormal code in the target parameter type according to the code abnormal parameters of the abnormal code; Sort the abnormal codes according to the target value of the abnormal code to obtain a sorting result; Display the abnormal codes according to the sorting result.

4. The method according to claim 3, characterized in that, The step of displaying the abnormal code according to the sorting result includes: Obtain the position information of the abnormal code in the source code and construct the abnormal code name of the abnormal code; Generate an abnormal location identifier corresponding to the abnormal code according to the abnormal code name and position information of the abnormal code; Display the abnormal codes according to the sorting result based on the abnormal location identifier of the abnormal code.

5. The method according to claim 4, characterized in that, After the step of displaying the abnormal codes according to the sorting result based on the abnormal location identifier of the abnormal code, it further includes: In response to a trigger operation on the displayed abnormal location identifier, obtain the target location identifier corresponding to the trigger operation; Parse the target location identifier to obtain the target position information corresponding to the target location identifier; Display the abnormal code at the target position information in the source code.

6. An abnormal code processing device, characterized in that, The device includes: A source code acquisition module, configured to acquire the source code and execute the source code to obtain a code execution result; An execution result acquisition module, configured to determine the function execution results of each function code segment in the source code from the execution result; A call count acquisition module, configured to determine the call counts of the function execution results of each function code segment according to the parameter call relationship in the source code; An abnormal code determination module, configured to filter out function code segments with an empty function execution result or a zero call count as abnormal codes based on the function execution results of each function code segment and the call counts of the function execution results; An abnormal parameter acquisition module, configured to determine the code complexity of the abnormal code based on the line number of the abnormal code; determine the execution complexity of the abnormal code based on the number of input variables in the abnormal code; determine the result output complexity of the abnormal code based on the number of call objects of the output variables in the abnormal code; calculate the code repair time of the abnormal code according to the code complexity, the execution complexity, and the result output complexity; An abnormal function display module, configured to receive a target parameter type and display the abnormal code based on the code abnormal parameters corresponding to the target parameter type, where the code abnormal parameters include at least one of a code abnormal type, the code repair time, and a code function level.

7. A computer device, characterized in that the computer device includes: One or more processors; A memory; and One or more applications, where the one or more applications are stored in the memory and configured to be executed by the processor to implement the abnormal code processing method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that a computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in the abnormal code processing method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Defect positioning method and device

    CN106339315A

  • Code positioning method and device and electronic equipment

    CN108132850A