Program defect reproduction method and device and computer readable storage medium
Through the machine learning model, the reproduction script is processed through multiple rounds of iterative processing, which solves the problem of poor quality of reproduction scripts and achieves a more efficient bug reproduction effect.
Patent Information
- Application Number
- CN202510525792.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-24
- Publication Date
- 2025-08-15
AI Technical Summary
In the prior art, the quality of reproduction scripts is poor, resulting in poor bug reproduction effect.
The machine learning model is used to perform multiple iterations on the reproduction script, and the state transition and action adjustment of the reproduction script are guided according to the prompt information of the running environment, including creation, execution, verification, reporting and modification until the program defects are successfully reproduced.
Improve the quality of reproduction scripts and bug reproduction effect, ensuring the accuracy and effectiveness of reproduction scripts.
Smart Images

Figure CN120492291A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a program defect reproduction method, a program defect reproduction device, and a computer-readable storage medium. Background Art
[0002] Automatically reproducing bugs (i.e., program defects) in a program involves reproducing a discovered bug using specific steps and conditions. This process not only helps developers understand the root cause of the problem but also enables them to be discovered and fixed promptly, ensuring that the problem does not recur, thereby facilitating software development and maintenance.
[0003] In related technologies, a bug reproduction script is constructed based on problems that occur during program operation; and the bug is reproduced by executing the reproduction script. Summary of the Invention
[0004] The inventors of the present disclosure have discovered that the above-mentioned related technologies have the following problems: the quality of the reproduction script is poor, resulting in poor bug reproduction effect.
[0005] In view of this, the present disclosure proposes a bug reproduction technical solution, which can improve the quality of the reproduction script under the guidance of prompt information, thereby improving the bug reproduction effect.
[0006] According to some embodiments of the present disclosure, a method for reproducing program defects is provided, comprising: utilizing a machine learning model to execute a current action on a reproduction script for a program defect to be reproduced; sending the current action and a current state corresponding to the current action to a running environment of the program, wherein the program includes the program defect to be reproduced; converting the current state into a next state and the current action into a next action corresponding to the next state according to prompt information fed back by the running environment, wherein the prompt information includes execution result information of the current action; and repeating the above steps until the reproduction script successfully reproduces the program defect to be reproduced.
[0007] In some embodiments, the execution result information includes condition information satisfied by the execution result of the current action, and the next state corresponding to the condition information.
[0008] In some embodiments, the current action includes executing a reproduction script, the current state includes an execution state, and using a machine learning model to execute the current action on the reproduction script for the program defect to be reproduced includes: using a first machine learning model to execute the reproduction script; according to the prompt information feedback from the operating environment, the current state is converted to the next state, and the current action is converted to the next state. The next action corresponding to the next state includes: in response to the execution result information including the completion of the execution of the reproduction script, the current state is converted to the first verification state, and the current action is converted to using the first machine learning model to verify whether the reproduction script successfully reproduces the program defect to be reproduced.
[0009] In some embodiments, according to the prompt information feedback from the operating environment, the current state is converted to the next state, and the current action is converted to the next action corresponding to the next state, including: in response to the execution result information including that the reproduction script fails to successfully reproduce the program defect to be reproduced, the current state is converted to a modified state, and the current action is converted to modifying the reproduction script using the first machine learning model.
[0010] In some embodiments, based on the prompt information feedback from the operating environment, the current state is converted to the next state, and the current action is converted to the next action corresponding to the next state, including: in response to the execution result information including the reproduction script successfully reproducing the program defect to be reproduced, the current state is converted to a second verification state, and the current action is converted to using a second machine learning model to verify whether the reproduction script successfully reproduces the program defect to be reproduced.
[0011] In some embodiments, according to the prompt information feedback from the operating environment, the current state is converted to the next state, and the current action is converted to the next action corresponding to the next state, including: in response to the execution result information including that the reproduction script fails to successfully reproduce the program defect to be reproduced, the current state is converted to a modified state, and the current action is converted to modifying the reproduction script using the first machine learning model.
[0012] In some embodiments, according to the prompt information feedback from the operating environment, the current state is converted to the next state, and the current action is converted to the next action corresponding to the next state, including: in response to the execution result information including the reproduction script successfully reproducing the program defect to be reproduced, the current state is converted to the reporting state, and the current action is converted to reporting that the reproduction script successfully reproduced the program defect to be reproduced.
[0013] In some embodiments, using a machine learning model, executing a current action on a reproduction script for a program defect to be reproduced includes: in response to prompt result information including that the reproduction script failed to successfully reproduce the program defect to be reproduced, using a machine learning model, determining a modification method for the reproduction script; checking whether the modification method meets the modification restriction conditions; in response to meeting the modification restriction conditions, applying the modification method to the reproduction script; in response to not meeting the modification restriction conditions, redetermining a modification method for the reproduction script, or regenerating the reproduction script.
[0014] In some embodiments, the modification restriction condition includes at least one of the following: the modification method includes outputting a statement of the program defect to be reproduced; the modification method causes the modified reproduction script to be repeated with the historical reproduction script; modifying files other than the reproduction script; the modification method includes a syntax error; the number of modifications to the reproduction script exceeds a threshold.
[0015] In some embodiments, the program defect reproduction method also includes: using a machine learning model to screen out code snippets related to the program defect to be reproduced based on the degree of correlation between the code snippets in the program's code repository and the program's problem description information; using a machine learning model to generate a reproduction script for the program defect to be reproduced based on the relevant code snippets.
[0016] In some embodiments, a machine learning model is used to screen out code snippets related to program defects to be reproduced based on the degree of correlation between code snippets in the program's code repository and the program's problem description information, including: screening out multiple candidate code snippets from the code repository based on the degree of correlation; sorting the multiple candidate code snippets based on the degree of correlation; and screening out relevant code snippets from the multiple candidate code snippets based on the sorting results.
[0017] In some embodiments, using a machine learning model to generate a reproduction script for a program defect to be reproduced based on relevant code snippets includes: generating context summary information of the program defect to be reproduced based on relevant information of the program defect to be reproduced in the problem description information, test information of the program defect to be reproduced in the code repository, and at least one of the explanatory information; generating a reproduction script based on the context summary information and relevant code snippets.
[0018] According to other embodiments of the present disclosure, a program defect reproduction device is provided, including: an execution unit, for using a machine learning model to execute a current action on a reproduction script of a program defect to be reproduced; a sending unit, for sending the current action and the current state corresponding to the current action to the running environment of the program, wherein the program includes the program defect to be reproduced; a conversion unit, for converting the current state into the next state and the current action into the next action corresponding to the next state according to prompt information fed back by the running environment, wherein the prompt information includes execution result information of the current action, and the execution unit, the sending unit, and the conversion unit repeat the above processing until the reproduction script successfully reproduces the program defect to be reproduced.
[0019] In some embodiments, the execution result information includes condition information satisfied by the execution result of the current action, and the next state corresponding to the condition information.
[0020] In some embodiments, the current action includes executing a reproduction script, the current state includes an execution state, and the execution unit uses a first machine learning model to execute the reproduction script. The conversion unit converts the current state to a first verification state in response to the execution result information including that the reproduction script has been executed, and converts the current action to verify whether the reproduction script successfully reproduces the program defect to be reproduced using the first machine learning model.
[0021] In some embodiments, the conversion unit converts the current state into a modification state in response to the execution result information including that the reproduction script fails to successfully reproduce the program defect to be reproduced, and converts the current action into modifying the reproduction script using the first machine learning model.
[0022] In some embodiments, the conversion unit converts the current state into a second verification state in response to the execution result information including that the reproduction script successfully reproduces the program defect to be reproduced, and converts the current action into using the second machine learning model to verify whether the reproduction script successfully reproduces the program defect to be reproduced.
[0023] In some embodiments, the conversion unit converts the current state into a modification state in response to the execution result information including that the reproduction script fails to successfully reproduce the program defect to be reproduced, and converts the current action into modifying the reproduction script using the first machine learning model.
[0024] In some embodiments, in response to the execution result information including the reproduction script successfully reproducing the program defect to be reproduced, the conversion unit converts the current state into a reporting state and converts the current action into reporting that the reproduction script successfully reproduced the program defect to be reproduced.
[0025] In some embodiments, the execution unit responds to the prompt result information including that the reproduction script fails to successfully reproduce the program defect to be reproduced, uses a machine learning model to determine a modification method for the reproduction script, checks whether the modification method meets the modification restrictions, applies the modification method to the reproduction script in response to meeting the modification restrictions, and redetermines a modification method for the reproduction script in response to not meeting the modification restrictions, or regenerates the reproduction script.
[0026] In some embodiments, the modification restriction condition includes at least one of the following: the modification method includes outputting a statement of the program defect to be reproduced; the modification method causes the modified reproduction script to be repeated with the historical reproduction script; modifying files other than the reproduction script; the modification method includes a syntax error; the number of modifications to the reproduction script exceeds a threshold.
[0027] In some embodiments, the program defect reproduction device also includes: a generation unit, which is used to use a machine learning model to screen out code snippets related to the program defect to be reproduced based on the degree of correlation between the code snippets in the program's code repository and the program's problem description information, and use the machine learning model to generate a reproduction script for the program defect to be reproduced based on the relevant code snippets.
[0028] In some embodiments, the generation unit selects multiple candidate code snippets from the code repository according to the degree of relevance; sorts the multiple candidate code snippets according to the degree of relevance, and selects relevant code snippets from the multiple candidate code snippets according to the sorting result.
[0029] In some embodiments, the generation unit generates context summary information of the program defect to be reproduced based on the relevant information of the program defect to be reproduced in the problem description information, the test information of the program defect to be reproduced in the code repository, and at least one of the explanation information; and generates a reproduction script based on the context summary information and related code snippets.
[0030] According to some further embodiments of the present disclosure, a program defect reproduction device is provided, comprising: a memory; and a processor coupled to the memory, wherein the processor is configured to execute the program defect reproduction method in any of the above embodiments based on instructions stored in the memory device.
[0031] According to some further embodiments of the present disclosure, a computer-readable storage medium is provided, on which computer instructions are stored. When the instructions are executed by a processor, the program defect reproduction method in any of the above embodiments is implemented.
[0032] According to some further embodiments of the present disclosure, a computer program product is provided, comprising instructions, which, when executed by a processor, cause the processor to execute the program defect reproduction method according to any one of the above embodiments.
[0033] In the above embodiment, the recurrence script is iteratively processed based on the prompt information fed back by the current state and current action of the operating environment. In this way, the quality of the recurrence script can be improved under the guidance of multiple rounds of prompt information, thereby improving the bug recurrence effect.
[0034] Other features, aspects and advantages of the present disclosure will become apparent from the following detailed description of exemplary embodiments of the present disclosure with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The following describes embodiments of the present disclosure with reference to the accompanying drawings. It should be understood that the drawings described below only relate to some embodiments of the present disclosure and do not constitute a limitation to the present disclosure. In the accompanying drawings:
[0036] Figure 1 Flowcharts showing some embodiments of the program defect reproduction method disclosed herein;
[0037] Figure 2 Schematic diagrams showing some embodiments of the program defect reproduction method disclosed herein;
[0038] Figure 3 Schematic diagrams showing some embodiments of the iterative processing method of the replication script of the present disclosure;
[0039] Figure 4 A block diagram showing some embodiments of the program defect reproduction device disclosed herein;
[0040] Figure 5A block diagram showing some other embodiments of the program defect reproduction device disclosed herein;
[0041] Figure 6 A block diagram showing some further embodiments of the program defect reproduction apparatus of the present disclosure.
[0042] It should be understood that, for ease of description, the dimensions of the various parts shown in the drawings are not necessarily drawn to scale. The same or similar reference numerals are used throughout the drawings to indicate the same or similar parts. Therefore, once an item is defined in one drawing, it may not be discussed further in subsequent drawings. DETAILED DESCRIPTION
[0043] The following will be combined with the accompanying drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. It should be understood that the present disclosure can be implemented in various forms and should not be interpreted as being limited to the embodiments described here.
[0044] It should be understood that the various steps described in the method embodiments of the present disclosure can be performed in different orders and / or performed in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect. Unless otherwise specifically stated, the relative arrangement, numerical expressions and numerical values of the parts and steps set forth in these embodiments should be interpreted as being merely exemplary and do not limit the scope of the present disclosure.
[0045] The term “including” and its variations used in the present disclosure are open terms that include at least the following elements / features but do not exclude other elements / features, that is, “including but not limited to.” The term “based on” means “at least partially based on.”
[0046] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules, or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules, or units. Unless otherwise specified, concepts such as "first" and "second" are not intended to imply that the objects described in such a manner must be in a given order in time, space, ranking, or any other manner.
[0047] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".
[0048] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0049] The following detailed description of the embodiments of the present disclosure is provided in conjunction with the accompanying drawings, but the present disclosure is not limited to these specific embodiments. The following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. In addition, in one or more embodiments, specific features, structures, or characteristics may be combined in any suitable manner that will be apparent to those skilled in the art from this disclosure.
[0050] As mentioned earlier, a reproduction script built only based on the problems that occur during program operation is usually long and often contains irrelevant code snippets, resulting in the failure of bug reproduction.
[0051] In response to the above technical problems, the present invention provides multiple rounds of detailed guidance on the processing of the reproduction script based on the prompt information of the current state and current action feedback of the running environment, thereby improving the quality of the reproduction script and thus improving the bug reproduction effect.
[0052] For example, the technical solutions of the present disclosure can be implemented through the following embodiments.
[0053] Figure 1 A flowchart illustrating some embodiments of the program defect reproduction method of the present disclosure.
[0054] like Figure 1 As shown, in step 110, a machine learning model is used to execute a current action on the reproduction script for the program defect to be reproduced. For example, the machine learning model can be an artificial intelligence model with natural language processing and generation capabilities; the current action can include multiple options of creation, execution, verification (including first verification, second verification, etc.), reporting, modification, and restart.
[0055] In step 120, the current action and the current state corresponding to the current action are sent to the program's runtime environment, where the program includes the program defect to be reproduced. For example, the current state may include multiple states of creation state, execution state, verification state (first verification state, second verification state, etc.), report state, modification state, and restart state.
[0056] In step 130, according to the prompt information fed back by the operating environment, the current state is converted to the next state, and the current action is converted to the next action corresponding to the next state. The prompt information includes the execution result information of the current action.
[0057] In step 140 , steps 110 - 130 are repeated until the reproduction script successfully reproduces the program defect to be reproduced.
[0058] In the above embodiment, the recurrence script is iteratively processed based on the prompt information fed back by the current state and current action of the operating environment. In this way, the quality of the recurrence script can be improved under the guidance of multiple rounds of prompt information, thereby improving the bug recurrence effect.
[0059] The following describes, through some embodiments, the method of creating the reproduction script in step 110.
[0060] In some embodiments, a machine learning model is used to filter out code snippets related to the program defect to be reproduced based on the correlation between code snippets in the program's code repository and the program's problem description information. The machine learning model is then used to generate a reproduction script for the program defect to be reproduced based on the relevant code snippets. For example, the problem description information may include error logs, user operation records, test cases, etc. The code repository may be a database containing program source code, including code snippets within the source code.
[0061] In some embodiments, multiple candidate code snippets are screened from a code repository based on their relevance, the multiple candidate code snippets are ranked based on their relevance, and relevant code snippets are screened from the multiple candidate code snippets based on the ranking results. For example, a machine learning model can be used to determine, based on the ranking results, candidate code snippets with a relevance above a threshold as relevant code snippets.
[0062] In the above embodiment, for a large number of code snippets retrieved from the code repository, each code snippet is sorted according to its degree of relevance to the problem description information, thereby obtaining sorted code snippets. In this way, based on the degree of relevance to the problem description information, code snippets with a high degree of relevance to the bug can be screened out, while irrelevant code snippets can be filtered out. This reduces the context pressure on the machine learning model, allowing the machine learning model to better understand and locate the bug, thereby improving the quality of the reproduction script and improving the reproduction performance.
[0063] In some embodiments, context summary information of the program defect to be reproduced is generated based on at least one of the following: information related to the program defect to be reproduced in the problem description information, test information for the program defect to be reproduced in the code repository, and explanation information; and a reproduction script is generated based on the context summary information and relevant code snippets. For example, the context summary information can be generated based on relevant code snippets, information related to the program defect to be reproduced, test information for the program defect to be reproduced, explanation information, etc.
[0064] For example, the context summary can be generated based on information about the program defect to be reproduced in the problem description. This information can include: a clear and detailed description of the bug, which helps the machine learning model understand the program problem; recommended test cases to assist in generating a reproduction script; and the current result caused by the bug and the expected result after fixing the bug. By analyzing the current and expected results, it helps verify whether the execution information of the reproduction script accurately reflects the bug.
[0065] For example, context summaries can be generated based on code snippets in the code repository that may cause bugs, test information for reproducing the program defect, and explanation information. Test information can include test cases that can be directly reused or are related to reproducing the bug. Explanation information can be related to the bug, including the bug code, related tests, and detailed explanations of the correlation between bugs. This explanation information helps machine learning models better utilize code snippets to reproduce bugs.
[0066] In the above embodiment, by summarizing the context of the bug-related code snippets, we obtain contextual summary information as the basis for generating a reproduction script. This simplifies the basis for generating the reproduction script and filters out irrelevant information, thereby reducing the context pressure on the machine learning model. This allows the machine learning model to better understand and locate the bug, thereby improving the quality of the reproduction script and enhancing reproduction performance.
[0067] For example, you can Figure 2 The embodiment in exemplarily illustrates creating context summary information.
[0068] Figure 2 Schematic diagrams showing some embodiments of the program defect reproduction method disclosed herein.
[0069] like Figure 2 As shown, the problem description information and the code repository are input into the bug-related context summary module. The first machine learning model performs retrieval, reordering and summary processing based on the problem description information and the code repository to generate context summary information related to the bug.
[0070] For example, in the retrieval process, the code structure can be extracted by parsing the files in the code repository, such as using AST (Abstract Syntax Tree). The code structure may include methods, classes, and identifiers. In order to facilitate fine-grained code retrieval, some search tools can be created, including "search_method (method retrieval)", "search_class (class retrieval)" and "search_identifier (identifier retrieval)" and so on; in response to the first machine learning model calling these search tools, the search request can be processed locally based on the parsed file; then, the search results (i.e., multiple candidate code snippets) are fed back to the first machine learning model as the retrieved context information. For example, the first machine learning model can also use bash commands such as "ls", "grep" and "find" for retrieval.
[0071] For example, in the sorting process (such as Rerank), the retrieved context information is a code snippet set C consisting of multiple candidate code snippets. retrieve ={c 1, c 2, ... , c n ,… , c N The first machine learning model ranks these candidate code snippets according to their relevance to the problem description information, and repeats this process M times to generate ranking results R1, R2, ..., R m ,...,R M Each R m Each is a vector representing the sorted position of the code snippet:
[0072] R m =(r m1 ,r m2 ,…,r mn ,…,r MN ), m=1,2,…,M
[0073] r mn Indicates the ranking position of the nth candidate code snippet in the mth sorting, r mn is an integer between 1 and N. The average ranking result set R of each candidate code snippet can be calculated by the following formula avg :
[0074]
[0075] According to R avg Sort all candidate code snippets to obtain the re-sorted context information set C rerankAs the ranking result of all candidate code snippets:
[0076] C reran k=Sort(C retr i eve ,R avg )
[0077] For example, in the summarization process, the first machine learning model is based on C rerank , filtering out lengthy and irrelevant code snippets, and generating the following bug-related context summary information based on the filtered relevant code snippets and problem description information:
[0078] Context from the problem description: 1. Bug description. A clear and detailed bug description helps the machine learning model understand the program problem. 2. Recommended test cases to assist in generating a reproduction script. 3. The current result caused by the bug and the expected result after fixing the bug. By analyzing the current and expected results, it helps to verify whether the execution information of the reproduction script accurately reflects the bug.
[0079] Context from the code repository: 1. Code snippets that may cause the bug; 2. Test information related to the bug, including test cases that can be directly reused or related to reproducing the bug; 3. Explanation of the relevance, including a detailed explanation of the buggy code, related tests, and the correlation between the bugs. This explanation helps the first machine learning model better utilize the code snippets to reproduce the bug.
[0080] For example, a reproduction script can be generated based on the context summary information and related code snippets.
[0081] In the above embodiment, by summarizing the context of the bug-related code snippets, we obtain contextual summary information as the basis for generating a reproduction script. This simplifies the basis for generating the reproduction script and filters out irrelevant information, thereby reducing the context pressure on the machine learning model. This allows the machine learning model to better understand and locate the bug, thereby improving the quality of the reproduction script and enhancing reproduction performance.
[0082] The iterative processing method of the recurrence script in steps 120-140 is exemplarily described below through some embodiments.
[0083] In some embodiments, the execution result information includes the condition information satisfied by the execution result of the current action, as well as the next state corresponding to the condition information. For example, the condition information may include multiple items of creation completed, execution completed, verification passed (including first verification passed, second verification passed, etc.), verification failed (including first verification failed, second verification failed, etc.), report completed, modification completed, and restart completed.
[0084] For example, an iterative processing model can be suggested, including a finite number of states, conditions for transitions between states, actions corresponding to states, etc., to guide and constrain the first machine learning model's processing of the reproduction script, such as creation, modification, verification, etc.
[0085] This allows the machine learning model to guide the various processing of the reproduction script until the reproduction script can successfully reproduce the program defect, avoiding the generation of duplicate and false reproduction scripts. This improves the quality of the reproduction script and the bug reproduction effect.
[0086] For example, the proposed iterative processing model can include a 5-tuple (Q, Σ, δ, q0, q4), where Q is the state set, Σ is the condition set for state transition, q0 is the initial state, q4 is the accepting state, and δ is the function of state transition.
[0087] The state set Q = {q0,q1,q2,q3,q4,q5,q6} represents the different states of the first machine learning model during the modification of the reproduction script: q0: creation state, q1: execution state, q2: self-verification state (i.e., first verification state), q3: external verification state (i.e., second verification state), q4: reporting state, q5: modification state, and q6: restart state. The condition set Σ = {a,b,c,d,e,f,g,h,i,j,k,l} represents the conditions that must be met for the first machine learning model to transition between states. In response to an action taken by the first machine learning model, a condition is satisfied, leading to a state transition. Conditions include creation completion, execution completion, and self-verification passing. The initial state q0 (i.e., creation state) represents the starting point for the first machine learning model to create the reproduction script based on the summarized context information. The acceptance state q4 (i.e., reporting state) indicates the moment when the first machine learning model successfully reproduces the bug and reports success, and is the final state of the iterative processing model. The transition function δ = Q × Σ → Q describes how the first machine learning model transitions between different states when specific conditions are met.
[0088] For example, based on the results of the previous round of processing of the reproduction script, prompt information can be generated to guide the first machine learning model to perform state transition and guide the reproduction script to successfully reproduce program defects, thereby improving the generation quality of the reproduction script.
[0089] For example, you can Figure 2 The embodiment in exemplarily illustrates the processing of the recurrence script through the transition between states and the guidance of prompt information.
[0090] like Figure 2As shown, the iterative processing model adopted by the script generation guidance module includes the creation state, execution state, first verification state, second verification state, report state, modification state and restart state, and performs corresponding actions based on the context summary information output by the bug-related context summary module; Figure 2 The arrows in the figure represent the transitions between states, which guide the generation of a reproduction script that can successfully reproduce the bug.
[0091] The following uses some embodiments to exemplify the first machine learning model, and processes the recurrence script through the transition between states and the guidance of prompt information.
[0092] In some embodiments, the current action includes executing a reproduction script, and the current state includes an execution state. The reproduction script is executed using the first machine learning model; in response to the execution result information in the prompt information including that the reproduction script has been executed, the current state is converted to a first verification state, and the current action is converted to verifying whether the reproduction script successfully reproduces the program defect to be reproduced using the first machine learning model (i.e., the first verification, or self-verification). For example, in response to the execution result information of the first verification in the prompt information including that the reproduction script failed to successfully reproduce the program defect to be reproduced, the current state is converted to a modification state, and the current action is converted to modifying the reproduction script using the first machine learning model.
[0093] In this way, under the guidance of prompt information, the machine learning model of the reproduction script is processed for self-verification, which can ensure that the reproduction script is continuously improved, thereby improving the quality of the reproduction script.
[0094] In some embodiments, in response to the execution result information of the first verification in the prompt information including that the reproduction script successfully reproduces the program defect to be reproduced, the current state is converted to the second verification state, and the current action is converted to verifying whether the reproduction script successfully reproduces the program defect to be reproduced using the second machine learning model (i.e., the second verification, or external verification). For example, in response to the execution result information of the second verification in the prompt information including that the reproduction script does not successfully reproduce the program defect to be reproduced, the current state is converted to the modification state, and the current action is converted to modifying the reproduction script using the first machine learning model; for example, in response to the execution result information of the second verification in the prompt information including that the reproduction script successfully reproduces the program defect to be reproduced, the current state is converted to the reporting state, and the current action is converted to reporting that the reproduction script successfully reproduces the program defect to be reproduced.
[0095] In this way, under the guidance of the prompt information, on the basis of the reproduction script passing the self-verification of the first machine learning model, the second machine learning model must be further called for external verification, which can ensure that the reproduction script is continuously improved under the verification of multiple machine learning models, thereby improving the quality of the reproduction script.
[0096] In some embodiments, after executing the current action, the first machine learning model may send a response message to the execution environment system to obtain feedback information from the execution environment system to guide the first machine learning model to perform the next state transition. For example, the response information may include the current action (Action) executed by the first machine learning model and the current state (State) corresponding to the current action; the response information may also include the thought (Thought) of the first machine learning model; and the feedback information may include the execution result (Observation) after the current action is executed, as well as the recommended next state.
[0097] This allows the machine learning model to guide the various processing of the reproduction script until the reproduction script can successfully reproduce the program defect, avoiding the generation of duplicate and false reproduction scripts. This improves the quality of the reproduction script and the bug reproduction effect.
[0098] For example, you can Figure 3 The embodiment in exemplarily illustrates the processing and reproducing script through the transition between states and the guidance of prompt information.
[0099] Figure 3 Schematic diagrams showing some embodiments of the iterative processing method of the replication script of the present disclosure.
[0100] like Figure 3 As shown, the iterative processing model guides and constrains the first machine learning model's modifications to the recurrence script through prompt information (such as feedback information). In each interaction with the first machine learning model, the first machine learning model's response includes thoughts, actions, and current state. The action and current state can be extracted from the response information and then executed in the runtime environment. Based on the current state and the conditions satisfied by the executed action, the feedback information from the runtime environment is used to guide the first machine learning model.
[0101] For example, feedback information includes the current observation, which is used to explain the conditions that are met and provide additional information, such as the execution details of the reproduction script, the explanation of the bug reproduction failure, the inspection report of the modification check failure, etc.; it can also include "state", which details the next state and the actions to be taken in the next state.
[0102] For example, based on the feedback information, the first machine learning model switches between different states and repeatedly modifies the reproduction script.
[0103] In state q0 (create), δ(q0,a) = q1. The first machine learning model creates the initial reproduction script. After creation is complete, condition a (creation completed) is satisfied, and the first machine learning model transitions to state q1 (execution). For example, the response information may include: Current thinking, I will create a reproduction script for the program defect; Current action, create statement; Current state, creation state; Feedback information may include: Current observation, you have created the initial reproduction script, now you should transition to...; Next state, execution state.
[0104] In state q1 (execution), δ(q1,b) = q2. The first machine learning model executes the replication script and obtains execution information (which may include output content and error information after execution). After execution is completed, condition b (execution completion) is met, and the first machine learning model transitions to state q2 (self-verification). For example, the response information may include: Current thinking, I am about to execute the replication script; Current action, execution statement; Current state, execution state; Feedback information may include: Current observation, you have executed the replication script, now you should transition to...; Next state, self-verification state.
[0105] In state q2 (self-verification), the first machine learning model verifies the execution information from q2 to determine whether the bug is accurately reproduced. For example, the response information may include: current thinking, I will verify whether the execution information reflects the bug; current action, self-verification statement; current state, self-verification state.
[0106] If the bug is accurately reproduced and condition c (self-verification passed) is met, the first machine learning model transitions the state to q3 (external verification), δ(q2,c)=q3; for example, the feedback information may include: current observation, you have verified that the execution information reflects the bug, now you should transition to...; next state, external verification state.
[0107] If the bug is not accurately reproduced, the first machine learning model explains the failure to reproduce the bug. If condition e (self-verification failure) is satisfied, the first machine learning model transitions the state to q5 (modify), where δ(q2,e) = q5. For example, the feedback information may include: Current observation, reproduction failure, now you should transition to...; Next state, modify the state.
[0108] In state q3 (external verification), another independent second machine learning model is used as the external verifier. Based on the current reproduction script from q0, the corresponding execution information from q1, and the context summary information, the second machine learning model determines whether the execution information accurately reflects the bug. For example, the response information may include: Current thinking, I will call the external machine learning model to verify the reproduction script; Current action, external verification statement; Current state, external verification status.
[0109] If the second machine learning model determines that the reproduction script accurately reflects the bug, then condition d (external verification passed) is satisfied, and the first machine learning model transitions its state to the accepting state q4 (report), where δ(q3, d) = q4. For example, the feedback information may include: Current observation, reproduction successful, now you should transition to...; Next state, report state.
[0110] If the second machine learning model determines that the reproduction script does not accurately reflect the bug, the second machine learning model explains why the bug reproduction failed. In this case, condition g (external verification failure) is met, and the first machine learning model transitions its state to q5 (modify), where δ(q3,f) = q5. For example, the feedback information may include: Current observation, reproduction failed, now you should transition to...; Next state, modify the state.
[0111] In state q4 (report), the first machine learning model submits the generated bug reproduction script and reports success, indicating that the bug has been successfully reproduced. For example, the response information may include: current thinking, I have successfully reproduced the bug, I will report the results; current action, report statement; current state, report status.
[0112] In state q5 (modify), the first machine learning model analyzes the explanation of the bug reproduction failure from q2 or q3, or the inspection report from q5, and provides modification suggestions. For example, the response information may include: Current thinking, I will modify the reproduction script; Current action, modify the statement; Current state, modify the state.
[0113] In some embodiments, before applying the modification, a check may be performed for modification restriction conditions such as Exceeded, Syntax, Repeated, and Authorized. If all of the conditions are met, the modification is applied.
[0114] The following examples illustrate the modification restrictions of the reproduction script.
[0115] In some embodiments, in response to the prompt result information including that the reproduction script fails to successfully reproduce the program defect to be reproduced, a machine learning model is used to determine a modification method for the reproduction script; whether the modification method meets the modification restriction conditions is checked; in response to meeting the modification restriction conditions, the modification method is applied to the reproduction script; in response to not meeting the modification restriction conditions, the modification method of the reproduction script is re-determined, or the reproduction script is regenerated.
[0116] For example, the modification restriction conditions include at least one of the following: the modification method includes outputting statements for the program defect to be reproduced; the modification method causes the modified reproduction script to be repeated with the historical reproduction script; modifying files other than the reproduction script; the modification method includes syntax errors; the number of modifications to the reproduction script exceeds a threshold.
[0117] For example, the modification restriction conditions may include restricting at least one of the following modifications: spurious modification, that is, the first machine learning model attempts to directly add statements such as print and raiseError to directly output the bug information to be reproduced, instead of reproducing the bug; repeated modification, repeated modification occurs during the iterative modification process, wasting the limited number of modifications and falling into useless modifications; unauthorized modification, involving code modifications other than modifying the reproduction script (such as modifying functional files in the code repository); grammatically incorrect modification, the modification does not meet the grammatical requirements, causing the grammar checking tool to report an error (such as incorrect indentation, mismatched brackets, etc.); excessive modification: the first machine learning model falls into endless modification during the iterative modification process.
[0118] For example, to avoid excessive modifications, you can configure the number of modifications. If the number of modifications exceeds the limit but a valid reproduction script is still not built, the current reproduction script is abandoned and a "restart" action is performed to regenerate the original reproduction script. This way, you can try more bug reproduction methods and increase the probability of successful reproduction.
[0119] In the above embodiment, by configuring modification restrictions as prompt information to guide the machine learning model in modifying the reproduction script, it is possible to avoid the generation of duplicate and false reproduction scripts. This improves the quality of the reproduction script and the bug reproduction effect.
[0120] For example, you can Figure 3 The embodiment in exemplarily illustrates the modification restriction conditions.
[0121] like Figure 3As shown, for overload checking, the number of applied modifications in the modification history is calculated. If the number exceeds a threshold, condition k is satisfied (overload checking failed), and the first machine learning model transitions the state to q6 (restart), where δ(q5,k) = q6. For example, the feedback information may include: Current observation: Your number of modification attempts exceeds the threshold, and you should now transition to...; Next state: Restart state.
[0122] For syntax checking, a syntax checking tool is used to verify the grammatical correctness of the modification. If a syntax bug is found, condition i is satisfied (syntax check failure), and the first machine learning model remains in state q5, with δ(q5, g) = q5. A detailed check report can also be provided, including the bug code and bug type. For example, feedback information may include: Current observation: Your modification contains syntax errors, and you should now maintain...; Next state: Modify the state.
[0123] For duplicate checking, it is necessary to evaluate whether the modification will result in a recurrence script identical to any previous version in the modification history. If so, condition h is satisfied (duplicate check failed), and the first machine learning model maintains the q5 state, δ(q5,h) = q5. A check report can be provided to the first machine learning model, explaining why the modification was duplicated; the report can also include the comprehensive context of the modification history. For example, feedback information can include: Current observation, your modification is duplicated, now you should maintain...; Next state, modified state.
[0124] For the authorization check, evaluate whether the first machine learning model attempted to modify a file in the original code repository, rather than the generated reproduction script. If so, condition i is satisfied (authorization check failure), and the first machine learning model remains in state q5, where δ(q5,i) = q5. A check report can be provided to the first machine learning model, explaining why the modification was unauthorized. For example, the feedback information may include: Current observation: Your modification is unauthorized, you should now maintain...; Next state: Modify state.
[0125] If the modification passes all the above checks, the modification is applied to the current reproduction script. Condition j (all checks passed) is satisfied, and the first machine learning model transitions its state to q1 (execution), where δ(q5,j) = q1. For example, the feedback information may include: Current observation, you modified the reproduction script, now you should transition to...; Next state, execution state.
[0126] In state q6 (restart), the first machine learning model summarizes the explanations of the bug reproduction failure in states q2 and q3. It can also clear the current reproduction script and its modification history to prepare for the first machine learning model to restart and create a new reproduction script. In this case, condition l (restart completed) is met, and the first machine learning model transitions the state to q0 (create), δ(q6,l) = q0. For example, the response information may include: Current thinking, I have tried to modify the reproduction script, but it didn't work; Current action, restart statement; Current state, restart state; Feedback information may include: Current observation, your number of modification attempts exceeds the threshold, now you should transition to...; Next state, restart state.
[0127] For example, to prevent the script modification process from becoming an endless loop, you can configure the maximum number of restart states; if the number of restarts reaches the maximum number, the first machine learning model stops modifying and outputs the current reproduction script
[0128] In the above embodiment, the guidance of the machine learning model includes: in each processing of the reproduction script, the machine learning model describes the current state through response information, so as to clarify the current processing stage and the action to be performed next; extract the current state from the response information and execute the extracted current action, and provide feedback information to the first machine learning model based on whether the current state and the execution result of the current action meet the state transition conditions (including additional information such as script execution information, reproduction failure explanation, modification inspection report, etc., and may also include information for describing the state that needs to be converted and the corresponding action); in each processing of the reproduction script, timely and effective external guidance information is provided through feedback information to constrain the decision of the first machine learning model and ensure efficient reproduction script construction.
[0129] In this way, the generation of duplicate and false reproduction scripts can be avoided, thereby improving the quality of the reproduction scripts and the bug reproduction effect.
[0130] Figure 4 A block diagram showing some embodiments of the program defect reproduction apparatus of the present disclosure.
[0131] like Figure 4As shown, the program defect reproduction device 4 includes: an execution unit 41, which is used to use a machine learning model to execute the current action on the reproduction script of the program defect to be reproduced; a sending unit 42, which is used to send the current action and the current state corresponding to the current action to the running environment of the program, and the program includes the program defect to be reproduced; a conversion unit 43, which is used to convert the current state into the next state and the current action into the next action corresponding to the next state according to the prompt information feedback from the running environment, and the prompt information includes the execution result information of the current action. The execution unit 41, the sending unit 42, and the conversion unit 43 repeat the above processing until the reproduction script successfully reproduces the program defect to be reproduced.
[0132] In some embodiments, the execution result information includes condition information satisfied by the execution result of the current action, and the next state corresponding to the condition information.
[0133] In some embodiments, the current action includes executing a reproduction script, the current state includes an execution state, and the execution unit 41 uses a first machine learning model to execute the reproduction script using a machine learning model. The conversion unit 43 responds to the execution result information including that the reproduction script has been executed, converts the current state to a first verification state, and converts the current action to verify whether the reproduction script successfully reproduces the program defect to be reproduced using the first machine learning model.
[0134] In some embodiments, in response to the execution result information including that the reproduction script fails to successfully reproduce the program defect to be reproduced, the conversion unit 43 converts the current state into a modification state and converts the current action into modifying the reproduction script using the first machine learning model.
[0135] In some embodiments, the conversion unit 43 converts the current state to a second verification state in response to the execution result information including that the reproduction script successfully reproduces the program defect to be reproduced, and converts the current action to verify whether the reproduction script successfully reproduces the program defect to be reproduced using the second machine learning model.
[0136] In some embodiments, in response to the execution result information including that the reproduction script fails to successfully reproduce the program defect to be reproduced, the conversion unit 43 converts the current state into a modification state and converts the current action into modifying the reproduction script using the first machine learning model.
[0137] In some embodiments, in response to the execution result information including the reproduction script successfully reproducing the program defect to be reproduced, the conversion unit 43 converts the current state into a reporting state and converts the current action into reporting that the reproduction script successfully reproduced the program defect to be reproduced.
[0138] In some embodiments, the execution unit 41 responds to the prompt result information including that the reproduction script fails to successfully reproduce the program defect to be reproduced, uses a machine learning model to determine the modification method of the reproduction script, checks whether the modification method meets the modification restrictions, applies the modification method to the reproduction script in response to meeting the modification restrictions, and redetermines the modification method of the reproduction script in response to not meeting the modification restrictions, or regenerates the reproduction script.
[0139] In some embodiments, the modification restriction condition includes at least one of the following: the modification method includes outputting a statement of the program defect to be reproduced; the modification method causes the modified reproduction script to be repeated with the historical reproduction script; modifying files other than the reproduction script; the modification method includes a syntax error; the number of modifications to the reproduction script exceeds a threshold.
[0140] In some embodiments, the program defect reproduction device 4 also includes: a generation unit 44, which is used to use a machine learning model to screen out code snippets related to the program defect to be reproduced based on the degree of correlation between the code snippets in the program's code repository and the problem description information of the program, and use the machine learning model to generate a reproduction script for the program defect to be reproduced based on the relevant code snippets.
[0141] In some embodiments, the generating unit 44 selects multiple candidate code snippets from the code repository according to the relevance, sorts the multiple candidate code snippets according to the relevance, and selects relevant code snippets from the multiple candidate code snippets according to the sorting result.
[0142] In some embodiments, the generation unit 44 generates context summary information of the program defect to be reproduced based on the relevant information of the program defect to be reproduced in the problem description information, the test information of the program defect to be reproduced in the code repository, and at least one of the explanation information; and generates a reproduction script based on the context summary information and related code snippets.
[0143] In the above embodiment, the recurrence script is iteratively processed based on the prompt information fed back by the current state and current action of the operating environment. In this way, the quality of the recurrence script can be improved under the guidance of multiple rounds of prompt information, thereby improving the bug recurrence effect.
[0144] According to some embodiments of the present disclosure, a program defect reproduction device is provided, comprising: a memory; and a processor coupled to the memory, wherein the processor is configured to execute the program defect reproduction method in any of the above embodiments based on instructions stored in the memory device.
[0145] For example, you can Figure 5 、 Figure 6 The embodiments in the present invention implement the program defect reproduction device of the present invention.
[0146] Figure 5 A block diagram showing some other embodiments of the program defect reproduction device of the present disclosure.
[0147] like Figure 5 The memory 51 is used to store one or more computer-readable instructions. The memory 51 may include any combination of various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory, including but not limited to random access memory (RAM), dynamic random access memory (DRAM), static random access memory (SRAM), read-only memory (ROM), and flash memory. The memory 51 may store, for example, an operating system, application programs, a boot loader, a database, and other programs, as well as various application programs and various data.
[0148] The processor 52 is used to run computer-readable instructions to implement the program defect reproduction method described in any of the above embodiments. The specific implementation of each step of the program defect reproduction method can be referred to the above embodiments, and the repeated parts are not repeated here.
[0149] The processor 52 can be configured to execute each step of the program defect reproduction method in any of the above embodiments. The processor 52 can be embodied as various processing devices, such as a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The central processing unit (CPU) can be of X86 or ARM architecture, etc.
[0150] The processor 52 and the memory 51 can communicate with each other directly or indirectly. For example, the processor 52 and the memory 51 can communicate via a network. The network can include a wireless network, a wired network, and / or any combination of wireless and wired networks. The processor 52 and the memory 51 can also communicate with each other via a system bus, which is not limited in this disclosure.
[0151] It should be noted that Figure 5 The components of the program defect reproduction device 51 shown are merely exemplary and non-limiting. The program defect reproduction device 5 may also have other components according to actual application requirements. The processor 52 may control other components in the program defect reproduction device 5 to perform desired functions.
[0152] The program defect reproduction device 5 can be implemented by software, firmware and / or hardware, and can be integrated into a device installed with relevant application programs.
[0153] Figure 6A block diagram showing some further embodiments of the program defect reproduction apparatus of the present disclosure.
[0154] Figure 6 The program defect reproduction device 6 shown can be a computer system with a dedicated hardware structure, which can execute corresponding functions when a related application program is installed.
[0155] The program defect reproduction device 6 includes but is not limited to mobile terminals such as smart phones, laptops, personal digital assistants (PDAs), tablet personal computers (Tablet PCs), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), wearable devices, etc., as well as fixed terminals such as digital televisions, desktop computers, etc.
[0156] like Figure 6 As shown, the central processing unit (CPU) 61 executes various processes according to the program stored in the read-only memory (ROM) 62 or the program loaded from the storage unit 68 to the random access memory (RAM) 63. In the RAM 63, data required when the CPU 61 executes various processes is stored as needed. The central processing unit is merely an example, and it may also be other types of processors, such as the various processors described above. The ROM 62, RAM 63 and storage unit 68 may be various forms of computer-readable storage media. It should be noted that although Figure 6 ROM 62, RAM 63 and storage portion 68 are shown separately in FIG, but one or more of them may be combined or located in the same or different memory or storage modules.
[0157] The CPU 61, the ROM 62, and the RAM 63 are connected to one another via a bus 64. To the bus 64, an input / output interface 65 is also connected.
[0158] The following components are connected to the input / output interface 65: an input portion 66 such as a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output portion 67 including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage portion 68 including a hard disk, a magnetic tape, etc.; and a communication portion 69 including a network interface card such as a LAN card, a modem, etc. The communication portion 69 allows communication processing to be performed via a network such as the Internet. It is easy to understand that although Figure 6It is shown that parts of the program defect reproduction device 6 communicate through the bus 64, but they can also communicate through a network or other means, wherein the network may include a wireless network, a wired network, and / or any combination of a wireless network and a wired network.
[0159] A drive 610 is also connected to the input / output interface 65 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is mounted on the drive 610 as needed so that a computer program read therefrom is installed in the storage section 68 as needed.
[0160] When the series of processing described above is implemented by software, the program constituting the software can be installed from a network such as the Internet or a storage medium such as the removable medium 611 .
[0161] According to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, some embodiments of the present disclosure include a computer program product, which, when running on a computer, enables the computer to implement the program defect reproduction method described in any of the aforementioned embodiments. The computer program product includes computer instructions carried on a computer-readable medium, containing program code for executing the method shown in the flowchart. In such an embodiment, the computer instructions can be downloaded and installed from the network through the communication part 69, or installed from the storage part 68, or installed from the ROM 62. When the computer program is executed by the CPU 61, the program defect reproduction method of any embodiment of the present disclosure is executed.
[0162] In the above embodiment, the recurrence script is iteratively processed based on the prompt information fed back by the current state and current action of the operating environment. In this way, the quality of the recurrence script can be improved under the guidance of multiple rounds of prompt information, thereby improving the bug recurrence effect.
[0163] According to some further embodiments of the present disclosure, a computer-readable storage medium is provided, on which computer instructions are stored. When the instructions are executed by a processor, the program defect reproduction method in any of the above embodiments is implemented.
[0164] It should be noted that, in the context of the present disclosure, a computer-readable medium may be a tangible medium that may contain or store a program for use by an instruction execution system, apparatus, or device or for use in conjunction with an instruction execution system, apparatus, or device.
[0165] The computer readable medium may be a computer readable storage medium, or a computer readable signal medium, or any combination of the two.
[0166] Computer-readable storage media include, but are not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or components, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or device. Computer instructions are stored on the computer-readable storage medium, and when the instructions are executed by the processor, the program defect reproduction method described in any of the aforementioned embodiments is implemented.
[0167] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0168] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0169] In the above embodiment, the recurrence script is iteratively processed based on the prompt information fed back by the current state and current action of the operating environment. In this way, the quality of the recurrence script can be improved under the guidance of multiple rounds of prompt information, thereby improving the bug recurrence effect.
[0170] In some embodiments, a computer program product is further provided, comprising: instructions, which, when executed by a processor, cause the processor to execute the program defect reproduction method described in any of the aforementioned embodiments. For example, the instructions may be embodied as computer program code.
[0171] In embodiments of the present disclosure, computer program code for performing the operations of the present disclosure can be written in one or more programming languages or combinations thereof, including but not limited to object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In situations involving a remote computer, the remote computer can be connected to the user's computer via any type of network (including a local area network (LAN) or a wide area network (WAN)), or can be connected to an external computer (e.g., using an Internet service provider to connect via the Internet).
[0172] In the above embodiment, the recurrence script is iteratively processed based on the prompt information fed back by the current state and current action of the operating environment. In this way, the quality of the recurrence script can be improved under the guidance of multiple rounds of prompt information, thereby improving the bug recurrence effect.
[0173] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0174] The functions described above may be performed at least in part by one or more hardware logic components. For example, and without limitation, exemplary hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0175] Although some specific embodiments of the present disclosure have been described in detail by way of examples, those skilled in the art will appreciate that the above examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Those skilled in the art will appreciate that modifications may be made to the above embodiments without departing from the scope and spirit of the present disclosure. The scope of the present disclosure is defined by the appended claims.
Claims
1. A method for reproducing a program defect, comprising: Use the machine learning model to execute the current action on the reproduction script that reproduces the program defect; Sending the current action and a current state corresponding to the current action to a running environment of a program, wherein the program includes the program defect to be reproduced; According to the prompt information fed back by the operating environment, the current state is converted to the next state, and the current action is converted to the next action corresponding to the next state, wherein the prompt information includes the execution result information of the current action; Repeat the above steps until the reproduction script successfully reproduces the program defect to be reproduced.
2. The program defect reproduction method according to claim 1, wherein: The execution result information includes condition information satisfied by the execution result of the current action and the next state corresponding to the condition information.
3. The program defect reproduction method according to claim 1, wherein: The current action includes executing the recurrence script, and the current state includes an execution state. The machine learning model is used to execute the following actions on the reproduction script of the program defect to be reproduced: Executing the reproduction script using the first machine learning model; The converting the current state to the next state and converting the current action to the next action corresponding to the next state according to the prompt information fed back by the operating environment includes: In response to the execution result information including that the reproduction script is executed, the current state is converted to a first verification state, and the current action is converted to using the first machine learning model to verify whether the reproduction script successfully reproduces the program defect to be reproduced.
4. The program defect reproduction method according to claim 3, wherein: The converting the current state to the next state and converting the current action to the next action corresponding to the next state according to the prompt information fed back by the operating environment includes: In response to the execution result information including that the reproduction script fails to successfully reproduce the program defect to be reproduced, the current state is converted to a modification state, and the current action is converted to modifying the reproduction script using the first machine learning model.
5. The program defect reproduction method according to claim 3, wherein: The converting the current state to the next state and converting the current action to the next action corresponding to the next state according to the prompt information fed back by the operating environment includes: In response to the execution result information including that the reproduction script successfully reproduces the program defect to be reproduced, the current state is converted to a second verification state, and the current action is converted to using a second machine learning model to verify whether the reproduction script successfully reproduces the program defect to be reproduced.
6. The program defect reproduction method according to claim 5, wherein: The converting the current state to the next state and converting the current action to the next action corresponding to the next state according to the prompt information fed back by the operating environment includes: In response to the execution result information including that the reproduction script fails to successfully reproduce the program defect to be reproduced, the current state is converted to the modified state, and the current action is converted to modifying the reproduction script using the first machine learning model.
7. The program defect reproduction method according to claim 6, wherein: The converting the current state to the next state and converting the current action to the next action corresponding to the next state according to the prompt information fed back by the operating environment includes: In response to the execution result information including that the reproduction script successfully reproduces the program defect to be reproduced, the current state is converted to a reporting state, and the current action is converted to reporting that the reproduction script successfully reproduces the program defect to be reproduced.
8. The program defect reproduction method according to claim 1, wherein: The machine learning model is used to execute the following actions on the reproduction script of the program defect to be reproduced: In response to the prompt result information including that the reproduction script fails to successfully reproduce the program defect to be reproduced, determining a modification method for the reproduction script using the machine learning model; Check whether the modification method complies with the modification restriction conditions; In response to meeting the modification restriction condition, applying the modification method to the reproduction script; In response to not meeting the modification restriction condition, redetermining a modification method of the reproduction script, or regenerating the reproduction script.
9. The program defect reproduction method according to claim 8, wherein: The modification restriction condition includes at least one of the following: The modification method includes outputting a statement of the program defect to be reproduced; The modification method causes the modified reproduction script to be duplicated with the historical reproduction script; Modify files other than the reproduction script; Said modification method includes grammatical errors; The number of modifications to the reproduction script exceeds a threshold.
10. The program defect reproduction method according to any one of claims 1 to 9, further comprising: Using the machine learning model, based on the degree of correlation between the code snippets in the program's code repository and the problem description information of the program, filter out code snippets related to the program defect to be reproduced; Utilize the machine learning model and generate a reproduction script for the program defect to be reproduced based on the relevant code snippets.
11. The program defect reproduction method according to claim 10, wherein: The method of using the machine learning model to screen out code snippets related to the program defect to be reproduced based on the degree of relevance between the code snippets in the program's code repository and the problem description information of the program includes: Based on the relevance, multiple candidate code snippets are screened from the code repository; Sorting the plurality of candidate code snippets according to the relevance; According to the sorting result, the relevant code snippets are screened out from the multiple candidate code snippets.
12. The program defect reproduction method according to claim 10, wherein: The generating a reproduction script for the program defect to be reproduced by using the machine learning model according to the relevant code snippets includes: Generate context summary information of the program defect to be reproduced based on at least one of the relevant information of the program defect to be reproduced in the problem description information, the test information of the program defect to be reproduced in the code repository, and the explanation information; The reproduction script is generated according to the context summary information and the relevant code snippets.
13. A program defect reproduction device, comprising: An execution unit, configured to use a machine learning model to execute a current action on a reproduction script for a program defect to be reproduced; a sending unit, configured to send the current action and a current state corresponding to the current action to a running environment of a program, wherein the program includes the program defect to be reproduced; a conversion unit, configured to convert the current state into a next state and convert the current action into a next action corresponding to the next state according to the prompt information fed back by the operating environment, wherein the prompt information includes execution result information of the current action; The execution unit, the sending unit, and the conversion unit repeat the above processing until the reproduction script successfully reproduces the program defect to be reproduced.
14. A program defect reproduction device, comprising: Memory; and A processor coupled to the memory, wherein the processor is configured to execute the program defect reproduction method according to any one of claims 1 to 12 based on instructions stored in the memory.
15. A computer-readable storage medium storing computer instructions, wherein when the instructions are executed by a processor, the program defect reproduction method according to any one of claims 1 to 12 is implemented. 16 . A computer program product comprising instructions, which, when executed by a processor, cause the processor to execute the program defect reproduction method according to claim 1 .