Stack backtracking method, performance analysis method, device, equipment, medium and product of function

By combining the hybrid stack backtracing method of frame pointer FP and DWARF and selecting the appropriate backtracing method according to the backtracing method tag, the problem of difficult balance between stack backtracing accuracy and efficiency in the existing technology is solved, and efficient and accurate stack backtracing is achieved.

CN120371678BActive Publication Date: 2025-10-10ALIBABA CLOUD COMPUTING CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510857586.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-25
Publication Date
2025-10-10
Estimated Expiration
2045-06-25

AI Technical Summary

Technical Problem

In the prior art, when the function stack frame of the target function does not include a frame pointer, it is impossible to accurately and efficiently perform stack backtracing, resulting in a difficulty in balancing the accuracy and efficiency of performance analysis.

Method used

By obtaining the backtracing method tag of the target function, a hybrid stack backtracing method that combines the first backtracing method (based on frame pointer FP) and the second backtracing method (based on DWARF) is used to select the appropriate backtracing method according to the tag status, thereby reducing the amount of calculation and improving accuracy.

Benefits of technology

While ensuring the accuracy of stack backtracing, the computational complexity and performance consumption are reduced, efficient stack backtracing is achieved, and performance and accuracy are balanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371678B_ABST
    Figure CN120371678B_ABST
Patent Text Reader

Abstract

The application provides a function stack backtracking method, a performance analysis method, a device, equipment, a medium and a product. First, the backtracking method mark of a target function is acquired. Then, when the backtracking method mark is in an unmarked state, a first backtracking method with smaller calculation amount is used to backtrack the function stack frame corresponding to the upper-level function. When the backtracking method mark is in a marked state, the backtracking method corresponding to the marked content of the backtracking method mark is used to backtrack the function stack frame corresponding to the upper-level function. The accuracy of the function stack frame corresponding to the upper-level function obtained by stack backtracking is ensured, and the performance overhead and resource consumption required by stack backtracking are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a function stack backtracing method, performance analysis method, device, equipment, medium, and product. Background Art

[0002] Stack backtracing is a basic processing method used during performance analysis of processes running in an operating system. When a performance analysis program analyzes a process running on a processor, it first determines the function stack frame corresponding to the target function being run by the process being analyzed. Then, based on the register information in the target function's function stack frame, it backtraces to the parent function of that function. This parent function is then used again as the target function and the backtracing continues until the parent function is reached. Ultimately, the performance analysis of the process can be performed based on all of the target function's parent functions. Based on the performance analysis results, operating system maintenance personnel can identify performance bottlenecks in the process and locate specific functions or code, allowing for more effective analysis and maintenance of the operating system.

[0003] In related technologies, performance analysis programs typically backtrack directly based on register information such as the target function's frame pointer, thereby obtaining the function stack frame of the previous function corresponding to the frame pointer, which has higher backtracking efficiency. However, in some cases where the function stack frame corresponding to the target function does not include a frame pointer, this method will not be able to backtrack to obtain the function stack frame of the previous function. Therefore, how to improve the backtracking efficiency of stack backtracking while ensuring the accuracy of stack backtracking is a technical problem that needs to be solved in this field. Summary of the Invention

[0004] The present application provides a function stack backtracing method, performance analysis method, apparatus, equipment, medium and product to improve the backtracing efficiency of stack backtracing while ensuring the accuracy of stack backtracing.

[0005] In a first aspect, the present application provides a function stack backtracing method, comprising: obtaining a backtracing method tag of a target function; when the backtracing method tag is in an unmarked state, using a first backtracing method to backtrace a function stack frame corresponding to a function at the previous level of the target function; when the backtracing method tag is in a marked state, using the first backtracing method or the second backtracing method corresponding to the backtracing method tag to backtrace a function stack frame corresponding to a function at the previous level of the target function, wherein the computational amount of the first backtracing method is less than the computational amount of the second backtracing method.

[0006] In an embodiment of the first aspect of the application, obtaining the backtracing method mark of the target function includes: obtaining register information of a function stack frame corresponding to the target function; and obtaining the backtracing method mark of the target function based on the register information.

[0007] In an embodiment of the first aspect of the present application, the register information includes: a program counter; obtaining the backtracing method tag of the target function based on the register information includes: obtaining the function file where the instruction indicated by the program counter is located; obtaining the target parameter of the target data structure from the function file, and the content of the target parameter is the backtracing method tag of the target function.

[0008] In an embodiment of the first aspect of the present application, when the backtracing method mark is in a marked state, the first backtracing method or the second backtracing method corresponding to the backtracing method mark is used to backtrace the function stack frame corresponding to the previous level function of the target function, including: when the backtracing method mark is marked as the first content corresponding to the first backtracing method, the first backtracing method is used to backtrace the function stack frame corresponding to the previous level function of the target function; when the backtracing method mark is marked as the second content corresponding to the second backtracing method, the second backtracing method is used to backtrace the function stack frame corresponding to the previous level function of the target function.

[0009] In an embodiment of the first aspect of the present application, when the backtracing method mark is in an unmarked state, after backtracing the function stack frame corresponding to the previous level function of the target function using the first backtracing method, it also includes: obtaining register information of the function stack frame corresponding to the previous level function; based on the register information of the function stack frame corresponding to the previous level function, verifying the rationality of the obtained function stack frame corresponding to the previous level function; if the verification passes, marking the backtracing method mark as the first content; if the verification fails, marking the backtracing method mark as the second content, and using the second backtracing method to re-backtrace the function stack frame corresponding to the previous level function of the target function.

[0010] In an embodiment of the first aspect of the present application, the rationality of the obtained function stack frame corresponding to the upper-level function is verified based on the register information of the function stack frame corresponding to the upper-level function, including: obtaining the function file where the upper-level function is located, and obtaining the preset address range corresponding to the upper-level function from the function file; when the address of the function stack frame of the upper-level function indicated by the register information falls within the preset address range, it is determined that the rationality verification of the function stack frame corresponding to the upper-level function is passed; when the address of the function stack frame of the upper-level function indicated by the register information does not fall within the preset address range, it is determined that the rationality verification of the function stack frame corresponding to the upper-level function is failed.

[0011] In an embodiment of the first aspect of the present application, the first backtracing method includes: a backtracing method based on a frame pointer FP; the second backtracing method includes: a backtracing method based on a standardized debugging data format DWARF.

[0012] The second aspect of the present application provides a performance analysis method, comprising: in response to a predetermined time for performance analysis of an operating system, obtaining a target function currently executed by the operating system; backtracing the previous level function of the currently executed target function through a stack backtracing method of a function as described in any one of the first aspects of the present application, and using the previous level function as the target function until backtracing to the top-level function of the currently executed target function; outputting the hierarchical structure of the target function and the previous level function to which it backtraces to analyze the performance of the operating system.

[0013] The third aspect of the present application provides a performance analysis method, comprising: in response to a performance analysis instruction of an operating system, obtaining a target function currently executed by the operating system; backtracing back to the previous level function of the currently executed target function through a stack backtracing method of a function as described in any one of the first aspects of the present application, and using the previous level function as the target function until backtracing back to the top-level function of the currently executed target function; outputting the hierarchical structure of the target function and the previous level function to which it backtraces to analyze the performance of the operating system.

[0014] The fourth aspect of the present application provides a performance analysis method, comprising: obtaining a performance analysis instruction of an operating system through a first application programming interface; returning a performance analysis response through a second application programming interface, wherein the performance analysis response includes a target function currently executed by the operating system and a hierarchical structure of the upper-level function to which it traces back, and the upper-level function of the target function is obtained through a stack backtracing method of a function as described in any one of the first aspects of the present application.

[0015] In a fifth aspect, the present application provides a stack backtracing device for a function, which can be used to execute the stack backtracing method for a function provided in the first aspect of the present application. The stack backtracing device includes: an acquisition module for acquiring a backtracing method tag of a target function; a backtracing module for, when the backtracing method tag is in an unmarked state, using a first backtracing method to backtrace the function stack frame corresponding to the previous level function of the target function; and, when the backtracing method tag is in a marked state, using the first backtracing method or the second backtracing method corresponding to the backtracing method tag to backtrace the function stack frame corresponding to the previous level function of the target function, wherein the computational amount of the first backtracing method is less than the computational amount of the second backtracing method.

[0016] In a sixth aspect, the present application provides a performance analysis device that can be used to execute the performance analysis method as described in any one of the second aspects of the present application. The performance analysis device includes: an acquisition module for acquiring the target function currently executed by the operating system in response to a predetermined time for performance analysis of the operating system; a stack backtracing module for the stack backtracing method of the function as described in any one of the first aspects of the present application, backtracing the upper-level function of the currently executed target function, and using the upper-level function as the target function until backtracing to the top-level function of the currently executed target function; an output module for outputting the hierarchical structure of the target function and the upper-level function to which it backtraces, so as to analyze the performance of the operating system.

[0017] In the seventh aspect of the present application, a performance analysis device is provided, which can be used to execute the performance analysis method as described in any one of the third aspects of the present application. The performance analysis device includes: an acquisition module, which is used to obtain the target function currently executed by the operating system in response to a performance analysis instruction of the operating system; a stack backtracing module, which is used to backtrack the upper-level function of the currently executed target function through the stack backtracing method of the function as described in any one of the first aspects of the present application, and use the upper-level function as the target function until backtracing to the top-level function of the currently executed target function; an output module, which is used to output the hierarchical structure of the target function and the upper-level function to which it backtraces, so as to analyze the performance of the operating system.

[0018] In an eighth aspect, the present application provides an electronic device comprising: a memory and a processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the processor executes the method as described in any one of the first aspects of the present application.

[0019] In a ninth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of the first aspects of the present application.

[0020] In a tenth aspect, the present application provides a computer program product, including a computer program, which, when executed by a computer, implements the method described in any one of the first aspects of the present application.

[0021] In summary, the stack backtracing method, performance analysis method, device, equipment, medium and product of the function provided by this application enable the operation and maintenance platform to first obtain the backtracing method mark of the target function when performing stack backtracing on the target function during the maintenance of the operating system. Then, when the backtracing method mark is not marked, the first backtracing method with smaller computational complexity is used to backtrace the function stack frame corresponding to the previous function, so that the function to be backtraced can default to using the backtracing method with smaller computational complexity, reducing the computational complexity and performance consumption required for stack backtracing. When the backtracing method mark is marked, the first backtracing method or the second backtracing method corresponding to the content marked by the backtracing method mark is used to backtrace the function stack frame corresponding to the previous function, thereby increasing the accuracy of the function stack frame of the previous function obtained by stack backtracing. Therefore, based on whether the backtracing method mark is in a marked state, the first backtracing method with smaller computational complexity can be used as much as possible to backtrace the function stack frame corresponding to the previous level function, and only when some backtracing method marks are clearly marked, a more appropriate backtracing method can be used based on the backtracing method mark to backtrace the function stack frame corresponding to the previous level function. This ensures the accuracy of the function stack frame corresponding to the previous level function obtained by stack backtracing, while reducing the performance overhead and resource consumption required for stack backtracing. By combining the advantages of the first stack backtracing method and the second stack backtracing method and complementing each other's deficiencies, a balance is achieved between the performance and accuracy of stack backtracing, so that the stack backtracing method can have both high backtracing accuracy and high backtracing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0023] Figure 1 A schematic diagram of the application scenario of this application;

[0024] Figure 2 A schematic flow chart of the steps of a function stack backtracing method provided in an embodiment of the present application;

[0025] Figure 3 A schematic diagram of the correspondence between the backtracking method mark and the backtracking method provided in this application;

[0026] Figure 4 A schematic diagram of the steps of a stack backtracing method for a function provided in this application;

[0027] Figure 5 A schematic diagram of the steps of a stack backtracing method for a function provided in this application;

[0028] Figure 6A flowchart of an embodiment of a performance analysis method for an operating system provided by this application;

[0029] Figure 7 A flowchart of an embodiment of a performance analysis method for an operating system provided by this application;

[0030] Figure 8 A flowchart of an embodiment of a performance analysis method for an operating system provided by this application;

[0031] Figure 9 This is a structural diagram of an embodiment of a function stack backtracing device provided by this application;

[0032] Figure 10 This is a schematic diagram of the structure of an embodiment of a performance analysis device for an operating system provided by this application;

[0033] Figure 11 This is a schematic structural diagram of an embodiment of an electronic device provided in this application.

[0034] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION

[0035] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application. It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0036] Figure 1 This is a schematic diagram of the application scenario of this application. Figure 1 , explain the scenarios in which this application is applied and the professional terms involved.

[0037] This application can be applied in the process of developing and maintaining an operating system, where it is necessary to debug the currently running process in the operating system, or when an exception occurs in a running application or operating system, it is necessary to perform exception analysis on the currently running process and corresponding program in the operating system.

[0038] In a specific implementation method, the present application can be specifically applied to an operation and maintenance platform for maintaining an operating system. The operation and maintenance platform is used to provide a unified platform to implement host management, system monitoring, abnormal diagnosis, log auditing, security control, etc. of the operating system.

[0039] When operating system performance analysis is performed on maintenance platforms, occasional issues often occur in the online environment in which the operating system resides. Therefore, the importance of continuous profiling (CP) for operating systems is becoming increasingly prominent. In continuous operating system performance analysis technology, maintenance platforms can insert probes into program code or use specific tools to collect real-time performance data on the operating system as it executes programs and runs processes. Performance data includes CPU usage, memory allocation, thread lock wait time, and more. Based on this collected performance data, continuous performance analysis of the operating system is performed.

[0040] Furthermore, stack backtracing is a fundamental function of the operations and maintenance platform when performing operating system performance analysis, and is particularly important for continuous performance analysis, enabling a more comprehensive analysis of program execution flow and performance. Specifically, stack backtracing, also known as stack backtracing, call stack backtracing, or call stack tracing, can be used to determine the functions called by the operating system and the order in which they were called when executing a program.

[0041] In one embodiment, the operation and maintenance platform can periodically perform stack backtracing operations to analyze possible performance bottlenecks based on the functions and calling sequences obtained by backtracing, and locate the functions of the abnormal code or even the abnormal lines in the code, greatly improving the efficiency of performance analysis and problem location of the operating system.

[0042] like Figure 1 As shown in the figure, the operating system executes function 1. Function 1 also calls function 2, and function 2 calls function 3. When executing functions, the operating system allocates corresponding stack space in memory for each function. This stack space is called a stack frame. Stack frames are created when a function is called and destroyed after the function returns. For example, function 1 corresponds to frame 1 of the function stack frame, function 2 corresponds to frame 2 of the function stack frame, function 3 corresponds to frame 3 of the function stack frame, and so on.

[0043] The stack frame of each function may be indicated by registers, for example, register A in the operating system may be used to store a program counter PC, register B may be used to store a stack pointer SP, and register C may be used to store a frame pointer FP.

[0044] Taking the x86_64 operating system as an example, register A can be the program counter register RIP, register B can be the top-of-stack register RSP, and register C can be the base-of-stack register RBP. The program counter register RIP is used to store the program counter (PC), specifically the address fetched by the CPU when the operating system executes a function. The top-of-stack register RSP is used to store the stack pointer (SP), specifically the address of the stack. The stack address of SP is automatically updated when push and pop instructions are used. The base-of-stack register RBP is used to store the frame pointer (FP), which points to the bottom of a function's stack frame, indicating the beginning of a function's stack.

[0045] In the first stack backtracing method of the related technology, the dimension platform can backtrace to obtain the function stack frame of the previous level function based on the backtracing method of the frame pointer FP in the function stack frame corresponding to the currently executed function, thereby determining the previous level function that calls the currently executed function.

[0046] refer to Figure 1 In the example shown, during stack backtracing based on the frame pointer FP, the bottom of the stack of the currently executing function 3 can be determined based on the frame pointer FP stored in register C. Based on the bottom of the stack of function 3, the frame pointer FP in the stack of function 3 can be obtained. Subsequently, based on the frame pointer FP of function 3, the bottom of the stack of the previous-level function 2 and the stack frame corresponding to function 2 can be determined. Based on the bottom of the stack of function 2, the frame pointer FP in the stack of function 2 can be obtained. Finally, based on the frame pointer FP of function 2, the bottom of the stack of the previous-level function 1 and the stack frame corresponding to function 1 can be determined, thereby obtaining the function call relationship of each level among functions 1, 2, and 3.

[0047] The first stack backtracing method offers simple processing logic, minimal computational effort, and minimal performance overhead. However, the accuracy of the stack frame of the parent function determined using this method is poor. One possible reason for this is that some program functions, after compilation and optimization, do not include a frame pointer in their corresponding stack frames. This prevents the operation and maintenance platform from determining the parent function using this method, hindering performance analysis of the operating system.

[0048] In the second stack backtracing method of the related technology, the operation and maintenance platform can backtrace to obtain the function stack frame of the previous level function based on the backtracing method of the standardized debugging data format (Debugging With Attributed Record Formats, DWARF), thereby determining the previous level function that called the currently executed function.

[0049] The second stack backtracing method stores debugging information entries (DIEs) such as Frame Description Entries (FDEs) in the executable file. This debugging information provides detailed information about function call frames, allowing the debug information to more accurately backtrace the function stack frame of the previous function without relying on frame pointers. However, when performing stack backtracing using the second stack backtracing method, the FDE must be saved and called, which requires a large amount of computation, high memory usage, and high performance overhead. When there are many functions to be backtraced, this may result in high CPU usage and memory usage of the operating system.

[0050] As can be seen, in the related art, the first stack backtracking method has a smaller computational load but lower accuracy, while the second stack backtracking method has higher accuracy but a larger computational load, resulting in a higher performance overhead. Given the shortcomings of both stack backtracking methods, it is difficult to achieve a balance between the performance and accuracy of stack backtracking. Therefore, how to reduce the performance overhead required for stack backtracking while ensuring the accuracy of stack backtracking, thereby achieving a balance between the performance and accuracy of stack backtracking, is a technical problem that needs to be solved in this field.

[0051] Based on this, an embodiment of the present application provides a stack backtracing method for a function. By combining the above-mentioned first stack backtracing method and the second stack backtracing method into a hybrid stack backtracing method, the advantages of the two stack backtracing methods are integrated while eliminating their respective shortcomings, thereby achieving a balance between the performance and accuracy of stack backtracing, so that the stack backtracing method provided in the embodiment of the present application can have both high backtracing accuracy and high backtracing efficiency.

[0052] The technical solutions shown in this application are described in detail below through specific embodiments. It should be noted that the following embodiments can exist independently or in combination with each other, and the same or similar contents will not be repeated in different embodiments.

[0053] Figure 2 A flowchart of a stack backtracking method for a function provided in an embodiment of the present application is shown as follows: Figure 2The method shown can be applied to the stack backtracking system shown in the figure, in which the operation and maintenance platform determines the upper level function of the target function run by the operating system during the maintenance of the operating system. When the operating system executes the target function, it calls the upper level function. Figure 2 , the stack backtracking method provided in this embodiment includes:

[0054] S101: Get the backtracing method tag of the target function. The target function is the function to be backtraced currently, and the backtracing method tag can be used to indicate the backtracing method used by the operation and maintenance platform when backtracing the upper-level function of the target function. It can be understood that there is a corresponding backtracing method tag for each target function. The backtracing method tag includes a marked state and an unmarked state. When the backtracing method tag is in the marked state, the content marked by the backtracing method tag is used to indicate the corresponding backtracing method. Exemplarily, the backtracing method is marked as the first content to indicate the first backtracing method, the backtracing method is marked as the second content to indicate the second backtracing method, and so on.

[0055] Specifically, when determining that it is necessary to determine the previous-level function of the target function, the operation and maintenance platform can, based on the stack backtracing method provided in this embodiment, backtrace to obtain the function stack frame corresponding to the previous-level function of the target function, and thereby determine the previous-level function and the calling relationship between the previous-level function and the target function based on the function stack frame corresponding to the previous-level function.

[0056] In one embodiment, the operation and maintenance platform executes the stack backtracing method provided in this embodiment in response to an instruction to perform stack backtracing on the target function, and backtraces to obtain a function stack frame corresponding to the upper-level function of the target function.

[0057] In another embodiment, the operation and maintenance platform executes the stack backtracing method provided in this embodiment in response to the target function determined by stack backtracing based on the next-level function, and backtraces to obtain the function stack frame corresponding to the previous-level function of the target function.

[0058] S102: When the backtracing method mark obtained in S101 is in an unmarked state, a first backtracing method is used to backtrace the function stack frame corresponding to the upper-level function of the target function.

[0059] Specifically, in the embodiment of the application, the operation and maintenance platform supports at least a first backtracing method and a second backtracing method when performing stack backtracing on the target function. The first amount of computation required to backtrace the function frame stack corresponding to the target function's parent function using the first backtracing method is less than the second amount of computation required to backtrace the function frame stack corresponding to the target function's parent function using the second backtracing method.

[0060] In an embodiment, the first backtracking method comprises a frame pointer (FP) based backtracking method, and the second backtracking method comprises a DWARF based backtracking method.

[0061] Then, before the stack of the target function is backtracked, the operation and maintenance platform determines the corresponding backtracking method according to the backtracking method marker of the target function. When the backtracking method marker is in the unmarked state, the operation and maintenance platform uses the first backtracking method to backtrack the function stack frame corresponding to the upper-level function, so as to reduce the calculation amount required for backtracking.

[0062] S103: When the backtracking method marker obtained in S101 is in the marked state, the first backtracking method or the second backtracking method corresponding to the backtracking method marker is used to backtrack the function frame stack corresponding to the upper-level function of the target function.

[0063] When the backtracking method marker is in the marked state, the operation and maintenance platform uses the backtracking method corresponding to the backtracking method marker to backtrack the function stack frame corresponding to the upper-level function, so as to backtrack the function frame stack corresponding to the upper-level function of the target function by using a more appropriate backtracking method. The backtracking method marker can be preset, set by the operation and maintenance platform, or specified by an operator of the operation and maintenance platform. It can be understood that the accuracy of the operation and maintenance platform using the backtracking method corresponding to the backtracking method marker to backtrack the function stack frame corresponding to the upper-level function is higher than that of the operation and maintenance platform using other backtracking methods to backtrack the function stack frame corresponding to the upper-level function.

[0064] Figure 3 The correspondence between the backtracking method marker and the backtracking method provided in the present application is shown in the schematic diagram as follows: Figure 3

[0065] When the backtracking method marker is in the unmarked state, the operation and maintenance platform uses the first backtracking method to backtrack the function stack frame corresponding to the upper-level function of the target function.

[0066] When the backtracking method marker is in the marked state, and the backtracking method marker is specifically marked as the first content corresponding to the first backtracking method, the operation and maintenance platform uses the first backtracking method corresponding to the first content to backtrack the function stack frame corresponding to the upper-level function of the target function.

[0067] When the backtracking method marker is in the marked state, and the backtracking method marker is specifically marked as the second content corresponding to the second backtracking method, the operation and maintenance platform uses the second backtracking method corresponding to the second content to backtrack the function stack frame corresponding to the upper-level function of the target function.

[0068] ​The first content and the second content are different contents, and the first content has a unique correspondence with the first backtracing method, and the second content has a unique correspondence with the second backtracing method, so that the operation and maintenance platform can determine the unique corresponding first backtracing method based on the backtracing method tag marked as the first content, and determine the unique corresponding second backtracing method based on the backtracing method tag marked as the second content. Exemplarily, the first content includes "fp", corresponding to the first backtracing method based on FP, and the second content includes "dwarf", corresponding to the second backtracing method based on DWARF.

[0069] In summary, the stack backtracing method of the function provided in the embodiment of the present application enables the operation and maintenance platform to first obtain the backtracing method mark of the target function when performing stack backtracing on the target function during the maintenance of the operating system. Then, when the backtracing method mark is not marked, the first backtracing method with smaller computational complexity is used to backtrace the function stack frame corresponding to the previous function, so that the function to be backtraced can default to using the backtracing method with smaller computational complexity, reducing the computational complexity and performance consumption required for stack backtracing. When the backtracing method mark is marked, the first backtracing method or the second backtracing method corresponding to the content marked by the backtracing method mark is used to backtrace the function stack frame corresponding to the previous function, thereby increasing the accuracy of the function stack frame of the previous function obtained by stack backtracing.

[0070] Therefore, the stack backtracing method of the function provided in this embodiment can, based on whether the backtracing method mark is in a marked state, use the first backtracing method with smaller computational complexity as much as possible to backtrace the function stack frame corresponding to the previous level function, and only when some backtracing method marks are clearly marked with content, use a more appropriate backtracing method based on the backtracing method mark to backtrace the function stack frame corresponding to the previous level function. Thus, while ensuring the accuracy of the function stack frame corresponding to the previous level function obtained by stack backtracing, the performance overhead and resource consumption required for stack backtracing can be reduced. By combining the advantages of the first stack backtracing method and the second stack backtracing method and complementing each other's deficiencies, a balance is achieved between the performance and accuracy of stack backtracing, so that the stack backtracing method provided in the embodiment of the present application can have both high backtracing accuracy and high backtracing efficiency.

[0071] It is understandable that the embodiment of the present application takes the first backtracking method and the second backtracking method as examples, and the operation and maintenance platform can also support other backtracking methods. Figure 3In the shown example, the backtracking method marker can also be marked as third content, fourth content, and so on, corresponding to the third backtracking method, the fourth backtracking method, and so on, respectively. Among them, the first calculation amount required by the function frame stack corresponding to the upper-level function of the target function through the first backtracking method can be the smallest, and the first calculation amount is less than the second calculation amount required by the function frame stack corresponding to the upper-level function of the target function through the second backtracking method, less than the third calculation amount required by the function frame stack corresponding to the upper-level function of the target function through the third backtracking method, and so on.

[0072] Therefore, when the operation and maintenance platform supports more than two backtracking methods, in addition to using the first backtracking method with smaller calculation amount when the backtracking method marker is in the unmarked state, the calculation amount required when performing stack backtracking and performance consumption are reduced, the operation and maintenance platform can also determine a more suitable backtracking method for the target function according to the content marked by the backtracking method marker when the backtracking method marker is in the marked state, thereby further improving the accuracy and effectiveness of backtracking the function stack frame corresponding to the upper-level function.

[0073] In an embodiment, the backtracking method marker is carried in the function file corresponding to the target function.

[0074] In an embodiment, the function file carrying the backtracking method marker includes a function file indicated by a program counter PC in the register information of the function stack frame corresponding to the target function. The function file can be a binary file of an executable program, including a dynamic library, an application program, and the like.

[0075] Therefore, when the operation and maintenance platform obtains the backtracking method marker of the target function in S101, the register information of the function stack frame corresponding to the target function can be obtained. Subsequently, based on the program counter PC in the register information, the function file corresponding to the target function is obtained. Then, the target parameter of the target data structure is obtained from the function file, and the backtracking method marker is obtained. The content of the target parameter is the backtracking method marker of the target function.

[0076] In an embodiment, when the operating system is a Linux system, the operation and maintenance platform can specifically obtain the mapping relationship of the function file involved by the process corresponding to the target function in the memory space by reading the / proc / [pid] / maps file, thereby determining the function file.

[0077] In a specific implementation manner, the backtracking method marker can be carried in the target data structure in the function file corresponding to the target function, and the content of the target parameter of the target data structure can be the backtracking method marker of the target function. Among them, the target data structure can be an existing data structure in the function file, or can be a newly added data structure in the function file.

[0078] Exemplarily, the target data structure can be a hash table established in the function file, denoted as HashMap<u64, u32>, where the key value u64 of the hash table includes the ID information of the function file, for example, build-id; and the value of the hash table is the target parameter, that is, the backtracking method marker. When the backtracking method marker is in an unmarked state, the value of the hash table HashMap<u64, u32> is none; when the backtracking method marker is in a marked state and the marked content is the first content, the target parameter value of the hash table HashMap<u64, u32> is fp; and when the backtracking method marker is in a marked state and the marked content is the second content, the target parameter value of the hash table HashMap<u64, u32> is dwarf.

[0079] It can be understood that the content of the backtracking method marker in the target data structure provided by the above embodiment is only an example, and the target data structure can also be implemented in other forms, and the content of the backtracking method marker can also be implemented in other forms, which are not limited in the embodiments of the present application.

[0080] The backtracking method marker provided by the embodiments of the present application when performing stack backtracking has a relatively simple and direct implementation method, and the logic of searching and processing is also relatively simple, so that the operation and maintenance platform can obtain the backtracking method marker at a faster speed and higher efficiency when performing stack backtracking, thereby determining the backtracking method based on the backtracking method marker. In addition, the backtracking method marker can be obtained based on the register information of the function stack frame corresponding to the target function, and the register information is information that needs to be obtained when performing stack backtracking. Therefore, in the embodiments of the present application, the backtracking method marker can be obtained based on the existing method of obtaining register information, so that the embodiments of the present application can determine and process the backtracking method marker more efficiently, and thus are more conducive to the application and promotion of the embodiments of the present application, although the embodiments of the present application add the acquisition and related processing of the backtracking method marker, the change of the existing stack backtracking logic is small, and the additional calculation is small.

[0081] In combination with S102 as shown in Figure 2 In the stack backtracking method of the function provided by the embodiments of the present application, when the backtracking method marker is in an unmarked state, in order to reduce the calculation amount required for backtracking, the operation and maintenance platform preferentially adopts the first backtracking method to backtrack the upper function of the target function. Since the accuracy of the first backtracking method is poor, after the first backtracking method is used to backtrack the upper function of the target function when the backtracking method marker is in an unmarked state, the operation and maintenance platform further verifies the rationality of the target function obtained by backtracking.

[0082] Figure 4A flowchart of the steps of a stack backtracking method for a function provided in this application is shown as follows: Figure 4 Shown Figure 2 In the embodiment shown, the steps after S102 are as follows. Specifically, Figure 4 The stack backtracking methods of the function shown include:

[0083] S1021: Verify the rationality of the function stack frame of the upper-level function determined in S102.

[0084] In one embodiment, the operation and maintenance platform can specifically obtain the register information of the function stack frame of the previous level function after determining the function stack frame of the previous level function in S102, and verify the rationality of the function stack frame corresponding to the previous level function based on the register information of the function stack frame of the previous level function.

[0085] In one embodiment, the operation and maintenance platform may specifically obtain the function file containing the previous-level function and obtain the preset address range corresponding to the previous-level function from the function file. For example, the function file containing the previous-level function may be obtained by reading the / proc / [pid] / maps file. The function file includes the address range in memory that can be used to store the function stack frame of the previous-level function, which is recorded as the preset address range. For example, the preset address range may be represented as AB.

[0086] Then, when the address C indicated by the register information of the function stack frame of the determined upper-level function falls within the range of the preset address range AB, it is determined that the rationality verification of the function stack frame corresponding to the upper-level function has passed; and when the address C indicated by the register information of the function stack frame of the determined upper-level function does not fall within the range of the preset address range AB, it is determined that the rationality verification of the function stack frame corresponding to the upper-level function has failed. In this embodiment, the register information used when judging the rationality verification of the function stack frame of the upper-level function includes one or more of PC, SP or FP.

[0087] S1022: If the rationality verification of the function stack frame corresponding to the upper-level function is passed, the backtracing method is marked as the first content, so that the backtracing method is marked in a marked state.

[0088] S1023: If the rationality verification of the function stack frame corresponding to the upper-level function fails, the backtracking method is marked as the second content, so that the backtracking method is marked in a marked state.

[0089] S1024: Since the rationality verification of the function stack frame corresponding to the previous level function fails, that is, the obtained function stack frame of the previous level function is inaccurate, the operation and maintenance platform also uses a second backtracing method with higher accuracy to backtrace the previous level function of the target function.

[0090] like Figure 4 According to the method shown, when the backtracing method mark is unmarked and the first backtracing method is used to backtrace the previous level function of the target function, the operation and maintenance platform also verifies the rationality of the target function obtained by backtracing, and if the verification is passed, the backtracing method mark is marked as the first content, so that when the previous level function of the target function is subsequently backtraced again, the first backtracing method can be used to reduce the amount of calculation based on the first content marked this time, and if the verification fails, the backtracing method mark is marked as the second content, so that when the previous level function of the target function is subsequently backtraced again, the second backtracing method can be used to improve the accuracy of the backtracing based on the second content marked this time. The stack backtracing method of the function provided in this embodiment can mark the backtracing method with corresponding content based on the verification of the rationality of the backtracing result. Therefore, when the backtracing result is ensured to be valid, there is no need to verify the backtracing result when the same function is subsequently backtraced. Instead, the corresponding backtracing method can be directly adopted according to the backtracing method label. This reduces the amount of calculation when the target function is subsequently backtraced, improves the calculation efficiency, and ensures that the stack backtracing can be performed based on a more appropriate backtracing method based on the marked backtracing method label, thereby improving the completeness and effectiveness of the stack backtracing method of the function.

[0091] Figure 5 The following is a flow chart of the steps of a stack backtracking method for a function provided by this application, showing a specific implementation of the stack backtracking method for a function provided by this application. Specifically, Figure 5 In the stack backtracing method for a function shown in FIG. 1 , the operation and maintenance platform first obtains register information for the function stack frame corresponding to the target function in S10 . The register information includes the values ​​of the program counter (PC), stack pointer (SP), and frame pointer (FP). Subsequently, in S20 , the backtracing method tag is determined based on the function file containing the instruction indicated by the program counter (PC) in the register information.

[0092] When the backtracing method mark is in an unmarked state, the operation and maintenance platform uses a backtracing method based on the frame pointer FP in S31 to backtrace the function stack frame corresponding to the previous level function of the target function, and obtains the register information corresponding to the function frame stack in S41, which is recorded as the program counter new_PC, stack pointer new_SP and frame pointer new_FP, and uses the function stack frame corresponding to the new previous level function as the input program counter PC, stack pointer SP and frame pointer FP values ​​of the next iteration, and then backtraces the previous level function of the previous level function.

[0093] Subsequently, in S50, the rationality of the register information of the function stack frame corresponding to the obtained upper-level function is verified. If the rationality verification of the function stack frame corresponding to the upper-level function is passed, in S61, the backtracing method is marked as the first content, and the function stack frame corresponding to the new upper-level function is used as the input program counter PC, stack pointer SP and frame pointer FP values ​​of the next iteration, thereby backtracing the upper-level function of the upper-level function.

[0094] If the rationality verification of the function stack frame corresponding to the previous level function fails, the backtracing method is marked as the second content in S62, and the DWARF-based backtracing method is used to backtrace the previous level function of the target function in S33. The register information corresponding to the function frame stack is obtained in S43, recorded as the program counter new_PC, stack pointer new_SP and frame pointer new_FP, and the function stack frame corresponding to the new previous level function is used as the input program counter PC, stack pointer SP and frame pointer FP values ​​of the next iteration, and then the previous level function of the previous level function is backtraced.

[0095] When the backtracing method is marked as the first content, the operation and maintenance platform adopts the backtracing method based on the frame pointer FP corresponding to the first content in S32, backtraces the function stack frame corresponding to the previous level function of the target function, obtains the register information corresponding to the function frame stack in S42, records it as the program counter new_PC, stack pointer new_SP and frame pointer new_FP, and uses the function stack frame corresponding to the new previous level function as the input program counter PC, stack pointer SP and frame pointer FP value of the next iteration, and then backtraces the previous level function of the previous level function.

[0096] When the backtracing method is marked as the second content, the operation and maintenance platform adopts the DWARF-based backtracing method corresponding to the second content in S33 to backtrack the function stack frame corresponding to the previous level function of the target function, and obtains the register information corresponding to the function frame stack in S43, which is recorded as the program counter new_PC, stack pointer new_SP and frame pointer new_FP, and uses the function stack frame corresponding to the new previous level function as the input program counter PC, stack pointer SP and frame pointer FP values ​​of the next iteration, and then backtraces the previous level function of the previous level function.

[0097] Figure 6 This is a flow chart of an embodiment of a performance analysis method for an operating system provided by this application, such as Figure 6 The method shown can be executed by the operation and maintenance platform when performing performance analysis on the operating system, such as Figure 6 The performance analysis methods for the operating system shown include:

[0098] S201: Responding to a performance analysis instruction for the operating system, obtaining a target function currently executed by the operating system. Specifically, the performance analysis instruction may be sent by an application, another device, or a user of the operation and maintenance system. Upon receiving the performance analysis instruction, the operation and maintenance platform responds to the performance analysis instruction.

[0099] S202: Backtrack the upper level function of the currently executed target function through the function stack backtracking method provided in any of the aforementioned embodiments of the present application, and use the upper level function obtained by backtracing as the target function, and continue to backtrack the upper level function through the function stack backtracing method provided in any of the aforementioned embodiments of the present application until backtracking to the top level function of the currently executed target function.

[0100] S203: Output the target function and the hierarchical structure of the target function's parent functions traced back in S202 to analyze the performance of the operating system. In one specific implementation, the operation and maintenance platform can display the target function and its parent function hierarchical structure in the form of a flame graph, allowing operation and maintenance personnel to analyze the performance of the operating system through the flame graph.

[0101] The performance analysis method for the operating system provided by this embodiment can reduce the performance overhead and resource consumption required for stack backtracing while ensuring the accuracy of the function stack frame corresponding to the upper-level function obtained by stack backtracing during the process of stack backtracing of the operation and maintenance platform after receiving the performance analysis instruction, thereby providing feedback on the performance analysis instruction more quickly. On the basis of ensuring the accuracy of the performance analysis performed by the operating system, the performance overhead and resource consumption of the operation and maintenance platform when performing performance analysis based on the performance analysis instruction set are reduced, and the efficiency of the performance analysis performed by the operating system is improved.

[0102] Figure 7 This is a flow chart of an embodiment of a performance analysis method for an operating system provided by this application, such as Figure 7 The method shown can be executed by the operation and maintenance platform when performing performance analysis on the operating system, such as Figure 7 The performance analysis methods for the operating system shown include:

[0103] S301: In response to a predetermined time for performing performance analysis on the operating system, obtaining a target function currently executed by the operating system. Specifically, the operation and maintenance platform may be configured to perform performance analysis on the operating system at predetermined intervals. When the predetermined interval reaches a predetermined time, the operation and maintenance platform performs performance analysis on the operating system in response to the predetermined time.

[0104] S302: Backtrack the upper level function of the currently executed target function through the function stack backtracking method provided in any of the aforementioned embodiments of the present application, and use the upper level function obtained by backtracing as the target function, and continue to backtrack the upper level function through the function stack backtracing method provided in any of the aforementioned embodiments of the present application until backtracking to the top level function of the currently executed target function.

[0105] S303: Output the target function and the hierarchical structure of the target function's parent function traced back in S302 to analyze the operating system's performance. In one specific implementation, the operation and maintenance platform can display the target function and its parent function's hierarchical structure in the form of a flame graph, allowing operation and maintenance personnel to analyze the operating system's performance using the flame graph.

[0106] The performance analysis method for the operating system provided by this embodiment can reduce the performance overhead and resource consumption required for stack backtracing while ensuring the accuracy of the function stack frame corresponding to the upper-level function obtained by stack backtracing during the operation and maintenance platform's stack backtracing of the function according to the scheduled time of performance analysis. Therefore, on the basis of ensuring the accuracy of the performance analysis performed by the operating system, after starting the performance analysis at the scheduled time, the performance analysis result can be obtained more quickly in the shortest time, thereby ensuring the real-time and effectiveness of the performance analysis result. In the process of obtaining the performance analysis, the performance overhead and resource consumption during the performance analysis are reduced, and the efficiency of the performance analysis performed by the operating system is improved.

[0107] Figure 8 This is a flow chart of an embodiment of a performance analysis method for an operating system provided by this application, such as Figure 8 The method shown can be executed by the cloud server when performing performance analysis on the operating system, such as Figure 8 The performance analysis methods for the operating system shown include:

[0108] S401: Obtaining a performance analysis instruction of an operating system through a first application programming interface.

[0109] S402: Return a performance analysis response through the second application programming interface, wherein the performance analysis response includes a hierarchical structure of a target function currently executed by the operating system and its upper-level function to which it backtracks, and the upper-level function of the target function is obtained through the stack backtracing method of the function provided by any of the aforementioned embodiments.

[0110] Through the performance analysis method of the operating system provided in this embodiment, the cloud server can provide performance analysis services. In the process of stack backtracing of the function, the cloud server can reduce the performance overhead and resource consumption required for the cloud server to perform stack backtracing, while ensuring the accuracy of the function stack frame corresponding to the upper-level function obtained by stack backtracing. Therefore, on the basis of ensuring the accuracy of the cloud server's performance analysis of the operating system, the performance overhead and resource consumption of the cloud server when performing performance analysis of the operating system are reduced, and the efficiency of the cloud server's performance analysis of the operating system is improved.

[0111] In the aforementioned embodiments of the present application, the stack backtracing method of the function and the performance analysis method of the operating system provided in the embodiments of the present application are introduced. In order to implement the various functions in the methods provided in the above embodiments of the present application, the operation and maintenance platform as the execution subject can be implemented by hardware structure and / or software module, for example, in the form of hardware structure, software module, or hardware structure plus software module to implement the above functions. Whether a function of the above functions is executed in the form of hardware structure, software module, or hardware structure plus software module depends on the specific application and design constraints of the technical solution.

[0112] Figure 9 This is a structural diagram of an embodiment of a stack backtracking device for a function provided by this application, as shown in FIG. Figure 9 The stack backtracking device of the function shown can be used to execute the stack backtracking method of the function provided in any of the aforementioned embodiments of the present application. Specifically, Figure 9 The stack backtracing device 1000 of a function shown includes: an acquisition module 1001 and a backtracing module 1002. The acquisition module 1001 is used to obtain the backtracing method tag of the target function. The backtracing module 1002 is used to, when the backtracing method tag is in an unmarked state, use a first backtracing method to backtrace the function stack frame corresponding to the upper-level function of the target function; and, when the backtracing method tag is in a marked state, use the first backtracing method or the second backtracing method corresponding to the backtracing method tag to backtrace the function stack frame corresponding to the upper-level function of the target function, wherein the computational complexity of the first backtracing method is less than that of the second backtracing method.

[0113] In one embodiment, the backtracing module 1002 is specifically configured to obtain register information of a function stack frame corresponding to a target function; and obtain a backtracing method tag of the target function based on the register information.

[0114] In one embodiment, the register information includes a program counter, and the backtracing module 1002 is specifically configured to obtain a function file where the instruction indicated by the program counter is located, obtain a target parameter of a target data structure from the function file, and obtain a backtracing method tag.

[0115] In one embodiment, the backtracing module 1002 is specifically used to use a first backtracing method to backtrace the function stack frame corresponding to the previous level function of the target function when the backtracing method mark is marked as the first content; and to use a second backtracing method to backtrace the function stack frame corresponding to the previous level function of the target function when the backtracing method mark is marked as the second content.

[0116] In one embodiment, the backtracing module 1002 is specifically used to obtain register information of a function stack frame corresponding to the previous-level function; based on the register information of the function stack frame corresponding to the previous-level function, verify the rationality of the obtained function stack frame corresponding to the previous-level function; if the verification passes, mark the backtracing method as the first content; if the verification fails, mark the backtracing method as the second content, and use the second backtracing method to re-trace the function stack frame corresponding to the previous-level function of the target function.

[0117] In one embodiment, the backtracking module 1002 is specifically configured to obtain a function file where the previous level function is located, and obtain a preset address range corresponding to the previous level function from the function file;

[0118] When the address of the function stack frame of the upper-level function indicated by the register information falls within the preset address range, it is determined that the function stack frame corresponding to the upper-level function has passed verification;

[0119] When the address of the function stack frame of the upper-level function indicated by the register information does not fall within the preset address range, it is determined that the function stack frame corresponding to the upper-level function fails verification.

[0120] In one embodiment, the first backtracing method includes a backtracing method based on a frame pointer FP, and the second backtracing method includes a backtracing method based on a standardized debugging data format DWARF.

[0121] The function stack backtracking device 1000 provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar and will not be repeated here.

[0122] Figure 10 This is a schematic diagram of the structure of an embodiment of the performance analysis device for an operating system provided by this application, as shown in FIG. Figure 10 The performance analysis device of the operating system shown can be used to execute the performance analysis method of the operating system provided in any of the aforementioned embodiments of the present application. Specifically, Figure 10 The performance analysis device 2000 for an operating system shown includes: an acquisition module 2001 , a stack backtrace module 2002 , and an output module 2003 .

[0123] In one embodiment, the acquisition module 2001 is used to obtain the target function currently executed by the operating system in response to a predetermined time for performance analysis of the operating system; the stack backtracing module 2002 is used to backtrace the previous level function of the currently executed target function through the stack backtracing method of any of the aforementioned functions in this application, and use the previous level function as the target function until backtracing to the top-level function of the currently executed target function; the output module 2003 is used to output the hierarchical structure of the target function and the previous level function to which it backtraces, so as to analyze the performance of the operating system.

[0124] In another embodiment, the acquisition module 2001 is used to obtain the target function currently executed by the operating system in response to a performance analysis instruction of the operating system; the stack backtracing module 2002 is used to backtrace the previous level function of the currently executed target function through the stack backtracing method of any of the aforementioned functions in this application, and use the previous level function as the target function until backtracing to the top-level function of the currently executed target function; the output module 2003 is used to output the hierarchical structure of the target function and the previous level function it backtraces to, so as to analyze the performance of the operating system.

[0125] The operating system performance analysis device 2000 provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar and will not be repeated here.

[0126] It should be understood that the division of the various modules of the above device is merely a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. Moreover, these modules can all be implemented in the form of software called by a processing element; or they can all be implemented in the form of hardware; or some modules can be implemented in the form of software called by a processing element, and some modules can be implemented in the form of hardware. For example, the processing module can be a separately established processing element, or it can be integrated into a chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called by a processing element of the above device to perform the functions of the above-mentioned module. The implementation of other modules is similar. In addition, these modules can all or partly be integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.

[0127] For example, the above modules can be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASICs), one or more microprocessors (digital signal processors (DSPs), or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented by scheduling program code on a processing element, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC). In the above embodiments, all or part of them can be implemented through software, hardware, firmware, or any combination thereof.

[0128] For example, Figure 11 This is a schematic diagram of the structure of an embodiment of an electronic device provided by this application, such as Figure 11 As shown, the electronic device 3000 may include a processor 3001 and a memory 3002. Exemplarily, the processor 3001 and the memory 3002 are interconnected via a bus 3003. The memory 3002 stores computer-executable instructions; the processor 3001 executes the computer-executable instructions stored in the memory 3002, causing the processor 3001 to perform the function stack backtracing method described in any of the above method embodiments, or to perform the operating system performance analysis method described in any of the above method embodiments.

[0129] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASICs), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the present invention may be directly executed by a hardware processor or by a combination of hardware and software modules within the processor.

[0130] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage.

[0131] A bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. Buses can be categorized as address buses, data buses, and control buses. For ease of illustration, the buses in the drawings of this application are not limited to just one bus or just one type of bus.

[0132] An embodiment of the present application provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are executed by a processor, they are used to implement the stack backtracing method of the function shown in any of the above method embodiments, or the performance analysis method of the operating system shown in any of the above method embodiments.

[0133] An embodiment of the present application may also provide a computer program product, including a computer program, which, when executed by a processor, can implement the stack backtracing method of the function shown in any of the above method embodiments, or the performance analysis method of the operating system shown in any of the above method embodiments.

[0134] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, compact disc read-only memory (CD-ROM), optical storage, etc.) containing computer-usable program code.

[0135] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, 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 produce 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 flowcharts and / or block diagrams. 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.

[0136] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work 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 The function specified in one or more boxes.

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

[0138] In a typical configuration, a computing device includes one or more processors, input / output interfaces, network interfaces, and memory.

[0139] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM), and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0140] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can be implemented using any method or technology for information storage. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, parameter random access memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media such as modulated data signals and carrier waves.

[0141] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0142] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.

Claims

1. A function stack backtracking method, characterized in that: include: Get the backtrace method tag of the target function; When the backtracing method mark is in an unmarked state, adopting a first backtracing method, backtracing a function stack frame corresponding to the upper-level function of the target function, obtaining register information of the function stack frame corresponding to the upper-level function and a preset address range corresponding to the upper-level function, and verifying that the address of the function stack frame of the upper-level function indicated by the register information falls within the preset address range, and switching the backtracing method mark to a marked state according to whether the verification is passed; When the backtracing method mark is in a marked state, the first backtracing method or the second backtracing method corresponding to the backtracing method mark is adopted to backtrace the function stack frame corresponding to the previous level function of the target function, and the computational amount of the first backtracing method is less than the computational amount of the second backtracing method.

2. The method according to claim 1, characterized in that The step of obtaining the backtracking method mark of the target function includes: Obtain register information of a function stack frame corresponding to the target function; A backtrace method tag of the target function is obtained based on the register information.

3. The method according to claim 2, characterized in that The register information includes: a program counter; The step of obtaining a backtracking method tag of the target function based on the register information includes: Obtaining the function file where the instruction indicated by the program counter is located; A target parameter of a target data structure is obtained from the function file, wherein the content of the target parameter is a backtracking method tag of the target function.

4. The method according to claim 1, wherein The method of backtracing a function stack frame corresponding to an upper-level function of the target function by using a first backtracing method or a second backtracing method corresponding to the backtracing method mark when the backtracing method mark is in a marked state includes: In a case where the backtracing method mark is marked as a first content corresponding to a first backtracing method, using the first backtracing method to backtrace a function stack frame corresponding to an upper-level function of the target function; In a case where the backtracing method tag is marked as the second content corresponding to the second backtracing method, the second backtracing method is used to backtrace the function stack frame corresponding to the upper-level function of the target function.

5. The method according to claim 4, characterized in that When the backtracking method mark is in an unmarked state, after backtracking the function stack frame corresponding to the upper-level function of the target function using the first backtracking method, the method further includes: Obtain register information of the function stack frame corresponding to the previous level function; Verifying the rationality of the obtained function stack frame corresponding to the previous level function based on register information of the function stack frame corresponding to the previous level function; If the verification is successful, marking the backtracking method as the first content; If the verification fails, the backtracing method is marked as the second content, and the second backtracing method is used to re-backtrace the function stack frame corresponding to the upper-level function of the target function.

6. The method according to claim 5, characterized in that The verifying the rationality of the obtained function stack frame corresponding to the upper-level function based on the register information of the function stack frame corresponding to the upper-level function includes: Obtaining a function file where the upper-level function is located, and obtaining a preset address range corresponding to the upper-level function from the function file; When the address of the function stack frame of the upper-level function indicated by the register information falls within the preset address range, it is determined that the rationality verification of the function stack frame corresponding to the upper-level function has passed; When the address of the function stack frame of the upper-level function indicated by the register information does not fall within the preset address range, it is determined that the rationality verification of the function stack frame corresponding to the upper-level function fails.

7. The method according to any one of claims 1 to 6, characterized in that The first backtracking method includes: a backtracking method based on a frame pointer FP; The second backtracing method includes: a backtracing method based on the standardized debugging data format DWARF.

8. A performance analysis method, characterized in that: include: In response to a predetermined time for performing performance analysis on the operating system, obtaining a target function currently executed by the operating system; Backtracking the upper level function of the currently executed target function by the stack backtracking method of any one of claims 1 to 7, and using the upper level function as the target function until backtracking to the uppermost function of the currently executed target function; The target function and the hierarchical structure of the upper-level function to which it is traced back are output to analyze the performance of the operating system.

9. A performance analysis method, characterized in that: include: In response to a performance analysis instruction for an operating system, obtaining a target function currently executed by the operating system; Backtracking the upper level function of the currently executed target function by the stack backtracking method of any one of claims 1 to 7, and using the upper level function as the target function until backtracking to the uppermost function of the currently executed target function; The target function and the hierarchical structure of the upper-level function to which it is traced back are output to analyze the performance of the operating system.

10. A performance analysis method, characterized in that: include: Obtaining a performance analysis instruction of the operating system through a first application programming interface; A performance analysis response is returned through a second application programming interface, wherein the performance analysis response includes a hierarchical structure of a target function currently executed by the operating system and a previous-level function to which it is traced back, and the previous-level function of the target function is obtained through a stack backtracing method of a function as described in any one of claims 1 to 7.

11. A stack backtracking device for a function, characterized in that: include: An acquisition module is used to obtain the backtracking method tag of the target function; A backtracing module is used to, when the backtracing method mark is in an unmarked state, adopt a first backtracing method to backtrace the function stack frame corresponding to the previous level function of the target function, obtain register information of the function stack frame corresponding to the previous level function and a preset address range corresponding to the previous level function, verify the rationality of the function stack frame corresponding to the previous level function based on the address of the function stack frame of the previous level function indicated by the register information falling into the preset address range, and switch the backtracing method mark to a marked state according to whether the verification is passed; and, when the backtracing method mark is in a marked state, adopt the first backtracing method or the second backtracing method corresponding to the backtracing method mark to backtrace the function stack frame corresponding to the previous level function of the target function, the computational amount of the first backtracing method is less than the computational amount of the second backtracing method.

12. A performance analysis device, characterized in that: include: an acquisition module, configured to acquire a target function currently executed by the operating system in response to a predetermined time of performing performance analysis on the operating system; A stack backtracing module, configured to backtrace the upper level function of the currently executed target function by the stack backtracing method of the function according to any one of claims 1 to 7, and use the upper level function as the target function until backtracing to the uppermost function of the currently executed target function; An output module is used to output the hierarchical structure of the target function and the upper-level function to which it is traced back, so as to analyze the performance of the operating system.

13. A performance analysis device, characterized in that: include: an acquisition module, configured to acquire a target function currently executed by the operating system in response to a performance analysis instruction for the operating system; A stack backtracing module, configured to backtrace the upper level function of the currently executed target function by the stack backtracing method of the function according to any one of claims 1 to 7, and use the upper level function as the target function until backtracing to the uppermost function of the currently executed target function; An output module is used to output the hierarchical structure of the target function and the upper-level function to which it is traced back, so as to analyze the performance of the operating system.

14. An electronic device, characterized in that: include: memory and processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 7.

15. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.

16. A computer program product, characterized in that The method comprises a computer program, which, when executed by a computer, implements the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method for selective back-tracking in a hierarchical system containing a flag which indicates the validity of a choice-point

    US5136698A