CN-122027082-A - Signaling automatic coding and decoding method and system based on DWARF debugging information
Abstract
The application provides a signaling automation coding and decoding method and system based on DWARF debugging information, and relates to the technical field of communication. The method comprises the steps of analyzing DWARF debugging information generated by compiling to construct a protocol type dictionary, starting from a top node of a target signaling message based on the protocol type dictionary, expanding a structure of the target signaling message into a signaling structure tree by replacing non-termination type references with complete definitions, performing flattened path traversal on the signaling structure tree to generate a field path and basic type mapping table, and automatically generating an encoding function and a decoding function according to the field path and basic type mapping table through a preset code template, wherein the decoding function is used for converting a protocol structure instance of the signaling to be decoded into a semantic key value pair containing a field name and a field value, and the encoding function is used for converting and filling the semantic key value pair to be encoded into the protocol structure instance.
Inventors
- MA XIAO
- ZHOU AO
- HOU ZHILI
- LI YUANZHE
- Si Jianing
- XU MENGWEI
- ZHANG YIRAN
- WANG SHANGGUANG
Assignees
- 北京邮电大学
Dates
- Publication Date
- 20260512
- Application Date
- 20260114
Claims (10)
- 1. The signaling automation coding and decoding method based on DWARF debugging information is characterized by comprising the following steps of: Analyzing DWARF debugging information generated by compiling, and constructing a protocol type dictionary which comprises complete definitions and reference relations of basic types, structural bodies, combinations, arrays and aliases; based on the protocol type dictionary, starting from a top node of a target signaling message, expanding the structure of the target signaling message into a signaling structure tree by replacing non-termination type references with complete definitions; performing flattened path traversal on the signaling structure tree to generate a field path and a basic type mapping table, wherein the field path and each record in the basic type mapping table are associated with a complete access path and a basic type of a termination field; And automatically generating an encoding function and a decoding function through a preset code template according to the field path and the basic type mapping table, wherein the decoding function is used for converting a protocol structure body instance of the signaling to be decoded into a semantic key value pair containing a field name and a field value, and the encoding function is used for converting and filling the semantic key value pair to be encoded into the protocol structure body instance.
- 2. The method of claim 1, wherein parsing the compiled DWARF debug information to construct a protocol type dictionary, comprises: sequentially scanning DWARF debugging information texts, and identifying compiling unit information lines, type label lines and attribute lines; recording the label type, the hierarchy depth and the address identification of the type label row, and storing the attribute row associated with the type label row into a node record, wherein the attribute information of the node record at least comprises at least one of a name, a byte size, a type reference address, a member offset, bit section information and an array upper bound; Constructing a node list and an address index table according to all the node records; searching a definition node of a target type from the node list, and recursively analyzing a type reference structure of the node based on the address index table to restore a complete type definition; And aggregating all the restored type definitions to obtain the protocol type dictionary.
- 3. The method of claim 2, wherein recursively resolving the type referencing structure of the node based on the address index table to restore a full type definition comprises: Recording a type name and a byte size for the base type; recording the whole byte size aiming at a structural body or a combination body, recursively analyzing the type references of all members to form a member list, wherein the member list comprises member names, byte offsets and type information; recording a mapping relation between the alias and the bottom real type aiming at the alias; For the array, the array element type and the length information of each dimension are recorded.
- 4. The method of claim 1, wherein expanding the structure of the target signaling message into a signaling structure tree by replacing non-termination type references with full definitions based on the protocol type dictionary starting from a top level node of the target signaling message comprises: taking the name of the target signaling message as a starting point, and acquiring a corresponding type definition from the protocol type dictionary; Recursively expanding the type definition to obtain the signaling structure tree; The recursion expansion comprises judging the type name of the reference under the condition that the type reference item is encountered, stopping expanding the reference item if the type name of the reference is a termination type, searching the complete definition from the protocol type dictionary and replacing the reference item if the type name of the reference is a non-termination type, and continuing to execute recursion expansion on the replaced content until the non-termination type reference needing to be expanded is not contained.
- 5. The method of claim 4, wherein in the recursively expanding, member types of the structure and the complex are recursively expanded, aliases are replaced with underlying real types to which they point, and arrays are expanded into composite representations containing element types and dimension information.
- 6. The method of claim 1, wherein performing a flattened path traversal of the signaling structure tree to generate a field path and base type mapping table, comprises: recursively traversing the signaling structure tree by taking a preset interface prefix as a root path; in the recursive traversal process, according to the type of the current node, the current path is extended by adopting a corresponding rule: expanding the current path into a current path-member name under the condition that the current node is a structural body; Under the condition that the current node is a complex, statically expanding each branch member of the complex to form a parallel path taking the current path-branch member name as a starting point; If the element type of the array is a non-termination type, generating a path item with a subscript index according to the dimension of the array, and continuing recursion traversal for each path item; using a pointer symbology in the current path if the current node contains pointer semantics; In the case of recursive traversal of a termination type node, generating a record containing a field path from the root path to the termination type node, and base type information for the termination type node; and forming the field path and the basic type mapping table by summarizing all the generated records.
- 7. The method according to any of claims 1-6, wherein automatically generating the encoding and decoding functions from the field path and base type mapping table by means of a preset code template comprises: reading a configuration file, and acquiring a prefix, a structure body name and a function name of a target signaling message; screening out field records belonging to the same signaling message from the field path and basic type mapping table according to the prefix; Traversing the screened field records, selecting a corresponding code generation rule according to the basic type in each record, converting a field path into an access or assignment statement for a protocol structure member, and respectively assembling the access or assignment statement into an encoding function template or a decoding function template.
- 8. The method of claim 7, wherein selecting the corresponding code generation rule based on the base type in each record comprises: When a decoding function is generated, codes for converting the value of the integer field into a character string and inserting the character string into a key value mapping table are generated; when the coding function is generated, for integer field, the code is generated, which extracts the character string value from the key value mapping table, converts the character string value into the corresponding value type and assigns the corresponding value type to the structural member, and for character array or byte array field, the code is generated, which converts and copies the character string value to the structural member.
- 9. The method of claim 8, wherein converting the field path into an access or assignment statement to a protocol fabric member comprises: in the case that there is a control field in the field path indicating the length or validity of the subsequent field, conditional judgment or length calculation logic that depends on the control field value is automatically inserted when an access or assignment statement for the corresponding data field is generated.
- 10. A signaling automation codec system based on DWARF debug information, comprising: The protocol structure extraction module is used for analyzing DWARF debugging information generated by compiling to construct a protocol type dictionary, and expanding the structure of the target signaling message into a signaling structure tree by replacing non-termination type references with complete definitions based on a top node of the target signaling message, wherein the protocol type dictionary comprises complete definitions and reference relations of basic types, structures, combinations, arrays and aliases; the path processing module is used for performing flattened path traversal on the signaling structure tree, generating a field path and basic type mapping table, and associating a complete access path of a termination field and a basic type with each record in the basic type mapping table; And the code generation module is used for automatically generating an encoding function and a decoding function through a preset code template according to the field path and the basic type mapping table, wherein the decoding function is used for converting a protocol structure body instance of the signaling to be decoded into a semantic key value pair containing a field name and a field value, and the encoding function is used for converting and filling the semantic key value pair to be encoded into the protocol structure body instance.
Description
Signaling automatic coding and decoding method and system based on DWARF debugging information Technical Field The application relates to the technical field of communication, in particular to a signaling automation coding and decoding method and system based on DWARF debugging information. Background In a 5G core network, the codec of non-access stratum (Non Access Stratum, NAS) and NG application layer (NG Application Protocol, NGAP) signaling is the basis for implementing control plane functions. At present, NGAP signaling is generally described according to ASN.1 standard, and static structure and coding and decoding functions are generated through a special compiler, and NAS signaling generally adopts TLV (Type-Length-Value) format and is analyzed by manually writing or templating codes. In any way, the related technology takes a predefined structure body as an intermediate carrier to realize conversion between binary streams and the structure body. However, the method has obvious limitation that only structural body objects with filling values can be obtained after decoding, semantic information such as field names, hierarchical relations and the like is lacking, if specific signaling fields are required to be accessed, structural body members are required to be accessed layer by layer through manual programming, the process is complicated, tight coupling is realized with the bottom layer, automatic processing and analysis are not facilitated, and in addition, decoding results cannot be directly understood and utilized by a log system, a testing tool or an intelligent analysis model, so that the operation and maintenance efficiency and the intelligent level are restricted. Therefore, the related art is difficult to meet the requirements of efficient, flexible and semantically processing of signaling in a communication network. Disclosure of Invention In view of the foregoing, embodiments of the present application provide a signaling automation codec method and system based on DWARF debug information, so as to overcome or at least partially solve the foregoing problems. In a first aspect of the embodiment of the present application, a signaling automation coding and decoding method based on DWARF debug information is disclosed, the method includes: Analyzing DWARF debugging information generated by compiling, and constructing a protocol type dictionary which comprises complete definitions and reference relations of basic types, structural bodies, combinations, arrays and aliases; based on the protocol type dictionary, starting from a top node of a target signaling message, expanding the structure of the target signaling message into a signaling structure tree by replacing non-termination type references with complete definitions; performing flattened path traversal on the signaling structure tree to generate a field path and a basic type mapping table, wherein the field path and each record in the basic type mapping table are associated with a complete access path and a basic type of a termination field; And automatically generating an encoding function and a decoding function through a preset code template according to the field path and the basic type mapping table, wherein the decoding function is used for converting a protocol structure body instance of the signaling to be decoded into a semantic key value pair containing a field name and a field value, and the encoding function is used for converting and filling the semantic key value pair to be encoded into the protocol structure body instance. Optionally, parsing the DWARF debug information generated by compiling to construct a protocol type dictionary, including: sequentially scanning DWARF debugging information texts, and identifying compiling unit information lines, type label lines and attribute lines; recording the label type, the hierarchy depth and the address identification of the type label row, and storing the attribute row associated with the type label row into a node record, wherein the attribute information of the node record at least comprises at least one of a name, a byte size, a type reference address, a member offset, bit section information and an array upper bound; Constructing a node list and an address index table according to all the node records; searching a definition node of a target type from the node list, and recursively analyzing a type reference structure of the node based on the address index table to restore a complete type definition; And aggregating all the restored type definitions to obtain the protocol type dictionary. Optionally recursively parsing the type referencing structure of the node based on the address index table to restore the full type definition, including: Recording a type name and a byte size for the base type; recording the whole byte size aiming at a structural body or a combination body, recursively analyzing the type references of all members to form a member list, wherein the member li