A method for dynamic debugging of program development code

By adjusting breakpoint settings and debugging strategies according to code characteristics in the code development process, the problem of dynamic debugging in the existing technology is solved, and the development efficiency and code quality are improved.

CN118779243BActive Publication Date: 2025-05-06北京科杰科技有限公司
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410999494.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-24
Publication Date
2025-05-06
Estimated Expiration
2044-07-24

AI Technical Summary

Technical Problem

In the prior art, the code development process involves multiple links such as coding, compilation, testing and deployment, and dynamic debugging cannot be achieved, resulting in low efficiency.

Method used

By writing script files, determine the number of breakpoints set during the compilation process and the status of error prompts based on the complexity of the code characteristics, and adjust the debugging process to improve efficiency.

Benefits of technology

Improves compilation and debugging efficiency, reduces resource waste, reduces testing costs, and improves code quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118779243B_ABST
    Figure CN118779243B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of program development technology, and in particular to a method for dynamic debugging of program development code, comprising: writing a script file; determining to set breakpoints in the code during the compilation of the script file according to the complexity of the code features in the script file, and determining the state of the error prompt of the corresponding segment code for setting the breakpoint; determining to debug the code in the script file according to the state of the error prompt during the compilation of the script file; determining to adjust the number of breakpoints in the compilation process of the script file according to the modification ratio of the code during the debugging of the script file; recompiling the debugged script file; and determining to adjust the debugging process of the script file according to the fluency in the recompiling process. The present invention overcomes the problem of low efficiency in the prior art due to the fact that the code development process involves multiple links such as coding, compilation, testing and deployment, and dynamic debugging cannot be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of program development, and in particular to a method for dynamic debugging of program development codes. Background Art

[0002] Code debugging plays a very important role in software development. It is an indispensable part of the development process. It is the process of analyzing, troubleshooting and correcting programs. In the actual development process, code debugging can help developers find potential problems in the program and improve the quality of the code. At the same time, code debugging can allow developers to gain an in-depth understanding of the program's operating mechanism and improve programming skills and experience. In short, code debugging is an important part of ensuring program quality and stability. However, traditional code debugging methods are often inefficient and cannot meet the needs of real-time debugging.

[0003] Chinese Patent Publication No.: CN106649087A discloses a code debugging method and device, wherein the method includes: obtaining entry parameters of a code modulation device; obtaining a search library chain corresponding to a logged-in user; modifying the search library chain so that the search priority of the temporary database is higher than the search priority of databases corresponding to each development level in the integrated development environment; copying the program from the integrated development environment to the temporary database according to the name of the program and the level of the program; calling a compilation command corresponding to the type of the program according to the type of the program to compile the program in the temporary database and generate a debugging code; debugging the debugging code to obtain a debugging result.

[0004] It can be seen that the existing technology has the problem of low efficiency due to the inability to implement dynamic debugging in multiple links such as coding, compiling, testing and deployment involved in the code development process. Summary of the invention

[0005] To this end, the present invention provides a method for dynamic debugging of program development codes, so as to overcome the problem of low efficiency in the prior art due to the inability to implement dynamic debugging in multiple links such as coding, compiling, testing and deployment involved in the code development process.

[0006] To achieve the above object, the present invention provides a method for dynamically debugging program development code, comprising:

[0007] Write script files;

[0008] Determine, according to the complexity of the code features in the script file, to set a breakpoint in the code during the compilation of the script file, and determine the state of the error prompt of the set breakpoint;

[0009] Determining the debugging of the code in the script file according to the state of the error prompt during the compilation process of the script file;

[0010] Determining the adjustment of the number of breakpoints in the compilation process of the script file according to the modification ratio of the code in the debugging process of the script file;

[0011] Recompile the debugged script file;

[0012] The adjustment of the debugging process of the script file is determined according to the fluency of the re-compilation process.

[0013] Furthermore, determining the compilation of the script file based on code features in the script file includes determining a complexity evaluation value of the script file based on the code features, determining the number of breakpoints to be set in the code of the script file based on the complexity evaluation value, and compiling each code segment.

[0014] Further, determining the number of breakpoints to be set in the script file according to the complexity evaluation value includes setting the number of breakpoints to a first preset number under the condition that the complexity evaluation value is less than or equal to a preset complexity evaluation value.

[0015] Further, determining the number of breakpoints to be set in the script file according to the complexity evaluation value includes setting the number of breakpoints to a second preset number under the condition that the complexity evaluation value is greater than a preset complexity evaluation value.

[0016] Furthermore, determining the debugging of the code in the script file according to the state of the error prompt during the compilation process of the script file includes modifying the code at the corresponding position of the error prompt under the condition that the state of the error prompt is clear.

[0017] Furthermore, the determining of modification of the code in the script file according to the status of the error prompt during the compilation of the script file includes, under the condition that the status of the error prompt is unclear, modifying the code at the corresponding position of the error prompt according to historically similar error prompts in a database, including determining the modification of the code of the script file according to a comparison result of the similarity with a preset similarity.

[0018] Further, determining the adjustment of the compilation of the script file according to the modification ratio of the code during the debugging of the script file includes adjusting the number of breakpoints according to an adjustment coefficient under the condition that the modification ratio of the code is greater than a preset ratio.

[0019] Further, determining to adjust the debugging process of the script file according to the fluency of the re-compilation process includes determining a fluency evaluation value of the compilation process, and determining to adjust the debugging process of the script file according to a comparison result of the fluency evaluation value and a preset fluency evaluation value.

[0020] Further, determining to adjust the debugging process of the script file according to the comparison result of the fluency evaluation value and the preset fluency evaluation value includes adjusting the debugging process of the script file under the condition that the fluency evaluation value is less than or equal to the preset fluency evaluation value.

[0021] Further, adjusting the debugging process of the script file includes determining the adjustment of the debugging process of the script file according to a comparison result between a difference between the fluency evaluation value and a preset fluency evaluation value and a difference between the preset fluency evaluation values.

[0022] Compared with the prior art, the beneficial effects of the present invention lie in that by determining the compilation of the script file according to the code features of the script file, and selecting different numbers of breakpoints to set when the comparison result of the complexity evaluation value of the script file is different from the preset complexity evaluation value, the compilation efficiency and debugging efficiency can be improved; it helps to improve the execution efficiency of the code and reduce unnecessary waste of resources; and by reasonably setting breakpoints, it helps to reduce testing costs and improve overall quality.

[0023] Furthermore, the present invention determines the debugging of the script file through the error prompt status during the compilation process of the script file, so that the modification of the code is more targeted, the debugging efficiency is improved, and the debugging difficulty can be reduced to a certain extent; different debugging methods are selected according to the error prompt status, which reflects the flexibility and scalability of the debugging strategy. As the project progresses and the complexity of the code increases, the debugging strategy can be adjusted according to the actual situation to better adapt to different needs.

[0024] Furthermore, the present invention determines the adjustment of the number of breakpoints in the compilation process of the script file according to the modification ratio of the code in the debugging process of the script file. When the modification ratio of the code is high, it usually means that there are more error repairs and code reconstructions in the code. At this time, appropriately increasing the number of breakpoints can ensure that the compilation process covers more code paths and scenarios, thereby improving efficiency; by increasing the number of breakpoints, it is easier to track and manage the debugging process. In the adjustment process, a specific adjustment coefficient is set to avoid over-adjustment.

[0025] Furthermore, the present invention adjusts the debugging process of the script file by determining according to the fluency in the re-compilation process, and adjusts the debugging process of the script file under the condition that the flow degree evaluation value is less than or equal to a preset fluency evaluation value. When the fluency evaluation value does not meet the standard, it means that there are still some errors or unresolved problems in the code, and the debugging process of the code needs to be adjusted.

[0026] Furthermore, the present invention can make the adjustment of the code more targeted and make the result more accurate by determining different adjustment methods for the debugging process of the script file according to the difference between the fluency evaluation value and the preset fluency evaluation value and the difference between the preset fluency evaluation values. At the same time, a specific adjustment coefficient is set during the adjustment process to avoid over-adjustment.

[0027] Furthermore, the present invention overcomes the problem of low efficiency in the prior art due to the inability to implement dynamic debugging in multiple links such as coding, compiling, testing and deployment involved in the code development process. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 A flowchart of a method for dynamically debugging program development code according to an embodiment of the present invention;

[0029] Figure 2 A flowchart of the compilation process in the method for dynamic debugging of program development code according to an embodiment of the present invention;

[0030] Figure 3 A flowchart of the debugging process in the method for dynamic debugging of program development code according to an embodiment of the present invention;

[0031] Figure 4 The present invention is a flowchart of adjusting the debugging process of a script file in the method for dynamically debugging program development code according to an embodiment of the present invention. DETAILED DESCRIPTION

[0032] In order to make the objects and advantages of the present invention more clearly understood, the present invention is further described below in conjunction with embodiments; it should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0033] The preferred embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.

[0034] It should be noted that, in the description of the present invention, terms such as "up", "down", "left", "right", "inside" and "outside" indicating directions or positional relationships are based on the directions or positional relationships shown in the drawings. This is merely for the convenience of description and does not indicate or imply that the device or element must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it cannot be understood as a limitation on the present invention.

[0035] In addition, it should be noted that in the description of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0036] Example

[0037] See also Figure 1-Figure 3 As shown, the embodiment of the present invention is used for a method for dynamic debugging of program development code, including:

[0038] Step S1, writing a script file;

[0039] Step S2, determining to set a breakpoint in the code during the compilation of the script file according to the complexity of the code features in the script file, and determining the state of the error prompt of the corresponding code segment where the breakpoint is set;

[0040] Step S3, determining the debugging of the code in the script file according to the state of the error prompt during the compilation process of the script file;

[0041] Step S4, determining the adjustment of the number of breakpoints in the compilation process of the script file according to the modification ratio of the code in the debugging process of the script file;

[0042] Step S5, recompile the debugged script file.

[0043] Step S6: Determine the adjustment of the debugging process of the script file according to the fluency of the re-compilation process.

[0044] Specifically, determining the compilation of the script file based on the code features in the script file includes determining a complexity evaluation value P of the script file based on the code features, determining the number N of breakpoints to be set in the code of the script file based on the complexity evaluation value P, and compiling each section of code.

[0045] In the embodiment of the present invention, the code features include the total number of code lines, the number of structures, the loop nesting depth, and the number of function calls.

[0046] In the embodiment of the present invention, the complexity evaluation value is calculated according to the following formula, and is set:

[0047] P=ω1×C+ω2×D+ω3×E+ω3×F

[0048] Where P represents the complexity evaluation value, ω1, ω2, ω3, and ω4 represent weight coefficients, C represents the number of rows, D represents the number of structures, E represents the loop nesting depth, and F represents the number of function calls.

[0049] In the embodiment of the present invention, the sum of the weight coefficients ω1, ω2, ω3, and ω4 is 1, the value of ω1 is 0.1, the value of ω2 is 0.3, the value of ω3 is 0.3, and the value of ω4 is 0.3.

[0050] Specifically, determining the number N of breakpoints to be set in the script file according to the complexity evaluation value P includes:

[0051] If P≤P0, the number of breakpoints is set to a first preset number N1;

[0052] If P>P0, the number of breakpoints is set to a second preset number N2.

[0053] In the embodiment of the present invention, the preset complexity evaluation value is 50.

[0054] In an embodiment of the present invention, the locations where the breakpoints are set include the beginning and end of a loop, before and after a function call, and at the judgment point of a conditional statement. The value of the first number N1 is 20, and the value of the second preset number N2 is 50.

[0055] In an embodiment of the present invention, when the comparison result of the complexity evaluation value of the script file and the preset complexity evaluation value is different, choosing to set a different number of breakpoints can improve compilation efficiency and debugging efficiency; help improve code execution efficiency and reduce unnecessary waste of resources; and through reasonable setting of breakpoints, help reduce testing costs and improve overall quality.

[0056] Specifically, determining the debugging of the code in the script file according to the state of the error prompt during the compilation of the script file includes modifying the code at the corresponding position of the error prompt under the condition that the state of the error prompt is clear.

[0057] In the embodiment of the present invention, the situation where the state of the error prompt is clear includes:

[0058] Syntax errors, including indentation and spacing errors, keyword errors such as writing "if" as "iff", operator errors such as writing "==" as "=", and expression errors such as missing parentheses;

[0059] Initialization errors, including variables not being initialized or variables with incorrect initialization values;

[0060] Declaration errors, including undeclared variables, undeclared functions, and incorrect function parameters;

[0061] Control flow errors, including logic errors such as errors in logical expressions in "if, for, while" statements, loop errors such as loop control expression errors that cause the loop to fail to execute normally or fall into an infinite loop, and branch errors such as branch condition errors in "switch" statements;

[0062] Pointer errors, including uninitialized pointer, pointer type mismatch, and pointer operation errors.

[0063] In the embodiment of the present invention, under the condition that the state of the error prompt is clear, the code at the corresponding position is modified according to the error prompt.

[0064] Specifically, determining the modification of the code in the script file according to the state of the error prompt during the compilation of the script file includes modifying the code at the corresponding position of the error prompt according to historically similar error prompts in a database when the state of the error prompt is unclear.

[0065] Specifically, the code modification is determined based on the comparison result of the similarity Y of the historically similar error prompts in the database with the preset similarity Y0, including:

[0066] If Y ≥ Y0, the error code is replaced according to the historical modification code in the database;

[0067] If Y<Y0, the codes with problems are screened and the screened codes are deleted.

[0068] Specifically, the screening of problematic codes includes screening out code combinations that do not exist in the historical database.

[0069] In the embodiment of the present invention, the similarity Y is determined according to the ratio of the number of similar code lines in the error prompt to the total number of code lines.

[0070] In the embodiment of the present invention, the situation where the state of the error prompt is unclear includes:

[0071] Runtime errors, such as memory leaks and null pointer references. If such runtime errors occur, the compiler does not give clear error messages.

[0072] Resource or dependency issues, such as when the program lacks necessary resource files, library dependencies, or environment configuration, the compiler will not give obvious error prompts;

[0073] Permission or security issues. In this case, there will be no obvious error prompts during the compilation process.

[0074] In the embodiment of the present invention, the debugging of the script file is determined by the error prompt status during the compilation process of the script file, so that the modification of the code is more targeted, the debugging efficiency is improved, and the debugging difficulty can be reduced to a certain extent; different debugging methods are selected according to the error prompt status, which reflects the flexibility and scalability of the debugging strategy. As the project progresses and the complexity of the code increases, the debugging strategy can be adjusted according to the actual situation to better adapt to different needs.

[0075] Specifically, the step of determining the adjustment of the compilation of the script file according to the modification ratio L of the code during the debugging of the script file includes:

[0076] If L>L0, the number of breakpoints N is adjusted according to the adjustment coefficient;

[0077] If L≤L0, the number of breakpoints N is not adjusted.

[0078] In the embodiment of the present invention, the modification ratio of the code is determined according to the ratio of the number of modified code lines ΔH to the total number of code lines, and the value of the preset ratio L0 is 20%.

[0079] In the embodiment of the present invention, the adjustment coefficient is Where represents the number of lines of code that were modified.

[0080] In an embodiment of the present invention, the number of breakpoints in the compilation process of the script file is adjusted according to the modification ratio of the code in the debugging process of the script file. When the modification ratio of the code is high, it usually means that there are more error repairs and code reconstructions in the code. At this time, appropriately increasing the number of breakpoints can ensure that the compilation process covers more code paths and scenarios, thereby improving efficiency; by increasing the number of breakpoints, it is easier to track and manage the debugging process. In the adjustment process, by setting a specific adjustment coefficient, over-adjustment is avoided.

[0081] Specifically, determining to adjust the debugging process of the script file according to the fluency of the re-compilation process includes determining a fluency evaluation value Q of the compilation process, and determining to adjust the debugging process of the script file according to a comparison result between the fluency evaluation value Q and a preset fluency evaluation value Q0.

[0082] In the embodiment of the present invention, the fluency evaluation value is calculated according to the following formula, and is set:

[0083]

[0084] Among them, Q represents the fluency evaluation value, T represents the total time of code compilation, B represents the CPU usage, M represents the memory usage, and S represents the error rate.

[0085] Specifically, determining to adjust the debugging process of the script file according to the comparison result of the fluency evaluation value Q and the preset fluency evaluation value Q0 includes:

[0086] If Q≤Q0, the debugging process of the script file is adjusted;

[0087] If Q>Q0, the debugging process of the script file is not adjusted.

[0088] Specifically, adjusting the debugging process of the script file includes determining the adjustment of the debugging process of the script file according to a comparison result of a difference ΔQ between the fluency evaluation value Q and a preset fluency evaluation value Q0 and a preset fluency evaluation value difference ΔQ0;

[0089] If ΔQ≤ΔQ0, the segment codes between the breakpoints are debugged segment by segment, and the segment codes are modified segment by segment;

[0090] If ΔQ>ΔQ0, the preset similarity Y0 is adjusted according to the adjustment coefficient X2.

[0091] Specifically, the adjustment coefficient X2 is

[0092] Specifically, adjusting the debugging process of the script file includes:

[0093] In the embodiment of the present invention, the preset fluency evaluation value is 0.5, and under the condition that the fluency evaluation value is less than or equal to the preset fluency evaluation value, the debugging process of the script file is adjusted.

[0094] In an embodiment of the present invention, the debugging process of the script file is adjusted by determining the adjustment according to the fluency in the re-compilation process. Under the condition that the flow degree evaluation value is less than or equal to a preset fluency evaluation value, the debugging process of the script file is adjusted. When the fluency evaluation value does not meet the standard, it means that there are still some errors or unresolved problems in the code, and the debugging process of the code needs to be adjusted.

[0095] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.

[0096] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for dynamic debugging of program development code, characterized in that: include: Write script files; Determine, according to the complexity of the code features in the script file, to set breakpoints in the code during the compilation of the script file, compile each code segment, and determine the state of the error prompt of the code segment corresponding to the breakpoint; Wherein, the complexity of the script file is determined according to the code features, and the complexity evaluation value is calculated according to the following formula, setting: P=ω1×C+ω2×D+ω3×E+ω3×F Where P represents the complexity evaluation value, ω1, ω2, ω3, ω4 represent weight coefficients, C represents the number of rows, D represents the number of structures, E represents the loop nesting depth, and F represents the number of function calls; Determining the debugging of the code in the script file according to the state of the error prompt during the compilation process of the script file; Determining the adjustment of the number of breakpoints in the compilation process of the script file according to the modification ratio of the code in the debugging process of the script file; Recompile the debugged script file; Determining the adjustment of the debugging process of the script file according to the fluency of the re-compilation process, including determining the fluency evaluation value of the compilation process, setting, Among them, Q represents the fluency evaluation value, T represents the total time of code compilation, B represents the CPU usage, M represents the memory usage, and S represents the error rate.

2. The program development code dynamic debugging method according to claim 1, characterized in that: Under the condition that the state of the error prompt is clear, the code at the corresponding position of the error prompt is modified.

3. The program development code dynamic debugging method according to claim 1, characterized in that: Under the condition that the state of the error prompt is unclear, the code at the corresponding position of the error prompt is modified according to the historically similar error prompts in the database, and the modification of the code of the script file is determined according to the comparison result of the similarity with the preset similarity.

4. The method for dynamic debugging of program development code according to claim 1, characterized in that: Under the condition that the modification ratio of the code is greater than the preset ratio, the number of breakpoints is adjusted according to the adjustment coefficient X1, and the setting Where ΔH is the number of lines of modified code.

Citation Information

Patent Citations

  • Code debugging method and apparatus

    CN106649087A

  • Compiler plug-in debugging method and device, computer device and readable storage medium

    CN109542773A

  • Script debugging method and device and computer storage medium

    CN109783342A