Method, device and computer equipment for tracking program function execution

By modifying the preset address item in the global offset table and jumping to the tracking function to track the call of the objective function, the problem of difficult to monitor the execution of the function in the existing technology is solved, and real-time analysis and optimization of program performance is achieved .

CN112347483BActive Publication Date: 2024-11-22CAMBRICON TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910738961.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-08-09
Publication Date
2024-11-22
Estimated Expiration
2039-12-04

AI Technical Summary

Technical Problem

The prior art is difficult to effectively track and analyze the execution of program functions, especially when function calls lack real-time monitoring of function execution time and performance.

Method used

By modifying the preset address item in the global offset table, jump to the corresponding tracking function to track the call of the target function, and record the execution of the function, including the entry and exit times.

Benefits of technology

Real-time tracking and performance analysis of program function execution is realized, and the ability to optimize program performance is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112347483B_ABST
    Figure CN112347483B_ABST
Patent Text Reader

Abstract

The embodiments of the present application disclose a method, an apparatus, and a computer device for tracking the execution of a program function, which implements tracking of the execution of a calling function by modifying the content of a preset address item in a global offset table.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of program development, and in particular to a method, apparatus and computer device for tracking program function execution. Background Art

[0002] Performing performance analysis on a program can help resolve vulnerabilities in the program and optimize the program's performance. When a program is running, it needs to call external functions. In order to perform performance analysis on the program, it is necessary to understand the specific execution of the function, such as the function's running time. Therefore, it is necessary to track the function calls. Summary of the invention

[0003] The embodiments of the present application provide a method, apparatus, computer device and storage medium for tracking the execution of a program function, which can track the execution of a called function by modifying the content of a preset address item in a global offset table.

[0004] In a first aspect, an embodiment of the present application provides a method for tracking program function execution, the method comprising:

[0005] When calling the target function, jump to the target item corresponding to the target function in the global offset table;

[0006] If the target item includes the target address of the target function, calling the target function according to the target address;

[0007] Modify the preset address item in the global offset table to the first address of the first tracking function;

[0008] Jump to a preset address item in the global offset table, call the first tracing function according to the first address in the preset address item, and trace the call of the target function according to the first tracing function.

[0009] In a second aspect, an embodiment of the present application provides a device for tracking program function execution, the device comprising a jump unit, a call unit and a modification unit, wherein:

[0010] The jump unit is used to jump to the target item corresponding to the target function in the global offset table when calling the target function;

[0011] The calling unit is configured to call the target function according to the target address when the target address of the target function is included in the target item;

[0012] The modifying unit is used to modify the preset address item in the global offset table to a first address of a first tracking function;

[0013] The jump unit is further used to jump to a preset address item in the global offset table, call the first tracing function according to the first address in the preset address item, and trace the call of the target function according to the first tracing function.

[0014] In a third aspect, an embodiment of the present application provides a computer device, comprising a processor and a memory, wherein the processor and the memory are interconnected, wherein the memory is used to store a computer program that supports the computer device to execute the above-mentioned method, and the computer program includes program instructions, and the processor is configured to call the program instructions to execute the above-mentioned method of the first aspect.

[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the method of the first aspect above.

[0016] In a fifth aspect, an embodiment of the present application provides a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the method of the first aspect.

[0017] In implementing the embodiment of the present application, the computer device jumps to the target item corresponding to the target function in the global offset table when calling the target function. If the target item includes the target address of the target function, the target function is called according to the target address, the preset address item in the global offset table is modified to the first address of the first tracking function, and the computer device jumps to the preset address item in the global offset table. The first tracking function is called according to the first address in the preset address item, and the call of the target function is tracked according to the first tracking function. In this way, the execution of the called function can be tracked by modifying the content of the preset address item in the global offset table. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for describing the embodiments.

[0019] Figure 1 is a structural schematic diagram of a computer device provided in an embodiment of the present application;

[0020] Figure 2A It is a flowchart of a method for tracking program function execution provided by an embodiment of the present application;

[0021] Figure 2B is a demonstration schematic diagram of a global offset table provided in an embodiment of the present application;

[0022] Figure 3AIt is a flowchart of another method for tracking program function execution provided by an embodiment of the present application;

[0023] Figure 3B It is a flowchart of another method for tracking program function execution provided by an embodiment of the present application;

[0024] Figure 4 It is a flowchart diagram of another method for tracking program function execution disclosed in an embodiment of the present application;

[0025] Figure 5 It is a flowchart diagram of another method for tracking program function execution disclosed in an embodiment of the present application;

[0026] Figure 6 It is a structural diagram of a device for tracking program function execution provided by an embodiment of the present application;

[0027] Figure 7 The embodiment of this application provides Figure 6 A variant structure of the device for tracking the execution of program functions is shown. DETAILED DESCRIPTION

[0028] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0029] It should be understood that the terms "first", "second", etc. in the claims, specifications and drawings of the present disclosure are used to distinguish different objects rather than to describe a specific order. The terms "include" and "comprise" used in the specifications and claims of the present disclosure indicate the presence of the described features, wholes, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or their collections.

[0030] It should also be understood that the terms used in this disclosure are only for the purpose of describing specific embodiments and are not intended to limit the disclosure. As used in this disclosure and claims, the singular forms of "a", "an", and "the" are intended to include the plural forms unless the context clearly indicates otherwise. It should also be further understood that the term "and / or" used in this disclosure and claims refers to any combination of one or more of the associated listed items and all possible combinations, including these combinations.

[0031] See also Figure 1 , is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. Figure 1As shown, the computer device 10 may include a processor 101 , a memory 102 , a communication bus 103 and a communication interface 104 , wherein the processor 101 is connected to the memory 102 and the communication interface 103 via the communication bus 103 .

[0032] The processor 101 may be a central processing unit (CPU), and the processor 101 may also be an artificial intelligence processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor may be a microprocessor or the processor 101 may also be any conventional processor, etc.

[0033] The processor 101 may also be an integrated circuit chip with signal processing capability. In the implementation process, each step of the resource configuration method of the present application may be completed by an integrated logic circuit of hardware in the processor 101 or by instructions in the form of software.

[0034] The memory 102 may be a read-only memory (ROM), a random access memory (RAM) or other memory. In the embodiment of the present application, the memory 102 is used to store data and various software programs, such as the target program running during the performance analysis process in the embodiment of the present application.

[0035] Optionally, in the embodiment of the present application, the memory may include a physical device for storing information, which is usually to digitize the information and then store it in a medium using electrical, magnetic or optical methods. The memory described in this embodiment may also include: a device that stores information using electrical energy, such as RAM, ROM, etc.; a device that stores information using magnetic energy, such as a hard disk, a floppy disk, a magnetic tape, a magnetic core memory, a magnetic bubble memory, a USB flash drive; a device that stores information using optical means, such as a CD or a DVD. Of course, there are other types of memory, such as quantum memory, graphene memory, etc.

[0036] The communication interface 104 uses a transceiver device such as, but not limited to, a transceiver to implement communication between the computer device 10 and other devices or a communication network.

[0037] It should be understood that the computer device 10 is only an example provided in the embodiment of the present application, and the computer device 10 may have more or fewer components than those shown, may combine two or more components, or may have different configurations of components.

[0038] like Figure 2A As shown, Figure 2A A flowchart of a method for tracking program function execution provided in an embodiment of the present application, the method comprising:

[0039] 201. When calling a target function, jump to a target item corresponding to the target function in a global offset table.

[0040] The target function refers to the external function in the dynamic function library that is called during program execution.

[0041] Among them, the Global Offset Table (GOT) is a table for storing global variable pointers and an area for storing function addresses. The Global Offset Table includes items for storing specific addresses. For example, a preset address item can be used to store the address of a preset function. For another example, a linked list address item can be used to store the linked list address of a loaded function library, such as Figure 2B As shown, it is a demonstration diagram of a global offset table provided by an embodiment of the present application, wherein the first three items of the global offset table are used to save the address of a specific data structure, and the items other than the first three items are used to save the address of an external function. Specifically, the first item got[0] can be used to save the .dynamic segment address, the second item got[1] can be used as a linked list address item, the got[1] item can be used to save the linked list address of the loaded function library, the third item got[2] can be used as a preset address item, and the got[2] item can be used to save the _dl_runtime_resolve function address.

[0042] Since the specific address of the called external function is not clear during the compilation stage of the program code, the specific address of the called external function will be determined only after the function library containing the external function is loaded into the memory through the dynamic linker during the running stage. Therefore, when calling the target function during the running of the program, you can jump to the target item corresponding to the target function in the global offset table, save the address of the target function through the target item, and then, you can reference the address of the target function in the target item to call the target function.

[0043] 202. If the target item includes a target address of the target function, call the target function according to the target address.

[0044] In the embodiment of the present application, the target item does not have the target address of the target function in the initial state. Therefore, it is necessary to determine whether the target address of the target function has been saved in the target item. If the target item includes the target address of the target function, the target function can be called directly according to the target address.

[0045] 203. Modify the preset address item in the global offset table to a first address of a first tracking function.

[0046] In an embodiment of the present application, considering that the content of each item in the global offset table can be modified, the preset address item in the global offset table can be modified to the first address of the first tracking function, thereby, the preset address item is modified from "the preset address of the preset function" to "the first address of the first tracking function".

[0047] 204. Jump to a preset address item in the global offset table, call the first tracing function according to the first address in the preset address item, and trace the call of the target function according to the first tracing function.

[0048] After modifying the preset address item in the global offset table to the first address of the first tracing function, you can jump to the preset address item in the global offset table, call the first tracing function according to the first address, and track the call of the target function according to the first tracing function. Specifically, the first tracing function can record the first running parameter of the program when calling the target function.

[0049] Optionally, the first tracking function may further record an entry time into the target function.

[0050] It can be seen that the technical solution provided by the present application is that the computer device jumps to the target item corresponding to the target function in the global offset table when calling the target function. If the target item includes the target address of the target function, the target function is called according to the target address, the preset address item in the global offset table is modified to the first address of the first tracking function, and the computer device jumps to the preset address item in the global offset table, calls the first tracking function according to the first address in the preset address item, and tracks the call of the target function according to the first tracking function. In this way, the execution of the called function can be tracked by modifying the content of the preset address item in the global offset table.

[0051] like Figure 3A As shown, Figure 3A A flowchart of another method for tracking program function execution provided in an embodiment of the present application, the method comprising:

[0052] 301. When calling a target function, jump to a target item corresponding to the target function in a global offset table.

[0053] 302. If the target item includes a preset instruction, execute the preset instruction, where the preset instruction is used to push the item number corresponding to the target function in the global offset table into the stack.

[0054] 303. Jump to a preset address item in the global offset table, wherein the preset address item includes a preset address of a preset function.

[0055] 304. Call the preset function according to the preset address, obtain the target address of the target function according to the preset function, add the target address to the target item in the global offset table, jump to the target item, and call the target function according to the target address; modify the preset address item in the global offset table to the first address of the first tracking function.

[0056] 305. Jump to a preset address item in the global offset table, call the first tracing function according to a first address in the preset address item, and trace the call of the target function according to the first tracing function.

[0057] Among them, when the address of any function has not been saved in the target item, preset instructions can be stored in the target item. If the target function needs to be called when running the program, the preset instructions can be executed to push the item number corresponding to the target function in the global offset table into the stack. For example, if the target function is the nth function whose corresponding function address needs to be saved in the global offset table, the item number n can be pushed into the stack, so that the got[n+2] item in the global offset table can be used as the target item to save the target address of the target function.

[0058] At this time, the target item, i.e., the got[n+2] item, has not yet saved the target address of the target function, and can jump to the preset address item in the global offset table. The preset address item now saves the preset address of the preset function. The target address of the target function can be obtained by calling the preset function. Then, the target address can be added to the target item in the global offset table, and jump to the target item, and call the target function according to the target address saved in the target item.

[0059] Optionally, the preset function may be a _dl_runtime_resolve function. By calling the dl_runtime_resolve function, the target address of the target function may be found, and the target address may be written into the target item got[n+2] in the global offset table.

[0060] It can be seen that the technical solution provided by the present application is that the computer device jumps to the target item corresponding to the target function in the global offset table when calling the target function. If the target item includes a preset instruction, the preset instruction is executed. The preset instruction is used to push the item number corresponding to the target function in the global offset table into the stack, jump to the preset address item in the global offset table, call the preset function according to the preset address, obtain the target address of the target function according to the preset function, and add the target address to the target item in the global offset table, and jump to the target item, and call the target function according to the target address; modify the preset address item in the global offset table to the first address of the first tracking function, jump to the preset address item in the global offset table, call the first tracking function according to the first address in the preset address item, and track the call of the target function according to the first tracking function. In this way, the target address of the target function can be written in the preset address item in the global offset table first, and then the target function can be called through the target address of the target function, and the execution of the called function can be tracked by modifying the content of the preset address item in the global offset table.

[0061] like Figure 3B As shown, Figure 3B A flowchart of another method for tracking program function execution provided in an embodiment of the present application, the method comprising:

[0062] 306. When calling the target function, jump to the target item corresponding to the target function in the global offset table.

[0063] 307. If the target item includes a preset instruction, execute the preset instruction, where the preset instruction is used to push the item number corresponding to the target function in the global offset table into the stack.

[0064] 308. Push the linked list address item in the global offset table into the stack, wherein the linked list address item contains the linked list address of the loaded function library, the function library includes the target function, and the linked list address item is used to identify the module corresponding to the global offset table, and the module encapsulates all operations of all functions in the function library that share the global offset table.

[0065] In the embodiment of the present application, after executing the preset instruction, before jumping to the preset address item, the linked list address item in the global offset table can also be pushed into the stack, and the linked list address item is used to identify the module corresponding to the global offset table, and the module encapsulates all operations of all functions in the function library that share the global offset table, so it can be identified that the global offset table can be used to store the function addresses of all functions in the function library. In this way, in the process of calling the target function, the global offset table corresponding to the function library can be quickly determined, and then the target function can be called according to the target item of the global offset table, thereby improving the efficiency of function calling.

[0066] 309. Jump to a preset address item in the global offset table, wherein the preset address item includes a preset address of a preset function.

[0067] 310. Call the preset function according to the preset address, obtain the target address of the target function according to the preset function, add the target address to the target item in the global offset table, jump to the target item, and call the target function according to the target address; modify the preset address item in the global offset table to the first address of the first tracking function.

[0068] 311. Jump to a preset address item in the global offset table, call the first tracing function according to a first address in the preset address item, and trace the call of the target function according to the first tracing function.

[0069] The specific implementation process of the above steps 306-307 and 309-311 can be referred to Figure 3A The corresponding description in the method shown will not be repeated here.

[0070] It can be seen that the technical solution provided by the present application is that the computer device jumps to the target item corresponding to the target function in the global offset table when calling the target function. If the target item includes a preset instruction, the preset instruction is executed. The preset instruction is used to push the item number corresponding to the target function in the global offset table into the stack, and push the linked list address item in the global offset table into the stack. The linked list address item is the linked list address of the loaded function library. The function library includes the target function. The linked list address item is used to identify the module corresponding to the global offset table. The module encapsulates all operations of all functions in the function library that share the global offset table, jumps to the preset address item in the global offset table, calls the preset function according to the preset address, obtains the target address of the target function according to the preset function, and The target address is added to the target item in the global offset table, and the target item is jumped to, and the target function is called according to the target address; the preset address item in the global offset table is modified to the first address of the first tracking function, and the preset address item in the global offset table is jumped to, and the first tracking function is called according to the first address in the preset address item, and the call of the target function is tracked according to the first tracking function. In this way, the target function can be called through the target address of the target function, and the execution of the called function can be tracked by modifying the content of the preset address item in the global offset table; in addition, in the process of calling the target function, the global offset table corresponding to the function library can be quickly determined, and then the target function can be called according to the target item in the global offset table, thereby improving the efficiency of function calling.

[0071] like Figure 4 As shown, Figure 4A flowchart of another method for tracking program function execution provided in an embodiment of the present application, the method comprising:

[0072] 401. When calling a target function, jump to a target item corresponding to the target function in a global offset table.

[0073] 402. If the target item includes a target address of the target function, call the target function according to the target address.

[0074] 403. Modify the preset address item in the global offset table to a first address of a first tracking function.

[0075] 404. Jump to a preset address item in the global offset table, call the first tracing function according to the first address in the preset address item, and trace the call of the target function according to the first tracing function.

[0076] The specific implementation process of the above steps 401-404 can be referred to Figure 2A The corresponding description in the method shown will not be repeated here.

[0077] 405. After the target function is called, modify the preset address item in the global offset table to the second address of the second tracking function.

[0078] 406. When the target function exits, jump to a preset address item in the global offset table, call the second tracing function according to the second address in the preset address item, and trace the return of the target function according to the second tracing function.

[0079] In an embodiment of the present application, after the target function is called, the preset address item in the global offset table can be modified to the second address of the second tracking function, so that the content saved in the preset address item can be modified from "the first address of the first tracking function" to "the second address of the second tracking function".

[0080] Furthermore, when the target function exits, it can jump to the preset address item in the global offset table, call the second tracing function according to the second address in the preset address item, and track the return of the target function according to the second tracing function. Specifically, the second tracing function can record the second operating parameter of the program when calling the target function, and then, the impact of the target function on the performance of the program can be determined according to the second operating parameter.

[0081] Optionally, the second tracking function can also be used to record the exit time of the target function, so that the running time of the target function can be determined according to the entry time and the exit time, so that R&D personnel can analyze the program execution performance according to the running time.

[0082] It can be seen that the technical solution provided by the present application is that the computer device jumps to the target item corresponding to the target function in the global offset table when calling the target function. If the target item includes the target address of the target function, the target function is called according to the target address, the preset address item in the global offset table is modified to the first address of the first tracking function, and the computer device jumps to the preset address item in the global offset table. The first tracking function is called according to the first address in the preset address item, and the call of the target function is tracked according to the first tracking function. After the target function is called, the preset address item in the global offset table is modified to the second address of the second tracking function. When the target function exits, the computer device jumps to the preset address item in the global offset table, and the second tracking function is called according to the second address in the preset address item. The return of the target function is tracked according to the second tracking function. In this way, the execution of the called function can be tracked by modifying the content of the preset address item in the global offset table.

[0083] like Figure 5 As shown, Figure 5 A flowchart of another method for tracking program function execution provided in an embodiment of the present application, the method comprising:

[0084] 501. When calling a target function, jump to a target item corresponding to the target function in a global offset table.

[0085] 502. If the target item includes a target address of the target function, call the target function according to the target address.

[0086] 503. If the target item includes a preset instruction, execute the preset instruction, where the preset instruction is used to push the item number corresponding to the target function in the global offset table into the stack.

[0087] 504. Jump to a preset address item in the global offset table, wherein the preset address item includes a preset address of a preset function.

[0088] 505. Call the preset function according to the preset address, obtain the target address of the target function according to the preset function, add the target address to the target item in the global offset table, jump to the target item, and call the target function according to the target address.

[0089] 506. Modify the preset address item in the global offset table to a first address of a first tracing function.

[0090] 507. Jump to a preset address item in the global offset table, call the first tracing function according to the first address in the preset address item, and trace the call of the target function according to the first tracing function.

[0091] 508. After the target function is called, modify the preset address item in the global offset table to the second address of the second tracking function.

[0092] 509. When the target function exits, jump to the preset address item in the global offset table, call the second tracing function according to the second address in the preset address item, and trace the return of the target function according to the second tracing function.

[0093] The specific implementation process of the above steps 501-509 can be referred to Figure 2A The corresponding description in the method shown will not be repeated here.

[0094] It can be seen that the technical solution provided by the present application is that the computer device jumps to the target item corresponding to the target function in the global offset table when calling the target function, and if the target item includes the target address of the target function, calls the target function according to the target address, and if the target item includes a preset instruction, executes the preset instruction, and the preset instruction is used to push the item number corresponding to the target function in the global offset table into the stack, jump to the preset address item in the global offset table, call the preset function according to the preset address, obtain the target address of the target function according to the preset function, and add the target address to the target item in the global offset table, and jump to the target item, call the target function according to the target address, and add the global offset table to the target item. The preset address item in the global offset table is modified to the first address of the first tracking function, and the preset address item in the global offset table is jumped to. The first tracking function is called according to the first address in the preset address item. The call of the target function is tracked according to the first tracking function. After the target function is called, the preset address item in the global offset table is modified to the second address of the second tracking function. When the target function exits, the preset address item in the global offset table is jumped to, and the second tracking function is called according to the second address in the preset address item. The return of the target function is tracked according to the second tracking function. In this way, the execution of the called function can be tracked by modifying the content of the preset address item in the global offset table.

[0095] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should know that the present disclosure is not limited by the order of the actions described, because according to the present disclosure, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present disclosure.

[0096] It should be further explained that although Figure 2A , Figure 3A-Figure 5The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2A , Figure 3A-Figure 5 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0097] The following introduces the device for tracking program function execution provided by this application.

[0098] See also Figure 6 , Figure 6 600 is a schematic diagram of a device for tracking program function execution provided by an embodiment of the present application. The device 600 may at least include a jump unit 601, a call unit 602, and a modification unit 603, wherein:

[0099] The jump unit 601 is used to jump to the target item corresponding to the target function in the global offset table when calling the target function;

[0100] The calling unit 602 is configured to call the target function according to the target address when the target address of the target function is included in the target item;

[0101] The modifying unit 603 is used to modify the preset address item in the global offset table to the first address of the first tracking function;

[0102] The jump unit 601 is further used to jump to a preset address item in the global offset table, call the first tracing function according to the first address in the preset address item, and trace the call of the target function according to the first tracing function.

[0103] In a possible implementation, the preset function is a _dl_runtime_resolve function, and the _dl_runtime_resolve function is used to obtain a target address of the target function; and the first tracking function is used to record an entry time into the target function.

[0104] In one possible implementation, Figure 7 As shown, Figure 7 for Figure 6 The variant structure of the device for tracking program function execution shown in FIG. Figure 6In comparison, it may also include: an execution unit 604, wherein:

[0105] The execution unit 604 is used to execute the preset instruction when the target item includes the preset instruction, and the preset instruction is used to push the item number corresponding to the target function in the global offset table into the stack;

[0106] The jump unit 601 is further used to jump to a preset address item in the global offset table, wherein the preset address item includes a preset address of a preset function;

[0107] The calling unit 602 is further configured to call the preset function according to the preset address, obtain the target address of the target function according to the preset function, add the target address to the target item in the global offset table, jump to the target item, and call the target function according to the target address; modify the preset address item in the global offset table to the first address of the first tracking function;

[0108] The jump unit 601 is further used to jump to a preset address item in the global offset table;

[0109] The calling unit 602 is further configured to call the first tracing function according to the first address in the preset address item, and trace the calling of the target function according to the first tracing function.

[0110] In a possible implementation, after executing the preset instruction, the execution unit 604 is further configured to:

[0111] Pushing a linked list address item in the global offset table into a stack, the linked list address item containing the linked list address of a loaded function library, the function library including the target function, the linked list address item being used to identify a module corresponding to the global offset table, the module encapsulating all operations of all functions in the function library that share the global offset table.

[0112] In a possible implementation, the modification unit 603 is further configured to modify the preset address item in the global offset table to a second address of a second tracking function after the target function is called;

[0113] The jump unit 601 is further configured to jump to a preset address item in the global offset table when the target function exits;

[0114] The calling unit 602 is further configured to call the second tracing function according to the second address in the preset address item, and trace the return of the target function according to the second tracing function.

[0115] In a possible implementation manner, the second tracking function is used to record the exit time of the target function.

[0116] It can be seen that the technical solution provided by the present application is that the computer device jumps to the target item corresponding to the target function in the global offset table when calling the target function. If the target item includes the target address of the target function, the target function is called according to the target address, the preset address item in the global offset table is modified to the first address of the first tracking function, and the computer device jumps to the preset address item in the global offset table, calls the first tracking function according to the first address in the preset address item, and tracks the call of the target function according to the first tracking function. In this way, the execution of the called function can be tracked by modifying the content of the preset address item in the global offset table.

[0117] It should be understood that the above-mentioned device embodiments are only illustrative, and the device disclosed herein may also be implemented in other ways. For example, the division of units / modules described in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components may be combined, or may be integrated into another system, or some features may be ignored or not executed.

[0118] The units or modules described as separate components may or may not be physically separated. The components described as units or modules may or may not be physical units, that is, they may be located in one device or distributed on multiple devices. The schemes of the embodiments in this disclosure may be implemented by selecting some or all of the units therein according to actual needs.

[0119] The present application also provides a computer storage medium for storing the above Figure 2A , Figure 3A-Figure 5 The computer software instructions used by the computer device shown include the programs involved in executing the above method embodiments. By executing the stored programs, the verification of the neural network online model can be realized, and the verification speed can be improved.

[0120] The present application also provides a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the above Figure 2A , Figure 3A-Figure 5 The computer software instructions used by the computer device shown include the programs involved in executing the above method embodiments. By executing the stored programs, the verification of the neural network online model can be realized, and the verification speed can be improved.

[0121] As can be seen from the above, the embodiments of the present application provide a method, apparatus, computer device and storage medium for tracking the execution of program functions. The method can conveniently verify the forward propagation of the online model by randomly generating the verification input data required for the online model without preparing the input data set in advance.

[0122] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.

[0123] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0124] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0125] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0126] If the integrated unit / module in the embodiment of the present application is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. Unless otherwise specified, the processor may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, and an ASIC, etc. Unless otherwise specified, the memory may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc.

[0127] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution disclosed herein is essentially or partly contributed to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, including several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the disclosure. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0128] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution disclosed herein is essentially or partly contributed to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, including several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the disclosure. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0129] In the above embodiments, the description of each embodiment has its own emphasis. For the part not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0130] Furthermore, the foregoing content can be better understood according to the following terms:

[0131] For example, clause A1, a method for tracing program function execution, the method comprising:

[0132] When calling the target function, jump to the target item corresponding to the target function in the global offset table;

[0133] If the target item includes the target address of the target function, calling the target function according to the target address;

[0134] Modify the preset address item in the global offset table to the first address of the first tracking function;

[0135] Jump to a preset address item in the global offset table, call the first tracing function according to the first address in the preset address item, and trace the call of the target function according to the first tracing function.

[0136] A2. The method according to A1, further comprising:

[0137] If the target item includes a preset instruction, executing the preset instruction, wherein the preset instruction is used to push the item number corresponding to the target function in the global offset table into the stack;

[0138] Jump to a preset address item in the global offset table, wherein the preset address item includes a preset address of a preset function;

[0139] Call the preset function according to the preset address, obtain the target address of the target function according to the preset function, add the target address to the target item in the global offset table, jump to the target item, and call the target function according to the target address; modify the preset address item in the global offset table to the first address of the first tracking function;

[0140] Jump to a preset address item in the global offset table, call the first tracing function according to a first address in the preset address item, and trace the call of the target function according to the first tracing function.

[0141] A3. According to the method described in A2, the preset function is a _dl_runtime_resolve function, and the _dl_runtime_resolve function is used to obtain the target address of the target function; and the first tracking function is used to record the entry time into the target function.

[0142] A4. According to the method of A2 or A3, after executing the preset instruction, the method further includes:

[0143] Pushing a linked list address item in the global offset table into a stack, the linked list address item containing the linked list address of a loaded function library, the function library including the target function, the linked list address item being used to identify a module corresponding to the global offset table, the module encapsulating all operations of all functions in the function library that share the global offset table.

[0144] A5. The method according to any one of A1 to A4, further comprising:

[0145] After the target function is called, modifying the preset address item in the global offset table to a second address of a second tracking function;

[0146] When the target function exits, jump to the preset address item in the global offset table, call the second tracking function according to the second address in the preset address item, and track the return of the target function according to the second tracking function.

[0147] A6. According to the method described in any one of A1-A5, the second tracking function is used to record the exit time of the target function.

[0148] B1. A device for tracking program function execution, the device comprising a jump unit, a call unit and a modification unit, wherein:

[0149] The jump unit is used to jump to the target item corresponding to the target function in the global offset table when calling the target function;

[0150] The calling unit is configured to call the target function according to the target address when the target address of the target function is included in the target item;

[0151] The modifying unit is used to modify the preset address item in the global offset table to a first address of a first tracking function;

[0152] The jump unit is further used to jump to a preset address item in the global offset table, call the first tracing function according to the first address in the preset address item, and trace the call of the target function according to the first tracing function.

[0153] B2. The device according to B1, further comprising an execution unit, wherein:

[0154] The execution unit is used to execute the preset instruction when the target item includes the preset instruction, and the preset instruction is used to push the item number corresponding to the target function in the global offset table into the stack;

[0155] The jump unit is further used to jump to a preset address item in the global offset table, wherein the preset address item includes a preset address of a preset function;

[0156] The calling unit is further configured to call the preset function according to the preset address, obtain the target address of the target function according to the preset function, add the target address to the target item in the global offset table, jump to the target item, and call the target function according to the target address; modify the preset address item in the global offset table to the first address of the first tracking function;

[0157] The jump unit is further used to jump to a preset address item in the global offset table;

[0158] The calling unit is further configured to call the first tracing function according to the first address in the preset address item, and trace the calling of the target function according to the first tracing function.

[0159] B3. According to the device described in B2, the preset function is a _dl_runtime_resolve function, and the _dl_runtime_resolve function is used to obtain the target address of the target function; and the first tracking function is used to record the entry time into the target function.

[0160] B4. According to the device described in B2 or B3, after executing the preset instruction, the execution unit is further used to:

[0161] Pushing a linked list address item in the global offset table into a stack, the linked list address item containing the linked list address of a loaded function library, the function library including the target function, the linked list address item being used to identify a module corresponding to the global offset table, the module encapsulating all operations of all functions in the function library that share the global offset table.

[0162] B5. According to any one of B1-B4, the modification unit is further configured to modify the preset address item in the global offset table to a second address of a second tracking function after the target function is called;

[0163] The jump unit is further used to jump to a preset address item in the global offset table when the target function exits;

[0164] The calling unit is further configured to call the second tracing function according to the second address in the preset address item, and to trace the return of the target function according to the second tracing function.

[0165] B6. According to any one of items B5, the second tracking function is used to record the exit time of the target function.

[0166] C1. A computer device, characterized in that it comprises a processor and a memory, wherein the processor and the memory are interconnected, wherein the memory is used to store a computer program, the computer program comprises program instructions, and the processor is configured to call the program instructions to execute a method as described in any one of clauses A1 to A6.

[0167] D1. A computer-readable storage medium, characterized in that the computer storage medium stores a computer program, the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the method described in any one of clauses A1 to A6.

[0168] The embodiments of the present disclosure are described in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present disclosure. The description of the above embodiments is only used to help understand the method and its core idea of ​​the present disclosure. At the same time, changes or deformations made by those skilled in the art based on the ideas of the present disclosure, the specific implementation methods and the scope of application of the present disclosure, all belong to the scope of protection of the present disclosure. In summary, the content of this specification should not be understood as a limitation on the present disclosure.

Claims

1. A method for tracking program function execution, characterized in that: The method comprises: When calling a target function, jump to the target item corresponding to the target function in the global offset table; the target function refers to an external function in a dynamic function library called during program execution; If the target item includes the target address of the target function, calling the target function according to the target address; Modify the preset address item in the global offset table to the first address of the first tracking function; the preset address item is used to store the address of the first tracking function; Jump to the preset address item in the global offset table, call the first tracing function according to the first address in the preset address item, and trace the call of the target function according to the first tracing function.

2. The method according to claim 1, characterized in that The method further comprises: If the target item includes a preset instruction, executing the preset instruction, wherein the preset instruction is used to push the item number corresponding to the target function in the global offset table into the stack; Jump to the preset address item in the global offset table, wherein the preset address item includes a preset address of a preset function; Call the preset function according to the preset address, obtain the target address of the target function according to the preset function, add the target address to the target item in the global offset table, jump to the target item, and call the target function according to the target address; modify the preset address item in the global offset table to the first address of the first tracking function; Jump to the preset address item in the global offset table, call the first tracing function according to the first address in the preset address item, and trace the call of the target function according to the first tracing function.

3. The method according to claim 2, characterized in that The preset function is a _dl_runtime_resolve function, and the _dl_runtime_resolve function is used to obtain a target address of the target function; the first tracking function is used to record an entry time into the target function.

4. The method according to claim 2 or 3, characterized in that: After executing the preset instruction, the method further includes: Pushing a linked list address item in the global offset table into a stack, the linked list address item containing the linked list address of a loaded function library, the function library including the target function, the linked list address item being used to identify a module corresponding to the global offset table, the module encapsulating all operations of all functions in the function library that share the global offset table.

5. The method according to claim 4, characterized in that The method further comprises: After the target function is called, modifying the preset address item in the global offset table to a second address of a second tracking function; When the target function exits, jump to the preset address item in the global offset table, call the second tracking function according to the second address in the preset address item, and track the return of the target function according to the second tracking function.

6. The method according to claim 5, characterized in that The second tracking function is used to record the exit time of the target function.

7. A device for tracking the execution of program functions, characterized in that: The device comprises a jump unit, a call unit and a modification unit, wherein: The jump unit is used to jump to the target item corresponding to the target function in the global offset table when calling the target function; the target function refers to an external function in the dynamic function library called during the program running process; The calling unit is configured to call the target function according to the target address when the target address of the target function is included in the target item; The modifying unit is used to modify the preset address item in the global offset table to the first address of the first tracing function; the preset address item is used to store the address of the first tracing function; The jump unit is further used to jump to the preset address item in the global offset table, call the first tracing function according to the first address in the preset address item, and trace the call of the target function according to the first tracing function.

8. The device according to claim 7, characterized in that The device further comprises an execution unit, wherein: The execution unit is used to execute the preset instruction when the target item includes the preset instruction, and the preset instruction is used to push the item number corresponding to the target function in the global offset table into the stack; The jump unit is further used to jump to a preset address item in the global offset table, wherein the preset address item includes a preset address of a preset function; The calling unit is further configured to call the preset function according to the preset address, obtain the target address of the target function according to the preset function, add the target address to the target item in the global offset table, jump to the target item, and call the target function according to the target address; modify the preset address item in the global offset table to the first address of the first tracking function; The jump unit is further used to jump to the preset address item in the global offset table; The calling unit is further configured to call the first tracing function according to the first address in the preset address item, and trace the calling of the target function according to the first tracing function.

9. The device according to claim 8, characterized in that The preset function is a _dl_runtime_resolve function, and the _dl_runtime_resolve function is used to obtain a target address of the target function; the first tracking function is used to record an entry time into the target function.

10. The device according to claim 8 or 9, characterized in that After executing the preset instruction, the execution unit is further used for: Pushing a linked list address item in the global offset table into a stack, the linked list address item containing the linked list address of a loaded function library, the function library including the target function, the linked list address item being used to identify a module corresponding to the global offset table, the module encapsulating all operations of all functions in the function library that share the global offset table.

11. The device according to claim 10, characterized in that The modification unit is further used to modify the preset address item in the global offset table to the second address of the second tracking function after the target function is called; The jump unit is further used to jump to the preset address item in the global offset table when the target function exits; The calling unit is further used to call the second tracing function according to the second address in the preset address item, and trace the return of the target function according to the second tracing function.

12. The device according to claim 11, characterized in that The second tracking function is used to record the exit time of the target function.

13. A computer device, characterized in that: The method comprises a processor and a memory, wherein the processor and the memory are connected to each other, wherein the memory is used to store a computer program, the computer program comprises program instructions, and the processor is configured to call the program instructions to execute the method according to any one of claims 1 to 6.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 6.