A function positioning method and device, electronic equipment and storage medium

By generating a target two-dimensional array and using index value mapping, the software module to which the function belongs is automatically located, solving the problem of cumbersome and time-consuming function location in the existing technology, and achieving efficient and accurate function location.

CN115878129BActive Publication Date: 2026-04-21GUOKE FOUNDATION STONE (CHONGQING) SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUOKE FOUNDATION STONE (CHONGQING) SOFTWARE CO LTD
Filing Date
2022-12-15
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

In existing technologies, the function location process is cumbersome and time-consuming, especially in the process of software module development, which requires traversing and searching through each software module, resulting in low efficiency.

Method used

By generating a target two-dimensional array and using the index value mapping between function name and file ID, the software module to which the function belongs can be automatically located. This includes obtaining the target function name, finding its position in the two-dimensional array, obtaining the corresponding index value, and decoding the binary file to determine the software module.

Benefits of technology

It achieves automated function location, improves location efficiency and accuracy, reduces manual operation, and enhances the accuracy of function location.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115878129B_ABST
    Figure CN115878129B_ABST
Patent Text Reader

Abstract

This disclosure relates to a function location method, apparatus, electronic device, and storage medium, comprising: obtaining a target function name; locating the position of the target function name in a target two-dimensional array and obtaining the corresponding second-dimensional index value; determining a first-dimensional index value of the position of the target function name based on the second-dimensional index value; converting the first-dimensional index value to obtain a file ID of a binary file; obtaining the corresponding binary file based on the file ID; decoding the binary file to obtain the software module to which the target function name belongs. This disclosure enables automated function location, improves the efficiency of function location, and achieves high location accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a function location method, apparatus, electronic device, and computer-readable storage medium. Background Technology

[0002] In related technologies, during software module development, developers often encounter "undefined function" errors during the compilation and linking phase. To resolve this, it's typically necessary to first determine which library implements the function. The general steps are: search the include directory of the compilation and linking environment to identify the header file corresponding to the function, then determine the source file and obtain the library compiled from it. For example, assuming the `xxx_function` function is implemented in `xxx.c` and ultimately compiled into `xxx.so`, use `readelf -d xxx.so` to check the "Library soname" information. If it outputs "libxxx.so", add `-lxxx` to the LDFLAGS in the Makefile. This will ensure the linker links to `libxxx.so` and successfully links the symbol for the `xxx_function` function. Similarly, if a program crashes during runtime, use `gdb` to analyze the call stack. Based on the symbol clues of the functions in the call stack, follow the steps described above to locate which software module the function belongs to.

[0003] However, the process of locating the automotive software module to which the above-mentioned function belongs is manual, step-by-step, tedious and time-consuming, especially during the software module development process, which may involve hundreds of software modules, requiring traversal and searching through each software module, resulting in long time consumption for function location.

[0004] Therefore, there is an urgent need for a method that can quickly and accurately locate functions and improve the efficiency of function location. Summary of the Invention

[0005] To overcome the problems existing in related technologies, this disclosure provides a function location method, apparatus, electronic device, and computer-readable storage medium.

[0006] According to a first aspect of the present disclosure, a function location method is provided, comprising: obtaining a target function name; searching for the position of the target function name in a target two-dimensional array and obtaining a corresponding second-dimensional index value; determining a first-dimensional index value of the position of the target function name based on the second-dimensional index value; converting the first-dimensional index value to obtain a file ID of a binary file; obtaining the corresponding binary file based on the file ID; decoding the binary file to obtain the software module to which the target function name belongs.

[0007] In some embodiments, the generation of the target two-dimensional array includes: obtaining a software module and generating a binary file based on the software module; parsing the binary file and extracting function names from the symbol table of the binary file; obtaining the file ID of the binary file, and obtaining the first-dimensional index value and the second-dimensional index value of the variable-length two-dimensional array based on the file ID and the function name; generating the target two-dimensional array based on the first-dimensional index value and the second-dimensional index value, and storing the function name in the form of a string at the corresponding position of the target two-dimensional array.

[0008] In some embodiments, obtaining the first and second dimension index values ​​of the variable-length two-dimensional array based on the file ID and function name includes: obtaining the file ID and function name of the binary file; mapping the file ID and function name using enumeration type variables or macro definitions; mapping the file ID to elements of the enumeration type variables or macro definitions to obtain the file ID element, which is used as the first dimension index value of the variable-length two-dimensional array; and mapping the function name to elements of the enumeration type variables or macro definitions to obtain the function name element, which is used as the second dimension index value of the variable-length two-dimensional array.

[0009] In some embodiments, generating a target two-dimensional array based on the first and second dimension index values, and storing the function name as a string in the corresponding position of the target two-dimensional array, includes: obtaining the first dimension index value of the variable-length two-dimensional array based on the file ID element; obtaining the function name corresponding to the file ID, obtaining the corresponding function name element based on the function name, and obtaining the second dimension index value of the variable-length two-dimensional array, wherein the file ID corresponds to several function names; obtaining the target two-dimensional array corresponding to the binary file based on the first and second dimension index values; and storing the function name as a string in the corresponding position of the target two-dimensional array.

[0010] In some embodiments, obtaining the target function name, finding the position of the target function name in the target two-dimensional array, and obtaining the corresponding second-dimensional index value includes: obtaining the corresponding target function name when an undefined function occurs during compilation and linking or an exception occurs during runtime; traversing the target two-dimensional array according to the target function name until the target function name is found in the target two-dimensional array; obtaining the target position of the target function name in the target two-dimensional array, and determining the second-dimensional index value corresponding to the target function name according to the target position.

[0011] In some embodiments, determining the first-dimensional index value of the location of the target function name based on the second-dimensional index value, and converting the first-dimensional index value to obtain the file ID of the binary file, includes: determining the first-dimensional index value of the location of the target function name based on the second-dimensional index value and the target location; and converting the first-dimensional index value to obtain the file ID of the binary file based on the first-dimensional index value and the corresponding mapping rule.

[0012] In some embodiments, obtaining the corresponding binary file based on the file ID, decoding the binary file, and obtaining the software module to which the target function name belongs includes: searching for the corresponding binary file in the database based on the file ID; decoding the binary file to obtain the corresponding decoded file; and determining the software module corresponding to the binary file based on the decoded file to obtain the software module to which the target function name belongs.

[0013] According to a second aspect of the present disclosure, a function location apparatus is provided, comprising: a target function name lookup module, configured to obtain a target function name, locate the position of the target function name in a target two-dimensional array, and obtain a corresponding second-dimensional index value; a file ID conversion module, configured to determine a first-dimensional index value of the position of the target function name based on the second-dimensional index value, and convert the first-dimensional index value into a file ID of a binary file; and a software module acquisition module, configured to obtain a corresponding binary file based on the file ID, decode the binary file, and obtain the software module to which the target function name belongs.

[0014] According to a third aspect of the present disclosure, an electronic device is provided, comprising: a processor; a memory for storing executable instructions of the processor; the processor being configured to read the executable instructions from the memory and execute the instructions to implement the function location method provided in the first aspect of the present disclosure.

[0015] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided that stores computer program instructions thereon, which, when executed by a processor, implement the steps of the function location method provided in the first aspect of the present disclosure.

[0016] The technical solutions provided by the embodiments of this disclosure can include the following beneficial effects: by obtaining the target function name, finding the position of the target function name in the target two-dimensional array, obtaining the second-dimensional index value of the position of the target function name, determining the first-dimensional index value of the position of the target function name based on the second-dimensional index value, converting the first-dimensional index value to obtain the file ID of the binary file, obtaining the corresponding binary file based on the file ID, and decoding to obtain the software module to which the target function name belongs, thereby realizing the automatic location of the function, improving the efficiency of function location, and achieving high location accuracy.

[0017] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0018] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0019] Figure 1 This is a flowchart illustrating a function location method according to an exemplary embodiment.

[0020] Figure 2 A flowchart illustrating a method for generating a target two-dimensional array as an exemplary embodiment.

[0021] Figure 3 A flowchart illustrating an index value acquisition method as an exemplary embodiment.

[0022] Figure 4 This is a flowchart illustrating a method for generating a target two-dimensional array based on index values, as shown in an exemplary embodiment.

[0023] Figure 5 A flowchart illustrating a method for obtaining the second-dimensional index value as an exemplary embodiment.

[0024] Figure 6 A flowchart illustrating a file ID conversion method as an exemplary embodiment.

[0025] Figure 7 A flowchart illustrating a function location method is provided as an exemplary embodiment.

[0026] Figure 8 This is a block diagram illustrating a function positioning device according to an exemplary embodiment.

[0027] Figure 9 This is a block diagram illustrating an electronic device according to an exemplary embodiment. Detailed Implementation

[0028] The exemplary embodiments will now be described in detail with reference to the accompanying drawings.

[0029] It should be noted that the relevant embodiments and accompanying drawings are only for describing and illustrating exemplary embodiments provided by this disclosure, and not all embodiments of this disclosure, nor should this disclosure be understood to be limited to the relevant exemplary embodiments.

[0030] It should be noted that the terms "first," "second," etc., used in this disclosure are only used to distinguish different steps, devices, or modules. These terms do not represent any specific technical meaning, nor do they indicate any order or interdependence between them.

[0031] It should be noted that the terms “a,” “a plurality of,” and “at least one” used in this disclosure are illustrative rather than restrictive. Unless otherwise expressly indicated in the context, they should be understood as “one or more.”

[0032] It should be noted that the term "and / or" used in this disclosure is used to describe the relationship between related objects, and generally indicates that there are at least three relationships. For example, A and / or B can at least indicate: the existence of A alone, the existence of both A and B, and the existence of B alone.

[0033] It should be noted that the various steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Unless otherwise specified, the scope of this disclosure is not limited to the order in which the steps are described in the relevant embodiments.

[0034] It should be noted that all actions involving the acquisition of signals, information, or data in this disclosure are carried out in accordance with the relevant data protection laws and policies of the country where the location is situated, and with the authorization granted by the owner of the relevant device.

[0035] Exemplary methods

[0036] Figure 1 This is a flowchart illustrating a function location method according to an exemplary embodiment, such as... Figure 1 As shown, the function location method used in computers includes the following steps.

[0037] In step S110, the target function name is obtained, the position of the target function name is found in the target two-dimensional array, and the corresponding second-dimensional index value is obtained.

[0038] In some embodiments, when an exception occurs during the compilation or execution of a software module, the corresponding target function name is obtained based on the exception message. The location of the target function name is then located using a target two-dimensional array stored in the database. Based on the position of the target function name within the target two-dimensional array, the corresponding second-dimensional index value is obtained. The target two-dimensional array stores all compiled software modules and their corresponding function names, and allows for the location of function names using the second-dimensional index value.

[0039] In step S120, the first-dimensional index value of the target function name is determined based on the second-dimensional index value, and the first-dimensional index value is converted to obtain the file ID of the binary file.

[0040] In some embodiments, based on the second-dimensional index value corresponding to the target function name, the first-dimensional index value corresponding to the position of the target function name in the target two-dimensional array is determined. The file ID of the binary file is then obtained by conversion based on the first-dimensional index value. The first-dimensional index value is encoded based on the file ID of the binary file; therefore, the corresponding binary file can be determined based on the first-dimensional index value.

[0041] In step S130, the corresponding binary file is obtained according to the file ID, the binary file is decoded, and the software module to which the target function name belongs is obtained.

[0042] In some embodiments, the corresponding binary file is retrieved based on its file ID, and then decoded to obtain the software module to which the target function name belongs. Since the binary file is derived from the software module, the corresponding software module can be obtained based on its file ID, thereby automating function location and improving its accuracy and efficiency.

[0043] In the above embodiment, by obtaining the target function name, finding the position of the target function name in the target two-dimensional array, obtaining the second-dimensional index value of the target function name position, determining the first-dimensional index value of the target function name position based on the second-dimensional index value, converting the first-dimensional index value to obtain the file ID of the binary file, obtaining the corresponding binary file based on the file ID, and decoding to obtain the software module to which the target function name belongs, the automatic location of the function is realized, improving the efficiency of function location and the location accuracy is high.

[0044] Figure 2 This is a flowchart illustrating a method for generating a target two-dimensional array, as shown in an exemplary embodiment. Figure 2 As shown, the method for generating the target two-dimensional array is used in step S110, and includes the following steps:

[0045] Step S210: Obtain the software module and generate a binary file based on the software module.

[0046] Specifically, when a software module is released, its library files, executable files, etc., typically need to be packaged into a binary file and stored in a database. A software module contains one or more library files and executable files. For example, assuming the source code file is example1.cpp, the corresponding binary file compiled and built is example1.so. The source code file example1.cpp contains three function names: function1, function2, and function3.

[0047] Step S220: Parse the binary file and extract the function names from the binary file symbol table.

[0048] Specifically, when parsing binary files, tools such as readelf, objdump, and nm are used to parse binary files generated by software modules and extract function names from the binary file symbol table. For example, parsing the binary file example1 will yield the corresponding function names function1, function2, and function3.

[0049] Step S230: Obtain the file ID of the binary file, and obtain the first and second dimension index values ​​of the variable-length two-dimensional array based on the file ID and function name.

[0050] Specifically, the file ID of the binary file is obtained, and the file ID and function name are mapped to the first and second dimension index values ​​of a variable-length two-dimensional array, respectively, so as to construct the target two-dimensional array based on all function names and file IDs in the binary file.

[0051] Step S240: Generate a target two-dimensional array based on the first-dimensional index value and the second-dimensional index value, and store the function name as a string in the corresponding position of the target two-dimensional array.

[0052] Specifically, based on all function names in the binary file, all second-dimensional index values ​​are obtained, and combined with the first-dimensional index values, a target two-dimensional array is generated in a variable-length two-dimensional array. At the same time, the function names are stored as strings at the positions corresponding to the second-dimensional index values, thus generating the target two-dimensional array.

[0053] In this embodiment, by acquiring the software module and generating a binary file based on the software module, the binary file is parsed to obtain the function name and the file ID of the binary file. Combined with the function name, the first and second dimension index values ​​of the variable-length two-dimensional array are obtained respectively. Combining the first dimension index value and all the second dimension index values, a target two-dimensional array is generated. The function name is stored as a string in the corresponding position in the target two-dimensional array. Thus, the position and corresponding second dimension index value of the function can be found by querying the function name in the target two-dimensional array, which is convenient for function location.

[0054] Figure 3 This is a flowchart illustrating an index value retrieval method as an exemplary embodiment. Figure 3 As shown, the index value acquisition method is used in step S230 and includes the following steps:

[0055] Step S310: Obtain the file ID and function name of the binary file.

[0056] Specifically, before generating the index values ​​of the target two-dimensional array, it is necessary to obtain the file ID and function name of the binary file. The file ID can be used to query the corresponding software module, and the function name can be used to locate the position of the function in the target two-dimensional array.

[0057] Step S320: Map file IDs and function names using enumerated type variables or macro definitions.

[0058] Specifically, when generating index values ​​based on file IDs and function names, enumeration type variables or macro definitions can be used to map file IDs and function names. For example, when using enumeration type variables for mapping, the file IDs of binary files example1, example2, example3, and example4 can be mapped to 0, 1, 2, and 3, respectively; and the function names function1, function2, and function3 in example1 can be mapped to 0, 1, and 2, respectively.

[0059] Step S330: Map the file ID to an enumeration type variable or macro definition element, and obtain the file ID element. The file ID element is used as the index value of the first dimension of the variable-length two-dimensional array.

[0060] Specifically, when mapping file IDs, the file IDs are mapped to elements of enumeration type variables or macro definitions. The file ID element is obtained. For example, the file ID element of example1 is 0, and 0 is used as the index value of the first dimension of the variable-length two-dimensional array.

[0061] Step S340: Map the function name to an enumeration type variable or macro definition element, and obtain the function name element, which is used as the index value of the second dimension of the variable-length two-dimensional array.

[0062] Specifically, when mapping function names, function names can also be mapped to elements of enumeration type variables or macro definitions, and must be consistent with the file ID. The function name elements can be obtained. For example, the function name elements of function1, function2 and function3 are 0, 1 and 2 respectively, and 0, 1 and 2 are also the second dimension index values ​​of variable-length two-dimensional arrays.

[0063] In this embodiment, the file ID and function name of the binary file are obtained, and the file ID and function name are mapped using enumeration type variables or macro definitions. The file ID is mapped to obtain a file ID element, which is used as the first dimension index value of a variable-length two-dimensional array. The function name is mapped to obtain a function name element, which is used as the second dimension index value of the variable-length two-dimensional array. This achieves the mapping of the binary file and obtains the corresponding index value, so that the function can be located according to the index value.

[0064] Figure 4 This is a flowchart illustrating a method for generating a target two-dimensional array based on index values, as shown in an exemplary embodiment. Figure 4 As shown, the method for generating a target two-dimensional array based on index values ​​is used in step S240, and includes the following steps:

[0065] Step S410: Obtain the index value of the first dimension of the variable-length two-dimensional array based on the file ID element.

[0066] Specifically, the mapped file ID element is used as the first dimension index of a variable-length two-dimensional array to realize the correspondence between the first dimension index and the binary file, and further correspondence with the software module, so that the corresponding software module can be determined through the first dimension index.

[0067] Step S420: Obtain the function name corresponding to the file ID, obtain the corresponding function name element based on the function name, and obtain the second dimension index value of the variable-length two-dimensional array. The file ID corresponds to several function names.

[0068] Specifically, since a binary file may correspond to multiple function names, all function names corresponding to the binary file can be obtained based on the file ID, and the function name elements corresponding to the function names can be obtained, thereby obtaining all the second-dimensional index values ​​of the variable-length two-dimensional array.

[0069] Step S430: Obtain the target two-dimensional array of the corresponding binary file based on the first-dimensional index value and the second-dimensional index value.

[0070] Specifically, after adding the first dimension index value and all the second dimension index values ​​to the variable-length two-dimensional array, the target two-dimensional array of the corresponding binary file is obtained. For example, the target two-dimensional arrays corresponding to the binary file example1.so are [0][0], [0][1] and [0][2].

[0071] Step S440: Store the function name as a string in the corresponding position of the target two-dimensional array.

[0072] Specifically, all function names corresponding to the binary file are obtained, and the function names are mapped to the second-dimensional index values ​​and stored as strings in the corresponding positions in the target two-dimensional array, so that the position of the function in the target two-dimensional array can be determined based on the function name.

[0073] In this embodiment, the first dimension index value of the variable-length two-dimensional array is obtained based on the file ID element. All corresponding function names are obtained based on the file ID, and the corresponding function name element is obtained based on the function name to obtain the second dimension index value of the variable-length two-dimensional array. The target two-dimensional array of the binary file is generated based on the first dimension index value and the second dimension index value. The function name is stored as a string in the corresponding position of the target two-dimensional array, thereby realizing the generation of the target two-dimensional array. This allows the function to be located in the target two-dimensional array based on the function name, improving the efficiency and accuracy of function location.

[0074] Figure 5 A flowchart illustrating a method for obtaining the second-dimensional index value as an exemplary embodiment. Figure 5 As shown, the method for obtaining the second-dimensional index value is used in step S110, and includes the following steps:

[0075] Step S510: When an undefined function is encountered during the compilation and linking process or a runtime exception occurs, obtain the corresponding target function name.

[0076] Specifically, when an undefined function is encountered during the compilation and linking of a software module, or when an exception occurs during the execution of a software module after compilation, the corresponding target function name is obtained, for example, function3.

[0077] Step S520: Traverse the target two-dimensional array according to the target function name until the target function name is found in the target two-dimensional array.

[0078] Specifically, since the function name is stored as a string in the target two-dimensional array, the target two-dimensional array can be traversed according to the target function name until the target function name in the target two-dimensional array is found.

[0079] Step S530: Obtain the target position of the target function name in the target two-dimensional array, and determine the second-dimensional index value corresponding to the target function name based on the target position.

[0080] Specifically, by obtaining the target position of the target function name in the target two-dimensional array, for example, the position of function3 is [0][2], the second-dimensional index value corresponding to the target function name can be determined based on the target position, and the second-dimensional index value is 2.

[0081] In this embodiment, when an undefined function occurs during the compilation and linking of a software module, or when an abnormal interruption occurs during runtime, the corresponding target function name is obtained. The target function name is then traversed and searched in the target two-dimensional array until it is found. The target position of the function name in the target two-dimensional array is obtained, and the second-dimensional index value corresponding to the target function name is determined based on the target position. Thus, the function name can be located in the target two-dimensional array based on the target function name.

[0082] Figure 6 A flowchart illustrating a file ID conversion method as an exemplary embodiment. Figure 6 As shown, the file ID conversion method used in step S120 includes the following steps:

[0083] Step S610: Determine the first-dimensional index value of the location of the target function name based on the second-dimensional index value and the target location.

[0084] Specifically, based on the obtained second-dimensional index value and the target position, the first-dimensional index value of the target function name is determined. For example, if the position of function3 is [0][2], then the first-dimensional index value corresponding to the target function name can be determined based on the target position, and the first-dimensional index value is 0.

[0085] Step S620: Based on the first dimension index value and the corresponding mapping rule, the file ID of the binary file is obtained.

[0086] Specifically, based on the first-dimensional index value and the corresponding mapping rule, that is, the mapping rule of the file ID to the first-dimensional index value, the file ID of the binary file is obtained. For example, based on the first-dimensional index value 0, the file ID of the corresponding binary file example1 is obtained.

[0087] In this embodiment, the first-dimensional index value of the target function name is determined based on the second index value and the target position. The file ID of the binary file is obtained by converting the first-dimensional index value and the corresponding mapping rule. Thus, the correspondence between the target function name and the file ID of the binary file can be obtained based on the index value, so as to determine the software module corresponding to the target function based on the file ID in the future.

[0088] Figure 7 A flowchart illustrating a function location method is provided as an exemplary embodiment. Figure 7 As shown, the function location method is used in step S130, which includes the following steps:

[0089] Step S710: Based on the file ID, search for the corresponding binary file in the enumeration type definition or macro definition.

[0090] Specifically, after obtaining the file ID corresponding to the target function name, the corresponding binary file is retrieved by searching in the enumeration type definition or macro definition based on the file ID. The file ID and the binary file are in one-to-one correspondence.

[0091] Step S720: Decode the binary file to obtain the corresponding decoded file.

[0092] Specifically, since the binary file is converted by the software module, after obtaining the binary file corresponding to the target function name, the binary file is decoded to obtain the corresponding decoded file.

[0093] Step S730: Determine the software module corresponding to the binary file based on the decoded file, and obtain the software module to which the target function name belongs.

[0094] Specifically, based on the decoded file obtained from decoding, the software module corresponding to the binary file is determined, thereby obtaining the software module described in the target function name. This enables rapid and accurate location of the target function, greatly improving the efficiency of target function location and facilitating efficient handling of abnormal situations by R&D personnel.

[0095] In this embodiment, based on the file ID, the corresponding binary file is searched in the enumeration type definition or macro definition. The binary file is decoded to obtain the corresponding decoded file. Based on the decoded file, the software module corresponding to the binary file is determined, and the corresponding decoded file is obtained. Based on the decoded file, the software module corresponding to the binary file is determined, and the software module mentioned in the target function name is obtained. This realizes the location of the function based on the target function name, and the location efficiency and location accuracy are high. It is convenient for R&D personnel to handle abnormal situations in a timely and efficient manner, and improves work efficiency.

[0096] Exemplary device

[0097] Figure 8 This is a block diagram illustrating a function positioning device according to an exemplary embodiment. (Refer to...) Figure 8 The device 800 includes a target function name lookup module 810, a file ID conversion module 820, and a software module acquisition module 830.

[0098] The target function name lookup module 810 is used to obtain the target function name, find the position of the target function name in the target two-dimensional array, and obtain the corresponding second-dimensional index value;

[0099] The file ID conversion module 820 is used to determine the first-dimensional index value of the target function name based on the second-dimensional index value, and convert the first-dimensional index value to obtain the file ID of the binary file.

[0100] The software module 830 is used to obtain the corresponding binary file based on the file ID, decode the binary file, and obtain the software module to which the target function name belongs.

[0101] In this embodiment, the target function name is obtained by the target function name lookup module 810, and the position of the target function name is found in the target two-dimensional array to obtain the corresponding second-dimensional index value. The file ID conversion module 820 determines the first-dimensional index value of the target function name based on the second-dimensional index value and converts it to obtain the file ID of the binary file. The software module acquisition module 830 obtains the corresponding binary file based on the file ID and decodes it to obtain the software module to which the target function name belongs. This achieves fast and accurate location of the target function name, replacing manual operation and improving the efficiency and accuracy of function location.

[0102] In some embodiments, the apparatus further includes: a binary file generation module for acquiring a software module and generating a binary file based on the software module; a function name extraction module for parsing the binary file and extracting function names from the binary file symbol table; an index value acquisition module for acquiring the file ID of the binary file and, based on the file ID and function names, acquiring the first-dimensional index value and the second-dimensional index value of a variable-length two-dimensional array, respectively; and a target two-dimensional array generation module for generating a target two-dimensional array based on the first-dimensional index value and the second-dimensional index value, and storing the function names as strings in the corresponding positions of the target two-dimensional array.

[0103] In some embodiments, the apparatus further includes: a filename acquisition module for acquiring the file ID and function name of a binary file; a mapping module for mapping the file ID and function name using an enumeration type variable or a macro definition; a file ID element acquisition module for mapping the file ID to an element of the enumeration type variable or macro definition and acquiring the file ID element, which is used as the index value of the first dimension of a variable-length two-dimensional array; and a function name element acquisition module for mapping the function name to an element of the enumeration type variable or macro definition and acquiring the function name element, which is used as the index value of the second dimension of a variable-length two-dimensional array.

[0104] In some embodiments, the apparatus further includes: a first index value acquisition module, configured to acquire a first-dimensional index value of a variable-length two-dimensional array based on a file ID element; a second index value acquisition module, configured to acquire a function name corresponding to a file ID, acquire a corresponding function name element based on the function name, and obtain a second-dimensional index value of the variable-length two-dimensional array, wherein the file ID corresponds to several function names; a target two-dimensional array acquisition module, configured to acquire a target two-dimensional array of a corresponding binary file based on the first-dimensional index value and the second-dimensional index value; and a function name storage module, configured to store the function name in the form of a string at the corresponding position in the target two-dimensional array.

[0105] In some embodiments, the apparatus further includes: a target function name acquisition module, used to acquire the corresponding target function name when an undefined function occurs during compilation and linking or when an exception occurs during runtime; a target function name search module, used to traverse and search in a target two-dimensional array according to the target function name until the target function name is found in the target two-dimensional array; and a second-dimensional index value determination module, used to acquire the target position of the target function name in the target two-dimensional array and determine the second-dimensional index value corresponding to the target function name according to the target position.

[0106] In some embodiments, the apparatus further includes: a first-dimensional index value determination module, configured to determine the first-dimensional index value of the location of the target function name based on the second-dimensional index value and the target location; and a first-dimensional index value conversion module, configured to convert the first-dimensional index value and the corresponding mapping rule to obtain the file ID of the binary file.

[0107] In some embodiments, the apparatus further includes: a binary file lookup module, configured to look up the corresponding binary file in an enumeration type definition or macro definition based on the file ID; a decoded file acquisition module, configured to decode the binary file and acquire the corresponding decoded file; and a software module determination module, configured to determine the software module corresponding to the binary file based on the decoded file and obtain the software module to which the target function name belongs.

[0108] In the above embodiments, the operation of the device enables the implementation of a function positioning method, ensuring that the device can realize all the contents of the function positioning method.

[0109] Exemplary electronic devices

[0110] Figure 9 This is a block diagram illustrating an electronic device 900 according to an exemplary embodiment. The electronic device 900 may be a vehicle controller, an in-vehicle terminal, an in-vehicle computer, or other types of electronic devices.

[0111] Reference Figure 9The electronic device 900 may include at least one processor 910 and a memory 920. The processor 910 can execute instructions stored in the memory 920. The processor 910 is communicatively connected to the memory 920 via a data bus. In addition to the memory 920, the processor 910 can also be communicatively connected to an input device 930, an output device 940, and a communication device 950 via the data bus.

[0112] Processor 910 can be any conventional processor, such as a commercially available CPU. Processors may also include graphics processing units (GPUs), field-programmable gate arrays (FPGAs), systems-on-chips (SoCs), application-specific integrated circuits (ASICs), or combinations thereof.

[0113] The memory 920 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0114] In this embodiment of the present disclosure, the memory 920 stores executable instructions, and the processor 910 can read the executable instructions from the memory 920 and execute the instructions to implement all or part of the steps of the function location method described in any of the exemplary embodiments above.

[0115] Exemplary computer-readable storage media

[0116] In addition to the methods and apparatus described above, exemplary embodiments of this disclosure may also be a computer program product or a computer-readable storage medium storing the computer program product. The computer product includes computer program instructions that can be executed by a processor to perform all or part of the steps described in any of the methods in the exemplary embodiments described above.

[0117] The computer program product can be written in any combination of one or more programming languages ​​to perform the operations of the embodiments of this application. The programming languages ​​include object-oriented programming languages ​​such as Java and C++, as well as conventional procedural programming languages ​​such as C or similar languages, and scripting languages ​​(e.g., Python). The program code can be executed entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0118] The computer-readable storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media include: static random access memory (SRAM) having one or more electrically connected wires, electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk, or any suitable combination thereof.

[0119] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of this disclosure. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.

[0120] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.

Claims

1. A function location method, characterized in that, include: Obtain the target function name, find the position of the target function name in the target two-dimensional array, and obtain the corresponding second-dimensional index value; Based on the second-dimensional index value, determine the first-dimensional index value of the location of the target function name, and convert the first-dimensional index value to obtain the file ID of the binary file; Based on the file ID, obtain the corresponding binary file, decode the binary file, and obtain the software module to which the target function name belongs; The generation of the target two-dimensional array includes: Obtain the software module and generate a binary file based on the software module; The binary file is parsed to extract function names from the binary file's symbol table; Obtaining the file ID of the binary file, and based on the file ID and function name, obtaining the first and second dimension index values ​​of a variable-length two-dimensional array, includes: obtaining the file ID and function name of the binary file; mapping the file ID and function name using enumeration type variables or macro definitions; mapping the file ID to elements of enumeration type variables or macro definitions, and obtaining the file ID element, which is used as the first dimension index value of the variable-length two-dimensional array; mapping the function name to elements of enumeration type variables or macro definitions, and obtaining the function name element, which is used as the second dimension index value of the variable-length two-dimensional array. A target two-dimensional array is generated based on the first and second dimension index values, and the function name is stored as a string in the corresponding position of the target two-dimensional array.

2. The function location method according to claim 1, characterized in that, The step of generating a target two-dimensional array based on the first-dimensional index value and the second-dimensional index value, and storing the function name as a string in the corresponding position of the target two-dimensional array, includes: Obtain the first dimension index value of the variable-length two-dimensional array based on the file ID element; Obtain the function name corresponding to the file ID, obtain the corresponding function name element based on the function name, and obtain the second dimension index value of the variable-length two-dimensional array. The file ID corresponds to several function names. Based on the first-dimensional index value and the second-dimensional index value, obtain the target two-dimensional array corresponding to the binary file; The function name is stored as a string in the corresponding position of the target two-dimensional array.

3. The function location method according to claim 1, characterized in that, The step of obtaining the target function name, which involves locating the target function name in the target two-dimensional array and obtaining the corresponding second-dimensional index value, includes: When an undefined function is encountered during compilation and linking or a runtime exception occurs, the corresponding target function name is obtained. The target function name is traversed and searched in the target two-dimensional array until the target function name is found in the target two-dimensional array. Obtain the target position of the target function name in the target two-dimensional array, and determine the second-dimensional index value corresponding to the target function name based on the target position.

4. The function location method according to claim 3, characterized in that, The step of determining the first-dimensional index value of the location of the target function name based on the second-dimensional index value, and converting the first-dimensional index value to obtain the file ID of the binary file, includes: Based on the second-dimensional index value and the target position, determine the first-dimensional index value of the position where the target function name is located; Based on the first dimension index value and the corresponding mapping rule, the file ID of the binary file is obtained.

5. The function location method according to claim 1, characterized in that, The step of obtaining the corresponding binary file based on the file ID, decoding the binary file, and obtaining the software module to which the target function name belongs includes: Based on the file ID, find the corresponding binary file in the enumeration type definition or macro definition; The binary file is decoded to obtain the corresponding decoded file; Based on the decoded file, the software module corresponding to the binary file is determined, and the software module to which the target function name belongs is obtained.

6. A function positioning device, characterized in that, include: The target function name lookup module is used to obtain the target function name, find the position of the target function name in the target two-dimensional array, and obtain the corresponding second-dimensional index value; The file ID conversion module is used to determine the first-dimensional index value of the location of the target function name based on the second-dimensional index value, and convert the first-dimensional index value to obtain the file ID of the binary file. The software module acquisition module is used to acquire the corresponding binary file based on the file ID, decode the binary file, and acquire the software module to which the target function name belongs; wherein, the generation of the target two-dimensional array includes: Obtain the software module and generate a binary file based on the software module; The binary file is parsed to extract function names from the binary file's symbol table; Obtaining the file ID of the binary file, and based on the file ID and function name, obtaining the first and second dimension index values ​​of a variable-length two-dimensional array, includes: obtaining the file ID and function name of the binary file; mapping the file ID and function name using enumeration type variables or macro definitions; mapping the file ID to elements of enumeration type variables or macro definitions, and obtaining the file ID element, which is used as the first dimension index value of the variable-length two-dimensional array; mapping the function name to elements of enumeration type variables or macro definitions, and obtaining the function name element, which is used as the second dimension index value of the variable-length two-dimensional array. A target two-dimensional array is generated based on the first and second dimension index values, and the function name is stored as a string in the corresponding position of the target two-dimensional array.

7. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to read the executable instructions from the memory and execute the instructions to implement the function location method according to any one of claims 1-5.

8. A computer-readable storage medium having computer program instructions stored thereon, characterized in that, When the program instructions are executed by the processor, they implement the steps of the function location method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Risk code positioning method, device and equipment and storage medium

    CN112035354A

  • Source code positioning detection method and system, electronic equipment and storage medium

    CN114817920A