CN110489179B - Method, device, medium and equipment for acquiring call stack frame function signature - Google Patents

Method, device, medium and equipment for acquiring call stack frame function signature Download PDF

Info

Publication number
CN110489179B
CN110489179B CN201910710289.9A CN201910710289A CN110489179B CN 110489179 B CN110489179 B CN 110489179B CN 201910710289 A CN201910710289 A CN 201910710289A CN 110489179 B CN110489179 B CN 110489179B
Authority
CN
China
Prior art keywords
call stack
parameter
function
target thread
obtaining
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
CN201910710289.9A
Other languages
Chinese (zh)
Other versions
CN110489179A (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 CN201910710289.9A priority Critical patent/CN110489179B/en
Publication of CN110489179A publication Critical patent/CN110489179A/en
Application granted granted Critical
Publication of CN110489179B publication Critical patent/CN110489179B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/079Root cause analysis, i.e. error or fault diagnosis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • G06F9/4484Executing subprograms

Abstract

The present disclosure provides a method, apparatus, medium, and device for obtaining a call stack frame function signature, where the method includes: acquiring a call stack storage object in a trigger event; strongly converting a call stack storage object into an object array; taking a first element of the object array, and converting the first element into an integer array or a long integer array; traversing a call stack frame, taking an element with index i of the integer array or the long integer array as a first parameter, and taking an element with index i +1 of the object array as a second parameter; and obtaining a function signature of the call stack frame through the first parameter and the second parameter. The method can accurately obtain the function signature of the call stack frame in the crash event or the pause event, so that the APK can still find the crash position of the file after deleting the line number information in the installation package, the volume of the android application installation package can be effectively reduced, the success rate of downloading the application is further improved, more users are brought to the product, and the popularization efficiency of the product is improved.

Description

Method, device, medium and equipment for acquiring call stack frame function signature
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method, an apparatus, a medium, and a device for obtaining a signature of a call stack frame function.
Background
The inclusion volume of android applications is one of the important indexes for measuring the application quality: the smaller the bag volume is, the higher the download success rate of the user is, and the more users can use the application. The dex in the installation package (apk file) of the android application stores the code of the application, and occupies a considerable volume. If the volume of the part can be reduced, the volume of the installation package can be effectively reduced undoubtedly, the line number information of the application code is stored in the debug item in the dex, the operation effect of the code cannot be influenced after deletion, but the line number information of the source code corresponding to the application cannot be obtained, and the positioning is difficult when the application goes wrong.
Therefore, how to accurately acquire the function signature of the call stack after deleting the line number of the source code of the call stack and further find the function collapse position is a technical problem to be solved.
BRIEF SUMMARY OF THE PRESENT DISCLOSURE
The present disclosure is directed to a method, an apparatus, a medium, and a device for obtaining a signature of a frame function of a call stack, which can solve at least one of the above-mentioned technical problems. The specific scheme is as follows:
according to a specific implementation manner of the present disclosure, in a first aspect, the present disclosure provides a method for obtaining a signature of a frame function of a call stack, including:
acquiring a call stack storage object in a trigger event;
converting the call stack storage object into an object array;
taking a first element of the object array, and converting the first element into an integer array or a long integer array;
traversing the call stack frame, taking an element with the index of the integer array or the long integer array as i as a first parameter, and taking an element with the index of the object array as i +1 as a second parameter, wherein i is a natural number from 0 to N-1, and N is the number of the stack frame;
and obtaining a function signature of the call stack frame through the first parameter and the second parameter.
Optionally, the obtaining a function signature of the call stack frame through the first parameter and the second parameter includes:
converting the first and second parameters from a first language environment to a second language environment;
in a second language environment, inputting the first parameter and the second parameter into a conversion function to obtain a function object;
and in a first language environment, extracting the signature of the function object to obtain the function signature of the call stack frame.
Optionally, the obtaining a call stack storage object in the trigger event includes:
and when the trigger event is a crash event, directly reflecting and acquiring a call stack storage object.
Optionally, the obtaining of the call stack storage object in the trigger event includes: when the trigger event is a stuck event, the obtaining of the call stack storage object in the trigger event includes:
acquiring the ID of a target thread;
pausing the target thread according to the ID of the target thread;
acquiring the call stack storage object from the suspended target thread;
resuming execution of the target thread.
Optionally, the obtaining the ID of the target thread includes:
obtaining a pointer parameter for storing local service in the katton event through reflection;
and executing the first function to obtain the ID of the target thread.
Optionally, the suspending the target thread according to the ID of the target thread includes:
and inputting the ID of the target thread as a parameter into a second function, and pausing the target thread.
Optionally, the obtaining the call stack storage object from the suspended target thread includes:
inputting a pointer parameter for storing local services in the morton event into a third function to obtain the call stack storage object; and/or
The resuming execution of the target thread includes:
and inputting the ID of the target thread as a parameter into a fourth function, and recovering the execution of the target thread.
According to a second aspect of the present disclosure, an apparatus for obtaining a signature of a frame function of a call stack is provided, which includes:
the first acquisition unit is configured to acquire a call stack storage object in a trigger event;
the first conversion unit is configured to convert the call stack storage object into an object array;
the second conversion unit is configured to take a first element of the object array and strongly convert the first element into an integer array or a long integer array;
a second obtaining unit, configured to traverse the call stack frame, take the element with index i of the integer array or the long integer array as a first parameter, and take the element with index i +1 of the object array as a second parameter, where i is a natural number from 0 to N-1, and N is the number of stack frames;
and the third acquisition unit is configured to acquire the function signature of the call stack frame through the first parameter and the second parameter.
According to a third aspect, the present disclosure provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method of any one of the above.
According to a fourth aspect thereof, the present disclosure provides an electronic device, comprising: one or more processors; storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to carry out a method as claimed in any preceding claim.
Compared with the prior art, the scheme of the embodiment of the disclosure at least has the following beneficial effects: the method can accurately obtain the function signature of the call stack frame in the crash event or the stuck event, so that after the APK deletes the line number information in the installation package, the APK can still obtain the function signature of the call stack frame in the crash event or the stuck event through the built-in SDK, and further find out the crash position of the file, so that the volume of the android application installation package can be effectively simplified, the download success rate of the application is improved, more users are brought to the product, and the popularization efficiency of the product is improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure. It is to be understood that the drawings in the following description are merely exemplary of the disclosure, and that other drawings may be derived from those drawings by one of ordinary skill in the art without the exercise of inventive faculty. In the drawings:
FIG. 1 illustrates a logical relationship diagram according to an embodiment of the present disclosure;
FIG. 2 illustrates a flowchart of an edit process method according to an embodiment of the disclosure;
FIG. 3 illustrates a parsing process method flow diagram according to an embodiment of the disclosure;
FIG. 4 illustrates a flow diagram of a get instruction offset method according to an embodiment of the disclosure;
FIG. 5 shows a flow diagram of a method of obtaining a function signature according to an embodiment of the disclosure;
FIG. 6 is a schematic diagram illustrating an apparatus for obtaining a function signature according to an embodiment of the disclosure;
fig. 7 shows an electronic device connection structure schematic according to an embodiment of the present disclosure.
Detailed Description
To make the objects, technical solutions and advantages of the present disclosure clearer, the present disclosure will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present disclosure, rather than all embodiments. All other embodiments, which can be derived by one of ordinary skill in the art from the embodiments disclosed herein without making any creative effort, shall fall within the scope of protection of the present disclosure.
The terminology used in the embodiments of the present disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. As used in the disclosed embodiments and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise, and "a plurality" typically includes at least two.
It should be understood that the term "and/or" as used herein is merely a relationship that describes an associated object, meaning that three relationships may exist, e.g., a and/or B, may represent: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
It should be understood that while the terms first, second, third, etc. may be used in embodiments of the disclosure to describe … …, these … … should not be limited to these terms. These terms are used only to distinguish … …. For example, a first … … may also be referred to as a second … …, and similarly, a second … … may also be referred to as a first … …, without departing from the scope of embodiments of the present disclosure.
The words "if", as used herein, may be interpreted as "at … …" or "at … …" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrases "if determined" or "if detected (a stated condition or event)" may be interpreted as "when determined" or "in response to a determination" or "when detected (a stated condition or event)" or "in response to a detection (a stated condition or event)", depending on the context.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a good 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 good or apparatus. Without further limitation, an element defined by the phrase "comprising a … …" does not exclude the presence of another like element in a commodity or device comprising the element.
Alternative embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
As shown in fig. 1, the logic relationship diagram according to the embodiment of the present disclosure includes a compiling process, a mobile phone terminal, an analysis server, and a front-end display, where the compiling process is that a program developer performs simplified editing of an APK through a compiler, the generated APK installation package is installed in the mobile phone terminal of a user, when the mobile phone terminal crashes or jams, an instruction offset value and a function name of a call stack are obtained through an SDK in the APK, and are reported to the analysis server, and the analysis server obtains an accurate crash position after analyzing, and displays the crash position to the program developer through the front-end display device, and the program developer can accurately locate the crash or jam position. The method comprises the following specific steps:
the APK compilation process is as follows, as shown in fig. 2:
step S202: and acquiring a dex file in the APK.
The Android Package (APK) is an Android Package (APK), and the APK file can be installed by directly transmitting the APK file to an Android simulator or an Android mobile phone for execution.
The APK is used for packaging the project compiled by the android sdk into an installer file with the format of APK. The apk file is in zip format, but the suffix name is modified into apk, and the dex file can be seen after being decompressed by UnZip.
The dex file is the type of executable file on the Android platform. DEX (Dalvik vm executables), an Android Dalvik executive, is a Dalvik bytecode. When the Android runs a program, unZip decompression is firstly needed, and a dex file can be seen after decompression.
Step S204: and storing the mapping relation between the instruction offset and the line number in the dex file as a first data file through a first file application tool.
The first file application tool can be dexdump to obtain a complete dex file before the deletion line number of Proguard, the dex file reserves the relation between each function dexPC (instruction offset) and the source code line number, and the relation can be stored as a data file by the dexdump tool and is used for describing the relation between each function dexPC (instruction offset) and the source code line number. This data file will be used by the parsing server.
Step S206: and deleting the line number file in the dex file through a second file application tool to form a simplified installation package file.
The second file application tool may be Proguard, which controls Proguard to generate a dex file without including debug item, and may be implemented by removing a configuration option of "-keep linemanaging table" used in general development, so that the generated dex file does not retain a relationship between a dexPC (instruction offset) and a line number of a function, and an APK volume is reduced.
Optionally, the method further comprises the following steps:
step S208: and saving the confusion relation of the function names in the dex file as a second data file through a third file application tool.
The third file application tool may be a trace, which saves the relationship between the member name of the class name before confusion and the member name of the class name after confusion as a mapping file, and the mapping file is also used by the resolution server. For example, the function name "do sth" is confused as "d", and the mapping file retains the mapping relationship between "do sth" and "d", so that anyone can know that the function name is "do sth" substantially through "d".
Optionally, the APK compiling process further includes one of the following method steps:
firstly, the first data file is sent to a server for data analysis.
And sending the dex file without deleting the line number to a server side, wherein the dex file reserves the mapping relation between the instruction offset and the line number, and when the corresponding instruction offset value is obtained from the mobile phone crash side, the accurate line number of the call stack can be obtained through the mapping relation.
Secondly, the simplified installation package file is sent to a mobile terminal for installation.
And the APK file with the row number deleted is sent to the mobile terminal, and the mobile terminal rapidly installs the APK file after obtaining the APK, so that the time and the space for installing the APK are reduced, the data flow is saved, and the user experience performance is improved.
The mobile terminal can be any android system such as a mobile phone and a PAD (PAD application program), and can be an intelligent terminal for operating the APK, after the intelligent terminal obtains the simplified APK file, once the intelligent terminal is broken down (for example, flashing) in the installation and operation process, the SDK in the APK can automatically obtain the needed call stack to analyze the reason of the breakdown. And after the SDK acquires the dexPC and the function signature of each stack frame in the call stack, reporting to a server for analysis.
And thirdly, sending the second data file to a server for data analysis.
The server comprises any analysis server used for analyzing the crash problem, the analysis server is used for analyzing the information reported by the android client into a call stack with a real source code line number, and the analysis server is divided into two parts:
A. and obtaining the source code line number of each stack frame in the call stack according to the relationship between the dexPC and the source code line number of each function in the dex generated in the compiling process and the reported dexPC value and function signature of each stack frame in the call stack.
B. And obtaining the class name and the function name before each stack frame is confused according to the mapping file generated in the compiling process and the stack frame information in the call stack obtained in the last step (which is realized by a trace tool of Proguard). This results in a call stack with a true source line number and an un-obfuscated class name method name for each stack frame.
The APK resolution process is as follows, as shown in fig. 3:
step S302: and acquiring a first data file, wherein the first data file stores the mapping relation between the instruction offset and the line number in the dex file.
The first data file is a dex file which reserves the mapping relation between the instruction offset and the line number in the APK file.
The complete dex file before deleting the line number is acquired through Proguard, the dex file maintains the relation between each function dexPC (instruction offset) and the source code line number, and the relation can be saved as a data file through a dexdump tool and is used for describing the relation between each function dexPC (instruction offset) and the source code line number. This data file will be used by the parsing server.
Step S304: and acquiring a second data file, wherein the second data file stores the confusion relation of the function names in the dex file.
The second data file is a file storing the confusion relationship of the function name in the dex file, the application tool trace saves the relationship between the member name of the class name before confusion and the member name of the class name after confusion as a mapping file, and the file is also used by the analysis server. For example, the function name "do sth" is confused as "d", and the mapping file retains the mapping relationship between "do sth" and "d", so that anyone can know that the function name is "do sth" substantially through "d".
Step S306: and acquiring an instruction offset value and a function signature of each stack frame in a call stack reported by a network.
The network report is obtained from the mobile terminal provided with the simplified APK, and the mobile terminal is quickly installed after obtaining the APK, so that the time and the space for installing the APK are reduced, the data flow is saved, and the user experience performance is improved.
The mobile terminal can be any android system such as a mobile phone and a PAD (PAD application program), and can be an intelligent terminal for operating the APK, after the intelligent terminal obtains the simplified APK file, once the intelligent terminal is broken down (for example, flashing) in the installation and operation process, the SDK in the APK can automatically obtain the needed call stack to analyze the reason of the breakdown. And after the SDK acquires the dexPC and the function signature of each stack frame in the call stack, reporting to a server for analysis.
Step S308: and finding the source code line number and the class name function name before confusion of each stack frame from the relationship between the first data file and the second data file through the instruction deviation value and the function signature.
The server comprises any analysis server used for analyzing the crash problem, the analysis server is used for analyzing the information reported by the android client into a call stack with a real source code line number, and the analysis server is divided into two parts:
A. and obtaining the source code line number of each stack frame in the call stack according to the relationship between the dexPC and the source code line number of each function in the dex generated in the compiling process and the reported dexPC value and function signature of each stack frame in the call stack.
B. And obtaining a class name and a function name before each stack frame is confused according to the mapping file generated in the compiling process and the stack frame information in the call stack obtained in the last step (the class name and the function name are realized through a trace tool of Proguard). This results in a call stack with a true source line number and an un-obfuscated class name method name for each stack frame.
Optionally, the method further comprises the following steps:
step S310: determining an accurate call stack according to the line number of the source code and the name of the class name function before confusion; and displaying the call stack information.
Once the accurate call stack is determined through the source code line number and the class name function name before confusion, the call stack is sent to the front end to be displayed, the front end is used for displaying the call stack from the android client after being processed by the analysis server, and an intuitive visual interface is provided for a developer to solve problems and acquire application information.
The method for acquiring the instruction offset by the mobile phone terminal comprises the following steps:
as shown in fig. 4, the method comprises the following steps:
step S402: and acquiring a call stack storage object in the trigger event.
Optionally, the method specifically includes:
when the trigger event is a crash event (a Throwable object), a call stack storage object (a backup object) is directly obtained through reflection, wherein the crash event is that when problems such as invalid access of a memory, an invalid object, memory leakage, stack overflow and the like occur in the running process of a mobile phone application program, the application program cannot run normally, so that the program has phenomena such as flash back, no response and the like.
When the trigger event is a stuck event (Thread object), the stuck event refers to an unsmooth event such as delayed response occurring in the process of program running. The acquiring a call stack storage object (backing object) in the trigger event comprises:
first, the ID of the target thread is obtained. Obtaining a pointer parameter for storing local service in the katton event through reflection; and executing the first function to obtain the ID of the target thread.
Firstly, obtaining a member which is stored with a native (local service) layer representation in a target Thread object through reflection, wherein the member is a pointer and is called targetPtr below; then, execute the GetThreadID function of Dbg class to get the id of the target thread, which is called targetId below.
And secondly, pausing the target thread according to the ID of the target thread. And inputting the ID of the target thread as a parameter into a second function, and pausing the target thread.
Then, using targetId as a parameter, the suspend thread function of Dbg class is executed, and then the target thread suspends execution.
And thirdly, acquiring the call stack storage object from the suspended target thread. And inputting the pointer parameter of the local service stored in the morton event into a third function to obtain the call stack storage object.
And then, taking the targetPtr as a parameter, executing a creatInternalStackTrace function, and obtaining a return result, namely backtrace.
Fourth, resume execution of the target thread. And inputting the ID of the target thread as a parameter into a fourth function, and recovering the execution of the target thread.
Finally, with targetId as a parameter, the resumeThread function of Dbg class is executed, and then the target thread resumes execution.
Step S404: and converting the call stack storage object into an object array by force.
Step S406: and taking a first element of the object array, and converting the first element into an integer array or a long integer array.
Step S408: and intercepting the second half section data of the integer array or the long integer array to obtain the call stack frame instruction offset.
Specifically, the call stack storage Object backtrace is forced to be an Object [ ] type Object (hereinafter referred to as backtraceArr); then taking a first element first of the backstraceArr; then, the first is converted into an object (hereinafter referred to as first IL) of an int [ ] type (under 32-bit operation condition) or a long [ ] type (under 64-bit operation condition); and finally, taking out the data of the second half section of the array of the firstIL, namely the dexPC value of all stack frames.
The method for acquiring the function signature by the mobile phone terminal is as follows, as shown in fig. 5:
step S502: and acquiring a call stack storage object in the trigger event.
Optionally, the method specifically includes:
when the trigger event is a crash event (a Throwable object), a call stack storage object (a backup object) is directly obtained through reflection, wherein the crash event is that when problems such as invalid access of a memory, an invalid object, memory leakage, stack overflow and the like occur in the running process of a mobile phone application program, the application program cannot run normally, so that the program has phenomena such as flash back, no response and the like.
When the trigger event is a stuck event (Thread object), the stuck event refers to an unsmooth event such as delayed response occurring in the process of program running. The acquiring a call stack storage object (back object) in the trigger event includes:
first, the ID of the target thread is obtained. Obtaining a pointer parameter for storing local service in the katton event through reflection; and executing the first function to obtain the ID of the target thread.
Firstly, obtaining a member which is stored with a native (local service) layer representation in a target Thread object through reflection, wherein the member is a pointer and is called targetPtr below; then, the GetThreadID function of Dbg class is executed to obtain the id of the target thread, which is called targetId hereinafter.
And secondly, pausing the target thread according to the ID of the target thread. And inputting the ID of the target thread as a parameter into a second function, and pausing the target thread.
Then, using targetId as a parameter, the suspend thread function of Dbg class is executed, and then the target thread suspends execution.
And thirdly, acquiring the call stack storage object from the suspended target thread. And inputting the pointer parameter of the local service stored in the morton event into a third function to obtain the call stack storage object.
And then, taking the targetPtr as a parameter, executing a creatInternalStackTrace function, and obtaining a return result, namely backtrace.
Fourth, resume execution of the target thread. And inputting the ID of the target thread as a parameter into a fourth function, and recovering the execution of the target thread.
Finally, with targetId as a parameter, the resumeThread function of Dbg class is executed, and then the target thread resumes execution.
Step S504: and converting the call stack storage object into an object array by force. Specifically, the call stack storage Object backtrace is forced to an Object [ ] type Object (hereinafter, backtraceArr).
Step S506: and taking a first element of the object array, and converting the first element into an integer array or a long integer array.
Taking a first element first of the backstraceArr; the first is then forced to an object of int [ ] type (32 bit run case) or long [ ] type (64 bit run case) (hereinafter called first il).
Step S508: and traversing the call stack frame, taking an element mid with the index i of the integer array or the long integer array as a first parameter, and taking an element cls with the index i +1 of the object array as a second parameter, wherein i is a natural number from 0 to N-1, and N is the number of the stack frames.
Step S510: and obtaining a function signature of the call stack frame through the first parameter and the second parameter.
Optionally, the obtaining a function signature of the call stack frame through the first parameter and the second parameter includes:
converting the first and second parameters from a first language environment (java language) to a second language environment (c language);
in a second language environment, inputting the first parameter and the second parameter into a conversion function to obtain a function object;
and in a first language environment, extracting the signature of the function object to obtain the function signature of the call stack frame.
Wherein, the size of the backoff is the number of stack frames N +1, so that N = the length of the backoff is-1; then i starts traversing from 0 to N-1, i.e. all stack frames are traversed, and each traversal process is as follows: taking an element (hereinafter referred to as mid) with an index of i of firstIL, which is jmehthodID of the method of the stack frame, taking an element (hereinafter referred to as cls) with an index of i +1 of backstraceArr, which is a class where the method of the stack frame is located, then transferring the mid and the cls from a java layer to a c layer, obtaining a function object (hereinafter referred to as method) by the c layer through a ToReflectMethod function of a java virtual machine, and then transferring the method to the java layer and recording a signature (including a method name, a parameter number and types of each parameter).
The method can accurately obtain the function signature of the call stack frame in the crash event or the stuck event, so that after the APK deletes the line number information in the installation package, the APK can still obtain the function signature of the call stack frame in the crash event or the stuck event through the built-in SDK, and further find out the crash position of the file, so that the volume of the android application installation package can be effectively simplified, the download success rate of the application is improved, more users are brought to the product, and the popularization efficiency of the product is improved.
In addition, the present disclosure also provides an apparatus embodiment adapted to the above embodiment, for implementing the method steps described in the above embodiment, and the explanation based on the same name and meaning is the same as that in the above embodiment, and has the same technical effect as that in the above embodiment, and is not described again here.
As shown in fig. 6, according to a specific embodiment of the present disclosure, an apparatus for obtaining a signature of a frame function of a call stack is provided, which includes a first obtaining unit 602, a first converting unit 604, a second converting unit 606, a third converting unit 608, and a second obtaining unit 610.
The first acquisition unit 602: and acquiring a call stack storage object in the trigger event.
Optionally, the method specifically includes:
when the trigger event is a crash event (timeout object), a call stack storage object (backtrace object) is directly reflected and acquired, wherein the crash event is that when problems such as invalid access of a memory, an invalid object, memory leakage, stack overflow and the like occur in the running process of a mobile phone application program, the application program cannot run normally, so that the program has phenomena such as flash back, no response and the like.
When the trigger event is a stuck event (Thread object), the stuck event refers to an unsmooth event such as delayed response occurring in the process of program running. The acquiring a call stack storage object (backing object) in the trigger event comprises:
first, the ID of the target thread is obtained. Obtaining a pointer parameter for storing local service in the katton event through reflection; and executing the first function to obtain the ID of the target thread.
And secondly, pausing the target thread according to the ID of the target thread. And inputting the ID of the target thread as a parameter into a second function, and suspending the target thread.
And thirdly, acquiring the call stack storage object from the suspended target thread. And inputting the pointer parameter of the local service stored in the morton event into a third function to obtain the call stack storage object.
Fourth, resume execution of the target thread. And inputting the ID of the target thread as a parameter into a fourth function, and recovering the execution of the target thread.
The first conversion unit 604: and converting the call stack storage object into an object array by force.
Second conversion unit 606: and taking a first element of the object array, and converting the first element into an integer array or a long integer array.
Third conversion unit 608: and traversing the call stack frame, taking an element mid with the index i of the integer array or the long integer array as a first parameter, and taking an element cls with the index i +1 of the object array as a second parameter, wherein i is a natural number from 0 to N-1, and N is the number of the stack frames.
The second acquisition unit 610: and obtaining a function signature of the call stack frame through the first parameter and the second parameter.
Optionally, the obtaining a function signature of the call stack frame through the element mid and the element cls includes:
converting the first and second parameters from a first language environment to a second language environment;
in a second language environment, inputting the first parameter and the second parameter into a conversion function to obtain a function object;
and in a first language environment, extracting the signature of the function object to obtain the function signature of the call stack frame.
The device can accurately obtain the function signature of the call stack frame in the crash event or the stuck event, so that after the APK deletes the line number information in the installation package, the APK still can obtain the function signature of the call stack frame in the crash event or the stuck event through the built-in SDK, and then finds the crash position of the file, so that the volume of the android application installation package can be effectively simplified, the download success rate of the application is further improved, more users are brought to the product, and the popularization efficiency of the product is improved.
As shown in fig. 7, the present embodiment provides an electronic device, including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the one processor to cause the at least one processor to perform the method steps of the above embodiments.
The disclosed embodiments provide a non-volatile computer storage medium having stored thereon computer-executable instructions that may perform the method steps as described in the embodiments above.
Referring now to FIG. 7, shown is a schematic diagram of an electronic device suitable for use in implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 7, the electronic device may include a processing device (e.g., central processing unit, graphics processor, etc.) 701, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 702 or a program loaded from a storage device 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the electronic apparatus are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other through a bus 705. An input/output (I/O) interface 705 is also connected to bus 705.
Generally, the following devices may be connected to the I/O interface 705: input devices 706 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 705 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 708 including, for example, magnetic tape, hard disk, etc.; and a communication device 705. The communication means 705 may allow the electronic device to communicate wirelessly or by wire with other devices to exchange data. While fig. 7 illustrates an electronic device having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such embodiments, the computer program may be downloaded and installed from a network via the communication means 705, or from the storage means 708, or from the ROM 702. The computer program, when executed by the processing device 701, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
Computer program code for carrying out operations for aspects of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of an element does not in some cases constitute a limitation on the element itself.

Claims (9)

1. A method for obtaining a signature of a frame function of a call stack, comprising:
acquiring a call stack storage object in a trigger event;
converting the call stack storage object into an object array by force;
taking a first element of the object array, and converting the first element into an integer array or a long integer array;
traversing the call stack frame, taking an element with the index of the integer array or the long integer array as i as a first parameter, and taking an element with the index of the object array as i +1 as a second parameter, wherein i is a natural number from 0 to N-1, and N is the number of the stack frame;
obtaining a function signature of the call stack frame through the first parameter and the second parameter;
wherein the obtaining a function signature of the call stack frame through the first parameter and the second parameter includes:
converting the first and second parameters from a first language environment to a second language environment;
in a second language environment, inputting the first parameter and the second parameter into a conversion function to obtain a function object;
and in a first language environment, extracting the signature of the function object to obtain the function signature of the call stack frame.
2. The method of claim 1, wherein said obtaining a call stack storage object in a triggering event comprises:
and when the trigger event is a crash event, directly reflecting and acquiring a call stack storage object.
3. The method of claim 1, wherein obtaining a call stack memory object in a triggering event comprises: when the trigger event is a stuck event, the obtaining of the call stack storage object in the trigger event includes:
acquiring the ID of a target thread;
pausing the target thread according to the ID of the target thread;
acquiring the call stack storage object from the suspended target thread;
resuming execution of the target thread.
4. The method of claim 3, wherein obtaining the ID of the target thread comprises:
obtaining a pointer parameter for storing local service in the katton event through reflection;
and executing the first function to obtain the ID of the target thread.
5. The method of claim 4, wherein said pausing said target thread based on said target thread's ID comprises:
and inputting the ID of the target thread as a parameter into a second function, and pausing the target thread.
6. The method of claim 5, wherein said fetching the call stack memory object from the suspended target thread comprises:
inputting a pointer parameter for storing local services in the morton event into a third function to obtain the call stack storage object; and/or
The resuming execution of the target thread includes:
and inputting the ID of the target thread as a parameter into a fourth function, and recovering the execution of the target thread.
7. An apparatus for obtaining a signature of a frame function of a call stack, comprising:
the first acquisition unit is configured to acquire a call stack storage object in a trigger event;
the first conversion unit is configured to convert the call stack storage object into an object array;
the second conversion unit is configured to take a first element of the object array and strongly convert the first element into an integer array or a long integer array;
a second obtaining unit, configured to traverse the call stack frame, take the element with index i of the integer array or the long integer array as a first parameter, and take the element with index i +1 of the object array as a second parameter, where i is a natural number from 0 to N-1, and N is the number of stack frames;
a third obtaining unit, configured to obtain a function signature of the call stack frame through the first parameter and the second parameter;
wherein the third obtaining unit is specifically configured to:
converting the first and second parameters from a first language environment to a second language environment;
in a second language environment, inputting the first parameter and the second parameter into a conversion function to obtain a function object;
and in a first language environment, extracting the signature of the function object to obtain the function signature of the call stack frame.
8. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 6.
9. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to carry out the method of any one of claims 1 to 6.
CN201910710289.9A 2019-08-02 2019-08-02 Method, device, medium and equipment for acquiring call stack frame function signature Active CN110489179B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910710289.9A CN110489179B (en) 2019-08-02 2019-08-02 Method, device, medium and equipment for acquiring call stack frame function signature

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910710289.9A CN110489179B (en) 2019-08-02 2019-08-02 Method, device, medium and equipment for acquiring call stack frame function signature

Publications (2)

Publication Number Publication Date
CN110489179A CN110489179A (en) 2019-11-22
CN110489179B true CN110489179B (en) 2022-12-27

Family

ID=68549304

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910710289.9A Active CN110489179B (en) 2019-08-02 2019-08-02 Method, device, medium and equipment for acquiring call stack frame function signature

Country Status (1)

Country Link
CN (1) CN110489179B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111639004B (en) * 2020-05-12 2023-03-24 腾讯音乐娱乐科技(深圳)有限公司 User interface card pause monitoring method and device and storage medium
CN111813465B (en) * 2020-06-19 2023-11-21 北京字节跳动网络技术有限公司 Information acquisition method, device, medium and equipment
CN111813641A (en) * 2020-06-19 2020-10-23 北京字节跳动网络技术有限公司 Method, device, medium and equipment for collecting crash information
CN112083976A (en) * 2020-08-12 2020-12-15 北京字节跳动网络技术有限公司 Information acquisition method, device, medium and equipment
CN113238800B (en) * 2021-05-25 2022-06-28 上海安路信息科技股份有限公司 Stack frame structure and function calling method and system

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CA2347404C (en) * 2001-05-10 2008-11-18 Corel Corporation System and method for recovering applications
CN101539883B (en) * 2009-05-05 2011-11-16 北京和利时系统工程有限公司 Error tracking method of embedded system and device thereof
CN106933689B (en) * 2015-12-29 2020-05-19 伊姆西Ip控股有限责任公司 Method and device for computing equipment
US10534643B2 (en) * 2016-05-09 2020-01-14 Oracle International Corporation Correlation of thread intensity and heap usage to identify heap-hoarding stack traces
CN106802785B (en) * 2016-12-13 2019-07-09 北京华为数字技术有限公司 A kind of stack analysis method and device

Also Published As

Publication number Publication date
CN110489179A (en) 2019-11-22

Similar Documents

Publication Publication Date Title
CN110489179B (en) Method, device, medium and equipment for acquiring call stack frame function signature
CN110489165B (en) Method, device, medium and equipment for acquiring call stack frame instruction offset
CN110764941B (en) Method, device, medium and equipment for acquiring call stack frame instruction offset
CN110489101B (en) Interface simulation method, system, medium and electronic equipment
CN110865898B (en) Method, device, medium and equipment for converging crash call stack
CN109873735B (en) Performance test method and device for H5 page and computer equipment
CN111367516B (en) Application interface generation method and device and electronic equipment
CN111813641A (en) Method, device, medium and equipment for collecting crash information
CN111240684B (en) Cutting method and device of JS codes, medium and electronic equipment
CN103885814A (en) Simulator device and method for operating ARM APKs on x86 framework
CN110489159A (en) Installation kit compressing method and data analysis method, device, medium and equipment
CN111813465B (en) Information acquisition method, device, medium and equipment
CN110727480B (en) Method, device, medium and equipment for acquiring call stack frame instruction offset
CN110941549B (en) Memory leak detection method, device, medium and electronic equipment
CN110489164B (en) Acquisition method, device, medium and equipment of hidden assertion information
CN110188166B (en) Document searching method and device and electronic equipment
CN111435328B (en) Application testing method and device, electronic equipment and readable storage medium
CN113377365B (en) Code display method, apparatus, device, computer readable storage medium and product
CN111258797B (en) Memory leak detection method, device, medium and electronic equipment
CN110908860B (en) Java thread acquisition method and device, medium and electronic equipment
CN111382058A (en) Service testing method and device, server and storage medium
CN111539200B (en) Method, device, medium and electronic equipment for generating rich text
CN111381813B (en) Front-end page debugging method and device, computer equipment and storage medium
CN111274082B (en) Memory performance analysis method, device, medium and electronic equipment
CN117311838A (en) File processing method, device, equipment and storage medium based on dynamic plug-in

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