CN113032215B - Thread snapshot analysis method, device, equipment and storage medium - Google Patents

Thread snapshot analysis method, device, equipment and storage medium Download PDF

Info

Publication number
CN113032215B
CN113032215B CN202110315442.5A CN202110315442A CN113032215B CN 113032215 B CN113032215 B CN 113032215B CN 202110315442 A CN202110315442 A CN 202110315442A CN 113032215 B CN113032215 B CN 113032215B
Authority
CN
China
Prior art keywords
address
thread
target
determining
offset address
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110315442.5A
Other languages
Chinese (zh)
Other versions
CN113032215A (en
Inventor
刘成清
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202110315442.5A priority Critical patent/CN113032215B/en
Publication of CN113032215A publication Critical patent/CN113032215A/en
Priority to PCT/CN2022/076543 priority patent/WO2022199282A1/en
Application granted granted Critical
Publication of CN113032215B publication Critical patent/CN113032215B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3089Monitoring arrangements determined by the means or processing involved in sensing the monitored data, e.g. interfaces, connectors, sensors, probes, agents
    • G06F11/3093Configuration details thereof, e.g. installation, enabling, spatial arrangement of the probes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the disclosure relates to a thread snapshot parsing method, a thread snapshot parsing device, thread snapshot parsing equipment and a storage medium, wherein the thread snapshot parsing method comprises the following steps: determining at least one target program counter address based on the program counter address corresponding to the second layer stack frame in the call stack of each thread in the preset running period of the application program; acquiring a symbol table file of an application program, and determining an initial starting address and an initial ending address of a main function recorded in the symbol table file and a virtual offset value of a code segment corresponding to the application program; determining at least one offset address interval based on the foregoing information; determining a target offset address corresponding to the thread snapshot in a preset running period based on a preset strategy and at least one offset address interval; and carrying out symbolized analysis on the thread snapshot in the preset running period based on the target offset address. The embodiment of the disclosure realizes accurate acquisition of the related program information in the running process of the application program, and is beneficial to realizing accurate monitoring of the running performance of the application program.

Description

Thread snapshot analysis method, device, equipment and storage medium
Technical Field
The disclosure relates to the field of computer technology, and in particular, to a thread snapshot parsing method, device, equipment and storage medium.
Background
With the development of software development technology, applications such as news-type applications, education-type applications, or entertainment-type applications, which can be installed on a user terminal, are layered endlessly, greatly improving the lifestyle of people.
The software developer monitors the running performance of the application program with the released version, and is helpful to find out the abnormal state in the running process of the program in time, so that the application program is improved in time, and the use experience of a user on the application program is ensured.
However, due to the difference of the user terminals, the accurate acquisition of the related program information in the running process of the application program cannot be ensured, and thus the running performance of the application program cannot be accurately analyzed.
Disclosure of Invention
In order to solve the technical problems described above or at least partially solve the technical problems described above, embodiments of the present disclosure provide a thread snapshot parsing method, apparatus, device, and storage medium.
In a first aspect, an embodiment of the present disclosure provides a thread snapshot parsing method, including:
determining at least one target program counter address based on the program counter address corresponding to the second layer stack frame in the call stack of each thread in the preset running period of the application program; the program counter address is used for identifying a function instruction address which is being executed in the running process of the program;
Acquiring a symbol table file of the application program, and determining an initial starting address and an initial ending address of a main function recorded in the symbol table file and a virtual offset value of a code segment corresponding to the application program;
Determining at least one offset address interval corresponding to a thread snapshot in the preset run period based on the at least one target program counter address, the initial start address, the initial end address, and the virtual offset value;
Determining a target offset address corresponding to a thread snapshot in the preset running period based on a preset strategy and the at least one offset address interval; the preset strategy is used for defining a rule for determining the target offset address;
And carrying out symbolized analysis on the thread snapshot in the preset running period based on the target offset address.
In a second aspect, an embodiment of the present disclosure further provides a thread snapshot parsing apparatus, including:
The target program counter address determining module is used for determining at least one target program counter address based on the program counter address corresponding to the second layer stack frame in the call stack of each thread in the preset running period of the application program; the program counter address is used for identifying a function instruction address which is being executed in the running process of the program;
The symbol table file acquisition module is used for acquiring a symbol table file of the application program and determining an initial starting address and an initial ending address of a main function recorded in the symbol table file and a virtual offset value of a code segment corresponding to the application program;
An offset address interval determining module, configured to determine at least one offset address interval corresponding to a thread snapshot in the preset running period based on the at least one target program counter address, the initial start address, the initial end address, and the virtual offset value;
The target offset address determining module is used for determining a target offset address corresponding to the thread snapshot in the preset running period based on a preset strategy and the at least one offset address interval; the preset strategy is used for defining a rule for determining the target offset address;
And the thread snapshot analysis module is used for carrying out symbolized analysis on the thread snapshot in the preset running period based on the target offset address.
In a third aspect, an embodiment of the present disclosure further provides an electronic device, including a memory and a processor, where the memory stores a computer program, and when the computer program is executed by the processor, causes the electronic device to implement any one of the thread snapshot parsing methods provided in the embodiments of the present disclosure.
In a fourth aspect, the disclosure further provides a computer readable storage medium, where a computer program is stored, where the computer program, when executed by a computing device, causes the computing device to implement any one of the thread snapshot parsing methods provided in the embodiments of the disclosure.
Compared with the prior art, the technical scheme provided by the embodiment of the disclosure has at least the following advantages: in the embodiment of the disclosure, at least one target program counter address is determined based on a program counter address (or referred to as a PC address) corresponding to a second layer stack frame in a call stack of each thread in a preset operation period of an application program, then a target offset address allocated to a function in the operation process of the application program is predicted by combining information recorded in a symbol table file of the application program, and further, a thread snapshot in the preset operation period is symbolized and analyzed based on the target offset address, specifically, a real address of the function in the operation process of the program can be acquired based on the target offset address, and description information such as a function name can be determined based on the real address of the function. Moreover, by adopting the technical scheme of the embodiment of the disclosure, the monitoring and analysis of the running performance of the application program can be realized without debugging the source code of the application program, and the efficiency of the monitoring and analysis of the running performance of the application program is improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure.
In order to more clearly illustrate the embodiments of the present disclosure or the solutions in the prior art, the drawings that are required for the description of the embodiments or the prior art will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
FIG. 1 is a flowchart of a thread snapshot parsing method according to an embodiment of the present disclosure;
FIG. 2 is a flowchart of another thread snapshot resolution method according to an embodiment of the present disclosure;
FIG. 3 is a flowchart of another thread snapshot resolution method according to an embodiment of the present disclosure;
Fig. 4 is a schematic diagram of a processing architecture for establishing communication with a device to be monitored according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of a thread snapshot parsing device according to an embodiment of the present disclosure;
Fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the disclosure.
Detailed Description
In order that the above objects, features and advantages of the present disclosure may be more clearly understood, a further description of aspects of the present disclosure will be provided below. It should be noted that, without conflict, the embodiments of the present disclosure and features in the embodiments may be combined with each other.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure, but the present disclosure may be practiced otherwise than as described herein; it will be apparent that the embodiments in the specification are only some, but not all, embodiments of the disclosure.
Fig. 1 is a flowchart of a thread snapshot parsing method according to an embodiment of the present disclosure, where the method may be suitable for performing symbolic parsing on each thread snapshot (refer to a program counter address of a code call stack or a PC address of an application program at a specific time of running the application program), so as to obtain description information such as a function name of each function in the running process of the program, so as to monitor and analyze running performance of the application program.
The Program Counter (PC) address (or referred to as PC address) refers to an instruction address stored in the Program Counter, and may be used to identify a function instruction address that is being executed during the running process of the Program. In particular, the program counter is a register in a central processing unit (Central Processing Unit, CPU) that indicates the position of the computer in its program sequence, and in some microprocessors, the program counter may also be referred to as an instruction pointer, an instruction address register, or an instruction counter, etc.
The application mentioned in the embodiments of the present disclosure may be at least one type of application installed on an electronic device, such as a video interactive type application or the like. The electronic device may be at least one type of device having computing capabilities, such as a terminal or server or the like. The operating system in the electronic device in which the application is installed may be, for example, an iOS system or the like.
The thread snapshot analysis method provided by the embodiment of the disclosure can be executed by a thread snapshot analysis device, and the device can be realized by software and/or hardware and can be integrated on electronic equipment for executing the technical scheme of the embodiment of the disclosure.
As shown in fig. 1, the thread snapshot parsing method provided by the embodiment of the present disclosure may include:
s101, determining at least one target program counter address based on a program counter address corresponding to a second layer stack frame in a call stack of each thread in a preset running period of an application program; wherein the program counter address is used for identifying the function instruction address being executed in the running process of the program.
In the running process of the application program, the second layer stack frame in the call stack of the main thread is used for storing the related information of the main function (main function), namely the second layer stack frame in the call stack of the main thread is a certain main function. Under the condition that a main thread and a sub thread in the program running process are not determined in advance, program counter addresses corresponding to second layer stack frames in call stacks of all threads in the program running process can be obtained, and at least one target program counter address is determined from the obtained multiple program counter addresses according to a program counter address screening strategy (for example, the occurrence times of the program counter addresses in each thread, whether one program counter address is in at least two threads and the like) and is used as an effective program counter address so as to be used for predicting offset addresses corresponding to thread snapshots in the program running process (namely, offset addresses of functions in the program running process). The offset addresses of the various functions are the same during program operation.
The time length of the preset operation period may be set according to requirements, and the embodiment of the present disclosure is not particularly limited. The program counter address corresponding to the second layer stack frame in the call stack of each thread is periodically acquired according to the preset running period so as to be used for predicting the offset address of the function in the running process of the program, and the prediction accuracy of the offset address can be ensured.
Optionally, in a preset running period of the application program, determining at least one target program counter address based on the program counter address corresponding to the second layer stack frame in the call stack of each thread includes:
determining a program counter address corresponding to a second layer stack frame in a call stack of each thread in a preset running period of an application program, wherein the total number of times of occurrence in the thread;
Determining the occurrence count of each program counter address in each thread as a ratio p, such as p= (m/sum) ×100%, based on the total occurrence count m of each program counter address in each thread and the sum of the thread snapshot counts in the respective threads;
Program counter addresses whose occurrence number duty ratio is greater than or equal to a second duty ratio threshold value and which occur in only one thread are determined as at least one target program counter address. Wherein, the value of the second duty ratio threshold may be determined according to circumstances, and embodiments of the disclosure are not particularly limited.
Under normal conditions, only the second layer stack frame in the call stack of the main thread corresponds to the main function in the program running process, and the main function appears in each call stack of the main thread, so that the confidence of the program counter address which only appears in one thread is higher than the confidence of the program counter address which simultaneously appears in a plurality of threads in the acquired plurality of program counter addresses, the confidence of the program counter address which has the frequency of occurrence ratio larger than or equal to the second duty ratio threshold value is higher than the confidence of the program counter address which has the frequency of occurrence ratio smaller than the second duty ratio threshold value. Program counter addresses with the frequency of occurrence being larger than or equal to a second duty ratio threshold value and only appearing in one thread are determined as at least one target program counter address, and a foundation is laid for correctly predicting offset addresses subsequently.
The preset running period of the application program may include a plurality of threads, specifically taking thread 1 and thread 2 therein as examples, the determining process of the target program counter address is illustrated, and the sum of the snapshot total number of the threads in the plurality of threads is 100, that is, the total number of the program counter addresses in the plurality of threads is 100, where:
in thread 1:
The total number of occurrences of the program counter address A is 10, and the number of occurrences accounts for 10%;
The total occurrence number of the program counter address B is 1, and the occurrence number accounts for 1%;
the total number of occurrences of the program counter address C is 2, and the number of occurrences accounts for 2%;
in thread 2:
the total occurrence number of the program counter address C is 5 times, and the occurrence number is 5 percent;
the total occurrence number of the program counter address D is 8 times, and the occurrence number accounts for 8 percent;
Of course, the number of occurrences of the program counter address in other threads and the number of occurrences duty cycle are also included, and specific examples are not given herein.
Assuming that the second duty ratio threshold is 1.5%, the number of occurrences of the program counter address B is 1% and less than 1.5%, so the program counter address B needs to be filtered, the program counter address C needs to be filtered because it occurs in both the thread 1 and the thread 2, and finally the program counter address a and the program counter address D can be used as target program counter addresses.
S102, acquiring a symbol table file of the application program, and determining an initial starting address and an initial ending address of a main function recorded in the symbol table file and a virtual offset value of a code segment corresponding to the application program.
Each application program has a corresponding symbol table (dsym) file, the symbol table is a mapping table of memory address and function name, file name and line number, and is generated in the program installation package packaging stage. Because the second layer stack frame in the call stack of the main thread corresponds to the main function and belongs to a definite known condition in the program running process, the initial starting address main_low_pc and the initial ending address main_high_pc of the pre-recorded main function and the virtual offset value vm of the code section text section corresponding to the current application program can be obtained from the symbol table file of the application program and used as factors participating in predicting offset addresses.
S103, determining at least one offset address interval corresponding to the thread snapshot in the preset running period based on at least one target program counter address, an initial starting address, an initial ending address and a virtual offset value.
For each target program counter address, a corresponding offset address interval [ offset_min, offset_max ] may be calculated in the following manner, each target program counter address being denoted by pc during the calculation:
the maximum endpoint value of the offset address interval may be expressed as:
offset_max=pc-main_low_pc+vm;
the minimum endpoint value of the offset address interval may be expressed as:
offset_min=pc-main_high_pc+vm。
the number of target program counter addresses is the same as the number of offset address intervals.
S104, determining a target offset address corresponding to the thread snapshot in a preset running period based on a preset strategy and at least one offset address interval; the preset strategy is used for defining a rule for determining the target offset address.
Illustratively, the preset policy may include: the target offset address is in an offset address interval and is an integer multiple of 10 to the power N, for example, the offset address is an integer multiple of 1000, etc., so when a plurality of offset address intervals are obtained, it can be determined whether an address value conforming to the prediction policy exists in each offset address interval, and if so, the target offset address can be obtained. It should be noted that, the offset address interval may be calculated to obtain a plurality of offset addresses, but generally, the number of address values in the interval conforming to the preset policy is limited, so that the present solution may obtain a more accurate target offset address.
If at least two address values conforming to the preset strategy are determined based on the preset strategy and at least one offset address interval, a target offset address can be determined from the at least two address values conforming to the preset strategy according to the number of times of occurrence of the target program counter address participating in determining the offset address interval. Specifically, it is preferable to use, as the target offset address, an address value in the offset address section conforming to a preset policy when the number of occurrences of the target program counter address participating in determining the offset address section exceeds a first duty threshold (the value can be flexibly determined).
For example, based on the preset strategy and the offset address interval 1, determining an address value d1 conforming to the preset strategy in the offset address interval 1; determining an address value d2 conforming to a preset strategy in the offset address interval 2 based on the preset strategy and the offset address interval 2; since the number of occurrences of the target program counter address a participating in determining the offset address interval 1 is x1 and is smaller than the first duty threshold, but the number of occurrences of the target program counter address B participating in determining the offset address interval 2 is x2 and is larger than the first duty threshold, the address value d2 conforming to the preset policy in the offset address interval 2 may be determined as the target offset address. Continuing with this example, if the number of occurrences of the target program counter address a participating in determining the offset address section 1 and the number of occurrences of the target program counter address B participating in determining the offset address section 2 are both greater than the first duty threshold, the address value with the smallest value among the address value d1 and the address value d2 may be taken as the target offset address.
Because the main function is an entry function in the program running process, the smaller the offset address is, the larger the actual address of the main function is obtained based on the program counter address and the offset address of the main function in the program running process, namely the closer the actual end position of the main function is, the higher the accuracy is relatively.
S105, performing symbolized analysis on the thread snapshot in a preset running period based on the target offset address.
Specifically, based on the target offset address and the program counter address of the call stack of each thread in the preset running period of the application program, the real address (namely, the function address defined in the program development process) of each function in each thread can be restored and obtained, then, based on the real address of each function, the description information such as the function name of each function, the file name of the file in which the function is located, the corresponding line number (code line number) of the function in the file and the like can be obtained by utilizing the symbol table file of the application program, namely, the symbolic analysis result is obtained, and finally, based on the description information of each function, the running performance of the application program is monitored and analyzed.
In addition, in the running process of the application program, each thread snapshot has a corresponding time stamp, the first occurrence time in the function stack is the starting time of the function, and the last occurrence time is the ending time of the function by merging the same items from bottom to top of the thread snapshots. And drawing a flame graph according to the function calling relation in the thread snapshot, the starting time and the ending time of each function, and analyzing the running performance of the application program. Specifically, the flame graph is a presentation form of function call relation and time distribution, the depth of a call stack is represented vertically, the consumed time is represented horizontally, and the larger the width of one grid on the flame graph is, the function corresponding to the grid is indicated to be a bottleneck in the running process of a program, so that the flame graph is a sharp tool for performing performance analysis on an application program at present.
In the embodiment of the disclosure, at least one target program counter address is determined based on a program counter address corresponding to a second layer stack frame in a call stack of each thread in a preset operation period of an application program, then a target offset address allocated to a function in the operation process of the program is predicted by combining information recorded in a symbol table file of the application program, further, a thread snapshot in the preset operation period is symbolized and analyzed based on the target offset address, specifically, a real address of the function in the operation process of the program can be acquired based on the target offset address, and description information such as a function name can be determined based on the real address of the function, namely, the embodiment of the disclosure realizes accurate acquisition of related program information in the operation process of the application program, thereby being beneficial to realizing accurate monitoring and analysis of the operation performance of the application program, and solving the problem that the related program information in the operation process of the application program cannot be accurately acquired in the prior art, so that the operation performance of the application program cannot be accurately monitored and analyzed. In addition, the method and the device can realize symbolized analysis of the thread snapshot based on the offset address by predicting the offset address of the function in the program running process, and the method and the device have the advantages of convenience and high efficiency without debugging an application program, and simultaneously solve the problem that the program running performance cannot be analyzed due to incapability of debugging the program.
On the basis of the above technical solution, optionally, determining, based on a preset policy and at least one offset address interval, a target offset address corresponding to a thread snapshot in a preset running period includes:
Determining a target integer align corresponding to each offset address interval based on a maximum endpoint value offset_max and a minimum endpoint value offset_min of each offset address interval, which may be referred to as performing a downward alignment process on the maximum endpoint value and the minimum endpoint value; where the target integer is to the power of 10N, for example, N is equal to 3, the target integer is 1000, and from the perspective of program writing, the target integer may be expressed as align=int (0 x 1000);
The quotient between the minimum endpoint value offset_min and the target integer align of each offset address interval is rounded downwards to obtain a first multiple value corresponding to each offset address interval;
Illustratively, from a programming perspective, the first multiplier value may be expressed as: offset_min/align;
Adding 1 to the first multiple value corresponding to each offset address interval to obtain a second multiple value, and obtaining at least one candidate offset address offset based on the product of the second multiple value and the target integer corresponding to each offset address interval;
Illustratively, from a program writing perspective, the candidate offset address may be expressed as:
offset=(offset_min/align+1)×align;
determining a target offset address offset corresponding to the thread snapshot in the preset running period from at least one candidate offset address based on the numerical relation between each candidate offset address offset and the corresponding offset address interval and the occurrence frequency duty ratio of each target program counter address; the occurrence frequency ratio is obtained based on the ratio of the total occurrence frequency of each target program counter address in the corresponding thread in the preset operation period to the sum of the thread snapshot total numbers in each thread.
Further, determining a target offset address corresponding to the thread snapshot in the preset running period from at least one candidate offset address based on a numerical relation between each candidate offset address and a corresponding offset address interval and an occurrence number duty ratio of each target program counter address, including:
If the candidate offset address is in the corresponding offset address interval and the number of times of occurrence of the target program counter address participating in determining the offset address interval exceeds a first duty ratio threshold, determining the candidate offset address as a target offset address, namely a valid predicted offset address, otherwise, not serving as the target offset address.
And if the number of the candidate offset addresses is at least two and the number of the occurrence times of the target program counter address participating in determining the offset address interval exceeds the first duty ratio threshold value in the condition that the candidate offset addresses are in the corresponding offset address interval, determining the minimum value of the at least two candidate offset addresses as the target offset address.
On the basis of the above technical solution, optionally, before performing symbolized parsing on the thread snapshot in the preset operation period based on the target offset address, the method provided in the embodiment of the present disclosure may further include:
Determining a loading address addr (namely a first address of the code segment) of the code segment recorded in the symbol table file and a space occupation size of the code segment;
Based on the loading address addr, the space occupation size of the code segment and the virtual offset value vm, determining a position parameter lib_size corresponding to the application program can be specifically expressed as follows:
lib_size=addr-vm+size;
Correspondingly, the symbolic analysis of the thread snapshot in the preset running period is carried out based on the target offset address, and the method comprises the following steps:
Determining an address which is larger than a target offset address offset and smaller than the sum of the target offset address and a position parameter (namely offset +lib_size) in each thread snapshot in a preset running period as a program counter address to be resolved;
And carrying out symbolized analysis on the program counter address to be analyzed based on the target offset address.
The addresses in each thread snapshot are smaller than or equal to the target offset address offset and the sum of the target offset address and the position parameter (i.e., offset +lib_size), belong to the addresses of the operating system call functions, symbolic analysis is not needed based on the target offset address, analysis can be performed through a preset analysis method corresponding to the operating system, for example, for the iOS operating system, and the command line tool atos can be used for analyzing the addresses belonging to the operating system call functions in each thread snapshot.
According to the embodiment of the disclosure, the address of the program counter to be analyzed is determined by calculating the position parameter corresponding to the application program and filtering the address in each thread snapshot in the running process of the program based on the target offset address and the position parameter, so that the symbolized analysis efficiency is improved.
FIG. 2 is a flowchart of another thread snapshot parsing method provided by an embodiment of the present disclosure, for exemplary purposes of illustrating the embodiment of the present disclosure, but should not be construed as specifically limiting the embodiment of the present disclosure. As shown in fig. 2, during the running process of the application program, the thread snapshots of each thread can be obtained according to a preset running period, whether the offset address corresponding to the thread snapshot is obtained or not is determined, if so, the obtained offset address can be directly used for carrying out symbolized analysis on the thread snapshot in the current running period, and if the offset address cannot be obtained, the obtained thread snapshot can be split according to the thread ID; program counter addresses corresponding to second layer stack frames in a call stack of each thread are obtained from thread snapshots of each thread, and the same number of program counter addresses are obtained for each thread;
Traversing the program counter address and determining whether the number of occurrences of the program counter address is greater than a threshold (specifically referring to the second duty cycle threshold described above for specific calculations, and reference is made to the explanation in the previous embodiments), if not, continuing to traverse the program counter address, and if so, determining whether the program counter address is present in other threads, i.e., whether one program counter address is present in at least two threads simultaneously; if the program counter address appears in other threads, continuing to traverse the program counter address, if the program counter address does not appear in other threads, obtaining a symbol table (dsym) file of an application program at the current program counter address, and obtaining an initial starting address main_low_pc, an initial ending address main_high_pc of a pre-recorded main function, a virtual offset value vm of a code section text section corresponding to the application program, a loading address addr and a space occupation size from the symbol table file; using the data obtained from the symbol table (dsym) file and the destination counter address (which may be denoted by pc), an offset address interval [ offset_min, offset_max ], and the location parameter lib_size corresponding to the application are calculated, wherein:
the maximum endpoint value of the offset address interval may be expressed as:
offset_max=pc-main_low_pc+vm;
the minimum endpoint value of the offset address interval may be expressed as:
offset_min=pc-main_high_pc+vm;
the location parameter lib_size can be expressed as: lib_size=addr-vm+size;
Performing downward alignment processing on the maximum endpoint value offset_max and the minimum endpoint value offset_min, and determining a target integer align corresponding to each offset address interval, wherein the target integer align can be expressed as align=int (0 x 1000); based on the minimum endpoint value offset_min and the target integer align, a candidate offset address offset is calculated, which may be expressed as:
offset=(offset_min/align+1)×align;
Determining whether the candidate offset address offset is in an offset address interval, if not, continuing to traverse the acquired program counter address, executing the determination operation of the target program counter address and the calculation operation of the candidate offset address, and if so, indicating that the probability that the current candidate offset address belongs to the target offset address is larger; further, for each obtained candidate offset address in the offset address interval, the target offset address offset may be determined therefrom, for example, if the number of occurrences of the target program counter address participating in determining the offset address interval exceeds the first duty cycle threshold, and there is only one offset address interval currently meeting the condition, that is, there is only one candidate offset address meeting the condition, the candidate offset address is taken as the target offset address offset ;
After determining the target offset address offset , traversing each obtained thread snapshot again, determining an address which is larger than the target offset address offset and smaller than the sum of the target offset address and the position parameter (namely, offset +lib_size) as a program counter address to be resolved, and carrying out symbolized resolving on the program counter address to be resolved based on the target offset address offset , thereby improving resolving efficiency.
Fig. 3 is a flowchart of another thread snapshot parsing method according to an embodiment of the present disclosure, which is further optimized and expanded based on the above technical solution, and may be combined with the above various optional implementations.
As shown in fig. 3, the thread snapshot parsing method provided by the embodiment of the present disclosure may include:
s301, determining the equipment to be monitored according to the equipment identification.
In the embodiment of the disclosure, an application program needing to perform operation performance analysis may be installed on a device to be monitored, such as a mobile terminal, a tablet computer, and the like. The number of devices to be monitored may be one or more. In the process of executing the technical scheme of the embodiment of the disclosure, the current device to be monitored can be determined according to the device identifier (for uniquely identifying the device).
S302, determining an application program to be monitored in the equipment to be monitored according to the application program identification.
Various types of applications can be installed in each device to be monitored. The application program identification is used for uniquely distinguishing different application programs, so that the application program to be monitored in the equipment to be monitored can be determined according to the application program identification, and the error of a monitored object is avoided.
S303, establishing communication with the device to be monitored, and acquiring thread snapshots of each thread in a preset running period of the application program and thread IDs of each thread.
After the device to be monitored and the application program to be monitored are determined, the electronic device for executing the technical scheme of the embodiment of the disclosure can establish communication connection with the device to be monitored by adopting a communication establishment mode capable of realizing data transmission between the devices, so that in the running process of the application program to be monitored, thread snapshots of each thread and thread IDs of each thread are obtained according to a preset running period. The thread ID is used to uniquely distinguish between different threads. For example, for a device to be monitored of an iOS operating system, libimobiledevice technology may be utilized to establish communication with the device to be monitored. Wherein libimobiledevice is a cross-platform software protocol library and tools that can be used to enable local communication between electronic devices other than iOS operating systems and iOS devices (i.e., electronic devices having iOS operating systems as operating systems).
Fig. 4 is a schematic diagram of a processing architecture for establishing communication with a device to be monitored according to an embodiment of the present disclosure, and specifically, an os operating system is taken as an operating system of the device to be monitored, which is illustrated in an exemplary manner, but should not be construed as a specific limitation of the embodiment of the present disclosure. As shown in fig. 4, the device to be monitored may include a device to be monitored 1, a device to be monitored 2 and a device to be monitored 3, a current device to be monitored may be determined according to a device identifier, and then an application to be monitored in the current device to be monitored may be determined according to an application identifier, where the device identifier and the application identifier may be transferred as configuration information (Config information) in a designated data channel, so that thread snapshot data in a running process of a required application may be accurately acquired through the designated data channel.
After the libimobiledevice technology is used for establishing communication with the current equipment to be monitored, the collection of the thread snapshot is affected under the condition that the current equipment to be monitored is in a screen locking state, so that before the collection of the thread snapshot, whether the current equipment to be monitored is in the screen locking state is detected; if the current equipment to be monitored is in the screen locking state, thread snapshots of all threads in the running process of the application program cannot be acquired, and the acquisition flow of the current thread snapshots is finished; if the current device to be monitored is in an unlocking state, starting a mounting service (START SERVER 'mobile_image_ mounter') in the device to be monitored, and determining whether to mount a development Image file (an Image file of a set of all data acquisition services in the device to be monitored), wherein the device for mounting the Image file can use each data acquisition service).
Since Instruments Server background service (which is a background service for acquiring kernel and performance data by the iOS device) in the device to be monitored is started, a development Image file of the iOS device needs to be mounted, so that whether the development Image file is mounted or not needs to be judged, if not, downloading of the development Image file corresponding to the device version and mounting of the device need to be executed, then Instruments Server background service (START SERVER "instruments. Remote") in the device to be monitored is started, communication is carried out through a socket interface packaged based on libimobiledevice technology, and a thread snapshot of each thread in the running process of an application program is requested to a specified data channel (such as ACTIVITYTRACETAP channels). Illustratively, during the process of collecting the thread snapshot, the process and the thread to which the thread snapshot belongs can be distinguished by the threadinfo. Pid (i.e. the process identifier or the process ID) and the threadinfo. Tid (i.e. the thread identifier or the thread ID) based on the definition of the data structure in the data collection service (e.g. the definition of the structure of the collected data in the data collection service kpdecode), so that the thread snapshot of each thread during the running process of the application to be monitored can be accurately extracted.
S304, splitting the obtained thread snapshot based on the thread ID, and determining a program counter address corresponding to a second layer stack frame in a call stack of each thread from the thread snapshot of each thread.
At least one call stack may be included in each thread during program execution. The obtained thread snapshots are split according to the thread ID, so that the obtained thread snapshots can be classified, and further, the target program counter address meeting the conditions can be determined for the thread snapshots in each thread. For example, a program counter address that occurs in each thread with a number of occurrences greater than or equal to the second duty cycle threshold and that occurs in only one thread may be determined as the target program counter address.
S305, determining at least one target program counter address based on the program counter address corresponding to the second layer stack frame in the call stack of each thread in the preset running period of the application program; wherein the program counter address is used for identifying the function instruction address being executed in the running process of the program.
S306, acquiring a symbol table file of the application program, and determining an initial starting address and an initial ending address of the main function recorded in the symbol table file and a virtual offset value of a code segment corresponding to the application program.
S307, determining at least one offset address interval corresponding to the thread snapshot in the preset running period based on the at least one target program counter address, the initial start address, the initial end address and the virtual offset value.
S308, determining a target offset address corresponding to a thread snapshot in a preset running period based on a preset strategy and at least one offset address interval; the preset strategy is used for defining a rule for determining the target offset address.
S309, performing symbolized analysis on the thread snapshot in a preset running period based on the target offset address.
The symbolic analysis result comprises at least one of a function name, a file name where the function is located and a row number corresponding to the function in the file.
S310, determining the analysis function names corresponding to the second layer stack frames in the call stack of each thread after symbolized analysis.
S311, determining whether a function name of a main function exists in at least one analysis function name, and whether the function name only exists in one thread, and verifying the target offset address according to a determination result.
Under normal conditions, only the second layer stack frame in the call stack of the main thread corresponds to the main function in the program running process, if the prediction of the target offset address is accurate, after the thread snapshot in the preset running period is symbolized and analyzed based on the target offset address, the function name of the main function is necessarily existed in at least one analysis function name, and the function name only appears in one thread, namely the main thread. Therefore, if it is determined that the function name of the main function exists in at least one resolved function name and the function name only appears in one thread, the target offset address passes verification, the target offset address belongs to a real offset address, and further a symbolized resolving result obtained based on the target offset address is reliable; if it is determined that at least one resolved function name does not exist in the function names of the main function or exists, but the function names exist in at least two threads, verification of the target offset address is not passed, the target offset address does not belong to a real offset address, and further a symbolized analysis result obtained based on the target offset address is unreliable, at this time, the technical scheme of the embodiment of the disclosure may be executed again to estimate the offset address until an accurate target offset address is obtained.
Optionally, if during the starting process of the application program, performing an operation of symbolizing and parsing the thread snapshot in the preset running period, the method provided by the embodiment of the present disclosure further includes: it is determined whether a function name of the program start function DidFinishLaunch exists in the at least one resolved function name so that the determination results participate in verification of the target offset address. The program start function belongs to a function which must be executed in the start stage of the application program, so that if the preset running period is in the start stage of the application program, the function name of the program start function DidFinishLaunch exists in at least one analysis function name, the verification of the target offset address can be determined to pass, otherwise, the verification is not passed.
Of course, for the start-up stage of the application program, it may also be determined whether there is a function name of the program start function DidFinishLaunch and a function name of the main function in at least one of the resolved function names, if both function names exist, the target offset value verification is passed, and if only the function name of the program start function DidFinishLaunch or the function name of the main function exists, the target offset address verification may be considered not to be passed. By setting the check of the double function names, the prediction accuracy of the target offset address can be further improved.
On the basis of the above technical solution, further, the thread snapshot parsing method provided by the embodiment of the present disclosure may further include: monitoring the running performance of an application program based on a symbolic analysis result of a thread snapshot in a preset running period; the symbolic analysis result comprises at least one of a function name, a file name where the function is located and a row number corresponding to the function in the file. For example, flame patterns may be drawn according to the run time period of each function to enable analysis of the running performance of the application.
In the embodiment of the disclosure, the target offset address is obtained by aggregating and filtering the thread snapshots of each thread in the preset running period of the application program, predicting the offset address based on the offset address prediction mode provided by the scheme, then performing symbolized analysis on each thread snapshot based on the target offset address, and verifying the target offset address according to the symbolized analysis result, namely verifying whether the predicted result of the offset address is accurate or not, until the target offset address with the highest confidence (namely, the offset address predicted value with the highest confidence) is filtered out, performing symbolized analysis on all the thread snapshots again as the final real offset address, wherein the symbolized analysis result at the moment can be used as an effective analysis result for monitoring and analyzing the running performance of the application program, and the accuracy of the monitoring and analysis of the running performance of the application program is ensured. Moreover, by adopting the technical scheme of the embodiment of the disclosure, the monitoring and analysis of the running performance of the application program can be realized without debugging the source code of the application program, and the efficiency of the monitoring and analysis of the running performance of the application program is improved.
Fig. 5 is a schematic structural diagram of a thread snapshot parsing apparatus according to an embodiment of the present disclosure, where the apparatus may be implemented in software and/or hardware, and may be integrated on an electronic device with computing capability, such as a terminal or a server.
As shown in fig. 5, a thread snapshot parsing apparatus 500 provided in an embodiment of the present disclosure may include a target program counter address determining module 501, a symbol table file acquiring module 502, an offset address interval determining module 503, a target offset address determining module 504, and a thread snapshot parsing module 505, where:
A target program counter address determining module 501, configured to determine at least one target program counter address based on a program counter address corresponding to a second layer stack frame in a call stack of each thread in a preset running period of an application program; the program counter address is used for identifying the function instruction address being executed in the running process of the program;
the symbol table file obtaining module 502 is configured to obtain a symbol table file of an application program, and determine an initial start address and an initial end address of a main function recorded in the symbol table file, and a virtual offset value of a code segment corresponding to the application program;
An offset address interval determining module 503, configured to determine at least one offset address interval corresponding to a thread snapshot in a preset running period based on at least one target program counter address, an initial start address, an initial end address, and a virtual offset value;
A target offset address determining module 504, configured to determine a target offset address corresponding to the thread snapshot in the preset operation period based on the preset policy and at least one offset address interval; the preset strategy is used for defining a rule for determining the target offset address;
The thread snapshot parsing module 505 is configured to perform symbolic parsing on the thread snapshot in a preset operation period based on the target offset address.
Optionally, the target offset address determination module 504 includes:
the first determining unit is used for determining a target integer corresponding to each offset address interval based on the maximum endpoint value and the minimum endpoint value of each offset address interval; wherein the target integer is 10 to the power of N;
the second determining unit is used for rounding down the quotient between the minimum endpoint value of each offset address interval and the target integer to obtain a first multiple value corresponding to each offset address interval;
The third determining unit is used for adding 1 to the first multiple value corresponding to each offset address interval to obtain a second multiple value, and obtaining at least one candidate offset address based on the product of the second multiple value and the target integer corresponding to each offset address interval;
A fourth determining unit, configured to determine, from at least one candidate offset address, a target offset address corresponding to a thread snapshot in a preset running period, based on a numerical relation between each candidate offset address and a corresponding offset address interval, and an occurrence number duty ratio of each target program counter address;
The occurrence frequency ratio is obtained based on the ratio of the total occurrence frequency of each target program counter address in the corresponding thread in the preset operation period to the sum of the thread snapshot total numbers in each thread.
Optionally, the fourth determining unit is specifically configured to:
If the candidate offset address is in the corresponding offset address interval and the number of occurrences of the target program counter address participating in determining the offset address interval exceeds a first duty cycle threshold, determining the candidate offset address as the target offset address.
Optionally, if the candidate offset address is in the corresponding offset address interval, and the number of occurrence times of the target program counter address participating in determining the offset address interval exceeds the first duty ratio threshold, determining the minimum value of the at least two candidate offset addresses as the target offset address.
Optionally, the thread snapshot parsing apparatus 500 provided in the embodiment of the present disclosure further includes:
The loading address and space occupation size determining module is used for determining the loading address of the code segment and the space occupation size of the code segment recorded in the symbol table file;
The position parameter determining module is used for determining position parameters corresponding to the application program based on the loading address, the space occupation size of the code segment and the virtual offset value;
Accordingly, the thread snapshot parsing module 505 includes:
The program counter address determining unit to be resolved is used for determining the addresses which are larger than the target offset address and smaller than the sum of the target offset address and the position parameter in each thread snapshot in the preset operation period as the program counter address to be resolved;
And the address analysis unit is used for symbolizing and analyzing the address of the program counter to be analyzed based on the target offset address.
Optionally, the object counter address determination module 501 includes:
The occurrence number determining unit is used for determining the program counter address corresponding to the second layer stack frame in the call stack of each thread in the preset running period of the application program, and the total occurrence number in the thread;
The number of occurrences of each program counter address in each thread is determined based on the total number of occurrences of each program counter address in each thread and the sum of the total number of thread snapshots in each thread;
and a target program counter address determining unit configured to determine, as at least one target program counter address, a program counter address whose number of occurrences is greater than or equal to a second duty threshold and which occurs in only one thread.
Optionally, the thread snapshot parsing apparatus 500 provided in the embodiment of the present disclosure further includes:
The first function name determining module is used for determining the analytic function names corresponding to the second layer stack frames in the call stack of each thread after symbolized analysis;
And the offset address verification module is used for determining whether the function name of the main function exists in at least one analysis function name and whether the function name exists in only one thread or not, and verifying the target offset address according to the determination result.
Optionally, if the operation of symbolic parsing of the thread snapshot in the preset operation period is performed during the starting process of the application program, the thread snapshot parsing apparatus 500 provided in the embodiment of the present disclosure further includes:
And the second function name determining module determines whether the function name of the program starting function DidFinishLaunch exists in at least one analysis function name so that the determination result participates in verification of the target offset address.
Optionally, the thread snapshot parsing apparatus 500 provided in the embodiment of the present disclosure further includes:
The program monitoring module is used for monitoring the running performance of the application program based on the symbolic analysis result of the thread snapshot in the preset running period; the symbolic analysis result comprises at least one of a function name, a file name where the function is located and a row number corresponding to the function in the file.
Optionally, the thread snapshot parsing apparatus 500 provided in the embodiment of the present disclosure further includes:
the device to be monitored determining module is used for determining the device to be monitored according to the device identification;
the application program to be monitored determining module is used for determining an application program to be monitored in the equipment to be monitored according to the application program identification;
the thread snapshot and thread ID determining module is used for establishing communication with the equipment to be monitored, and acquiring thread snapshots of all threads and thread IDs of all threads in a preset running period of an application program;
The program counter address determining module is used for splitting the obtained thread snapshot based on the thread ID and determining the program counter address corresponding to the second layer stack frame in the call stack of each thread from the thread snapshot of each thread.
The thread snapshot analysis device provided by the embodiment of the disclosure can execute any thread snapshot analysis method provided by the embodiment of the disclosure, and has the corresponding functional modules and beneficial effects of the execution method. Details of the embodiments of the apparatus of the present disclosure that are not described in detail may refer to descriptions of any of the embodiments of the method of the present disclosure.
Fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure, which is used to exemplarily illustrate an electronic device implementing a thread snapshot parsing method according to an embodiment of the present disclosure. The electronic devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), car terminals (e.g., car navigation terminals), and the like, as well as stationary terminals such as digital TVs, desktop computers, smart home devices, wearable electronic devices, servers, and the like. The electronic device shown in fig. 6 is merely an example and should not be construed to limit the functionality and scope of the disclosed embodiments.
As shown in fig. 6, the electronic device 600 includes one or more processors 601 and memory 602. The processor 601 may be a Central Processing Unit (CPU) or other form of processing unit having data processing and/or instruction execution capabilities and may control other components in the electronic device 600 to perform desired functions.
The memory 602 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory. Volatile memory can include, for example, random Access Memory (RAM) and/or cache memory (cache) and the like. The non-volatile memory may include, for example, read Only Memory (ROM), hard disk, flash memory, and the like. One or more computer program instructions may be stored on a computer readable storage medium and the processor 601 may execute the program instructions to implement the thread snapshot parsing method provided by the embodiments of the present disclosure, as well as other desired functions. Various contents such as an input signal, a signal component, a noise component, and the like may also be stored in the computer-readable storage medium.
The thread snapshot parsing method provided by the embodiment of the present disclosure may include: determining at least one target program counter address based on the program counter address corresponding to the second layer stack frame in the call stack of each thread in the preset running period of the application program; the program counter address is used for identifying the function instruction address being executed in the running process of the program; acquiring a symbol table file of an application program, and determining an initial starting address and an initial ending address of a main function recorded in the symbol table file and a virtual offset value of a code segment corresponding to the application program; determining at least one offset address interval corresponding to the thread snapshot in the preset running period based on at least one target program counter address, an initial starting address, an initial ending address and a virtual offset value; determining a target offset address corresponding to the thread snapshot in a preset running period based on a preset strategy and at least one offset address interval; the preset strategy is used for defining a rule for determining the target offset address; and carrying out symbolized analysis on the thread snapshot in the preset running period based on the target offset address. It should be understood that electronic device 600 may also perform other alternative implementations provided by the method embodiments of the present disclosure.
In one example, the electronic device 600 may further include: input device 603 and output device 604, which are interconnected by a bus system and/or other form of connection mechanism (not shown).
In addition, the input device 603 may also include, for example, a keyboard, a mouse, and the like.
The output device 604 may output various information to the outside, including the determined distance information, direction information, and the like. The output means 604 may include, for example, a display, speakers, a printer, and a communication network and remote output devices connected thereto, etc.
Of course, only some of the components of the electronic device 600 that are relevant to the present disclosure are shown in fig. 6, with components such as buses, input/output interfaces, etc. omitted for simplicity. In addition, the electronic device 600 may include any other suitable components depending on the particular application.
In addition to the methods and apparatus described above, the disclosed embodiments also provide a computer program product comprising a computer program or computer program instructions that, when executed by a computing apparatus, cause the computing apparatus to implement any of the thread snapshot parsing methods provided by the disclosed embodiments.
The computer program product may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the consumer electronic device, partly on the consumer electronic device, as a stand-alone software package, partly on the consumer electronic device and partly on the remote electronic device, or entirely on the remote electronic device.
In addition, embodiments of the present disclosure may also provide a computer-readable storage medium having stored thereon computer program instructions that, when executed by a computing device, cause the computing device to implement any of the thread snapshot parsing methods provided by the embodiments of the present disclosure.
The thread snapshot parsing method provided by the embodiment of the present disclosure may include: determining at least one target program counter address based on the program counter address corresponding to the second layer stack frame in the call stack of each thread in the preset running period of the application program; the program counter address is used for identifying the function instruction address being executed in the running process of the program; acquiring a symbol table file of an application program, and determining an initial starting address and an initial ending address of a main function recorded in the symbol table file and a virtual offset value of a code segment corresponding to the application program; determining at least one offset address interval corresponding to the thread snapshot in the preset running period based on at least one target program counter address, an initial starting address, an initial ending address and a virtual offset value; determining a target offset address corresponding to the thread snapshot in a preset running period based on a preset strategy and at least one offset address interval; the preset strategy is used for defining a rule for determining the target offset address; and carrying out symbolized analysis on the thread snapshot in the preset running period based on the target offset address. It should be understood that the computer program instructions, when executed by a computing device, may also cause the computing device to implement other alternative implementations provided by the method embodiments of the present disclosure.
A computer readable storage medium may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may include, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium would include the following: an electrical connection having one or more wires, a portable disk, a hard disk, random Access Memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
It should be noted that in this document, relational terms such as "first" and "second" and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises an element.
The above is merely a specific embodiment of the disclosure to enable one skilled in the art to understand or practice the disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the disclosure. Thus, the present disclosure is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (13)

1. A method for thread snapshot resolution, comprising:
Determining at least one target program counter address based on the program counter address corresponding to the second layer stack frame in the call stack of each thread in the preset running period of the application program; the program counter address is used for identifying a function instruction address which is being executed in the running process of a program, and the target program counter address comprises a program counter address which occurs in one thread and has the frequency of occurrence in the thread more than or equal to a second duty ratio threshold value;
Acquiring a symbol table file of the application program, and determining an initial starting address and an initial ending address of a main function recorded in the symbol table file and a virtual offset value of a code segment corresponding to the application program;
Determining at least one offset address interval corresponding to a thread snapshot in the preset run period based on the at least one target program counter address, the initial start address, the initial end address, and the virtual offset value;
Determining a target offset address corresponding to a thread snapshot in the preset running period based on a preset strategy and the at least one offset address interval; the preset strategy is used for defining a rule for determining the target offset address;
And carrying out symbolized analysis on the thread snapshot in the preset running period based on the target offset address.
2. The method of claim 1, wherein determining a target offset address corresponding to a thread snapshot in the preset run period based on a preset policy and the at least one offset address interval comprises:
determining a target integer corresponding to each offset address interval based on the maximum endpoint value and the minimum endpoint value of each offset address interval; wherein the target integer is 10 to the power of N;
The quotient between the minimum endpoint value and the target integer of each offset address interval is rounded downwards, and a first multiple value corresponding to each offset address interval is obtained;
Adding 1 to the first multiple value corresponding to each offset address interval to obtain a second multiple value, and obtaining at least one candidate offset address based on the product of the second multiple value and the target integer corresponding to each offset address interval;
Determining a target offset address corresponding to the thread snapshot in the preset running period from the at least one candidate offset address based on the numerical relation between each candidate offset address and the corresponding offset address interval and the occurrence number duty ratio of each target program counter address;
The occurrence frequency ratio is obtained based on the ratio of the total occurrence frequency of each target program counter address in the corresponding thread in the preset operation period to the sum of the thread snapshot total numbers in each thread.
3. The method of claim 2, wherein determining a target offset address corresponding to the thread snapshot in the preset run period from the at least one candidate offset address based on a numerical relationship of each candidate offset address and a corresponding offset address interval, and a number of occurrences of each target program counter address duty cycle, comprises:
And if the candidate offset address is in the corresponding offset address interval and the occurrence number of the target program counter address participating in determining the offset address interval exceeds a first duty ratio threshold value, determining the candidate offset address as the target offset address.
4. A method according to claim 3, characterized in that if the candidate offset address is satisfied that it is in the corresponding offset address interval and the number of occurrences of the target program counter address participating in determining the offset address interval exceeds the first duty cycle threshold, the minimum value of the at least two candidate offset addresses is determined as the target offset address.
5. The method of claim 2, further comprising, prior to symbolizing the thread snapshot in the preset run period based on the target offset address:
Determining the loading address of the code segment and the space occupation size of the code segment recorded in the symbol table file;
determining a position parameter corresponding to the application program based on the loading address, the space occupation size of the code segment and the virtual offset value;
Correspondingly, performing symbolized analysis on the thread snapshot in the preset operation period based on the target offset address, including:
Determining an address which is larger than the target offset address and smaller than the sum of the target offset address and the position parameter in each thread snapshot in the preset running period as a program counter address to be resolved;
and carrying out symbolized analysis on the to-be-analyzed program counter address based on the target offset address.
6. The method of claim 1, wherein determining at least one target program counter address based on the program counter address corresponding to the second layer stack frame in the call stack of each thread in the preset run period of the application program comprises:
Determining a program counter address corresponding to a second layer stack frame in a call stack of each thread in a preset running period of the application program, wherein the total number of times of occurrence in the thread;
Determining a frequency of occurrence duty cycle of each program counter address in each thread based on a total number of occurrences of each program counter address in each thread and a sum of thread snapshot totals in the respective threads;
Program counter addresses whose occurrence number duty ratio is greater than or equal to a second duty ratio threshold value and which occur in only one thread are determined as the at least one target program counter address.
7. The method as recited in claim 1, further comprising:
determining the analysis function name corresponding to the second layer stack frame in the call stack of each thread after symbolization analysis;
and determining whether the function name of the main function exists in at least one analysis function name, and whether the function name exists in only one thread, and verifying the target offset address according to a determination result.
8. The method of claim 7, wherein if the operation of symbolizing the thread snapshot in the preset run period is performed during the start-up of the application, the method further comprises:
and determining whether a function name of a program starting function DidFinishLaunch exists in the at least one analysis function name so that a determination result participates in verification of the target offset address.
9. The method as recited in claim 1, further comprising:
monitoring the running performance of the application program based on the symbolized analysis result of the thread snapshot in the preset running period; the symbolic analysis result comprises at least one of a function name, a file name where the function is located and a line number corresponding to the function in the file.
10. The method of claim 1, further comprising, prior to determining at least one target program counter address based on the program counter address corresponding to the second layer stack frame in the call stack of each thread:
determining equipment to be monitored according to the equipment identification;
Determining an application program to be monitored in the equipment to be monitored according to the application program identification;
establishing communication with the equipment to be monitored, and acquiring thread snapshots of each thread and thread IDs of each thread in a preset running period of the application program;
splitting the obtained thread snapshot based on the thread ID, and determining a program counter address corresponding to a second layer stack frame in a call stack of each thread from the thread snapshot of each thread.
11. A thread snapshot parsing apparatus, comprising:
the target program counter address determining module is used for determining at least one target program counter address based on the program counter address corresponding to the second layer stack frame in the call stack of each thread in the preset running period of the application program; the program counter address is used for identifying a function instruction address which is being executed in the running process of a program, and the target program counter address comprises a program counter address which occurs in one thread and has the frequency of occurrence in the thread more than or equal to a second duty ratio threshold value;
The symbol table file acquisition module is used for acquiring a symbol table file of the application program and determining an initial starting address and an initial ending address of a main function recorded in the symbol table file and a virtual offset value of a code segment corresponding to the application program;
An offset address interval determining module, configured to determine at least one offset address interval corresponding to a thread snapshot in the preset running period based on the at least one target program counter address, the initial start address, the initial end address, and the virtual offset value;
The target offset address determining module is used for determining a target offset address corresponding to the thread snapshot in the preset running period based on a preset strategy and the at least one offset address interval; the preset strategy is used for defining a rule for determining the target offset address;
And the thread snapshot analysis module is used for carrying out symbolized analysis on the thread snapshot in the preset running period based on the target offset address.
12. An electronic device comprising a memory and a processor, wherein the memory stores a computer program that, when executed by the processor, causes the electronic device to implement the thread snapshot parsing method of any of claims 1-10.
13. A computer readable storage medium, characterized in that the storage medium has stored therein a computer program, which when executed by a computing device, causes the computing device to implement the thread snapshot parsing method of any one of claims 1-10.
CN202110315442.5A 2021-03-24 2021-03-24 Thread snapshot analysis method, device, equipment and storage medium Active CN113032215B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202110315442.5A CN113032215B (en) 2021-03-24 2021-03-24 Thread snapshot analysis method, device, equipment and storage medium
PCT/CN2022/076543 WO2022199282A1 (en) 2021-03-24 2022-02-17 Thread snapshot parsing method and apparatus, device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110315442.5A CN113032215B (en) 2021-03-24 2021-03-24 Thread snapshot analysis method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113032215A CN113032215A (en) 2021-06-25
CN113032215B true CN113032215B (en) 2024-05-28

Family

ID=76473912

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110315442.5A Active CN113032215B (en) 2021-03-24 2021-03-24 Thread snapshot analysis method, device, equipment and storage medium

Country Status (2)

Country Link
CN (1) CN113032215B (en)
WO (1) WO2022199282A1 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113032215B (en) * 2021-03-24 2024-05-28 北京字节跳动网络技术有限公司 Thread snapshot analysis method, device, equipment and storage medium
CN113608982A (en) * 2021-07-27 2021-11-05 远景智能国际私人投资有限公司 Function execution performance monitoring method and device, computer equipment and storage medium
CN113900910A (en) * 2021-12-08 2022-01-07 北京新唐思创教育科技有限公司 Application program monitoring method and device, storage medium and electronic equipment
CN115858399B (en) * 2023-02-09 2023-05-05 创智和宇信息技术股份有限公司 Method and system for analyzing code level performance by using thread stack snapshot
CN116540990B (en) * 2023-06-30 2023-09-01 贵州轻工职业技术学院 Code integration method and device for realizing electronic product based on embedded mode

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572046A (en) * 2013-10-16 2015-04-29 腾讯科技(深圳)有限公司 Method for restoring stacks and computer system
CN107943520A (en) * 2016-10-11 2018-04-20 腾讯科技(深圳)有限公司 Application stack information acquisition method and device, stack information analysis method and device
CN111625422A (en) * 2020-05-27 2020-09-04 北京字节跳动网络技术有限公司 Thread monitoring method and device, electronic equipment and computer readable storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6678883B1 (en) * 2000-07-10 2004-01-13 International Business Machines Corporation Apparatus and method for creating a trace file for a trace of a computer program based on loaded module information
US8245002B2 (en) * 2008-10-08 2012-08-14 International Business Machines Corporation Call stack protection
CN110888773B (en) * 2019-10-28 2023-06-06 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for acquiring thread identification
CN110908882A (en) * 2019-11-14 2020-03-24 北京无限光场科技有限公司 Performance analysis method and device of application program, terminal equipment and medium
CN113032215B (en) * 2021-03-24 2024-05-28 北京字节跳动网络技术有限公司 Thread snapshot analysis method, device, equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572046A (en) * 2013-10-16 2015-04-29 腾讯科技(深圳)有限公司 Method for restoring stacks and computer system
CN107943520A (en) * 2016-10-11 2018-04-20 腾讯科技(深圳)有限公司 Application stack information acquisition method and device, stack information analysis method and device
CN111625422A (en) * 2020-05-27 2020-09-04 北京字节跳动网络技术有限公司 Thread monitoring method and device, electronic equipment and computer readable storage medium

Also Published As

Publication number Publication date
CN113032215A (en) 2021-06-25
WO2022199282A1 (en) 2022-09-29

Similar Documents

Publication Publication Date Title
CN113032215B (en) Thread snapshot analysis method, device, equipment and storage medium
CN109284269B (en) Abnormal log analysis method and device, storage medium and server
JP5874936B2 (en) Operation management apparatus, operation management method, and program
US9104563B2 (en) Self-tuning statistical resource leak detection
EP3591485B1 (en) Method and device for monitoring for equipment failure
CN108446171B (en) Electronic device, distributed system execution task allocation method and storage medium
CN111353143A (en) Sensitive authority detection method and device and storage medium
US10970200B2 (en) Test result triage for a failed code validation
CN112306802A (en) Data acquisition method, device, medium and electronic equipment of system
CN112817831A (en) Application performance monitoring method, device, computer system and readable storage medium
CN112667317A (en) Abnormal time consumption detection method and device, electronic equipment and storage medium
WO2016063816A1 (en) Device and method for detecting abnormality pre-indications in a computer system
CN108197041B (en) Method, device and storage medium for determining parent process of child process
CN112817687A (en) Data synchronization method and device
CN110704273A (en) Configuration information processing method and device, electronic equipment and storage medium
CN113360182B (en) Method and apparatus for system performance diagnostics
CN111741046B (en) Data reporting method, data acquisition method, device, equipment and medium
CN110297639B (en) Method and apparatus for detecting code
US7769976B2 (en) Identifying code that wastes virtual memory
CN107169133B (en) Snapshot capturing method, device, server and system
CN112463343A (en) Business process restarting method and device, storage medium and electronic equipment
CN112363870B (en) Application program development processing method and device, computer equipment and storage medium
CN116225639B (en) Task allocation method and device, electronic equipment and readable storage medium
CN111026571B (en) Processor down-conversion processing method and device and electronic equipment
CN112286768A (en) Log processing method and system, distribution equipment, request equipment and processing equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant