Program code data processing method and device, electronic equipment and storage medium

By obtaining and analyzing the code call chain in the server running data, the problem of virtual prop output and consumption of business code modification in online games affects analysis, and improves analysis efficiency and accuracy.

CN119621525AActive Publication Date: 2025-03-14NETEASE (HANGZHOU) NETWORK CO LTD

Patent Information

Application Number
CN202411533213.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-30
Publication Date
2025-03-14
Estimated Expiration
2044-10-30

AI Technical Summary

Technical Problem

During the development and testing of online games, the output and consumption of virtual props involve a large amount of business code modification, which makes it difficult to fully test, and it is difficult for the existing technology to accurately analyze the scope of impact of code modification on the game economic system.

Method used

By obtaining the running data generated by the target program code running by the server, determining the code call chain of the target execution statement, and analyzing the code difference data of the functions indicated by the code call chain to understand the scope of influence of code modification.

Benefits of technology

Improves the efficiency of business functions that analyze the impact of code modification, enhances the accuracy of analyzing the impact of business impact, and helps developers to accurately and reliably review the impacts involved in code changes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119621525A_ABST
    Figure CN119621525A_ABST
Patent Text Reader

Abstract

The invention provides a program code data processing method and device, electronic equipment and a storage medium. The method comprises the steps of obtaining first running data generated when a server runs a target program code of a first version; obtaining a target execution statement from the first operation data, and determining a code call chain corresponding to the target execution statement based on the first operation data; and determining code difference data of the function indicated by the code call chain based on the target program code of the second version and the target program code of the first version. In the mode, a user can clearly understand the code execution process corresponding to the preset requirement influenced by the modified function by checking the code calling chain, the efficiency of analyzing the service function influenced by code modification is improved, the code calling chain is generated based on the operation data of the server, the code calling relation is more accurate, and the user experience is improved. Therefore, the analysis accuracy of the business influence effect is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of program code technology, and in particular to a method, device, electronic device and storage medium for processing program code data. Background Art

[0002] The game economy is the core system of online games. The game economy is manifested in the output and consumption of various virtual props during the game operation process. A major problem in the daily development and testing process of virtual props output and consumption is that basically all business codes of the game server are related to the generation and consumption of virtual props. Due to the characteristics of agile development of online games, there will be a large number of business code modifications on a daily basis, and it is very difficult to do a full test. In related technologies, relevant personnel usually perform code change analysis based on code file text comparison to determine the business functions affected by code modifications. This method is inefficient and the accuracy of the analysis results is low. There are also some methods that analyze the upstream and downstream call relationships of the code through the code syntax tree, so that relevant personnel can analyze the scope of the impact of code modifications based on the call relationship. The accuracy of the analysis results of this method is usually low. Summary of the invention

[0003] In view of this, the purpose of the present disclosure is to provide a method, device, electronic device and storage medium for processing program code data, so as to improve the efficiency of analyzing business functions affected by code modifications and improve the accuracy of analysis of business impact effects.

[0004] In a first aspect, an embodiment of the present disclosure provides a method for processing program code data, the method comprising: obtaining first running data generated by a server running a first version of a target program code; obtaining a target execution statement from the first running data, and determining a code call chain corresponding to the target execution statement based on the first running data; the code call chain is used to indicate multiple functions required to be called to execute the target execution statement, and the calling relationship between the multiple functions; based on the second version of the target program code and the first version of the target program code, determining code difference data of the function indicated by the code call chain.

[0005] In a second aspect, an embodiment of the present disclosure provides a device for processing program code data, the device comprising: an operation data acquisition module, used to acquire first operation data generated by a server running a first version of a target program code; a code call chain generation module, used to acquire a target execution statement from the first operation data, and determine a code call chain corresponding to the target execution statement based on the first operation data; the code call chain is used to indicate multiple functions required to be called to execute the target execution statement, and the calling relationship between the multiple functions; a code difference data determination module, used to determine the code difference data of the function indicated by the code call chain based on the second version of the target program code and the first version of the target program code.

[0006] In a third aspect, the method embodiment provides an electronic device, including a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above-mentioned program code data processing method.

[0007] In a fourth aspect, the method embodiment provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the above-mentioned program code data processing method.

[0008] This method embodiment brings the following beneficial effects:

[0009] The above-mentioned method, device, electronic device and storage medium for processing program code data obtain the first running data generated by the server running the first version of the target program code; obtain the target execution statement from the first running data, and determine the code call chain corresponding to the target execution statement based on the first running data; the code call chain is used to indicate multiple functions required to be called to execute the target execution statement, and the calling relationship between the multiple functions; based on the second version of the target program code and the first version of the target program code, determine the code difference data of the function indicated by the code call chain. In this way, the user can clearly understand the code execution process corresponding to the preset requirements affected by the modified function by viewing the code call chain, which improves the efficiency of analyzing the business functions affected by the code modification, and the code call chain is generated based on the server's running data, and the code call relationship is more accurate, thereby improving the accuracy of the analysis of the business impact effect.

[0010] Other features and advantages of the present disclosure will be described in the following description, and partly become apparent from the description, or understood by practicing the present disclosure. The purpose and other advantages of the present disclosure are realized and obtained by the structures particularly pointed out in the description, claims and drawings.

[0011] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the specific embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.

[0013] Figure 1A flowchart of a method for processing program code data provided by an embodiment of the present disclosure;

[0014] Figure 2 A flowchart of a code call chain collection timed task execution process provided by an embodiment of the present disclosure;

[0015] Figure 3 A flowchart of a code call chain collection timed task execution process provided by an embodiment of the present disclosure;

[0016] Figure 4 A schematic diagram of a code call chain graph generating a scheduled task execution process provided by an embodiment of the present disclosure;

[0017] Figure 5 A diagram showing the effect of a code call chain relationship provided by an embodiment of the present disclosure;

[0018] Figure 6 A flowchart of a function code DIFF update timing task that regularly executes updates to each function call node code DIFF and a process of modifying the status provided by an embodiment of the present disclosure;

[0019] Figure 7 A tree structure diagram of a file syntax tree provided by an embodiment of the present disclosure;

[0020] Figure 8 A schematic diagram of the structure of a device for processing program code data provided by an embodiment of the present disclosure;

[0021] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0022] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.

[0023] The game economy is the core system of online games. The game economy is manifested in the output and consumption of various virtual props during the game operation process. Once the output or consumption of virtual props in the game during the operation period, it will cause major operational accidents and have a serious impact on the game's reputation and vitality. The output and consumption of virtual props involve all aspects of the game operation process. Against the background of increasingly complex and high-frequency iterations of online game system functions, the risk of accidents in the game economic system during the operation period has always been the greatest.

[0024] A major difficulty in the daily development and testing process of virtual props production and consumption is that basically all business codes of the game server are related to the production and consumption of virtual props. Due to the characteristics of agile development of online games, a large number of business codes will be modified on a daily basis, and it is very difficult to conduct sufficient and comprehensive testing. Therefore, how to accurately analyze which specific code changes will affect the game economic system and be able to conduct detailed tests on the affected codes is very necessary. Although there are many code change confirmation methods in the industry, they are mainly based on code change analysis based on code file text comparison, and it is difficult to intuitively judge the business functions indirectly affected by code modifications. Even if there are some methods that analyze the impact scope of the upstream and downstream call relationships of code modifications through code syntax trees, static file syntax parsing is difficult to accurately analyze the game business logic developed mainly in dynamic languages ​​such as scripts. Therefore, the above methods cannot accurately and efficiently determine the impact scope of code changes on the game economic system.

[0025] Based on this, the embodiments of the present disclosure provide a method, device, electronic device, and storage medium for processing program code data. This technology can be applied to scenarios where program code data processing is required.

[0026] See also Figure 1 First, a method for processing program code data provided by the method embodiment is introduced. The method comprises the following steps:

[0027] Step S102: obtaining first running data generated by the server running the first version of the target program code.

[0028] The above-mentioned server can be of various types, such as a virtual host, a virtual private server (Virtual Private Server, referred to as "VPS"), a cloud server, or a special server set up for a business, etc., which is not limited here.

[0029] The above-mentioned target program code usually refers to the source file written by the programmer in the language supported by the development tool, and can also be the source file generated by other artificial intelligence systems through the development tool, which is not limited here. The target program code can be in a variety of languages, specifically Java, C language, C++, Python, JavaScript, etc. These languages ​​have their own characteristics and are suitable for different development needs, which are not limited here.

[0030] The target program code is essentially a clear system of rules that represent information in discrete form using characters, symbols or signal code elements. After the server runs the target program code, it can use the rules represented by the target program code to process business data.

[0031] After generating the target program code, the relevant personnel may modify the target program code to change the processing logic of the business data due to needs. In order to record the modification of the target program code and facilitate the relevant personnel to trace the code, a version number is usually set for the target program code. The version number of the modified target program code is usually different from that of the program code before modification, that is, the version is different.

[0032] When the server runs the first version of the target program code, it will generate running data. The running data usually includes the execution statement generated when the target program code is run, the call stack information of the execution statement code location, the database name where the execution statement is located, the database table name, etc. Among them, the execution statement refers to the statement that notifies the computer to complete a certain operation. These running data can be recorded in the form of logs.

[0033] When only the running data related to some execution statements are needed, relevant functions can also be set before and after these execution statements to capture the running data related to the execution statements. For example, a hook function can be set, and when the required execution statement is executed, the hook function will obtain the running data related to the execution statement.

[0034] Step S104, obtaining a target execution statement from the first operation data, and determining a code call chain corresponding to the target execution statement based on the first operation data; the code call chain is used to indicate multiple functions required to be called to execute the target execution statement, and the calling relationship between the multiple functions.

[0035] The above-mentioned target execution statement is usually set based on preset requirements. For example, if the requirement is to determine the frequency of use of a certain business processing method, the above-mentioned target execution statement can be an execution statement generated by running the program code part used to implement the business processing method. As mentioned above, when the target program code is used to implement the game system, the preset requirement can be to determine the output and consumption of virtual props. The relevant information of virtual props is usually stored in a database. If the output and consumption of virtual props need to be realized, it is necessary to write the relevant data of the virtual props in the database, which can specifically include operations such as deletion and writing. At this time, the target execution statement can be an execution statement used to write database data.

[0036] The relevant operation data of the target execution statement can be obtained from the first operation data, and based on these relevant operation statements, the function required to be called to execute the target execution statement is determined. Generally speaking, executing the target execution statement usually requires calling multiple functions. The calling relationship between the multiple functions can also be determined based on the relevant operation data of the target execution statement, and the calling relationship can reflect the calling relationship between the functions.

[0037] After determining that executing the target execution statement usually requires calling multiple functions and the calling relationship between the functions, a node can be generated for each function. The nodes are connected according to the calling relationship to generate a code call chain. The last node of the code call chain can also be generated based on the target execution statement.

[0038] Step S106 , determining code difference data of the function indicated by the code call chain based on the second version of the target program code and the first version of the target program code.

[0039] When the target program code is modified and a second version of the target program code is generated, code difference data of the function corresponding to the node in the code call chain can be determined based on the two different versions of the target program code.

[0040] First, the files related to the functions corresponding to the nodes in the code call chain can be determined from the files of the second version of the target program code. Then, these files are compared with the corresponding files of the first version of the target program code, that is, the functions corresponding to the nodes in the code call chain in the files of the first version of the target program code. Based on the comparison results, it is determined whether the function is modified, and if it is modified, the code difference data of the function is determined.

[0041] The difference between the target program codes of the two versions may also be determined first, and usually the modified files in the second version relative to the first version need to be determined. Then, the relevant files of the function corresponding to the node in the code call chain are determined from these files. Furthermore, the files corresponding to these files in the first version are compared with the files related to the function corresponding to the node that have been modified in the second version, and the code difference data of the function can be determined based on the comparison result.

[0042] If the relevant file of the function corresponding to a node in the code call chain cannot be found in the second version, it is generally considered that the function has been deleted. At this time, it is necessary to delete the function from the code call chain and further adjust the connection relationship of each node in the code call chain.

[0043] The above-mentioned method for processing program code data obtains the first running data generated by the server running the first version of the target program code; obtains the target execution statement from the first running data, and determines the code call chain corresponding to the target execution statement based on the first running data; the code call chain is used to indicate multiple functions required to be called to execute the target execution statement, and the calling relationship between the multiple functions; based on the second version of the target program code and the first version of the target program code, the code difference data of the function indicated by the code call chain is determined. In this way, the user can clearly understand the code execution process corresponding to the preset requirements affected by the modified function by viewing the code call chain, which improves the efficiency of analyzing the business functions affected by the code modification, and the code call chain is generated based on the server's running data, and the code call relationship is more accurate, thereby improving the accuracy of the analysis of the business impact effect.

[0044] The following embodiment provides a specific method for determining a code call chain corresponding to a target execution statement based on first running data.

[0045] In practical applications, a first target node can be generated based on a target execution statement. The target designation statement is usually also implemented by a function, and the first target node can be regarded as being established for the function that implements the target designation statement. Then, based on the first running data, multiple first functions are determined. Among them, the first function is called before executing the target execution statement. Then, based on the first function, a second target node is generated. Generally speaking, a second target node needs to be generated for each first function. That is, different second target nodes in the code call chain correspond to different functions. Finally, based on the calling relationship between the first target node, the second target node and multiple first functions, a code call chain corresponding to the target execution statement is generated.

[0046] In actual applications, a function may be called by multiple functions, or a function may call multiple functions. For example, the possible function call process 1 for a target specified statement is as follows: function 1 calls function 2, function 2 calls function 3, and function 3 calls the function used to implement the target specified statement; the possible function call process 2 is as follows: function 4 calls function 2, function 2 calls function 3, and function 3 calls the function used to implement the target specified statement; the possible function call process 3 is as follows: function 5 calls function 3, and function 3 calls the function used to implement the target specified statement. For the above three calling processes, it is necessary to generate corresponding second target nodes for function 1, function 2, function 3, function 4 and function 5, respectively referred to as node 1, node 2, node 3, node 4 and node 5; it is necessary to generate corresponding first target nodes for the function used to implement the target specified statement, referred to as node 6. Based on the above three function call processes, the corresponding code call chain can be generated. In the code call chain, function 2 is called multiple times, and function 3 is also called multiple times, then its corresponding node will be connected to multiple nodes, and this code call chain can also be called a code call graph.

[0047] The relevant data of the functions and corresponding code call chains involved in the function call process of the above-mentioned target execution statement can be stored in a designated server. The user can control the terminal device to request these data from the server, and the code call chain (code call map) can be displayed based on these data in the graphical user interface provided by the terminal device. The user can send a function to the server through the terminal device, and the server can return to the user part of the code call chain data related to the node corresponding to the function in the code call chain. The user can also send a target execution statement to the server through the terminal device, and the server can return to the user part of the code call chain data related to the node corresponding to the target execution statement in the code call chain. The user clicks on a node in the code call chain displayed on the graphical user interface to display the program code of the function corresponding to the node, such as the program code of the current version, the program code of the previous version, etc.

[0048] In the process of generating the first target node, the target execution statement can be parsed first to obtain the parsing result; the parsing result includes the grammatical structure of the target execution statement. In the specific implementation, the lexical parsing can be performed through the pre-trained statement parsing module, and finally a syntax tree is generated. The syntax tree records each keyword, field, parameter, operation symbol, identifier, etc. in the grammatical structure of the statement, which can be used to extract the operation executed by the judgment statement, the table, field, parameter value and condition of the statement operation. After the syntax tree is generated, the variable parameter value in the syntax tree is replaced by a placeholder representation, and then the grammatical structure of the database execution statement is reversely reconstructed. Further, the first target node can be generated based on the parsing result. In practical applications, the processing process of a certain business data can be implemented by different target execution statements, and the parameters of these target execution statements are different, but the grammatical structure is usually the same. For example, in a game, game tokens can be issued to different players through database execution statements; in the database execution statement used to issue game tokens, except for the different parameters representing the player's identification and the number of tokens, the grammatical structure of the database execution statement is the same, and the execution statements of these two execution behaviors can be classified as the same first target node.

[0049] When the target execution statement includes multiple database execution statements, the parsing result generally also includes the database operated by the database execution statement. In the case where the first target node has been generated based on the parsing result of the first database execution statement among the multiple database execution statements, if the syntax structure of the second database execution statement among the multiple database execution statements is the same as the syntax structure of the first database execution statement, and the database operated by the second database execution statement is the same as the database operated by the first target specified statement, the first target node corresponding to the first database execution statement can be determined as the first target node corresponding to the second database execution statement, thereby eliminating the need to generate a new target node. The node corresponding to the function required to execute the second database execution statement can be connected to the first target node.

[0050] When the target execution statement includes a database execution statement, that is, an execution statement that implements operations on data in the database. The parsing result also includes the database of the database execution statement operation and the corresponding data processing operation. When the demand is to determine the output and consumption of virtual props, it is necessary to perform write operations on the corresponding data in the database that stores the data of virtual props, which may include deletion, writing, etc. At this time, it is necessary to determine whether the database operated by the database execution statement is a preset database. The preset database is the database that stores the data of virtual props. If so, it is necessary to determine whether the data processing operation corresponding to the database execution statement is a data write operation; if it is a write operation, the first target node is generated based on the parsing result.

[0051] In order to facilitate users to further understand the calling relationship between functions and the calling of functions to the target execution statement based on the code call chain, for each first target node, the first called node list corresponding to the first target node can be determined. The first called node list includes the second target node that calls the first target node, which is the second target node directly connected to the first target node from the code call chain. For each second target node, it is necessary to determine the second called node list corresponding to the second target node and the calling node list. Among them, the second called node list includes other second target nodes that call the second target node, that is, other second target nodes that are directly adjacent to the second target node, and the calling relationship is before the second target node. The calling node list includes other second target nodes called by the second target node, and may also include the first target node.

[0052] As described above, the code call chain can be displayed in a graphical user interface in a graphical manner. For a node in the code call chain, the called list, calling list, etc. of the node can be displayed around the node. The display area where each node is located in the graphical user interface can also be set to be touchable. When the user clicks on the display area, the details window corresponding to the node will be displayed in the graphical user interface. The called list, calling list, etc. of the node can be displayed in the details window. In the above manner, the user can quickly understand the calling status of the node.

[0053] The following embodiment provides a specific method for determining code difference data corresponding to a function indicated by a code call chain based on a second version of the target program code and a first version of the target program code.

[0054] As described above, the above-mentioned code call chain includes multiple nodes, and each node has a corresponding function. The target program code usually includes multiple files. In order to determine the code difference data corresponding to the function indicated by the code call chain, the file of the target program code of the second version can be first compared with the file of the target program code of the first version; based on the comparison result, the modified file in the file of the target program code of the second version is determined, that is, the file that has been modified relative to the corresponding file in the first version. Then, based on the function corresponding to the node of the code call chain, the target file in the modified file is determined, and these target files usually record the relevant parameters of the function corresponding to the node of the code call chain, or the program code that implements the function. Further, the code difference data corresponding to the function indicated by the code call chain can be determined based on the target file and the corresponding file in the target program code of the first version.

[0055] After the target file is determined, for each function indicated by the code call chain, the target file corresponding to the function is searched from the target file. If found, it means that this function still exists in the second version of the program code. At this time, the code difference data corresponding to the function can be determined based on the found target file and the corresponding file of the function in the first version of the target program code. If not found, it can be considered that the function has been deleted in the second version of the target program code. At this time, it is necessary to delete the node corresponding to the function from the code call chain and update the code call chain.

[0056] After deleting the node corresponding to the function in the code call chain, you also need to check the nodes in the code call chain that were originally connected to the deleted node. For the convenience of writing, they are called related nodes. If the related node corresponds to the function used to implement the target execution statement, and there are no other nodes connected to the related node except the deleted node, then the related node needs to be deleted. If the related node does not correspond to the function used to implement the target specified statement, and there are no other nodes called by the related node, the related node also needs to be deleted. If the related node is deleted, it is necessary to consider the nodes connected to the related node until there are no nodes that need to be deleted.

[0057] As mentioned above, the nodes in the above code call chain usually have a called list and / or a calling list. The calling list and the calling list can be collectively referred to as the related node list, and the related node list includes other nodes called by the node, and other nodes that call the node. After deleting a node, it is necessary to determine the related nodes of the deleted node. The related node list of the related node includes the deleted node, that is, the related node originally called the deleted node, or was called by the deleted node. Then the deleted node needs to be deleted from the related node list of the related node. In some cases, the related node may also need to be deleted, then it can be determined first whether the related node needs to be deleted, and if the related node does not need to be deleted, the deleted node can be deleted from the related node list of the related node.

[0058] The server will generate a large amount of operation data during operation, and the operation data generated in different time periods are usually different. If a code call chain is generated based only on the operation data generated in one time period, the code call chain is usually incomplete. The operation data usually includes multiple specified execution statements. The multiple specified execution statements can be stored in a preset cache queue in the order of generation. The cache queue can be set in the server or in other databases, and there is no restriction here. When generating a code call chain, a time parameter can be set for it. The time parameter indicates the generation time of the operation data used to generate the code call chain.

[0059] In order to enable the code call chain to cover a relatively complete calling process of the target execution statement, the second running data can be read from the cache queue. The generation time of these second running data needs to be later than the code call chain time parameter. Then based on the second running data, the code call chain is updated. When the calling relationship of the function changes during the calling process of the target execution statement in the second running data, or other functions appear in the calling process of the target execution statement, the code call chain needs to be updated. At the same time, the time parameter of the updated code call chain is updated to the generation time of the second running data, so as to facilitate the next reading of the cached running data and update the code call chain.

[0060] In the process of updating the code call chain, multiple second functions can be determined based on the second running data. Similar to the first function, the second function is also called before executing the target execution statement. If the current code call chain does not include the third function among the multiple second functions, a third target node is generated based on the third function; further, the code call chain needs to be updated based on the third target node. At this time, the code call chain also includes the case of calling the target execution statement through the third function.

[0061] The present disclosure also provides another method for processing program code data. Figure 1 The method is implemented on the basis of the method shown. Taking the game program code as an example, the method provides a code call chain graph related to the game economic system that is collected and established in real time during the server operation process, in which the function is used as the unit node on the call chain graph. Based on the call chain graph, it can accurately analyze whether a code change of a certain function affects the game economic system, and which call links upstream and downstream have an impact on the game economic system, so that testers can design use cases in a targeted manner to cover all the impacts of the game economic system caused by the code change, and developers can also accurately and reliably review the game economic functions affected by the code change.

[0062] Since the essence of changes in the game economic system is the production and consumption of prop resources in each game, the production and consumption process of each type of game props for each game player will have corresponding database table record modifications, that is, there will be corresponding database execution statements executed. Therefore, this method uses database execution statement execution as the target endpoint to establish the code call chain map of the entire game.

[0063] This method is implemented in the following way:

[0064] The server code version used in the development and testing phase adds a hook to the underlying interface for executing database execution statements. That is, the server runs before and after the database execution statement is executed, and the event listening callback interface triggered by the hook is used to implement the statistical operation data of the database execution statement execution process. The data includes the database name where the execution statement is located, the database table name, the execution statement string, the call stack information of the execution statement code location, etc.

[0065] Each database execution statement running data collected during the server operation process is output in real time to the pending cache queue waiting for subsequent processing. The cache queue can be built using cache services such as Redis.

[0066] This method requires the deployment of a code call chain to collect scheduled tasks. Scheduled tasks must have permission to access the cache queue. Scheduled tasks process the running data of each database execution statement by starting and running regularly. Each time the scheduled task runs, it obtains data according to a certain processing limit for processing. After processing, the data is removed from the cache queue.

[0067] This method only processes the execution of data statements that affect the economic system. Therefore, the database tables related to the game's economic system will be configured in advance. Generally speaking, these are tables that record the number of virtual props for each account in the game. Other tables related to the output and consumption of valuable prop resources in the game and accounting are also related to the economic system. The corresponding tables are recorded in the running configuration of the scheduled task.

[0068] This method requires the deployment of a scheduled task generated by the code call chain graph of an economic system. The scheduled task starts to collect the database execution statement execution units and associated code call chains generated by the newly added processing of the scheduled task, analyze the content related to the game economic system, and incrementally process the related code call chains, merging them into the existing code call chain graph. The processing flow includes:

[0069] Scheduled tasks are started and run at scheduled times. Before a scheduled task is executed, the execution time point will be recorded once. This is used for incremental extraction of code call chain data whose collection time is greater than the last execution time point during the next execution to calculate the call chain graph. During the calculation, first, according to the configured economic system database table, the background database is queried to obtain the database execution statement execution units and corresponding code call chain lists of each table that have been incrementally updated since the last execution time point.

[0070] This method deploys a Web service site for graphically viewing the call chain graph from the front end of the web page. Each node of the graph will be saved in the background database of the Web service site. Users can query the complete call chain graph relationship network through the front-end web page, or specify the call function and query the associated graph relationship network from the database table.

[0071] In addition to establishing a call chain graph, this method also needs to deploy a function code DIFF update scheduled task to check whether the code content of each function node in the graph has changed compared to the baseline code version, as well as the code DIFF results of the specific function code content. Function nodes with code DIFF need to upload the code DIFF content to the function nodes in the graph.

[0072] This method incrementally obtains files with code changes, extracts specific function code content under specific class definitions in the code file by parsing the code syntax tree, and generates code DIFF.

[0073] This method is introduced by taking a MySql type relational database as an example. Other relational database types such as Oracle, PostGres and non-relational databases such as Mongo also meet the implementation process of this method.

[0074] When implementing this embodiment, it is necessary to add support for real-time collection of server access to the database, content of database execution statements and related operating data in one or more development and test servers that need to collect database execution statements for inspection. This embodiment chooses to add a hook to the underlying interface of the server code that executes the database execution statement, that is, the server operation process executes to the event monitoring callback interface triggered by the hook before and after the execution of the database execution statement to realize the statistical operation data of the database execution statement execution process. The statistical content includes the database name where the database execution statement is located, the database execution statement content and the current call stack information of the database execution statement call location, etc.

[0075] The data collected when each database execution statement is executed is taken as an independent database execution statement data unit, and the data content is packaged and temporarily stored in the cache specified by each server. The storage method can include server local log file recording, caching using cache services such as Redis, etc. In this embodiment, each server outputs the collected database execution statement data unit in real time to the key value of the list type of specified cache check data in the local Redis.

[0076] When implementing this embodiment, it is necessary to independently deploy a code call chain processing platform. The platform includes an HTTP service site that can support users to access the platform through the browser front-end to view the code call chain map. The platform background also deploys a series of scheduled tasks to collect and process the database execution statement data generated by each game server, generate code call chain maps, and update code change information.

[0077] The call chain processing platform includes a code call chain collection timing task, which is used to periodically execute and process the database execution statement data unit cache of each server that has enabled the statement collection function, and parse and classify them into database execution statement execution units and associated code call stack information, which are stored in the platform background database.

[0078] The call chain processing platform includes a scheduled task for generating a code call chain graph, which is used to perform incremental processing of database execution statement execution units and associated code call stack information, generate function call nodes and database execution unit nodes in the code call chain graph and the calling relationships between them, and merge them into the existing graph. The graph node-related data information is stored in the platform background database.

[0079] The call chain processing platform includes a function code DIFF update scheduled task, which is used to check whether the code content of each function node in the graph has changed compared to the baseline code version, as well as the code DIFF results and status of the specific function code content, and save the records in the graph node database association information.

[0080] This embodiment implements the establishment of a code call chain graph related to the game economic system in the following manner:

[0081] 1. Add a hook to the server's underlying database access interface in the development and test type servers that need to collect the database execution statements executed by the server, and obtain the database execution statement and running data content after the statistics of each statement execution, including the database name where the statement is executed, the database execution statement content, and the current call stack information of the database execution statement call location, etc. The above content is packaged into an independent database execution statement data unit and cached in the Redis key value of the list type specified for storage in the local Redis service specified on the server.

[0082] 2. Deploy a code call chain processing platform on a fixed machine, and deploy a code call chain collection timing task in the background of the platform. The task includes a data acquisition module and a data processing module. The data acquisition module is responsible for obtaining a certain upper limit of database execution statement data units from each server in the storage order after the process is started, and saves them in the local data queue to be processed in the order of acquisition. After all server data is acquired, the data processing module is responsible for batch processing of the data units in the queue to be processed. The database execution statement execution units and the associated code call stack information generated after processing will be saved in the background database of the platform.

[0083] See also Figure 2 , is a flowchart of the steps of the code call chain collection timed task execution process in this embodiment, which specifically includes the following contents:

[0084] 1 The platform pre-configures the IP, port, account password and other information of the Redis service of each server to be collected locally, which corresponds to the identification information of each server one by one. The data acquisition module of the scheduled task has a built-in Redis client. After the scheduled task is started, it connects to the Redis of each server in sequence according to the pre-configured server Redis connection information. Each time it runs, it obtains the database execution statement data unit content of a certain number of entries of each server according to the configured threshold and pulls it into the local processing queue of the platform, and deletes the obtained data unit from the server Redis at the same time.

[0085] 2 The platform pre-configures the database table belonging to the economic system in the game server database. Generally speaking, it is a table that records the number of virtual props for each account in the game. Other tables related to the output and consumption of valuable prop resources in the game and accounting are also tables related to the economic system. The configured table name is recorded in the platform's local background configuration file. The data processing module of the scheduled task takes out the data units in the processing queue one by one for processing.

[0086] See also Figure 3 , is a flowchart of the steps of the code call chain in this embodiment to collect the scheduled task to process each database data unit, which specifically includes the following contents:

[0087] 1 For each database execution statement unit to be processed, first extract the database execution statement in the running data, and then lexically parse the database execution statement through the statement parsing module, and finally generate a syntax tree. The syntax tree records every keyword, field, parameter, operation symbol, identifier, etc. in the statement syntax structure, which can be used to extract syntax information such as the operation to judge the statement execution, the table, field, parameter value and condition of the statement operation.

[0088] After generating the syntax tree, the variable parameter values ​​in the syntax tree are replaced with placeholders, and then the syntax structure information of the database execution statement is reconstructed in reverse. The generated syntax structure information is a placeholder symbol that replaces the values ​​of the variable parameters in the original statement, such as ?, and only retains the syntax information in the original statement. If there is a variable number of parameter lists in the statement, it can be further classified, such as using ? ...? to represent a variable number of variable parameter lists. The purpose is to enable different database execution statements to be classified and aggregated if only the variable parameter values ​​are different. The following is an example of SQL statement parsing.

[0089] The SQL statement is select * from tbname where field1 = 5 and field2 = 'string'. After parsing the syntax tree, the syntax tree diagram can be extracted.

[0090] When rebuilding the syntax structure through the syntax tree, you can replace variable parameter values, such as variable parameter nodes of Integer and Single types, with placeholders?, that is, select*from tbname where field1=? and field2=?.

[0091] 2 For each collected database execution statement syntax structure, we must first determine whether it belongs to a database operation that affects the economic system. First, we must determine whether the database table being operated belongs to a pre-configured table belonging to the economic system. If so, we must determine whether the database operation is a write operation, including insert, update, delete, etc. If so, we must proceed to the next step. In other cases, database execution statement structures that belong to tables outside the economic system or read-only operations are skipped and not processed.

[0092] For the database execution statement to be processed, the database name, database table name, and grammatical structure information corresponding to the statement are combined as a unique index identifier to create a database execution statement execution unit. That is, when the task processes different data, if the database name, database table name, and grammatical structure information of the data extracted are the same, they are all classified as belonging to the same database execution unit, and other information collected during the data processing process is also classified into the same execution unit.

[0093] 3 When the scheduled task processes data, it will also extract the code call stack of the execution location of the database execution statement. From the call stack, you can fully obtain the function call chain during the code execution process, extract the valid information of each node on the call chain, including the code file name, class name, function name, and the previous and next call relationships, package it into data formats such as Json, and associate it with the corresponding database execution unit for storage.

[0094] 4. The database execution unit data will be saved and recorded in the database of the platform background and assigned a unique ID tag. The code call chain data associated with each execution unit will also be saved in the database and the associated execution unit ID will be recorded. During the task collection and processing process, the code call chain data with the same content corresponding to the same execution unit will only be saved in one copy in the database. If the code call chains have different contents, they will be saved separately. One execution unit can be associated with multiple code call chains. There are also fields in the database to record the collection time of the code call chain data. When a task collects duplicate code call chain data, it only needs to update the latest collection time in the saved database record.

[0095] This embodiment needs to continuously build a code call chain graph that affects the game economic system. In the graph, each function call and database execution statement execution unit associated with the economic system is converted into a graphic node and displayed in the graph, and the mutual calling relationship of each function call node is represented by a directed connection between the nodes. Here, it is necessary to deploy a scheduled task generated by the code call chain graph of the economic system. The task is scheduled to start the call chain to collect the database execution statement execution unit and the associated code call chain generated by the newly added processing of the scheduled task, analyze the content related to the game economic system, and incrementally process the related code call chains and merge them into the existing code call chain graph.

[0096] See also Figure 4 , is a flowchart of the steps of the graph generation timed task execution process in this embodiment, which is as follows:

[0097] 1. Scheduled tasks are started and run at scheduled times. Before the scheduled task is executed, the execution time point of this execution will be recorded once and recorded in the platform background database. It is used for incremental extraction and collection of code call chain data with a collection time greater than the last execution time point for call chain graph calculation during the next execution. When calculating, first query the background database from the configured economic system database table to obtain the database execution statement execution units and corresponding code call chain lists of each table that have been incrementally updated since the last execution time point. Then process them one by one to generate the nodes and connection relationships in the call chain graph.

[0098] 2 For the execution unit to be processed currently, first determine whether this execution unit has been recorded in the existing call chain graph. The record is saved by recording a node record associated with the execution unit ID in the database graph node table. If the record has been saved, there is no need to create a new one. If not, create a new execution unit node in the graph table and associate the execution unit ID.

[0099] 3. Incrementally collect the code call chain list for the execution units that need to be processed. Each call chain is processed one by one to generate function call nodes and connection relationships, which are also saved in the graph node table. The file name, class name, and function name of the call node form a unique index identifier. Each calling function on the code call chain corresponds to a node in the graph. If a node for the function with the same unique index identifier already exists in the graph, there is no need to create it additionally and a node can be shared. If not, a new function call node is created, a unique index identifier is established, and a unique ID for the node is assigned.

[0100] 4 After creating and obtaining each function call node in each call chain, the calling and called relationships between each function node must be recorded according to the calling relationship before and after the call chain. The recording method is that each function call node will record two additional attributes, one is the called node list, and the other is the calling node list. The called node list records the node ID list of all other nodes that call this node in the total graph, and the calling node list records the node ID list of other nodes called by this node in the total graph. The last function call node of each call chain will record a corresponding database execution unit node ID in the call list. The node of the database execution unit will also have a called node ID list, which records the function node ID that calls it. In the graph, it is represented as the function node called at the end of each code call chain, which finally calls and executes the database execution statement of the database execution node.

[0101] The function call chain graph that is continuously constructed and generated in this embodiment constitutes a complete code call relationship network. As long as the server operation process has executed a database operation that changes the economic system, the nodes on its entire call chain will be added to the graph. Through the call and called relationship network of each node, it is possible to intuitively query through the graph which function nodes caused a certain database table to be modified. It is also possible to intuitively analyze that a certain function has code modifications, and from its call relationship network, it is also possible to intuitively query which database operations its modifications will affect and thus the possible impact on the economic system.

[0102] The code call chain graph constructed in this implementation can be accessed and viewed by users by accessing the HTTP service site of the call chain processing platform through a front-end browser. The HTTP service will query the database data of the search graph node from the background database according to the user's query conditions, and generate a directed graph data structure, which will be displayed graphically on the user's front-end browser interface. Users can query the complete call chain graph relationship network through the front-end web page, or specify the call function, database table or database execution statement unit to query the associated graph relationship network. The front-end display will display each node in the form of a graphic node. If there is a direct call relationship between the nodes, there will be a line with an arrow connecting the two nodes. The graph interface nodes can also support free dragging and scaling. The front-end graphical display function can be implemented using the popular open source X6 graphic editing engine.

[0103] The effect of querying a database execution statement execution unit in all the associated code call chain relationships in the graph is shown in the figure below Figure 5 shown.

[0104] Depend on Figure 5It can be seen intuitively that the database execution statement execution unit of the specified query belongs to the final node in the tree structure of the call chain, and all function calls that directly or indirectly affect this database execution statement execution unit can be intuitively displayed in the graphic structure through node display and link relationship, so that users can clearly know which code calls will affect the database modification operation of the economic system.

[0105] In addition to establishing a call chain graph, this embodiment also needs to deploy a function code DIFF update timing task to check whether the code content of each function node in the graph has changed compared to the baseline code version. Therefore, this embodiment needs to deploy two code version directories in the platform background, one is the current regularly updated working version, which is generally the code version that is currently under continuous development and update, and the other is a stable baseline version of the code used to compare with the working version to see if there are any code changes, which is generally the version that is currently running stably online.

[0106] The function code DIFF update timing task of this embodiment aims to regularly update the function definition code corresponding to each function call node in the entire code call chain graph, calculate the DIFF difference between the code content in the working version and the basic version, and upload the difference situation and difference content to the record stored in the database of the corresponding function node in the code call chain graph. Users can also intuitively understand and view whether each function call node has undergone code changes in the current working version compared to the baseline version through the front-end browser.

[0107] In this embodiment, a working code version directory and a benchmark code version directory are deployed in advance in the platform background, as well as a function code DIFF update scheduled task. The task updates the working code version directory regularly, and incrementally checks and updates the DIFF results and change status of the function definition code of each function call node in the code call chain graph in the working version and the benchmark version. Function nodes with code DIFF need to upload the code DIFF content to the function node of the graph, and mark the function node as a code modification state. If the function node has no corresponding function in the benchmark code version, the node status is marked as new. If the function node that has been created in the graph has been deleted in the latest code version, the node will be deleted from the graph node database, and all other nodes that have a calling and called relationship with the deleted node will refresh the calling and called node lists, and remove the ID of the deleted node from the list.

[0108] See also Figure 6 , is a flowchart of the steps of updating the DIFF code of each function call node and modifying the status of the function code update timing task in this embodiment, which specifically includes the following contents:

[0109] 1. Scheduled tasks are started at scheduled times, and the working version directory is updated to the latest version through version control software such as Svn / Git / P4, and the version number is recorded in the platform background database. Then the current version is compared with the last updated version number recorded in the background database during the last execution, and the list of files with code changes between the two version numbers is incrementally extracted. All function call nodes belonging to the above-mentioned list of changed files are queried from the graph database. In specific implementation, each time a scheduled task is executed, the list of files with code modifications between the two version numbers is incrementally extracted according to the code version number recorded in the last execution, and all function nodes belonging to the current list of modified files are queried from the graph node library.

[0110] 2 Check and update the code modification status and code DIFF content of each function node one by one. For the function node to be processed, first obtain the corresponding latest version code file and the benchmark version code file for comparison. Perform syntax tree parsing on both files, and obtain the syntax tree of the latest code file and the syntax tree of the benchmark code file respectively. The syntax tree records the specific location of each class definition and the specific location of each function under the class definition, including the starting line number and the ending line number. The location of the function node is found through the syntax tree, and then the text content of the code segment where the function definition is located is extracted from the latest code file and the benchmark code file respectively according to the location. Then, by calculating the code DIFF of the two segments of text, it is determined whether the code modification status of the function node is unchanged or modified. If the function is found in the syntax tree of the latest code file and the function is not found in the syntax tree of the benchmark code file, the code modification status of the function node is determined to be added, otherwise it is deleted.

[0111] Each programming language supports parsing the syntax tree of code files. The syntax tree represents an independent syntax tree per file. Each class definition and function definition in the file is saved in the syntax tree as a node. The specific location of each class definition and member function definition in the code file can be found by traversing the nodes, such as Figure 7 The figure shows a tree structure diagram of a file syntax tree.

[0112] For the function call node that needs to be updated, the class name and function name of the called function are obtained from the node, and the syntax tree node of the corresponding class name and function name can be found by traversing the nodes one by one in the corresponding file syntax tree. The syntax tree node will record the starting line number and ending line number of the function in the code file. Through these two line numbers, the code content of the function can be accurately extracted from the code file text.

[0113] When searching for the function syntax tree node corresponding to the call function node in the syntax tree, there are the following situations:

[0114] If the function call node has a corresponding function syntax tree node in both the working version and the baseline version syntax tree, extract the function definition code content of each version, and use the commonly used text DIFF algorithm to perform two text DIFF calculations. If there is no DIFF, it means that the function has not changed in the working version and the baseline version file, and the function node modification status is marked as no change. If there is a DIFF, it means that the function definition content of the working version has changed compared to the baseline version, and the function node modification status is marked as modified, and the DIFF content is recorded;

[0115] If the function call node has a corresponding function syntax tree node in the working version but cannot be obtained in the baseline version, the function node is judged to be a newly added function and the function node modification status is marked as newly added;

[0116] If a function call node has a corresponding function syntax tree node in the baseline version but cannot be obtained in the working version, it is determined that the function node has been deleted in the latest working version; the function node modification status is marked as deleted.

[0117] 3. The calculated function node modification status and DIFF results are synchronously uploaded and recorded in the database record corresponding to the function call node in the call chain map. Finally, in the call chain map, each function call node will be marked with the code modification status, which are unchanged, added, modified and deleted. Users can click to view the details of each function call node through the front-end web page display. The detailed information includes basic information such as the code file and class to which the node belongs, as well as the code content of the function and the DIFF results compared with the baseline version. Users can also set the confirmation status for the nodes that have been checked and confirmed through the front-end web page.

[0118] For functions that have been deleted in the working version, users can also remove the deleted function call nodes from the call chain graph through front-end operations. When removing, first remove the calling and called relationships with other nodes in the upstream and downstream call chains of the node to be deleted from the graph, and then delete the corresponding function node records from the graph node database.

[0119] For nodes that the user has set to confirm, when the subsequent scheduled task processes the node update, if it detects that the function code corresponding to the node has changed, it will automatically reset the set confirmation status and remind the user to reconfirm.

[0120] The embodiment of the method adopts a code call relationship chain network generated by collecting code call chains when the server is running. Compared with the common syntax tree analysis method in the industry, it is more reliable and accurate. The invention method of detecting the impact behavior of the economic system with database operation as the target can not only be used for the economic system, but also the impact detection of other systems can also refer to this set of methods. Finally, a graphical code call chain map is established, which not only facilitates the analysis of the impact scope and clarification of the logical chain during the review of the code change process, but also improves the efficiency and accuracy of the review.

[0121] For the above method embodiments, see Figure 8 A program code data processing device as shown, the device comprising:

[0122] An operation data acquisition module 802 is used to acquire first operation data generated by the server running the first version of the target program code;

[0123] The code call chain generation module 804 is used to obtain a target execution statement from the first operation data, and determine a code call chain corresponding to the target execution statement based on the first operation data; the code call chain is used to indicate multiple functions that need to be called to execute the target execution statement, and the calling relationship between the multiple functions;

[0124] The code difference data determining module 806 is used to determine the code difference data of the function indicated by the code call chain based on the second version of the target program code and the first version of the target program code.

[0125] The above-mentioned program code data processing device obtains the first running data generated by the server running the first version of the target program code; obtains the target execution statement from the first running data, and determines the code call chain corresponding to the target execution statement based on the first running data; the code call chain is used to indicate multiple functions required to be called to execute the target execution statement, and the calling relationship between the multiple functions; based on the second version of the target program code and the first version of the target program code, the code difference data of the function indicated by the code call chain is determined. In this way, the user can clearly understand the code execution process corresponding to the preset requirements affected by the modified function by viewing the code call chain, which improves the efficiency of analyzing the business functions affected by the code modification, and the code call chain is generated based on the server's running data, and the code call relationship is more accurate, thereby improving the accuracy of the analysis of the business impact effect.

[0126] The above-mentioned code call chain generation module is also used to: generate a first target node based on a target execution statement; determine multiple first functions based on first running data; the first function is called before executing the target execution statement; generate a second target node based on the first function; generate a code call chain corresponding to the target execution statement based on the calling relationship between the first target node, the second target node and multiple first functions.

[0127] The above-mentioned code call chain generation module is also used for: parsing the target execution statement to obtain a parsing result; the parsing result includes the grammatical structure of the target execution statement; and generating a first target node based on the parsing result.

[0128] The above-mentioned target execution statement includes multiple database execution statements; the parsing result also includes the database operated by the database execution statement and the corresponding data processing operation; the above-mentioned code call chain generation module is also used to generate a first target node based on the parsing result of the first database execution statement among the multiple database execution statements; if the grammatical structure of the second database execution statement among the multiple database execution statements is the same as the grammatical structure of the first target execution statement, and the database operated by the second database execution statement is the same as the database operated by the first target specified statement, the first target node corresponding to the first database execution statement is determined as the first target node corresponding to the second database execution statement.

[0129] The above device also includes: a first node list determination module, which is used to determine, for each first target node, a first called node list corresponding to the first target node; the called node list includes a second target node that calls the first target node.

[0130] The above-mentioned device also includes: a second node list determination module, which is used to generate a second called node list corresponding to the second target node and a calling node list for each second target node; the called node list includes other second target nodes that call the second target node; the calling node list includes other second target nodes and / or the first target node called by the second target node.

[0131] In the above code call chain, different second target nodes correspond to different functions.

[0132] The above-mentioned target execution statement includes a database execution statement; the parsing result also includes the database operated by the database execution statement and the corresponding data processing operation; the above-mentioned code call chain generation module is also used to: determine whether the database operated by the database execution statement is a preset database; if so, determine whether the data processing operation corresponding to the database execution statement is a data write operation; if so, generate the first target node based on the parsing result.

[0133] The above-mentioned code call chain includes multiple nodes, each node has a corresponding function; the target program code includes multiple files; the code difference data determination module is also used to: compare the files of the second version of the target program code with the files of the first version of the target program code; based on the comparison results, determine the modified files in the files of the second version of the target program code; based on the functions corresponding to the nodes of the code call chain, determine the target files in the modified files; based on the target files and the corresponding files in the first version of the target program code, determine the code difference data corresponding to the function indicated by the code call chain.

[0134] The above-mentioned code difference data determination module is also used to: for each function indicated by the code call chain, search for the target file corresponding to the function from the target file; if found, determine the code difference data corresponding to the function based on the found target file and the corresponding file of the function in the first version of the target program code.

[0135] The above-mentioned device also includes: a first code call chain updating module, which is used to delete the node corresponding to the function from the code call chain if it is not found, and update the code call chain.

[0136] The nodes in the above code call chain have a related node list; the related node list includes other nodes called by the node, and other nodes that call the node; the above device also includes: a node list update module, used to determine the related nodes of the deleted node; the related node list of the related node includes the deleted node; and the deleted node is deleted from the related node list of the related node.

[0137] The above-mentioned operation data includes multiple specified execution statements; the multiple specified execution statements are stored in a preset cache queue in sequence according to the order of generation; the code call chain has a corresponding time parameter; the time parameter indicates the generation time of the operation data used to generate the code call chain; the above-mentioned device also includes: an operation data reading module, used to read the second operation data from the cache queue; the generation time of the second operation data is later than the time parameter; a second code call chain update module, used to update the code call chain based on the second operation data; an event determination module is generated, used to update the time parameter of the updated code call chain to the generation time of the second operation data.

[0138] The above-mentioned second code call chain update module is also used to: determine multiple second functions based on second running data; the second function is called before executing the target execution statement; if the code call chain does not include a third function among the multiple second functions, generate a third target node based on the third function; and update the code call chain based on the third target node.

[0139] This embodiment further provides an electronic device, including a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above-mentioned method for processing program code data, for example:

[0140] Obtain first running data generated by a server running a first version of a target program code; obtain a target execution statement from the first running data, and determine a code call chain corresponding to the target execution statement based on the first running data; the code call chain is used to indicate multiple functions required to be called to execute the target execution statement, as well as the calling relationship between the multiple functions; based on the second version of the target program code and the first version of the target program code, determine code difference data of the function indicated by the code call chain.

[0141] In the above method, users can clearly understand the code execution process corresponding to the preset requirements affected by the modified function by viewing the code call chain, which improves the efficiency of analyzing business functions affected by code modifications. The code call chain is generated based on the server's operating data, and the code call relationship is more accurate, thereby improving the accuracy of the analysis of business impact effects.

[0142] Optionally, the above-mentioned step of determining the code call chain corresponding to the target execution statement based on the first running data includes: generating a first target node based on the target execution statement; determining multiple first functions based on the first running data; the first function is called before executing the target execution statement; generating a second target node based on the first function; generating a code call chain corresponding to the target execution statement based on the calling relationship between the first target node, the second target node and multiple first functions.

[0143] Optionally, the step of generating the first target node based on the target execution statement includes: parsing the target execution statement to obtain a parsing result; the parsing result includes a grammatical structure of the target execution statement; and generating the first target node based on the parsing result.

[0144] Optionally, the above-mentioned target execution statement includes multiple database execution statements; the parsing result also includes the database operated by the database execution statement and the corresponding data processing operation; based on the parsing result, the step of generating the first target node includes: generating the first target node based on the parsing result of the first database execution statement among the multiple database execution statements; if the grammatical structure of the second database execution statement among the multiple database execution statements is the same as the grammatical structure of the first target execution statement, and the database operated by the second database execution statement is the same as the database operated by the first target specified statement, the first target node corresponding to the first database execution statement is determined as the first target node corresponding to the second database execution statement.

[0145] Optionally, the method further includes: for each first target node, determining a first called node list corresponding to the first target node; the called node list includes a second target node that calls the first target node.

[0146] Optionally, the above method also includes: for each second target node, generating a second called node list corresponding to the second target node, and a calling node list; the called node list includes other second target nodes that call the second target node; the calling node list includes other second target nodes and\or the first target node called by the second target node.

[0147] Optionally, in the above code call chain, different second target nodes correspond to different functions.

[0148] Optionally, the above-mentioned target execution statement includes a database execution statement; the parsing result also includes the database operated by the database execution statement and the corresponding data processing operation; based on the parsing result, the step of generating the first target node includes: determining whether the database operated by the database execution statement is a preset database; if so, determining whether the data processing operation corresponding to the database execution statement is a data write operation; if so, generating the first target node based on the parsing result.

[0149] Optionally, the above-mentioned code call chain includes multiple nodes, each node has a corresponding function; the target program code includes multiple files; the step of determining the code difference data corresponding to the function indicated by the code call chain based on the second version of the target program code and the first version of the target program code includes: comparing the file of the second version of the target program code with the file of the first version of the target program code; based on the comparison result, determining the modified file in the file of the second version of the target program code; based on the function corresponding to the node of the code call chain, determining the target file in the modified file; based on the target file and the corresponding file in the first version of the target program code, determining the code difference data corresponding to the function indicated by the code call chain.

[0150] Optionally, the above step of determining the code difference data corresponding to the function indicated by the code call chain based on the target file and the corresponding file in the first version of the target program code includes: for each function indicated by the code call chain, searching for the target file corresponding to the function from the target file; if found, determining the code difference data corresponding to the function based on the found target file and the corresponding file of the function in the first version of the target program code.

[0151] Optionally, the above method also includes: if the function is not found, deleting the node corresponding to the function from the code call chain, and updating the code call chain.

[0152] Optionally, the node in the above code call chain has a related node list; the related node list includes other nodes called by the node, and other nodes that call the node; the above method also includes: determining the related nodes of the deleted node; the related node list of the related nodes includes the deleted node; and deleting the deleted node from the related node list of the related node.

[0153] Optionally, the above-mentioned operation data includes multiple specified execution statements; the multiple specified execution statements are stored in a preset cache queue in sequence according to the order of generation; the code call chain has a corresponding time parameter; the time parameter indicates the generation time of the operation data used to generate the code call chain; the above-mentioned method also includes: reading second operation data from the cache queue; the generation time of the second operation data is later than the time parameter; based on the second operation data, updating the code call chain; updating the time parameter of the updated code call chain to the generation time of the second operation data.

[0154] Optionally, the above-mentioned step of updating the code call chain based on the second running data includes: determining multiple second functions based on the second running data; the second function is called before executing the target execution statement; if the code call chain does not include a third function among the multiple second functions, generating a third target node based on the third function; and updating the code call chain based on the third target node.

[0155] See also Fig. 9 As shown, the electronic device includes a processor 100 and a memory 101. The memory 101 stores machine executable instructions that can be executed by the processor 100. The processor 100 executes the machine executable instructions to implement the above-mentioned program code data processing method.

[0156] Further, Fig. 9 The electronic device shown further includes a bus 102 and a communication interface 103 , and the processor 100 , the communication interface 103 and the memory 101 are connected via the bus 102 .

[0157] The memory 101 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 102 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig. 9 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0158] The processor 100 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 100. The above processor 100 can be a general-purpose processor, including 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 gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present disclosure can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present disclosure can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 101, and the processor 100 reads the information in the memory 101 and completes the steps of the method of the above embodiment in combination with its hardware.

[0159] This embodiment also provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the above-mentioned program code data processing method.

[0160] The embodiments of the present disclosure provide a method, device, and electronic device for processing program code data, including a computer-readable storage medium storing program code, wherein the program code includes instructions that can be used to execute the methods described in the foregoing method embodiments, for example:

[0161] Obtain first running data generated by a server running a first version of a target program code; obtain a target execution statement from the first running data, and determine a code call chain corresponding to the target execution statement based on the first running data; the code call chain is used to indicate multiple functions required to be called to execute the target execution statement, as well as the calling relationship between the multiple functions; based on the second version of the target program code and the first version of the target program code, determine code difference data of the function indicated by the code call chain.

[0162] In the above method, users can clearly understand the code execution process corresponding to the preset requirements affected by the modified function by viewing the code call chain, which improves the efficiency of analyzing business functions affected by code modifications. The code call chain is generated based on the server's operating data, and the code call relationship is more accurate, thereby improving the accuracy of the analysis of business impact effects.

[0163] Optionally, the above-mentioned step of determining the code call chain corresponding to the target execution statement based on the first running data includes: generating a first target node based on the target execution statement; determining multiple first functions based on the first running data; the first function is called before executing the target execution statement; generating a second target node based on the first function; generating a code call chain corresponding to the target execution statement based on the calling relationship between the first target node, the second target node and multiple first functions.

[0164] Optionally, the step of generating the first target node based on the target execution statement includes: parsing the target execution statement to obtain a parsing result; the parsing result includes a grammatical structure of the target execution statement; and generating the first target node based on the parsing result.

[0165] Optionally, the above-mentioned target execution statement includes multiple database execution statements; the parsing result also includes the database operated by the database execution statement and the corresponding data processing operation; based on the parsing result, the step of generating the first target node includes: generating the first target node based on the parsing result of the first database execution statement among the multiple database execution statements; if the grammatical structure of the second database execution statement among the multiple database execution statements is the same as the grammatical structure of the first target execution statement, and the database operated by the second database execution statement is the same as the database operated by the first target specified statement, the first target node corresponding to the first database execution statement is determined as the first target node corresponding to the second database execution statement.

[0166] Optionally, the method further includes: for each first target node, determining a first called node list corresponding to the first target node; the called node list includes a second target node that calls the first target node.

[0167] Optionally, the above method also includes: for each second target node, generating a second called node list corresponding to the second target node, and a calling node list; the called node list includes other second target nodes that call the second target node; the calling node list includes other second target nodes and\or the first target node called by the second target node.

[0168] Optionally, in the above code call chain, different second target nodes correspond to different functions.

[0169] Optionally, the above-mentioned target execution statement includes a database execution statement; the parsing result also includes the database operated by the database execution statement and the corresponding data processing operation; based on the parsing result, the step of generating the first target node includes: determining whether the database operated by the database execution statement is a preset database; if so, determining whether the data processing operation corresponding to the database execution statement is a data write operation; if so, generating the first target node based on the parsing result.

[0170] Optionally, the above-mentioned code call chain includes multiple nodes, each node has a corresponding function; the target program code includes multiple files; the step of determining the code difference data corresponding to the function indicated by the code call chain based on the second version of the target program code and the first version of the target program code includes: comparing the file of the second version of the target program code with the file of the first version of the target program code; based on the comparison result, determining the modified file in the file of the second version of the target program code; based on the function corresponding to the node of the code call chain, determining the target file in the modified file; based on the target file and the corresponding file in the first version of the target program code, determining the code difference data corresponding to the function indicated by the code call chain.

[0171] Optionally, the above step of determining the code difference data corresponding to the function indicated by the code call chain based on the target file and the corresponding file in the first version of the target program code includes: for each function indicated by the code call chain, searching for the target file corresponding to the function from the target file; if found, determining the code difference data corresponding to the function based on the found target file and the corresponding file of the function in the first version of the target program code.

[0172] Optionally, the above method also includes: if the function is not found, deleting the node corresponding to the function from the code call chain, and updating the code call chain.

[0173] Optionally, the node in the above code call chain has a related node list; the related node list includes other nodes called by the node, and other nodes that call the node; the above method also includes: determining the related nodes of the deleted node; the related node list of the related nodes includes the deleted node; and deleting the deleted node from the related node list of the related node.

[0174] Optionally, the above-mentioned operation data includes multiple specified execution statements; the multiple specified execution statements are stored in a preset cache queue in sequence according to the order of generation; the code call chain has a corresponding time parameter; the time parameter indicates the generation time of the operation data used to generate the code call chain; the above-mentioned method also includes: reading second operation data from the cache queue; the generation time of the second operation data is later than the time parameter; based on the second operation data, updating the code call chain; updating the time parameter of the updated code call chain to the generation time of the second operation data.

[0175] Optionally, the above-mentioned step of updating the code call chain based on the second running data includes: determining multiple second functions based on the second running data; the second function is called before executing the target execution statement; if the code call chain does not include a third function among the multiple second functions, generating a third target node based on the third function; and updating the code call chain based on the third target node.

[0176] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0177] In addition, in the description of the embodiments of the present disclosure, 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 disclosure can be understood according to specific circumstances.

[0178] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.

[0179] In the description of the present disclosure, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present disclosure and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present disclosure. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.

[0180] Finally, it should be noted that the above embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above embodiments, those skilled in the art should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A method for processing program code data, characterized in that: The method comprises: Acquire first running data generated by the server running the first version of the target program code; Acquire a target execution statement from the first operation data, and determine a code call chain corresponding to the target execution statement based on the first operation data; the code call chain is used to indicate multiple functions required to be called to execute the target execution statement, and a calling relationship between the multiple functions; Based on the second version of the target program code and the first version of the target program code, code difference data of the function indicated by the code call chain is determined.

2. The method according to claim 1, characterized in that The step of determining a code call chain corresponding to the target execution statement based on the first running data includes: Based on the target execution statement, generate a first target node; Based on the first operation data, a plurality of first functions are determined; the first functions are called before executing the target execution statement; Based on the first function, generating a second target node; Based on the calling relationship among the first target node, the second target node and the plurality of first functions, a code calling chain corresponding to the target execution statement is generated.

3. The method according to claim 2, characterized in that The step of generating a first target node based on the target execution statement includes: Parsing the target execution statement to obtain a parsing result; the parsing result includes a grammatical structure of the target execution statement; Based on the parsing result, a first target node is generated.

4. The method according to claim 3, characterized in that The target execution statement includes a plurality of database execution statements; the parsing result also includes the database operated by the database execution statement; Based on the parsing result, the step of generating a first target node includes: Generate a first target node based on the parsing result of a first database execution statement among the plurality of database execution statements; If the grammatical structure of a second database execution statement among the multiple database execution statements is the same as the grammatical structure of the first target execution statement, and the database operated by the second database execution statement is the same as the database operated by the first target specified statement, the first target node corresponding to the first database execution statement is determined as the first target node corresponding to the second database execution statement.

5. The method according to claim 2, characterized in that: The method further comprises: For each of the first target nodes, a first called node list corresponding to the first target node is determined; the called node list includes a second target node that calls the first target node.

6. The method according to claim 2, characterized in that The method further comprises: For each second target node, determine the second called node list and the calling node list corresponding to the second target node; the called node list includes other second target nodes that call the second target node; the calling node list includes other second target nodes called by the second target node and\or the first target node.

7. The method according to claim 2, characterized in that In the code call chain, different second target nodes correspond to different functions.

8. The method according to claim 3, characterized in that The target execution statement includes a database execution statement; the parsing result also includes the database operated by the database execution statement and the corresponding data processing operation; Based on the parsing result, the step of generating a first target node includes: Determine whether the database on which the database statement operation is executed is a preset database; If yes, determining whether the data processing operation corresponding to the database execution statement is a data writing operation; If yes, a first target node is generated based on the parsing result.

9. The method according to claim 1, characterized in that: The code call chain includes a plurality of nodes, each node having a corresponding function; the target program code includes a plurality of files; The step of determining code difference data corresponding to the function indicated by the code call chain based on the second version of the target program code and the first version of the target program code comprises: comparing the files of the second version of the object program code with the files of the first version of the object program code; Based on the comparison result, determining modified files in the files of the target program code of the second version; Determine a target file in the modified file based on a function corresponding to a node in the code call chain; Based on the target file and the corresponding file in the target program code of the first version, code difference data corresponding to the function indicated by the code call chain is determined.

10. The method according to claim 9, characterized in that The step of determining the code difference data corresponding to the function indicated by the code call chain based on the target file and the corresponding file in the target program code of the first version includes: For each function indicated by the code call chain, searching the target file corresponding to the function from the target file; If found, code difference data corresponding to the function is determined based on the found target file and the corresponding file of the function in the target program code of the first version.

11. The method according to claim 10, characterized in that The method further comprises: If not found, the node corresponding to the function is deleted from the code call chain, and the code call chain is updated.

12. The method according to claim 11, characterized in that The node in the code call chain has a related node list; the related node list includes other nodes called by the node, and other nodes that call the node; The method further comprises: Determine related nodes of the deleted node; the deleted node is included in a related node list of the related nodes; The deleted node is deleted from the related node list of the related node.

13. The method according to claim 1, characterized in that The operation data includes a plurality of designated execution statements; the plurality of designated execution statements are sequentially stored in a preset cache queue in the order in which they are generated; The code call chain has corresponding time parameters; The time parameter indicates the generation time of the running data used to generate the code call chain; The method further comprises: Reading second operation data from the cache queue; the generation time of the second operation data is later than the time parameter; Based on the second running data, updating the code call chain; The updated time parameter of the code call chain is updated to the generation time of the second running data.

14. The method according to claim 13, characterized in that The step of updating the code call chain based on the second running data includes: Based on the second operation data, determining a plurality of second functions; the second functions are called before executing the target execution statement; If the code call chain does not include a third function among the plurality of second functions, generating a third target node based on the third function; Based on the third target node, the code call chain is updated.

15. A device for processing program code data, characterized in that: The device comprises: An operation data acquisition module, used for acquiring first operation data generated by the server running the first version of the target program code; a code call chain generation module, configured to obtain a target execution statement from the first operation data, and determine a code call chain corresponding to the target execution statement based on the first operation data; the code call chain is used to indicate multiple functions required to be called to execute the target execution statement, and a calling relationship between the multiple functions; The code difference data determination module is used to determine the code difference data of the function indicated by the code call chain based on the second version of the target program code and the first version of the target program code.

16. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the method for processing program code data according to any one of claims 1 to 14.

17. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the method for processing program code data according to any one of claims 1 to 14.

Citation Information

Patent Citations

  • Source code analysis method and device, electronic equipment and storage medium

    CN116303013A

  • Regression testing method and device and storage medium

    CN116467210A

  • Dynamic call chain acquisition method and device, electronic equipment and readable storage medium

    CN117850787A

  • Coverage rate acquisition method and system, electronic equipment and storage medium

    CN118012766A

  • Execution result caching and searching

    US20100306751A1

Cited By

  • Repeated code snippet extraction method and system and storage medium

    CN122387864A