Program code analysis method and memory state analysis method based on analysis system

Through the method based on the parsing system, a parsing file is generated and the query model is used to find the properties and access paths of the structure field, the problem of too many structure fields and complex hierarchical structure in the program code is solved, reducing the difficulty of problem positioning and improving efficiency and accuracy.

CN119621143AActive Publication Date: 2025-03-14INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510158521.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-13
Publication Date
2025-03-14
Estimated Expiration
2045-02-13

AI Technical Summary

Technical Problem

In the prior art, there are too many structural fields in the program code and the hierarchical structure is complex, making it difficult for technicians to fully grasp all fields, thereby increasing the difficulty of positioning program code problems.

Method used

Using a method based on the parsing system, by obtaining the target program code and parsing reference information, building a prompt word and inputting a parsing model, a parsing file is generated, which contains the field properties and field access path of the structure field. At the same time, the query model is used to find the field properties and field access paths of the target structure field in the parsing file, and then perform memory state analysis.

Benefits of technology

It reduces the difficulty of positioning program code problems. Technical personnel can obtain parsed files without manually writing parsing files, and locate problems without being familiar with the target data structure, improving the efficiency and accuracy of problem positioning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119621143A_ABST
    Figure CN119621143A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, and discloses a program code analysis method and a memory state analysis method based on an analysis system. The method comprises: obtaining a target program code; parsing reference information is obtained, a first cue word is constructed according to the parsing reference information, and the parsing reference information comprises one or more of code parsing logic, example program codes, parsing examples and position features of the target data structure; inputting the target program code and the first cue word into an analysis model to obtain an analysis file, and obtaining field identification information of a target structure body field in the target program code; inputting the field identification information into a query model, and searching a field attribute and a field access path of the target structure body field; according to the field attribute and the field access path, searching a current value of the target structure body field in the memory in the analyzed memory state file; and performing memory state analysis according to the current value of the target structure body field. The problem positioning difficulty can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a program code parsing method and a memory state analysis method based on a parsing system. Background Art

[0002] With the rapid development of technologies such as big data, cloud computing, and cloud disks, the architecture of storage systems has gradually become more complex. This complexity is not only reflected in the diversification of storage media, but also in the multi-level design at the software level. Among them, the multi-level design at the software level involves file systems, data backup, cache mechanisms, data reduction / compression and deduplication, space virtualization, etc. The software functions in these storage systems may require more than millions of lines of program code to implement. In order to quickly locate problems in program code, some technologies will generate memory status files (also known as dump files). The memory status file includes the complete memory status of the program code in the storage system at the time when the problem occurs (such as the stack information of the process, the current value in the register, the memory allocation status, log information, etc.). By parsing the memory status file, the current values ​​of each field in the program code can be obtained. By analyzing the current values ​​of these fields, the location of the problem in the program code can be located, and then the problem can be corrected.

[0003] At present, it is generally the technicians who manually parse the memory status file and locate the program code problems in the storage system based on the parsing results. However, there are too many fields in the memory status file and the hierarchical structure is relatively complex. It is difficult for technicians to fully understand all the fields, which makes it difficult to locate the problem. Summary of the invention

[0004] In view of this, the present disclosure provides a program code parsing method, a memory status analysis method, an electronic device, a computer-readable storage medium, and a computer program product, which can reduce the difficulty of problem locating.

[0005] In a first aspect, the present disclosure provides a program code parsing method based on a parsing system, wherein the parsing system includes a first data processing module and a trained parsing model, and the method is applied to the first data processing module; the method includes: Acquire a target program code, wherein the target program code includes a predefined target data structure, wherein the target data structure includes one or more structure fields; Acquire parsing reference information, and construct a first prompt word according to the parsing reference information, wherein the parsing reference information includes one or more of code parsing logic, sample program code, parsing examples, and location features of the target data structure; The target program code and the first prompt word are input into the parsing model so that the parsing model outputs a parsing file of the target program code, wherein the parsing file includes field attributes and field access paths of the structure fields.

[0006] In a second aspect, the present disclosure provides a memory state analysis method based on a parsing system, wherein the parsing system includes a second data processing module and a trained query model, and the method is applied to the second data processing module; the method includes: Obtaining field identification information of a target structure field in the target program code; The field identification information is input into a query model, and the query model searches for field attributes and field access paths of the target structure field in a parsed file generated based on the above method based on the field identification information; According to the field attribute and the field access path, searching the current value of the target structure field in the memory in the parsed memory status file; Memory status analysis is performed based on the current value of the target structure field.

[0007] In a third aspect, the present disclosure provides a program code parsing device based on a parsing system, wherein the parsing system includes a first data processing module and a trained parsing model, the method is applied to the first data processing module, and the device includes: A code acquisition module, used for acquiring a target program code, wherein the target program code includes a predefined target data structure, wherein the target data structure includes one or more structure fields; An information acquisition module, configured to acquire parsing reference information and construct a first prompt word according to the parsing reference information, wherein the parsing reference information includes one or more of code parsing logic, sample program code, parsing examples, and location features of the target data structure; The file generation module is used to input the target program code and the first prompt word into the parsing model so that the parsing model outputs a parsing file of the target program code, wherein the parsing file includes field attributes and field access paths of the structure fields.

[0008] In a fourth aspect, the present disclosure provides a memory state analysis device based on a parsing system, wherein the parsing system includes a second data processing module and a trained query model, and the method is applied to the second data processing module; the device includes: An identification information acquisition module is used to obtain field identification information of a target structure field in a target program code; An information search module, used for inputting the field identification information into a query model, and the query model searches for the field attributes and field access path of the target structure field in the parsed file generated based on the above method; A value search module, used to search the current value of the target structure field in the memory in the parsed memory status file according to the field attribute and the field access path; The analysis module is used to perform memory status analysis based on the current value of the target structure field.

[0009] In a fifth aspect, the present disclosure provides an electronic device, comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the above method by executing the computer instructions.

[0010] In a sixth aspect, the present disclosure provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the above method.

[0011] In a seventh aspect, the present disclosure provides a computer program product, including computer instructions, and the computer instructions are used to enable a computer to execute the above method.

[0012] In the technical scheme of some embodiments of the present disclosure, on the one hand, a first prompt word is constructed based on the positional features, code parsing logic, sample program code and parsing example of the target data structure in the target program code, and the first prompt word and the target program code are input into the parsing model, and the parsing file of the target program code is output through the parsing model. In this way, the technician can locate the program code problem without manually writing the parsing file, and in the case where the technician is not familiar with the meaning of the structure field in the target data structure and cannot use the binary editing tool, the parsing file can also be obtained, thereby achieving the purpose of reducing the difficulty of positioning. On the other hand, the field identification information of the target structure field is input into the query model, and the query model searches for the field attributes and field access path of the target structure field in the parsing file based on the field identification information. In this way, when the technician forgets the field attributes and field access path of the target structure field, the problem positioning of the program code can still be performed, thereby greatly reducing the difficulty of problem positioning. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0014] Figure 1 is a schematic diagram of modules of a parsing system provided by some embodiments of the present disclosure; Figure 2 is an interactive schematic diagram of a program code parsing method provided by some embodiments of the present disclosure; Figure 3 is a flowchart of a program code parsing method provided by some embodiments of the present disclosure; Figure 4 is an interactive schematic diagram of adding a fill field in a parsed file provided by some embodiments of the present disclosure; Figure 5 is an interactive schematic diagram of adding field descriptions in a parsed file provided by some embodiments of the present disclosure; Figure 6 is an interactive schematic diagram of a memory state analysis method provided by some embodiments of the present disclosure; Figure 7 is a flowchart of a memory state analysis method provided by some embodiments of the present disclosure; Figure 8 is a module diagram of a program code parsing device provided by an embodiment of the present disclosure; Fig. 9 is a module schematic diagram of a memory state analysis device provided by an embodiment of the present disclosure; Fig.10 It is a schematic diagram of the structure of an electronic device provided by some embodiments of the present disclosure. DETAILED DESCRIPTION

[0015] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all 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.

[0016] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0017] In the description of the embodiments of the present disclosure, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The term "some embodiments" should be understood as "at least some embodiments". Other explicit and implicit definitions may also be included below.

[0018] Herein, unless explicitly stated, executing a step “in response to A” does not mean executing the step immediately after “A” but may include one or more intermediate steps.

[0019] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition, use, storage or deletion of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.

[0020] It is understandable that before using the technical solutions disclosed in the various embodiments of the present disclosure, the types, scopes of use, usage scenarios, etc. of the information involved in the present disclosure should be informed to relevant users and their authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations. The relevant users may include any type of right holders, such as individuals, enterprises, and groups.

[0021] For example, in response to receiving an active request from a user, a prompt message is sent to the relevant user to clearly prompt the relevant user that the operation requested to be performed will require obtaining and using the information of the relevant user, so that the relevant user can independently choose whether to provide information to software or hardware such as an electronic device, application, server or storage medium that executes the operation of the technical solution of the present disclosure based on the prompt message.

[0022] As an optional but non-limiting implementation, in response to receiving an active request from a relevant user, a prompt message is sent to the relevant user, for example, in the form of a pop-up window, in which the prompt message may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to select "agree" or "disagree" to provide information to the electronic device.

[0023] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet relevant laws and regulations may also be applied to the implementation of the present disclosure.

[0024] When a problem occurs in the program code in the storage system, the memory status file (i.e., dump file) can be parsed to obtain the current values ​​of each field in the program code. By comparing the current values ​​of each field with the theoretical values, the location of the problem in the program code can be located. For example, suppose the current value of field A parsed from the memory status file is 100. But theoretically, the value range of field A should be between 20 and 50. Then, it can be determined that there may be a problem with the program code related to field A in the storage system, and the program code problem can be modified.

[0025] In some technologies, the memory status file is a binary file. When locating the problem of the program code, the technician needs to manually perform the following steps 11)~13): 11) Write a parsing file for the program code based on the data structure defined in the program code.

[0026] The parsed file may include at least some of the structure fields of the data structure and the field attributes of these structure fields and the field access path. The field attributes may include but are not limited to the field name, field type, and the offset address of the structure field in the memory. The content in the parsed file and the content in the program code can be mapped according to the rules, for example, the int test in the program code can be mapped to the n32 test in the parsed file.

[0027] The field access path refers to the nested relationship between the data structure where the structure field is located and other data structures. This nested relationship is used to describe how to access the structure field starting from the root data structure, through one or more intermediate data structures. For example, suppose the following two global data structures are defined in the program code: struct NestedStruct { int f; short g; }; struct MyStruct { char a; int b; struct NesteStruct n; double d; char e

[10] ; }; Take the structure field f as an example. The data structure where the structure field f is located is NesteStruct, and the data structure NesteStruct is nested in the data structure MyStruct. Therefore, in the parsing file, the field access path and field attributes of the structure field f can be expressed in the following way: MyStruct { NesteStruct { n32 "f" } } Furthermore, each data structure can have its own corresponding base address. By combining the field access path, offset address and field type of each structure field in the parsed file, the current value of each structure field can be found in the memory. For example, in the above example, assuming that the base address of the data structure NesteStruct is 0x1000 and the offset address of the structure field f is 0x0020, the current value of the structure field f can be obtained at the physical address 0x1000+0x0020 in the memory.

[0028] 12) Based on the format of the parsed file, use a binary editing tool to parse the memory status file into a readable file to obtain the current value of each structure field in the data structure in memory.

[0029] For example, suppose the content of the parsed file is: struct { n32 "test1" n16 "test2" n16 "pad" n64 "test3" } Among them, the structure field pad is a padding field for achieving memory alignment and does not represent data.

[0030] According to the format of the parsed file, the memory status file is parsed and the following content can be obtained: test1 5 test2 2 pad 0 test3 1 The above content indicates that in the memory, the current value of the structure field test1 is 5, the current value of the structure field test2 is 2, and the current value of the structure field test3 is 3.

[0031] 13) From the parsed memory status file, check the current value of one or more structure fields, and compare the current value of each structure field with the theoretical value to locate program code problems.

[0032] Currently, when technicians manually perform the above steps 11)~13), the following problems occur: 21)~24): 21) There are many structure fields in the program code, and technicians usually cannot understand the meaning of all the structure fields. When writing the parsing file of the program code, they need to analyze the program code or consult with people who are familiar with the relevant structure fields. The process is cumbersome and difficult.

[0033] 22) In the process of writing the parsing file, it is not only required to write the structure fields one by one according to the data structure in the program code, but also to correctly align the memory address according to the structure fields and the memory size occupied by the structure. If the alignment is wrong, the memory status file cannot be correctly parsed according to the parsing file. This requires technicians to have high professional skills.

[0034] 23) When parsing the memory status file according to the format of the parsed file, the technician needs to master the use of binary editing tools, which requires high professional skills of the technician.

[0035] 24) When locating the problem of the program code based on the parsed memory status file, due to the large number of structure fields, the technicians cannot remember the field names and field access paths of all the structure fields, which increases the difficulty of locating the problem.

[0036] In summary, in some technologies, it is difficult to locate problems in the program code of the storage system, which results in the efficiency and accuracy of problem location being affected accordingly. To solve the above problems, the present disclosure first provides a parsing system. Figure 1 , which is a module diagram of the parsing system provided in some embodiments of the present disclosure. Figure 1 In the embodiment, the parsing system includes a first data processing module, a second data processing module, a trained parsing model, an alignment model, a description supplement model and a query model.

[0037] based on Figure 1 The present disclosure provides a program code parsing method based on the parsing system, which can reduce the difficulty of writing program code parsing files, thereby improving the efficiency and accuracy of program code positioning. The program code parsing method can be applied to the first data processing module in the parsing system, or can be applied to an electronic device running the parsing system. The electronic device can include but is not limited to a tablet computer, a laptop computer, a tablet computer, a server, etc. Figure 2 and Figure 3 . Figure 2 An interactive schematic diagram of a program code parsing method provided for some embodiments of the present disclosure. Figure 3 A flowchart of a program code parsing method provided for some embodiments of the present disclosure. Figure 3 In the method for analyzing program code, the method comprises the following steps: Step S301, obtaining a target program code, wherein the target program code includes a predefined target data structure, and the target data structure includes one or more structure fields.

[0038] In this embodiment, Figure 1 The first data processing module in the system can display a first human-computer interaction interface. Through the first human-computer interaction interface, the target program code or the storage path of the target program code input by the technician can be received. When the storage path of the target program code is received, the target program code can be obtained from the corresponding storage path.

[0039] The target program code may be a program code used to implement various software functions in the storage system, such as program code used to implement file system, data backup, cache mechanism, data reduction / compression and deduplication, space virtualization and other functions.

[0040] During the coding process of the target program code, one or more data structures can be defined. For example, in the target program code, a data structure MyStruct can be defined as follows:

[0041] After defining the data structure, the operating system can allocate memory space for the structure fields in the memory according to the field type of each structure field in the data structure.

[0042] Further, the data structure in the target program code can be divided into a global data structure and a local data structure. The global data structure is generally defined at the starting position of the target program code, and the local data structure is generally defined and used inside the function of the target program code. Normally, during the operation of the target program code, the global data structure can occupy memory space all the time, and the local data structure only occupies memory space during the operation of the corresponding function. When locating the problem of the target program code, it is generally mainly to compare the current value and theoretical value of each structure field in the global data structure. In view of this, in the present embodiment, the global data structure in the target program code can be used as the target data structure, and the target data structure includes one or more structure fields.

[0043] Step S302, obtaining parsing reference information, and constructing a first prompt word according to the parsing reference information, wherein the parsing reference information includes one or more of code parsing logic, sample program code, parsing examples, and location features of a target data structure.

[0044] In this embodiment, the electronic device executing the program code parsing method can display a second human-computer interaction interface. Through the second human-computer interaction interface, the parsing reference information of the target data structure input by the technician can be received. The parsing reference information may include code parsing logic, sample program code, parsing examples, and location characteristics of the global data structure in the target program code. Among them: The location features may include, but are not limited to, the regional location of the target data structure in the target program code (such as the line number of the target data structure in the target program code), the program code around the global data structure in the target program code, etc.

[0045] The code parsing logic may include a mapping relationship between the target program code and the parsed file content, such as mapping an int in the target program code to an n32 in the parsed file.

[0046] The sample program code may be part of the target program code or other program code outside the target program code. The sample program code may include a target data structure (such as a global data structure), and the target data structure in the sample program code is annotated. Thus, the target data structure can be identified in the sample program code through annotation.

[0047] The parsing example may be content in an example parsing file obtained by parsing the example program code.

[0048] By combining the above-mentioned position features, code parsing logic, sample program code and parsing examples, a first prompt word can be obtained, or by extracting keywords from the above-mentioned position features, code parsing logic, sample program code and parsing examples, and combining the keywords, a first prompt word can be obtained. Of course, the method for constructing the prompt word may include but is not limited to the above two methods, and the present disclosure does not limit the method for constructing the prompt word. For example, the above-mentioned position features, code parsing logic, sample program code and parsing examples can also be processed using natural language processing technology to obtain a prompt word.

[0049] It should be noted that, according to actual needs, the parsing reference information may only include part of the location features, code parsing logic, sample program code, and parsing examples. For example, it may only include code parsing logic, sample program code, and parsing examples, but not location features. The present disclosure does not limit this. In addition, according to actual needs, the target data structure may also include a local data structure. The present disclosure does not limit this.

[0050] Step S303: input the target program code and the first prompt word into the parsing model, so that the parsing model outputs a parsing file of the target program code, wherein the parsing file includes field attributes and field access paths of the structure fields.

[0051] Specifically, the parsing model may be a trained first language model. The parsing model uses the first prompt word as a reference and, based on the knowledge learned during the training process, can extract and output field attributes and field access paths of each structure field in the target data structure.

[0052] Field attributes may include but are not limited to field type, field size, field offset address, etc.

[0053] In this embodiment, the target program code may include multiple target data structures. The parsing model writes the hierarchical relationship between the target data structures in the parsing file, and represents the field access path of the structure field through the hierarchical relationship. For example, assuming that the structure field f is located in the target data structure NesteStruct, and the target data structure NesteStruct is located in the target data structure MyStruct, the parsing model can specify the field access path of the structure field f in the parsing file in the following manner: MyStruct { NesteStruct { n32 "f" } } In the hierarchical relationship between target data structures, target data structures at different levels may have different indentations. The higher the level of a target data structure, the less its indentation may be. Based on the indentation of each target data structure, the hierarchical relationship between the target data structures may be determined. For example, in the field access path of the structure field f above, the indentation of the target data structure MyStruct is less than the indentation of the target data structure NesteStruct.

[0054] In this embodiment, when the parsing reference information includes the location characteristics of the target data structure, the code parsing logic, the sample program code and the parsing example, the parsing model can output the parsing file based on the following method: Extracting the target data structure from the target program code according to the location feature of the target data structure; According to the code parsing logic, perform syntax conversion on the target data structure; With the sample program code and parsing examples as reference, generate and output the parsing file according to the target data structure after grammar conversion.

[0055] For example, assuming that the parsing reference information specifies that the location of the target data structure is located in the 2nd to 50th lines of the target program code, then according to the form of the data structure annotated in the example program code, a data structure with a corresponding form can be searched in the 2nd to 50th lines of the target program code as the target data structure. After the target data structure is found, the target data structure can be converted into a syntax according to the code parsing logic, and the field attributes and field access paths of each field in the target data structure can be written into the parsing file according to the style of the parsing example.

[0056] In the above embodiment, the location characteristics of the target data structure, the code parsing logic, the sample program code and the parsing example are selected as the parsing reference information, which has a relatively high reference value, thereby ensuring the accuracy of the generated parsing file.

[0057] In the technical solutions of some embodiments of the present disclosure, a first prompt word is constructed based on the positional features of the target data structure in the target program code, code parsing logic, sample program code, and parsing examples, and the first prompt word and the target program code are input into the parsing model, and a parsing file of the target program code is output through the parsing model. In this way, when locating program code problems, technicians do not need to manually write parsing files, and even if the technicians are not familiar with the meaning of the structure fields in the target data structure and do not know how to use binary editing tools, they can still obtain parsing files, thereby achieving the purpose of reducing the difficulty of locating.

[0058] Combined with reference Figure 4 In some embodiments, after obtaining the parsed file, the method of the present disclosure may further include: Acquire alignment reference information, and construct a second prompt word according to the alignment reference information, wherein the alignment reference information includes memory address alignment logic and / or alignment examples of structure fields; The second prompt word and the parsed file are input into the alignment model, so that the alignment model adds a padding field in the parsed file, and the padding field is used to make the memory address of the structure field meet the memory address alignment logic.

[0059] Specifically, the memory address alignment logic can characterize the memory address alignment requirements of each structure field in the target program code. For example, assume that structure field B is stored after structure field A, structure field A occupies 16 bits of memory, structure field B occupies 32 bits of memory, and the memory address of structure field B is required to start from a 4-byte aligned address. Based on the above assumptions, if structure field B is saved directly after structure field A, the memory address of structure field B does not start from a 4-byte aligned address. Therefore, a 16-bit padding field needs to be filled after structure field A to ensure that structure field B is saved from a 4-byte aligned address. This data storage method based on memory address alignment can increase the data reading speed. An alignment example can be the content of some of the padding fields that have been added to the parsed file.

[0060] Similar to the construction method of the first prompt word, the memory address alignment logic and the alignment example can be combined to obtain the second prompt word, or keywords can be extracted from the memory address alignment logic and the alignment example and the keywords can be combined to obtain the second prompt word.

[0061] In this embodiment, the electronic device executing the program code parsing method can display a third human-computer interaction interface. Through the third human-computer interaction interface, the alignment reference information input by the technician can be received. The alignment model can be a trained second language model.

[0062] By adding padding fields to the parsing file, it can be ensured that the memory address of the structure field meets the memory address alignment requirement, and then when the memory status file is parsed based on the parsing file, the correctness of the parsing result can be guaranteed.

[0063] Combined with reference Figure 5 In some embodiments, after obtaining the parsed file, the method of the present disclosure may further include: Obtaining an example field and a field description corresponding to the example field, and constructing a third prompt word according to the correspondence between the example field and the field description; The third prompt word and the parsing file are input into the description supplement model so that the description supplement model adds the field description of the structure field in the parsing file.

[0064] Specifically, the supplementary model can be a trained third language model. The construction method of the third prompt word is similar to that of the first prompt word and the second prompt word, which will not be repeated here. The supplementary model uses the third prompt word as a reference and, based on the knowledge learned during the training process, can supplement the field descriptions of each structure field in the parsing file. The field description can represent the meaning of the structure field, instructions for use, etc.

[0065] By adding field descriptions to the parsed file, it is easier for technicians to view the meaning of each structure field and other related instructions based on the field description. In this way, even if the technicians do not understand all the structure fields, they can still locate the problem of the program code, which greatly reduces the difficulty of problem location.

[0066] In the above embodiment, the electronic device executing the program code parsing method can display a fourth human-computer interaction interface. Through the fourth human-computer interaction interface, the example fields and field descriptions corresponding to the example fields input by the technician can be received.

[0067] In some embodiments, the example fields may be some structure fields in the parsed file. The description supplement model may add field descriptions in the parsed file based on the following method: For any structure field in the parsed file, if the structure field is an example field, the field description of the structure field in the third prompt word is added to the parsed file; if the structure field is not an example field, the third prompt word is used as a reference to add a field description for the structure field in the parsed file.

[0068] When some structure fields in the parsed file are used as example fields, the example fields and the structure fields are from the same file, and the field description style of the example fields can have a high degree of similarity with the structure fields. Therefore, when adding field descriptions for the structure fields, the field descriptions of the example fields can have a high degree of reference, thereby ensuring the accuracy of the field descriptions of the structure fields.

[0069] In some embodiments, the above-mentioned parsing model, alignment model and description supplement model can be integrated into a total model. After the above-mentioned first prompt word, second prompt word, third prompt word and target program code are input into the total model, a parsing file with added fill-in fields and field descriptions can be obtained. Through model integration, it is not necessary to generate a parsing file in multiple steps, thereby simplifying the operation.

[0070] Based on the parsed file, the present disclosure also provides a memory status analysis method based on the parsing system, which can further reduce the difficulty of locating program code problems. The memory status analysis method can be applied to the second data processing module in the parsing system, or can be applied to the electronic device running the parsing system. The electronic device may include a tablet computer, a laptop computer, a server, etc. Figure 6 and Figure 7 . Figure 6 An interactive schematic diagram of a memory status analysis method provided for some embodiments of the present disclosure. Figure 7 A flowchart of a memory status analysis method provided for some embodiments of the present disclosure. Figure 7 In the memory state analysis method, the memory state analysis method includes the following steps: Step S701, obtaining field identification information of a target structure field in a target program code.

[0071] Specifically, the target structure field may be a field selected by a technician for use in locating a program code problem. The second data processing module that performs memory state analysis may display a human-computer interaction interface to receive at least one of the following information of the target structure field through the human-computer interaction interface, and use the received information as field identification information: Field name, field ID, field description.

[0072] For example, when the technician is able to determine the field name or field ID of the target structure field, the field name or field ID of the target structure field can be entered in the human-computer interaction interface as field identification information; when the technician is unable to determine the field name or field ID of the target structure field, the field description of the target structure field can be entered in the human-computer interaction interface, and these field descriptions can be used as field identification information.

[0073] Furthermore, in order to ensure the accuracy of the field information, the technician can also use the combination of the field name and the field description of the target structure field as the field identification information. In this way, when the same field name exists in the program code, the target structure field can be identified based on the field description.

[0074] In this embodiment, considering that when there are many structure fields, the technician may not be able to grasp the field names and field descriptions of all structure fields, therefore, in the human-computer interaction interface, the technician may also be allowed to input partial field names and partial field descriptions of the target structure fields. Furthermore, one of the following information of the target structure field may be used as the field identification information, or a combination of at least two of the following information may be used as the field identification information: Partial field name, partial field description For example, suppose the field name of the target structure field is "VedioSourceID" and the field description is "Video Resource ID". If the technician can only remember part of the field name "SourceID" and the field description "Video ID", they can enter "SourceID" and "Video ID" in the human-computer interaction interface as the field identification information of the target structure field.

[0075] In the above embodiment, it is allowed to use part of the field name and part of the field description of the target structure field as field identification information. In this way, when the technician cannot completely remember the field name or field description of the target structure field, the method disclosed in the present invention can still be executed to locate program code problems. The scope of use is wider and the difficulty of problem location is reduced.

[0076] Step S702: input the field identification information into the query model, and the query model searches for the field attributes and field access path of the target structure field in the parsing file generated based on the above program code parsing method.

[0077] In this embodiment, the query model may be a trained fourth language model. The query model may search for field attributes and field access paths of the target structure field in the parsed file based on the following method: Match and compare the field identification information of the target structure field with the field identification information of the structure field in the parsed file, and obtain the structure field in the parsed file that matches the target structure field as a candidate field; The field attributes and field access path of the candidate field are used as the field attributes and field access path of the target structure field.

[0078] Specifically, if there is a structure field in the parsed file that has the same field identification information as the target structure field, the corresponding structure field is used as a candidate field; If there is no field in the parsed file that has the same field identification information as the target structure field, the field identification information of the target structure field is semantically compared with the field identification information of the structure field in the parsed file to obtain the structure field in the parsed file that has the same semantics as the target structure field as the candidate field.

[0079] For example, when the acquired field identification information is a combination of a partial field name and a partial field description of the target structure field, the query model can understand the semantics of the field identification information and search for fields in the parsed file that semantically match the field name and field description of the target structure field as candidate fields. In this way, even if the technician does not enter the complete field name and field description, the problem can still be located, greatly reducing the difficulty of problem location.

[0080] For another example, when the acquired field identification information is a complete field name and field description, the query model can search for fields in the parsed file whose field names and field descriptions are the same as the target structure fields as candidate fields. This can improve the accuracy of finding candidate fields and thus improve the accuracy of problem location.

[0081] In this embodiment, when the hierarchical relationship between target data structures is included in the parsed file, the field access path of the candidate field can be found according to the following method: Searching the parsed file for the first target data structure where the candidate field is located; According to the hierarchical relationship between the target data structures, if there are one or more second target data structures before the first target data structure, the first target data structure and the second target data structure are sorted according to the hierarchical relationship to obtain the field access path of the candidate field. If there is no second target data structure before the first target data structure, the first target data structure is used as the field access path of the candidate field. For example, assuming that in the parsed file, the hierarchical relationship between the target data structures corresponding to the candidate field f is as follows: MyStruct { NesteStruct { n32 "f" } } Then we can start from the candidate field f and search for the field NesteStruct which has one less indent than the candidate field f. The field NesteStruct is the structure name of the target data structure where the candidate field f is located. Then continue to search for the field MyStruct which has one less indent than the field NesteStruct. The field MyStruct is the structure name of the parent target data structure of the target data structure where the candidate field f is located. And so on, until the top-level field is found. Then, according to the hierarchical relationship between the target data structures, these structure names are sorted to obtain the field access path of the candidate field f. For example, the field access path of the candidate field f is MyStruct>NesteStruct>f.

[0082] Step S703, searching the current value of the target structure field in the memory in the parsed memory status file according to the field attribute and the field access path.

[0083] Specifically, according to the above parsing file, the memory status file can be parsed. According to the base address of each target data structure in the field access path and the field type of the structure field in the target data structure, the current value of the target structure field is found in the parsed memory status file. The relevant principle can be found in the above description, which will not be repeated here.

[0084] Step S704, performing memory status analysis based on the current value of the target structure field.

[0085] The so-called memory status analysis is to analyze whether the current value of the target structure field in the memory is reasonable. If it is unreasonable, it means that there is a problem with the program code of the storage system. The problem of the program code can be located according to the current value of the target structure field.

[0086] In the technical solutions of some embodiments of the present disclosure, the field identification information of the target structure field is input into the query model, and the query model searches for the field attributes and field access path of the target structure field in the parsed file based on the field identification information. In this way, when the technician forgets the field attributes and field access path of the target structure field, the problem of the program code can still be located, thereby greatly reducing the difficulty of problem location.

[0087] Corresponding to the program code analysis method, the present disclosure also provides a program code analysis device based on the analysis system. Figure 8 , which is a program code parsing device provided by an embodiment of the present disclosure. Figure 8 In the method, the program code parsing device comprises: The code acquisition module 801 is used to acquire the target program code, the target program code includes a predefined target data structure, and the target data structure includes one or more structure fields; An information acquisition module 802 is used to acquire parsing reference information and construct a first prompt word according to the parsing reference information, wherein the parsing reference information includes one or more of code parsing logic, sample program code, parsing examples, and location features of a target data structure; The file generation module 803 is used to input the target program code and the first prompt word into the parsing model so that the parsing model outputs a parsing file of the target program code, wherein the parsing file includes field attributes and field access paths of the structure fields.

[0088] In some embodiments, the parsing system further includes a trained alignment model; after obtaining the parsed file, the file generation module 803 is further used to: Acquire alignment reference information, and construct a second prompt word according to the alignment reference information, wherein the alignment reference information includes memory address alignment logic and / or alignment examples of structure fields; The second prompt word and the parsed file are input into the alignment model, so that the alignment model adds a padding field in the parsed file, and the padding field is used to make the memory address of the structure field meet the memory address alignment logic.

[0089] In some embodiments, the parsing system further includes a trained description supplement model; after obtaining the parsed file, the file generation module 803 is further used to: Obtaining an example field and a field description corresponding to the example field, and constructing a third prompt word according to the correspondence between the example field and the field description; The third prompt word and the parsing file are input into the description supplement model so that the description supplement model adds the field description of the structure field in the parsing file.

[0090] In some embodiments, the example fields are some structure fields in the parsed file; after the file generation module 803 inputs the third prompt word and the parsed file into the description supplement model, the description supplement model adds field descriptions to the parsed file based on the following method: For any structure field in the parsed file, if the structure field is an example field, the field description of the structure field in the third prompt word is added to the parsed file; if the structure field is not an example field, the third prompt word is used as a reference to add a field description for the structure field in the parsed file.

[0091] In some embodiments, the target program code includes multiple target data structures. After the file generation module 803 inputs the third prompt word and the parsing file into the description supplement model, the parsing model writes the hierarchical relationship between the target data structures in the parsing file, and represents the field access path of the structure field through the hierarchical relationship, wherein in the hierarchical relationship, target data structures at different levels have different indentations.

[0092] In some embodiments, when the parsing reference information includes code parsing logic, sample program code, parsing examples, and location features of the target data structure, after the file generation module 803 inputs the third prompt word and the parsing file into the description supplement model, the parsing model outputs the parsing file based on the following method: Extracting the target data structure from the target program code according to the location feature of the target data structure; According to the code parsing logic, perform syntax conversion on the target data structure; With the sample program code and parsing examples as reference, generate and output the parsing file according to the target data structure after grammar conversion.

[0093] Corresponding to the memory state analysis method, the present disclosure also provides a memory state analysis device based on the parsing system. Fig. 9 , which is a memory status analysis device provided by an embodiment of the present disclosure. Fig. 9 In the embodiment, the memory state analysis device comprises: The information acquisition module 901 is used to acquire the field identification information of the target structure field in the target program code; An information search module 902 is used to input the field identification information into a query model, and the query model searches for the field attributes and field access path of the target structure field in the parsed file generated based on the above method; The value search module 903 is used to search the current value of the target structure field in the memory in the parsed memory status file according to the field attribute and the field access path; The analysis module 904 is used to perform memory status analysis based on the current value of the target structure field.

[0094] In some embodiments, the information acquisition module 901 is specifically used to: Display a human-computer interaction interface to receive at least one of the following information of the target structure field through the human-computer interaction interface, and use the received information as field identification information: Field name, field ID, field description.

[0095] In some embodiments, after the information search module 902 inputs the field identification information into the query model, the query model searches for the field attributes and field access paths of the target structure field in the parsed file based on the following method: Match and compare the field identification information of the target structure field with the field identification information of the structure field in the parsed file, and obtain the structure field in the parsed file that matches the target structure field as a candidate field; The field attributes and field access path of the candidate field are used as the field attributes and field access path of the target structure field.

[0096] In some embodiments, after the information search module 902 inputs the field identification information into the query model, the query model is specifically used to: If there is a structure field in the parsed file that has the same field identification information as the target structure field, the corresponding structure field is used as a candidate field; If there is no field in the parsed file that has the same field identification information as the target structure field, the field identification information of the target structure field is semantically compared with the field identification information of the structure field in the parsed file to obtain the structure field in the parsed file that has the same semantics as the target structure field as the candidate field.

[0097] In some embodiments, when the target program code includes multiple target data structures and the parsed file includes the hierarchical relationship between the target data structures, the information search module 902 is specifically used to search for the field access path of the candidate field according to the following method: Searching the parsed file for the first target data structure where the candidate field is located; According to the hierarchical relationship between the target data structures, if there are one or more second target data structures before the first target data structure, the first target data structure and the second target data structure are sorted according to the hierarchical relationship to obtain the field access path of the candidate field; if there is no second target data structure before the first target data structure, the first target data structure is used as the field access path of the candidate field.

[0098] In some embodiments, the field attributes include the field type, and the field type is used to characterize the size of the memory space occupied by the structure field; the value search module 903 is specifically used to: According to the base address of each target data structure in the field access path and the field type of the structure field in the target data structure, the current value of the target structure field is found in the parsed memory status file.

[0099] The performance monitoring device of the input and output card in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0100] The present disclosure also provides an electronic device having the above Figure 8 The program code parsing device shown, or Fig. 9 The memory status analysis device is shown.

[0101] Combined with reference Fig.10 , is a schematic diagram of the structure of an electronic device provided by some embodiments of the present disclosure. Fig.10 As shown, the electronic device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Fig.10 A processor 10 is taken as an example.

[0102] The processor 10 may be a first PCIe device, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0103] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.

[0104] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0105] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0106] The electronic device further comprises a communication interface 30 for the electronic device to communicate with other devices or a communication network.

[0107] The embodiments of the present disclosure also provide a computer-readable storage medium. The above-mentioned method according to the embodiments of the present disclosure can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium and downloaded through a network, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0108] A part of the present disclosure may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present disclosure through the operation of the computer. Those skilled in the art should understand that the existence of computer program instructions in computer-readable media includes, but is not limited to, source files, executable files, installation package files, etc., and accordingly, the way in which computer program instructions are executed by a computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.

[0109] Although the embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A program code analysis method based on an analysis system, characterized in that: The parsing system includes a first data processing module and a trained parsing model, and the method is applied to the first data processing module; the method includes: Acquire a target program code, wherein the target program code includes a predefined target data structure, wherein the target data structure includes one or more structure fields; Acquire parsing reference information, and construct a first prompt word according to the parsing reference information, wherein the parsing reference information includes one or more of code parsing logic, sample program code, parsing examples, and location features of the target data structure; The target program code and the first prompt word are input into the parsing model so that the parsing model outputs a parsing file of the target program code, wherein the parsing file includes field attributes and field access paths of the structure fields.

2. The method according to claim 1, characterized in that The parsing system also includes a trained alignment model; after obtaining the parsing file, the method further includes: Acquire alignment reference information, and construct a second prompt word according to the alignment reference information, wherein the alignment reference information includes memory address alignment logic and / or alignment examples of the structure field; The second prompt word and the parsed file are input into the alignment model, so that the alignment model adds a padding field in the parsed file, and the padding field is used to make the memory address of the structure field meet the memory address alignment logic.

3. The method according to claim 1, characterized in that The parsing system also includes a trained description supplement model; after obtaining the parsing file, the method further includes: Obtaining an example field and a field description corresponding to the example field, and constructing a third prompt word according to the correspondence between the example field and the field description; The third prompt word and the parsing file are input into the description supplement model, so that the description supplement model adds the field description of the structure field in the parsing file.

4. The method according to claim 3, characterized in that The example fields are some structure fields in the parsed file; the description supplement model adds field descriptions to the parsed file based on the following method: For any structure field in the parsed file, if the structure field is an example field, adding the field description of the structure field in the third prompt word to the parsed file; If the structure field is not an example field, the third prompt word is used as a reference to add a field description for the structure field in the parsed file.

5. The method according to any one of claims 1 to 4, characterized in that: The target program code includes a plurality of the target data structures, the parsing model writes the hierarchical relationship between the target data structures in the parsing file, and represents the field access path of the structure field through the hierarchical relationship, wherein in the hierarchical relationship, target data structures at different levels have different indentations.

6. The method according to any one of claims 1 to 4, characterized in that: When the parsing reference information includes the code parsing logic, the example program code, the parsing example and the location feature of the target data structure, the parsing model outputs the parsing file based on the following method: Extracting the target data structure from the target program code according to the location feature of the target data structure; According to the code parsing logic, the target data structure is subjected to syntax conversion; The parsing file is generated and outputted based on the target data structure after grammar conversion, with the example program code and the parsing example as reference.

7. A memory state analysis method based on a parsing system, characterized in that: The parsing system includes a second data processing module and a trained query model, and the method is applied to the second data processing module; the method includes: Obtaining field identification information of a target structure field in the target program code; Inputting the field identification information into a query model, and allowing the query model to search for field attributes and field access paths of the target structure field in a parsed file generated based on the method described in any one of claims 1 to 6; According to the field attribute and the field access path, searching the current value of the target structure field in the memory in the parsed memory status file; Perform memory status analysis based on the current value of the target structure field.

8. The method according to claim 7, characterized in that The step of obtaining the field identification information of the target structure field in the target program code includes: Display a human-computer interaction interface to receive at least one of the following information of the target structure field through the human-computer interaction interface, and use the received information as the field identification information: Field name, field ID, field description.

9. The method according to claim 8, characterized in that The query model searches for the field attributes and field access paths of the target structure fields in the parsed file based on the following method: Match and compare the field identification information of the target structure field with the field identification information of the structure field in the parsed file, and obtain the structure field in the parsed file that matches the target structure field as a candidate field; The field attributes and field access path of the candidate field are used as the field attributes and field access path of the target structure field.

10. The method according to claim 9, characterized in that The matching and comparing of the field identification information of the target structure field with the field identification information of the structure field in the parsed file to obtain the structure field in the parsed file that matches the target structure field as a candidate field includes: If there is a structure field having the same field identification information as the target structure field in the parsed file, the corresponding structure field is used as the candidate field; If there is no field in the parsed file that has the same field identification information as the target structure field, a semantic comparison is performed between the field identification information of the target structure field and the field identification information of the structure field in the parsed file to obtain a structure field in the parsed file that has the same semantics as the target structure field as the candidate field.

11. The method according to claim 9 or 10, characterized in that: When the target program code includes a plurality of the target data structures, and the parsed file includes a hierarchical relationship between the target data structures, the field access path of the candidate field is found according to the following method: Searching the parsed file for a first target data structure where the candidate field is located; According to the hierarchical relationship between the target data structures, if there are one or more second target data structures before the first target data structure, the first target data structure and the second target data structure are sorted according to the hierarchical relationship to obtain the field access path of the candidate field; if there is no second target data structure before the first target data structure, the first target data structure is used as the field access path of the candidate field.

12. The method according to claim 11, characterized in that The field attributes include a field type, and the field type is used to characterize the size of the memory space that the structure field needs to occupy; The step of searching the current value of the target structure field in the memory in the parsed memory status file according to the field attribute and the field access path includes: According to the base address of each target data structure in the field access path and the field type of the structure field in the target data structure, the current value of the target structure field is searched in the parsed memory status file.

13. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the program code parsing method based on the parsing system as described in any one of claims 1 to 6, or executes the memory status analysis method based on the parsing system as described in any one of claims 7 to 12 by executing the computer instructions.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the program code parsing method based on the parsing system described in any one of claims 1 to 6, or to execute the memory status analysis method based on the parsing system described in any one of claims 7 to 12.

15. A computer program product, characterized in that It includes computer instructions, which are used to make a computer execute the program code parsing method based on the parsing system described in any one of claims 1 to 6, or execute the memory state analysis method based on the parsing system described in any one of claims 7 to 12.

Citation Information

Patent Citations

  • Memory overflow processing method and device, electronic equipment and storage medium

    CN112965851A

  • Data analysis method, data analysis device, electronic equipment and storage medium

    CN113392112A

  • Object model configuration method and device and computer readable storage medium

    CN115934098A

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

    CN116974946A

  • Electronic apparatus, credit feedback message parsing method, and storage medium

    WO2019196304A1